shanji 2 years ago
parent
commit
c75c66595a
  1. 95
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  2. 24
      BBWY.Server.Business/Sync/ProductSyncBusiness.cs
  3. 5
      BBWY.Server.Model/Db/Product/ProductSku.cs

95
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -673,6 +673,7 @@ namespace BBWY.Server.Business
List<string> giftSkuIdList = new List<string>(); List<string> giftSkuIdList = new List<string>();
long promotionId = 0; long promotionId = 0;
var brandName = string.Empty; var brandName = string.Empty;
#region 获取主商品品牌 #region 获取主商品品牌
{ {
stepText = "获取主商品品牌"; stepText = "获取主商品品牌";
@ -709,6 +710,7 @@ namespace BBWY.Server.Business
#region 上架赠品 #region 上架赠品
string barCode = string.Empty, categoryId = string.Empty; string barCode = string.Empty, categoryId = string.Empty;
IList<JToken> multiCateProps = null; IList<JToken> multiCateProps = null;
#region 获取主商品sku信息 barCode,categoryId,multiCateProps #region 获取主商品sku信息 barCode,categoryId,multiCateProps
{ {
stepText = "获取主商品sku信息"; stepText = "获取主商品sku信息";
@ -903,21 +905,14 @@ namespace BBWY.Server.Business
{ {
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) if (!string.IsNullOrEmpty(request.GiftTemplateSku))
{ {
try DeleteSkuList(new DeleteSkuListRequest()
{ {
foreach (var deleteSku in giftSkuIdList) AppKey = request.AppKey,
{ AppSecret = request.AppSecret,
DeleteSku(new DeleteSkuRequest() AppToken = request.AppToken,
{ Platform = request.Platform,
AppKey = request.AppKey, SkuList = giftSkuIdList
AppSecret = request.AppSecret, });
AppToken = request.AppToken,
Platform = request.Platform,
Sku = deleteSku
});
}
}
catch { }
} }
throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
@ -1001,19 +996,6 @@ namespace BBWY.Server.Business
req.bindType = req.bindType.Substring(0, req.bindType.Length - 1); req.bindType = req.bindType.Substring(0, req.bindType.Length - 1);
req.num = req.num.Substring(0, req.num.Length - 1); req.num = req.num.Substring(0, req.num.Length - 1);
//req.skuIds = "";
//req.jdPrices = ;
//req.promoPrices = ;
//req.seq = ;
//req.num = ;
//req.bindType = ;
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.IsError) if (res.IsError)
throw new BusinessException($"添加活动sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"添加活动sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
@ -1029,21 +1011,14 @@ namespace BBWY.Server.Business
{ {
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) if (!string.IsNullOrEmpty(request.GiftTemplateSku))
{ {
try DeleteSkuList(new DeleteSkuListRequest()
{ {
foreach (var deleteSku in giftSkuIdList) AppKey = request.AppKey,
{ AppSecret = request.AppSecret,
DeleteSku(new DeleteSkuRequest() AppToken = request.AppToken,
{ Platform = request.Platform,
AppKey = request.AppKey, SkuList = giftSkuIdList
AppSecret = request.AppSecret, });
AppToken = request.AppToken,
Platform = request.Platform,
Sku = deleteSku
});
}
}
catch { }
} }
throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
@ -1061,21 +1036,14 @@ namespace BBWY.Server.Business
{ {
if (!string.IsNullOrEmpty(request.GiftTemplateSku)) if (!string.IsNullOrEmpty(request.GiftTemplateSku))
{ {
try DeleteSkuList(new DeleteSkuListRequest()
{ {
foreach (var deleteSku in giftSkuIdList) AppKey = request.AppKey,
{ AppSecret = request.AppSecret,
DeleteSku(new DeleteSkuRequest() AppToken = request.AppToken,
{ Platform = request.Platform,
AppKey = request.AppKey, SkuList = giftSkuIdList
AppSecret = request.AppSecret, });
AppToken = request.AppToken,
Platform = request.Platform,
Sku = deleteSku
});
}
}
catch { }
} }
throw new BusinessException($"审核活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"审核活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
@ -1083,17 +1051,14 @@ namespace BBWY.Server.Business
#endregion #endregion
#region 下架赠品sku #region 下架赠品sku
foreach (var deleteSku in giftSkuIdList) DeleteSkuList(new DeleteSkuListRequest()
{ {
DeleteSku(new DeleteSkuRequest() AppKey = request.AppKey,
{ AppSecret = request.AppSecret,
AppKey = request.AppKey, AppToken = request.AppToken,
AppSecret = request.AppSecret, Platform = request.Platform,
AppToken = request.AppToken, SkuList = giftSkuIdList
Platform = request.Platform, });
Sku = deleteSku
});
}
#endregion #endregion
#region 设置完整标题 #region 设置完整标题

24
BBWY.Server.Business/Sync/ProductSyncBusiness.cs

@ -83,12 +83,14 @@ namespace BBWY.Server.Business.Sync
AppSecret = shop.AppSecret, AppSecret = shop.AppSecret,
AppToken = shop.AppToken, AppToken = shop.AppToken,
Platform = shop.PlatformId, Platform = shop.PlatformId,
Spu = product.Id Spu = product.Id,
IsContainSource = true
}); });
if (skuList == null || skuList.Count() == 0) if (skuList == null || skuList.Count() == 0)
continue; continue;
foreach (var sku in skuList) foreach (var sku in skuList)
{ {
var categoryId = sku.Source.Value<int>("categoryId");
var dbSku = dbProductSkus.FirstOrDefault(s => s.Id == sku.Id); var dbSku = dbProductSkus.FirstOrDefault(s => s.Id == sku.Id);
if (dbSku == null) if (dbSku == null)
{ {
@ -102,12 +104,16 @@ namespace BBWY.Server.Business.Sync
ProductId = sku.ProductId, ProductId = sku.ProductId,
ShopId = shopId, ShopId = shopId,
Title = sku.Title, Title = sku.Title,
State = sku.State State = sku.State,
CategoryId = categoryId
}); });
} }
else if (dbSku.State != sku.State || dbSku.Price != sku.Price) else if (dbSku.State != sku.State || dbSku.Price != sku.Price || dbSku.CategoryId != categoryId)
{ {
var update = fsql.Update<ProductSku>(dbSku.Id).Set(s => s.State, sku.State).Set(s => s.Price, sku.Price); var update = fsql.Update<ProductSku>(dbSku.Id)
.Set(s => s.State, sku.State)
.Set(s => s.Price, sku.Price)
.Set(s => s.CategoryId, categoryId);
updateProductSkuList.Add(update); updateProductSkuList.Add(update);
} }
} }
@ -211,11 +217,11 @@ namespace BBWY.Server.Business.Sync
public void SyncAllShopAllProduct() public void SyncAllShopAllProduct()
{ {
var shopList = venderBusiness.GetShopList(); var shopList = venderBusiness.GetShopList();
//SyncProduct(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), true); SyncProduct(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), true);
foreach (var shop in shopList) //foreach (var shop in shopList)
{ //{
Task.Factory.StartNew(() => SyncProduct(shop, true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler); // Task.Factory.StartNew(() => SyncProduct(shop, true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler);
} //}
} }
} }
} }

5
BBWY.Server.Model/Db/Product/ProductSku.cs

@ -46,6 +46,11 @@ namespace BBWY.Server.Model.Db
/// </summary> /// </summary>
public int? State { get; set; } public int? State { get; set; }
/// <summary>
/// 三级类目Id
/// </summary>
public int? CategoryId { get; set; }
} }
} }

Loading…
Cancel
Save