|
|
@ -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<HistoryPurchaseSchemeProductSku>(); |
|
|
@ -438,6 +447,9 @@ namespace BBWYB.Server.Business |
|
|
|
} |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
|
|
|
|
ps.DefaultCost = defaultCost; |
|
|
|
ps.BargainingCost = bargainingCost; |
|
|
|
var historyPs = ps.Map<HistoryPurchaseScheme>(); |
|
|
|
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<PurchaseSchemeProduct>(); |
|
|
@ -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<HistoryPurchaseSchemeProductSku>(); |
|
|
@ -499,6 +519,7 @@ namespace BBWYB.Server.Business |
|
|
|
} |
|
|
|
var psupdate = fsql.Update<PurchaseScheme>(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(); |
|
|
|