From b330aa191d3c57dc064e629b4dfd29b3472aa3a5 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Wed, 20 Sep 2023 02:29:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=87=87=E8=B4=AD=E6=96=B9?= =?UTF-8?q?=E6=A1=88=E6=94=AF=E6=8C=81=E8=AE=AE=E4=BB=B7=E6=88=90=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseScheme/PurchaseSchemeBusiness.cs | 30 +++++++++++++++++-- .../Db/PurchaseScheme/PurchaseScheme.cs | 15 ++++++++++ .../history/HistoryPurchaseScheme.cs | 15 ++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs b/BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs index 748c5de..0423870 100644 --- a/BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs +++ b/BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs @@ -390,7 +390,8 @@ namespace BBWYB.Server.Business { if (psReq.SchemeGroupId == null || psReq.SchemeGroupId == 0) psReq.SchemeGroupId = newPurchaseGroupId; - + var defaultCost = 0M; + decimal? bargainingCost = null; var ps = new PurchaseScheme() { CreateTime = DateTime.Now, @@ -419,7 +420,15 @@ namespace BBWYB.Server.Business pss.CreateTime = DateTime.Now; pss.SkuPurchaseSchemeId = ps.Id; addPurchaseSchemeProductSkuList.Add(pss); - ps.DefaultCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); + //ps.DefaultCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); + + defaultCost += pssReq.DefaultPrice ?? 0; + if (pssReq.ActualPrice != null && pssReq.ActualPrice > 0M) + { + if (bargainingCost == null) + bargainingCost = 0M; + bargainingCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); + } #region 处理历史版本 var historyPss = pss.Map(); @@ -438,6 +447,9 @@ namespace BBWYB.Server.Business } #region 处理历史版本 + + ps.DefaultCost = defaultCost; + ps.BargainingCost = bargainingCost; var historyPs = ps.Map(); historyPs.HistoryId = idGenerator.NewLong(); insertHistoryPSList.Add(historyPs); @@ -461,6 +473,7 @@ namespace BBWYB.Server.Business throw new BusinessException($"未找到编辑方案{schemeId}"); var newVersion = dbps.Version + 1; //采购方案版本 var defaultCost = 0M; + decimal? bargainingCost = null; //只有当任意配件包含议价成本时才具备此值 foreach (var pspReq in psReq.PurchaseSchemeProductList) { var psp = pspReq.Map(); @@ -476,7 +489,14 @@ namespace BBWYB.Server.Business pss.CreateTime = DateTime.Now; pss.SkuPurchaseSchemeId = schemeId; addPurchaseSchemeProductSkuList.Add(pss); - defaultCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); + //defaultCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); + defaultCost += pssReq.DefaultPrice ?? 0; + if (pssReq.ActualPrice != null && pssReq.ActualPrice > 0M) + { + if (bargainingCost == null) + bargainingCost = 0M; + bargainingCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); + } #region 处理历史版本 var historyPss = pssReq.Map(); @@ -499,6 +519,7 @@ namespace BBWYB.Server.Business } var psupdate = fsql.Update(schemeId) .Set(ps => ps.DefaultCost, defaultCost) + .Set(ps => ps.BargainingCost, bargainingCost) .Set(ps => ps.HYSchemeId, psReq.HYSchemeId) .Set(ps => ps.HYBDId, psReq.HYBDId) .Set(ps => ps.Version, newVersion); @@ -509,6 +530,9 @@ namespace BBWYB.Server.Business historyPs.LastPurchaseTime = dbps.LastPurchaseTime; historyPs.LastPurchasePriceCost = dbps.LastPurchasePriceCost; historyPs.DefaultCost = defaultCost; + historyPs.BargainingCost = bargainingCost; + historyPs.PurchasedCount = dbps.PurchasedCount; + historyPs.PurchasedAmount = dbps.PurchasedAmount; historyPs.CreateTime = DateTime.Now; historyPs.Version = newVersion; historyPs.HistoryId = idGenerator.NewLong(); diff --git a/BBWYB.Server.Model/Db/PurchaseScheme/PurchaseScheme.cs b/BBWYB.Server.Model/Db/PurchaseScheme/PurchaseScheme.cs index 2880073..b46941e 100644 --- a/BBWYB.Server.Model/Db/PurchaseScheme/PurchaseScheme.cs +++ b/BBWYB.Server.Model/Db/PurchaseScheme/PurchaseScheme.cs @@ -78,6 +78,21 @@ namespace BBWYB.Server.Model [Column(IsIgnore = true)] public List PurchaseSchemeProductList { get; set; } + + /// + /// 议价成本,只有当任意配件包含议价成本时才具备此值 + /// + public decimal? BargainingCost { get; set; } + + /// + /// 采购次数 + /// + public int? PurchasedCount { get; set; } = 0; + + /// + /// 采购金额 + /// + public decimal? PurchasedAmount { get; set; } = 0M; } } diff --git a/BBWYB.Server.Model/Db/PurchaseScheme/history/HistoryPurchaseScheme.cs b/BBWYB.Server.Model/Db/PurchaseScheme/history/HistoryPurchaseScheme.cs index fa4f370..8985be5 100644 --- a/BBWYB.Server.Model/Db/PurchaseScheme/history/HistoryPurchaseScheme.cs +++ b/BBWYB.Server.Model/Db/PurchaseScheme/history/HistoryPurchaseScheme.cs @@ -78,6 +78,21 @@ namespace BBWYB.Server.Model.Db [Column(DbType = "int")] public int? Version { get; set; } = 1; + /// + /// 议价成本,只有当任意配件包含议价成本时才具备此值 + /// + public decimal? BargainingCost { get; set; } + + /// + /// 采购次数 + /// + public int? PurchasedCount { get; set; } = 0; + + /// + /// 采购金额 + /// + public decimal? PurchasedAmount { get; set; } = 0M; + } }