|
|
@ -340,8 +340,8 @@ namespace BBWYB.Server.Business |
|
|
|
IUpdate<PurchaseSchemeGroupIndex>? updatePurchaseSchemeGroupIndex = null; |
|
|
|
|
|
|
|
List<HistoryPurchaseScheme> insertHistoryPSList = new List<HistoryPurchaseScheme>(); |
|
|
|
List<HistoryPurchaseScheme> insertHistoryPSPList = new List<HistoryPurchaseScheme>(); |
|
|
|
List<HistoryPurchaseScheme> insertHistoryPSSList = new List<HistoryPurchaseScheme>(); |
|
|
|
List<HistoryPurchaseSchemeProduct> insertHistoryPSPList = new List<HistoryPurchaseSchemeProduct>(); |
|
|
|
List<HistoryPurchaseSchemeProductSku> insertHistoryPSSList = new List<HistoryPurchaseSchemeProductSku>(); |
|
|
|
|
|
|
|
|
|
|
|
if (batchCURDSchemeRequest.AddPurchaseSchemeList != null && batchCURDSchemeRequest.AddPurchaseSchemeList.Count > 0) |
|
|
@ -400,7 +400,8 @@ namespace BBWYB.Server.Business |
|
|
|
ShopId = psReq.ShopId, |
|
|
|
HYBDId = psReq.HYBDId, |
|
|
|
HYSchemeId = psReq.HYSchemeId, |
|
|
|
SchemeGroupId = psReq.SchemeGroupId ?? 0 |
|
|
|
SchemeGroupId = psReq.SchemeGroupId ?? 0, |
|
|
|
Version = 1 |
|
|
|
}; |
|
|
|
addPurchaseSchemeList.Add(ps); |
|
|
|
foreach (var pspReq in psReq.PurchaseSchemeProductList) |
|
|
@ -419,8 +420,28 @@ namespace BBWYB.Server.Business |
|
|
|
pss.SkuPurchaseSchemeId = ps.Id; |
|
|
|
addPurchaseSchemeProductSkuList.Add(pss); |
|
|
|
ps.DefaultCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
var historyPss = psp.Map<HistoryPurchaseSchemeProductSku>(); |
|
|
|
historyPss.HistoryId = idGenerator.NewLong(); |
|
|
|
historyPss.Version = 1; |
|
|
|
insertHistoryPSSList.Add(historyPss); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
var historyPsp = psp.Map<HistoryPurchaseSchemeProduct>(); |
|
|
|
historyPsp.HistoryId = idGenerator.NewLong(); |
|
|
|
historyPsp.Version = 1; |
|
|
|
insertHistoryPSPList.Add(historyPsp); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
var historyPs = ps.Map<HistoryPurchaseScheme>(); |
|
|
|
historyPs.HistoryId = idGenerator.NewLong(); |
|
|
|
insertHistoryPSList.Add(historyPs); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -435,6 +456,10 @@ namespace BBWYB.Server.Business |
|
|
|
foreach (var psReq in batchCURDSchemeRequest.EditPurchaseSchemeList) |
|
|
|
{ |
|
|
|
var schemeId = psReq.Id; |
|
|
|
var dbps = dbPurchaseSchemes.FirstOrDefault(x => x.Id == schemeId); |
|
|
|
if (dbps == null) |
|
|
|
throw new BusinessException($"未找到编辑方案{schemeId}"); |
|
|
|
var newVersion = dbps.Version + 1; //采购方案版本
|
|
|
|
var defaultCost = 0M; |
|
|
|
foreach (var pspReq in psReq.PurchaseSchemeProductList) |
|
|
|
{ |
|
|
@ -452,13 +477,43 @@ namespace BBWYB.Server.Business |
|
|
|
pss.SkuPurchaseSchemeId = schemeId; |
|
|
|
addPurchaseSchemeProductSkuList.Add(pss); |
|
|
|
defaultCost += ((pssReq.ActualPrice ?? pssReq.DefaultPrice) ?? 0) * (pssReq.PurchaseRatio ?? 1); |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
var historyPss = pssReq.Map<HistoryPurchaseSchemeProductSku>(); |
|
|
|
historyPss.HistoryId = idGenerator.NewLong(); |
|
|
|
historyPss.CreateTime = DateTime.Now; |
|
|
|
historyPss.SkuPurchaseSchemeId = schemeId; |
|
|
|
historyPss.Version = newVersion; |
|
|
|
insertHistoryPSSList.Add(historyPss); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
var historyPsp = pspReq.Map<HistoryPurchaseSchemeProduct>(); |
|
|
|
historyPsp.HistoryId = idGenerator.NewLong(); |
|
|
|
historyPsp.CreateTime = DateTime.Now; |
|
|
|
historyPsp.SkuPurchaseSchemeId = schemeId; |
|
|
|
historyPsp.Version = newVersion; |
|
|
|
insertHistoryPSPList.Add(historyPsp); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
var psupdate = fsql.Update<PurchaseScheme>(schemeId) |
|
|
|
.Set(ps => ps.DefaultCost, defaultCost) |
|
|
|
.Set(ps => ps.HYSchemeId, psReq.HYSchemeId) |
|
|
|
.Set(ps => ps.HYBDId, psReq.HYBDId); |
|
|
|
.Set(ps => ps.HYBDId, psReq.HYBDId) |
|
|
|
.Set(ps => ps.Version, newVersion); |
|
|
|
updatePurchaseSchemeList.Add(psupdate); |
|
|
|
|
|
|
|
#region 处理历史版本
|
|
|
|
var historyPs = psReq.Map<HistoryPurchaseScheme>(); |
|
|
|
historyPs.LastPurchaseTime = dbps.LastPurchaseTime; |
|
|
|
historyPs.LastPurchasePriceCost = dbps.LastPurchasePriceCost; |
|
|
|
historyPs.DefaultCost = defaultCost; |
|
|
|
historyPs.CreateTime = DateTime.Now; |
|
|
|
historyPs.Version = newVersion; |
|
|
|
historyPs.HistoryId = idGenerator.NewLong(); |
|
|
|
insertHistoryPSList.Add(historyPs); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
@ -497,6 +552,13 @@ namespace BBWYB.Server.Business |
|
|
|
} |
|
|
|
insertPurchaseSchemeGroupIndex?.ExecuteAffrows(); |
|
|
|
updatePurchaseSchemeGroupIndex?.ExecuteAffrows(); |
|
|
|
|
|
|
|
if (insertHistoryPSList.Count() > 0) |
|
|
|
fsql.Insert(insertHistoryPSList).ExecuteAffrows(); |
|
|
|
if (insertHistoryPSPList.Count() > 0) |
|
|
|
fsql.Insert(insertHistoryPSPList).ExecuteAffrows(); |
|
|
|
if (insertHistoryPSSList.Count() > 0) |
|
|
|
fsql.Insert(insertHistoryPSSList).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
|
|
|
|
//删除信息残缺的采购方案
|
|
|
|