From 6b14f6fdebc6bb3cb99aea0c0848ddfad0e30633 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期三, 22 十二月 2021 14:02:46 +0800 Subject: [PATCH] 会员的免费质疑书,投诉书次数 --- zhengcaioa/Model/zcUserInfoN_db/UsergGadeRole.cs | 27 +++ zhengcaioa/Model/zcUserInfoN_db/GadeRole.cs | 36 ++++ zhengcaioa/DTO/CooperOrderDTO.cs | 15 + zhengcaioa/zhengcaioa/appsettings.Development.json | 3 zhengcaioa/zhengcaioa/Startup.cs | 4 zhengcaioa/IServices/ICooperOrderService.cs | 3 zhengcaioa/zhengcaioa/appsettings.json | 3 zhengcaioa/Model/zcUserInfoN_db/zcUserInfoN_dbContext.cs | 93 +++++++++++ zhengcaioa/Services/CooperOrderService.cs | 36 ++++ zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs | 235 +++++++++++++++++------------ 10 files changed, 355 insertions(+), 100 deletions(-) diff --git a/zhengcaioa/DTO/CooperOrderDTO.cs b/zhengcaioa/DTO/CooperOrderDTO.cs index c140c20..ca150cd 100644 --- a/zhengcaioa/DTO/CooperOrderDTO.cs +++ b/zhengcaioa/DTO/CooperOrderDTO.cs @@ -144,6 +144,21 @@ public string OrderId { get; set; } public int PrintNum { get; set; } + + + public bool AnswerRoles { get; set; } + public bool XiaocaiKeTang { get; set; } + public bool XiaoCaiQandA { get; set; } + public int Discount { get; set; } + public int BiddingDocumentsCount { get; set; } + public int ComplaintsDisputeCount { get; set; } + public int PerformanceDisputeCount { get; set; } + + public int BiddingDocumentsCountused { get; set; } + public int ComplaintsDisputeCountused { get; set; } + public int PerformanceDisputeCountused { get; set; } + + } public class CooperOrderDTOSearch : SearchEntity diff --git a/zhengcaioa/IServices/ICooperOrderService.cs b/zhengcaioa/IServices/ICooperOrderService.cs index 9c4c0fc..75d2cf0 100644 --- a/zhengcaioa/IServices/ICooperOrderService.cs +++ b/zhengcaioa/IServices/ICooperOrderService.cs @@ -87,5 +87,8 @@ ResultDataEntity<CooperOrderDTO> SearchByPagingWenshu(CooperOrderDTOSearch searchEntity); + //鑾峰彇璐ㄧ枒鎶曡瘔鐨勬鏁� + List<CooperOrderDTO> GetListComplaintsDisputeCount(string huiyuanid); + } } diff --git a/zhengcaioa/Model/zcUserInfoN_db/GadeRole.cs b/zhengcaioa/Model/zcUserInfoN_db/GadeRole.cs new file mode 100644 index 0000000..e9e3cb2 --- /dev/null +++ b/zhengcaioa/Model/zcUserInfoN_db/GadeRole.cs @@ -0,0 +1,36 @@ +锘縰sing System; +using System.Collections.Generic; + +#nullable disable + +namespace zhengcaioa.Models +{ + public partial class GadeRole + { + public GadeRole() + { + UsergGadeRoleSecondUserGadeRoles = new HashSet<UsergGadeRole>(); + UsergGadeRoleUserGadeRoles = new HashSet<UsergGadeRole>(); + } + + public Guid Id { get; set; } + public Guid? FrameworkRoleId { get; set; } + public bool AnswerRoles { get; set; } + public bool XiaocaiKeTang { get; set; } + public bool XiaoCaiQandA { get; set; } + public bool GaveBook { get; set; } + public int Discount { get; set; } + public int BiddingDocumentsCount { get; set; } + public int ComplaintsDisputeCount { get; set; } + public int PerformanceDisputeCount { get; set; } + public decimal Price { get; set; } + public bool OnShelf { get; set; } + public DateTime? CreateTime { get; set; } + public string CreateBy { get; set; } + public DateTime? UpdateTime { get; set; } + public string UpdateBy { get; set; } + + public virtual ICollection<UsergGadeRole> UsergGadeRoleSecondUserGadeRoles { get; set; } + public virtual ICollection<UsergGadeRole> UsergGadeRoleUserGadeRoles { get; set; } + } +} diff --git a/zhengcaioa/Model/zcUserInfoN_db/UsergGadeRole.cs b/zhengcaioa/Model/zcUserInfoN_db/UsergGadeRole.cs new file mode 100644 index 0000000..f4e96a5 --- /dev/null +++ b/zhengcaioa/Model/zcUserInfoN_db/UsergGadeRole.cs @@ -0,0 +1,27 @@ +锘縰sing System; +using System.Collections.Generic; + +#nullable disable + +namespace zhengcaioa.Models +{ + public partial class UsergGadeRole + { + public Guid Id { get; set; } + public Guid? UserId { get; set; } + public bool GaveBook { get; set; } + public DateTime? TimeOut { get; set; } + public int BiddingDocumentsCount { get; set; } + public int ComplaintsDisputeCount { get; set; } + public int PerformanceDisputeCount { get; set; } + public Guid? UserGadeRolesId { get; set; } + public Guid? SecondUserGadeRolesId { get; set; } + public DateTime? CreateTime { get; set; } + public string CreateBy { get; set; } + public DateTime? UpdateTime { get; set; } + public string UpdateBy { get; set; } + + public virtual GadeRole SecondUserGadeRoles { get; set; } + public virtual GadeRole UserGadeRoles { get; set; } + } +} diff --git a/zhengcaioa/Model/zcUserInfoN_db/zcUserInfoN_dbContext.cs b/zhengcaioa/Model/zcUserInfoN_db/zcUserInfoN_dbContext.cs new file mode 100644 index 0000000..598d78e --- /dev/null +++ b/zhengcaioa/Model/zcUserInfoN_db/zcUserInfoN_dbContext.cs @@ -0,0 +1,93 @@ +锘縰sing System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; + +#nullable disable + +namespace zhengcaioa.Models +{ + public partial class zcUserInfoN_dbContext : DbContext + { + public zcUserInfoN_dbContext() + { + } + + public zcUserInfoN_dbContext(DbContextOptions<zcUserInfoN_dbContext> options) + : base(options) + { + } + + public virtual DbSet<GadeRole> GadeRoles { get; set; } + public virtual DbSet<UsergGadeRole> UsergGadeRoles { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { +#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. + optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=zcUserInfoN_db;User ID=sa;Password=123456"); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS"); + + modelBuilder.Entity<GadeRole>(entity => + { + entity.ToTable("gadeRoles"); + + entity.HasIndex(e => e.FrameworkRoleId, "IX_gadeRoles_FrameworkRoleId"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("ID"); + + entity.Property(e => e.CreateBy).HasMaxLength(50); + + entity.Property(e => e.OnShelf).HasColumnName("onShelf"); + + entity.Property(e => e.Price) + .HasColumnType("decimal(18, 2)") + .HasColumnName("price"); + + entity.Property(e => e.UpdateBy).HasMaxLength(50); + + entity.Property(e => e.XiaoCaiQandA).HasColumnName("XiaoCaiQAndA"); + + entity.Property(e => e.XiaocaiKeTang).HasColumnName("xiaocaiKeTang"); + }); + + modelBuilder.Entity<UsergGadeRole>(entity => + { + entity.ToTable("usergGadeRoles"); + + entity.HasIndex(e => e.SecondUserGadeRolesId, "IX_usergGadeRoles_SecondUserGadeRolesId"); + + entity.HasIndex(e => e.UserGadeRolesId, "IX_usergGadeRoles_UserGadeRolesId"); + + entity.HasIndex(e => e.UserId, "IX_usergGadeRoles_UserId"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("ID"); + + entity.Property(e => e.CreateBy).HasMaxLength(50); + + entity.Property(e => e.UpdateBy).HasMaxLength(50); + + entity.HasOne(d => d.SecondUserGadeRoles) + .WithMany(p => p.UsergGadeRoleSecondUserGadeRoles) + .HasForeignKey(d => d.SecondUserGadeRolesId); + + entity.HasOne(d => d.UserGadeRoles) + .WithMany(p => p.UsergGadeRoleUserGadeRoles) + .HasForeignKey(d => d.UserGadeRolesId); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + } +} diff --git a/zhengcaioa/Services/CooperOrderService.cs b/zhengcaioa/Services/CooperOrderService.cs index d8facb5..83b46c6 100644 --- a/zhengcaioa/Services/CooperOrderService.cs +++ b/zhengcaioa/Services/CooperOrderService.cs @@ -14,11 +14,13 @@ public class CooperOrderService: ICooperOrderService { private readonly zhengcaioaContext _context; + private readonly zcUserInfoN_dbContext _zcUserInfoN_dbContext; private readonly IMapper _mapper; - public CooperOrderService(zhengcaioaContext context, IMapper mapper) + public CooperOrderService(zhengcaioaContext context, IMapper mapper, zcUserInfoN_dbContext zcUserInfoN_dbContext) { _context = context; _mapper = mapper; + _zcUserInfoN_dbContext = zcUserInfoN_dbContext; } @@ -1936,5 +1938,37 @@ data.LoadData(searchEntity, lianlist); return data; } + + + + + public List<CooperOrderDTO> GetListComplaintsDisputeCount(string huiyuanid) + { + var query = (from a in _zcUserInfoN_dbContext.UsergGadeRoles + join b in _zcUserInfoN_dbContext.GadeRoles + on a.UserGadeRolesId equals b.Id + where a.UserId == Guid.Parse(huiyuanid) + select new CooperOrderDTO + { + Id = a.UserId.ToString(), + AnswerRoles = b.AnswerRoles, + XiaocaiKeTang = b.XiaocaiKeTang, + XiaoCaiQandA = b.XiaoCaiQandA, + Discount = b.Discount, + BiddingDocumentsCount = b.BiddingDocumentsCount, + ComplaintsDisputeCount = b.ComplaintsDisputeCount, + PerformanceDisputeCount = b.PerformanceDisputeCount, + BiddingDocumentsCountused = a.BiddingDocumentsCount, + ComplaintsDisputeCountused = a.ComplaintsDisputeCount, + PerformanceDisputeCountused = a.PerformanceDisputeCount, + + } + ).ToList(); + + + + + return query; + } } } diff --git a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs index cc6a92d..8051741 100644 --- a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs +++ b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs @@ -582,120 +582,161 @@ var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); ViewData["curentuser"] = curentuser; data.RecStatus = "A"; - if (String.IsNullOrEmpty(data.Id)) - { - data.Creater = curentuser.Id; - data.Createtime = DateTime.Now; - data.XdTime = data.Createtime; - if (data.OrderType == "03" || data.OrderType == "07" || (data.OrderType == "02" && (data.OrderType1 == "浠f嫙鎶曡瘔涔�" || data.OrderType1 == "浠f嫙璐ㄧ枒鍑�"))) - { - var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(data.Khdw); - if (cooperatecustomCustomerDTO != null && !string.IsNullOrEmpty(cooperatecustomCustomerDTO.HuiyuanId)) - { - string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; - string SetCaseOrder = _configuration.GetSection("SetCaseOrder").Value; - Uri postUrl2 = new Uri(huiyuanurl + SetCaseOrder); + - JObject questions2 = new JObject(); - questions2.Add("UserID", cooperatecustomCustomerDTO.HuiyuanId); - if (data.OrderType == "03") - { - questions2.Add("CaseType", 0); - } - else if (data.OrderType == "07") - { - questions2.Add("CaseType", 1); - } - else if (data.OrderType == "07") - { - questions2.Add("CaseType", 1); - } - else if (data.OrderType == "02" && (data.OrderType1 == "浠f嫙鎶曡瘔涔�" || data.OrderType1 == "浠f嫙璐ㄧ枒鍑�")) - { - questions2.Add("CaseType", 2); - } + bool youhui = true; - questions2.Add("count", Decimal.ToInt32(data.OrderNum.Value) ); - - string requestJson2 = questions2.ToString(); - string result2 = string.Empty; - - using (HttpContent httpContent = new StringContent(requestJson2)) - { - httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); - - var httpClient2 = _clientFactory.CreateClient(); - httpClient2.Timeout = new TimeSpan(0, 0, 10); - var Result2 = await httpClient2.PostAsync(postUrl2, httpContent); - result2 = Result2.Content.ReadAsStringAsync().Result; - } - - _logger.LogInformation("result2:" + result2); - JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); - - if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") - { - resultEntity.Result = true; - } - else - { - resultEntity.Result = false; - resultEntity.Message = "鍐欏叆浼氬憳璁㈠崟澶辫触"; - return new JsonResult(resultEntity); - } - } - } - - - - - - } - - using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, - new TransactionOptions - { - IsolationLevel = IsolationLevel.ReadCommitted, - Timeout = TransactionManager.MaximumTimeout - } - )) + if (String.IsNullOrEmpty(data.Id)) { - - var youHuiDTOs = _askService.GetAskYouHuiList(data.Khdw, data.OrderType).FirstOrDefault(); - if (youHuiDTOs != null) + var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(data.Khdw); + if (cooperatecustomCustomerDTO != null && !string.IsNullOrEmpty(cooperatecustomCustomerDTO.HuiyuanId)) { - data.Youhuier = youHuiDTOs.Id; - if (youHuiDTOs.Youhuistandard == "01") + var cooperOrderDTOs = _cooperOrderService.GetListComplaintsDisputeCount(cooperatecustomCustomerDTO.HuiyuanId).FirstOrDefault(); + if(cooperOrderDTOs != null) { - data.Youhui = youHuiDTOs.YouHui.Value; - if (data.Money.Value < data.Youhui.Value) - { - data.Money = 0; - } - else - { - data.Money = data.Money.Value - data.Youhui.Value; - } - - } - else if (youHuiDTOs.Youhuistandard == "02") - { - if (youHuiDTOs.YouHui.Value >= 100) + if ((cooperOrderDTOs.ComplaintsDisputeCount - cooperOrderDTOs.ComplaintsDisputeCountused > 0) && (data.OrderType == "02" && (data.OrderType1 == "浠f嫙鎶曡瘔涔�" || data.OrderType1 == "浠f嫙璐ㄧ枒鍑�"))) { data.Youhui = data.Money.Value; data.Money = 0; + youhui = false; } - else + else if ((cooperOrderDTOs.BiddingDocumentsCount - cooperOrderDTOs.BiddingDocumentsCountused > 0) && data.OrderType == "03") { - data.Youhui = Math.Round(data.Money.Value * youHuiDTOs.YouHui.Value * new decimal(0.01), 2); - data.Money = data.Money.Value - data.Youhui.Value; + data.Youhui = data.Money.Value; + data.Money = 0; + youhui = false; } + else if ((cooperOrderDTOs.PerformanceDisputeCount - cooperOrderDTOs.PerformanceDisputeCountused > 0) && data.OrderType == "07") + { + data.Youhui = data.Money.Value; + data.Money = 0; + youhui = false; + } + } + } + + data.Creater = curentuser.Id; + data.Createtime = DateTime.Now; + data.XdTime = data.Createtime; + if (data.OrderType == "03" || data.OrderType == "07" || (data.OrderType == "02" && (data.OrderType1 == "浠f嫙鎶曡瘔涔�" || data.OrderType1 == "浠f嫙璐ㄧ枒鍑�"))) + { + + if (cooperatecustomCustomerDTO != null && !string.IsNullOrEmpty(cooperatecustomCustomerDTO.HuiyuanId)) + { + string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; + string SetCaseOrder = _configuration.GetSection("SetCaseOrder").Value; + + Uri postUrl2 = new Uri(huiyuanurl + SetCaseOrder); + + JObject questions2 = new JObject(); + questions2.Add("UserID", cooperatecustomCustomerDTO.HuiyuanId); + if (data.OrderType == "03") + { + questions2.Add("CaseType", 0); + } + else if (data.OrderType == "07") + { + questions2.Add("CaseType", 1); + } + else if (data.OrderType == "07") + { + questions2.Add("CaseType", 1); + } + else if (data.OrderType == "02" && (data.OrderType1 == "浠f嫙鎶曡瘔涔�" || data.OrderType1 == "浠f嫙璐ㄧ枒鍑�")) + { + questions2.Add("CaseType", 2); + } + + questions2.Add("count", Decimal.ToInt32(data.OrderNum.Value)); + + string requestJson2 = questions2.ToString(); + string result2 = string.Empty; + + using (HttpContent httpContent = new StringContent(requestJson2)) + { + httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + var httpClient2 = _clientFactory.CreateClient(); + httpClient2.Timeout = new TimeSpan(0, 0, 10); + var Result2 = await httpClient2.PostAsync(postUrl2, httpContent); + result2 = Result2.Content.ReadAsStringAsync().Result; + } + + _logger.LogInformation("result2:" + result2); + JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); + + if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") + { + resultEntity.Result = true; + } + else + { + resultEntity.Result = false; + resultEntity.Message = "鍐欏叆浼氬憳璁㈠崟澶辫触"; + return new JsonResult(resultEntity); + } + } + } + + + + + + } + + using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, + new TransactionOptions + { + IsolationLevel = IsolationLevel.ReadCommitted, + Timeout = TransactionManager.MaximumTimeout + } + )) + { + + if (youhui) + { + var youHuiDTOs = _askService.GetAskYouHuiList(data.Khdw, data.OrderType).FirstOrDefault(); + if (youHuiDTOs != null) + { + data.Youhuier = youHuiDTOs.Id; + if (youHuiDTOs.Youhuistandard == "01") + { + data.Youhui = youHuiDTOs.YouHui.Value; + if (data.Money.Value < data.Youhui.Value) + { + data.Money = 0; + } + else + { + data.Money = data.Money.Value - data.Youhui.Value; + } + + } + else if (youHuiDTOs.Youhuistandard == "02") + { + if (youHuiDTOs.YouHui.Value >= 100) + { + data.Youhui = data.Money.Value; + data.Money = 0; + } + else + { + data.Youhui = Math.Round(data.Money.Value * youHuiDTOs.YouHui.Value * new decimal(0.01), 2); + data.Money = data.Money.Value - data.Youhui.Value; + } + } + + + } + } + + data.ShouliStatus = "1"; data.Modifier = curentuser.Id; data.Modifytime = DateTime.Now; diff --git a/zhengcaioa/zhengcaioa/Startup.cs b/zhengcaioa/zhengcaioa/Startup.cs index 0fff994..a7dc189 100644 --- a/zhengcaioa/zhengcaioa/Startup.cs +++ b/zhengcaioa/zhengcaioa/Startup.cs @@ -74,6 +74,10 @@ services.AddDbContext<zcwebContext>(options => options.UseSqlServer(connectionString1)); + var connectionString2 = Configuration.GetConnectionString("zcUserInfoNConnection"); + services.AddDbContext<zcUserInfoN_dbContext>(options => + options.UseSqlServer(connectionString2)); + services.AddControllersWithViews(); services.AddScoped(typeof(ISimService), typeof(SimService)); diff --git a/zhengcaioa/zhengcaioa/appsettings.Development.json b/zhengcaioa/zhengcaioa/appsettings.Development.json index 7f62f45..ff35d65 100644 --- a/zhengcaioa/zhengcaioa/appsettings.Development.json +++ b/zhengcaioa/zhengcaioa/appsettings.Development.json @@ -1,7 +1,8 @@ { "ConnectionStrings": { "DefaultConnection": "server=.;database=zhengcaioa;uid=sa;pwd=123456;", - "zcwebConnection": "server=localhost;database=zcweb;uid=sa;pwd=123456;" + "zcwebConnection": "server=localhost;database=zcweb;uid=sa;pwd=123456;", + "zcUserInfoNConnection": "server=localhost;database=zcUserInfoN_db;uid=sa;pwd=123456;" }, "Logging": { "LogLevel": { diff --git a/zhengcaioa/zhengcaioa/appsettings.json b/zhengcaioa/zhengcaioa/appsettings.json index 565c423..a955d8f 100644 --- a/zhengcaioa/zhengcaioa/appsettings.json +++ b/zhengcaioa/zhengcaioa/appsettings.json @@ -1,7 +1,8 @@ { "ConnectionStrings": { "DefaultConnection": "server=localhost;database=zhengcaioa;uid=sa;pwd=123456;", - "zcwebConnection": "server=localhost;database=zcweb;uid=sa;pwd=123456;" + "zcwebConnection": "server=localhost;database=zcweb;uid=sa;pwd=123456;", + "zcUserInfoNConnection": "server=localhost;database=zcUserInfoN_db;uid=sa;pwd=123456;" }, "Logging": { "LogLevel": { -- Gitblit v1.9.1