|
|
@ -68,7 +68,6 @@ namespace BBWY.Server.Business.Sync |
|
|
|
|
|
|
|
List<ProductSku> inserSkuList = new List<ProductSku>(); |
|
|
|
List<IUpdate<ProductSku>> updateProductSkuList = new List<IUpdate<ProductSku>>(); |
|
|
|
List<string> deletedSkuIdList = new List<string>(); |
|
|
|
|
|
|
|
var productIds = productList.Items.Select(p => p.Id); |
|
|
|
var dbProducts = fsql.Select<Product>().Where(p => p.ShopId == shopId && productIds.Contains(p.Id)).ToList(); |
|
|
@ -95,7 +94,13 @@ namespace BBWY.Server.Business.Sync |
|
|
|
var currentDbSkus = dbProductSkus.Where(dbsku => dbsku.ProductId == product.Id).ToList(); |
|
|
|
var deletedSkuList = currentDbSkus.Where(dbsku => skuList.Count(s => s.Id == dbsku.Id) == 0).ToList(); |
|
|
|
if (deletedSkuList.Count() > 0) |
|
|
|
deletedSkuIdList.AddRange(deletedSkuList.Select(dbsku => dbsku.Id)); |
|
|
|
{ |
|
|
|
foreach (var deletedSku in deletedSkuList) |
|
|
|
{ |
|
|
|
var update = fsql.Update<ProductSku>(deletedSku.Id).Set(s => s.State, 4); |
|
|
|
updateProductSkuList.Add(update); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var sku in skuList) |
|
|
|
{ |
|
|
@ -167,8 +172,6 @@ namespace BBWY.Server.Business.Sync |
|
|
|
if (updateProductSkuList.Count > 0) |
|
|
|
foreach (var update in updateProductSkuList) |
|
|
|
update.ExecuteAffrows(); |
|
|
|
if (deletedSkuIdList.Count() > 0) |
|
|
|
fsql.Delete<ProductSku>(deletedSkuIdList).ExecuteAffrows(); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|