Browse Source

编辑采购方案支持议价成本

yijia
shanji 2 years ago
parent
commit
b330aa191d
  1. 30
      BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
  2. 15
      BBWYB.Server.Model/Db/PurchaseScheme/PurchaseScheme.cs
  3. 15
      BBWYB.Server.Model/Db/PurchaseScheme/history/HistoryPurchaseScheme.cs

30
BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs

@ -390,7 +390,8 @@ namespace BBWYB.Server.Business
{ {
if (psReq.SchemeGroupId == null || psReq.SchemeGroupId == 0) if (psReq.SchemeGroupId == null || psReq.SchemeGroupId == 0)
psReq.SchemeGroupId = newPurchaseGroupId; psReq.SchemeGroupId = newPurchaseGroupId;
var defaultCost = 0M;
decimal? bargainingCost = null;
var ps = new PurchaseScheme() var ps = new PurchaseScheme()
{ {
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
@ -419,7 +420,15 @@ namespace BBWYB.Server.Business
pss.CreateTime = DateTime.Now; pss.CreateTime = DateTime.Now;
pss.SkuPurchaseSchemeId = ps.Id; pss.SkuPurchaseSchemeId = ps.Id;
addPurchaseSchemeProductSkuList.Add(pss); 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 处理历史版本 #region 处理历史版本
var historyPss = pss.Map<HistoryPurchaseSchemeProductSku>(); var historyPss = pss.Map<HistoryPurchaseSchemeProductSku>();
@ -438,6 +447,9 @@ namespace BBWYB.Server.Business
} }
#region 处理历史版本 #region 处理历史版本
ps.DefaultCost = defaultCost;
ps.BargainingCost = bargainingCost;
var historyPs = ps.Map<HistoryPurchaseScheme>(); var historyPs = ps.Map<HistoryPurchaseScheme>();
historyPs.HistoryId = idGenerator.NewLong(); historyPs.HistoryId = idGenerator.NewLong();
insertHistoryPSList.Add(historyPs); insertHistoryPSList.Add(historyPs);
@ -461,6 +473,7 @@ namespace BBWYB.Server.Business
throw new BusinessException($"未找到编辑方案{schemeId}"); throw new BusinessException($"未找到编辑方案{schemeId}");
var newVersion = dbps.Version + 1; //采购方案版本 var newVersion = dbps.Version + 1; //采购方案版本
var defaultCost = 0M; var defaultCost = 0M;
decimal? bargainingCost = null; //只有当任意配件包含议价成本时才具备此值
foreach (var pspReq in psReq.PurchaseSchemeProductList) foreach (var pspReq in psReq.PurchaseSchemeProductList)
{ {
var psp = pspReq.Map<PurchaseSchemeProduct>(); var psp = pspReq.Map<PurchaseSchemeProduct>();
@ -476,7 +489,14 @@ namespace BBWYB.Server.Business
pss.CreateTime = DateTime.Now; pss.CreateTime = DateTime.Now;
pss.SkuPurchaseSchemeId = schemeId; pss.SkuPurchaseSchemeId = schemeId;
addPurchaseSchemeProductSkuList.Add(pss); 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 处理历史版本 #region 处理历史版本
var historyPss = pssReq.Map<HistoryPurchaseSchemeProductSku>(); var historyPss = pssReq.Map<HistoryPurchaseSchemeProductSku>();
@ -499,6 +519,7 @@ namespace BBWYB.Server.Business
} }
var psupdate = fsql.Update<PurchaseScheme>(schemeId) var psupdate = fsql.Update<PurchaseScheme>(schemeId)
.Set(ps => ps.DefaultCost, defaultCost) .Set(ps => ps.DefaultCost, defaultCost)
.Set(ps => ps.BargainingCost, bargainingCost)
.Set(ps => ps.HYSchemeId, psReq.HYSchemeId) .Set(ps => ps.HYSchemeId, psReq.HYSchemeId)
.Set(ps => ps.HYBDId, psReq.HYBDId) .Set(ps => ps.HYBDId, psReq.HYBDId)
.Set(ps => ps.Version, newVersion); .Set(ps => ps.Version, newVersion);
@ -509,6 +530,9 @@ namespace BBWYB.Server.Business
historyPs.LastPurchaseTime = dbps.LastPurchaseTime; historyPs.LastPurchaseTime = dbps.LastPurchaseTime;
historyPs.LastPurchasePriceCost = dbps.LastPurchasePriceCost; historyPs.LastPurchasePriceCost = dbps.LastPurchasePriceCost;
historyPs.DefaultCost = defaultCost; historyPs.DefaultCost = defaultCost;
historyPs.BargainingCost = bargainingCost;
historyPs.PurchasedCount = dbps.PurchasedCount;
historyPs.PurchasedAmount = dbps.PurchasedAmount;
historyPs.CreateTime = DateTime.Now; historyPs.CreateTime = DateTime.Now;
historyPs.Version = newVersion; historyPs.Version = newVersion;
historyPs.HistoryId = idGenerator.NewLong(); historyPs.HistoryId = idGenerator.NewLong();

15
BBWYB.Server.Model/Db/PurchaseScheme/PurchaseScheme.cs

@ -78,6 +78,21 @@ namespace BBWYB.Server.Model
[Column(IsIgnore = true)] [Column(IsIgnore = true)]
public List<PurchaseSchemeProduct> PurchaseSchemeProductList { get; set; } public List<PurchaseSchemeProduct> PurchaseSchemeProductList { get; set; }
/// <summary>
/// 议价成本,只有当任意配件包含议价成本时才具备此值
/// </summary>
public decimal? BargainingCost { get; set; }
/// <summary>
/// 采购次数
/// </summary>
public int? PurchasedCount { get; set; } = 0;
/// <summary>
/// 采购金额
/// </summary>
public decimal? PurchasedAmount { get; set; } = 0M;
} }
} }

15
BBWYB.Server.Model/Db/PurchaseScheme/history/HistoryPurchaseScheme.cs

@ -78,6 +78,21 @@ namespace BBWYB.Server.Model.Db
[Column(DbType = "int")] [Column(DbType = "int")]
public int? Version { get; set; } = 1; public int? Version { get; set; } = 1;
/// <summary>
/// 议价成本,只有当任意配件包含议价成本时才具备此值
/// </summary>
public decimal? BargainingCost { get; set; }
/// <summary>
/// 采购次数
/// </summary>
public int? PurchasedCount { get; set; } = 0;
/// <summary>
/// 采购金额
/// </summary>
public decimal? PurchasedAmount { get; set; } = 0M;
} }
} }

Loading…
Cancel
Save