diff --git a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs index 6531393b..8d9ccb5e 100644 --- a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs +++ b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs @@ -183,7 +183,7 @@ namespace BBWY.Server.Business IList> updatePurchaseOrderList = new List>(); IList> updateSkuDailySalesDetailList = new List>(); - ConcurrentDictionary> skuDailySalesDetailDictionary = new ConcurrentDictionary>(); + Dictionary> skuDailySalesDetailDictionary = new Dictionary>(); #endregion #region 赠品 @@ -684,9 +684,10 @@ namespace BBWY.Server.Business { var skuDailySalesDetailList = skuDailySalesDetailDictionary[date]; var skuDailySalesDetailIds = skuDailySalesDetailList.Select(s => s.Sku).ToList(); - var dbSkuDailySalesDetailIds = fsql.Select().Where(s => s.ShopId == shopId && - s.Date == date && - skuDailySalesDetailIds.Contains(s.Sku)).ToList(s => s.Sku); + var dbSkuDailySalesDetailList = fsql.Select().Where(s => s.ShopId == shopId && + s.Date == date && + skuDailySalesDetailIds.Contains(s.Sku)).ToList(); + var dbSkuDailySalesDetailIds = dbSkuDailySalesDetailList.Select(s => s.Sku); var exceptIds = skuDailySalesDetailIds.Except(dbSkuDailySalesDetailIds).ToList(); if (exceptIds.Count() > 0) { @@ -702,14 +703,14 @@ namespace BBWY.Server.Business var intersectIds = skuDailySalesDetailIds.Intersect(dbSkuDailySalesDetailIds).ToList(); if (intersectIds.Count() > 0) { - var updateList = skuDailySalesDetailList.Where(s => intersectIds.Contains(s.Sku)); - foreach (var s in updateList) + foreach (var intersectId in intersectIds) { - var iupdate = fsql.Update().Set(ds => ds.Amount + s.Amount) - .Set(ds => ds.OrderCount + s.OrderCount) - .Set(ds => ds.ItemTotal + s.ItemTotal) - .Where(ds => ds.ShopId == shopId && ds.Date == s.Date && ds.Sku == s.Sku); - updateSkuDailySalesDetailList.Add(iupdate); + var skudaily = skuDailySalesDetailList.FirstOrDefault(s => s.Sku == intersectId); + var dbSkudaily = dbSkuDailySalesDetailList.FirstOrDefault(s => s.Sku == intersectId); + var update = fsql.Update(dbSkudaily.Id).Set(ds => ds.Amount + skudaily.Amount) + .Set(ds => ds.OrderCount + skudaily.OrderCount) + .Set(ds => ds.ItemTotal + skudaily.ItemTotal); + updateSkuDailySalesDetailList.Add(update); } } } @@ -748,9 +749,9 @@ namespace BBWY.Server.Business update.ExecuteAffrows(); } - //if (updateSkuDailySalesDetailList.Count > 0) - // foreach (var update in updateSkuDailySalesDetailList) - // update.ExecuteAffrows(); + if (updateSkuDailySalesDetailList.Count > 0) + foreach (var update in updateSkuDailySalesDetailList) + update.ExecuteAffrows(); }); } @@ -776,7 +777,7 @@ namespace BBWY.Server.Business /// /// /// - private void CumulativeSkuDailySalesDetail(ConcurrentDictionary> skuDailySalesDetailDictionary, + private void CumulativeSkuDailySalesDetail(Dictionary> skuDailySalesDetailDictionary, DateTime orderStartTime, long shopId, string skuId, @@ -788,7 +789,7 @@ namespace BBWY.Server.Business if (!skuDailySalesDetailDictionary.TryGetValue(startDate, out List skuDailySalesDetailList)) { skuDailySalesDetailList = new List(); - skuDailySalesDetailDictionary.TryAdd(startDate, skuDailySalesDetailList); + skuDailySalesDetailDictionary.Add(startDate, skuDailySalesDetailList); } var skuDailySalesDetail = skuDailySalesDetailList.FirstOrDefault(s => s.Sku == skuId); if (skuDailySalesDetail == null)