shanji 2 years ago
parent
commit
5f3d728c16
  1. 231
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  2. 10
      BBWY.Server.Model/Dto/Request/Product/SearchProductSkuRequest.cs
  3. 8
      DongDongInJection/InDll/CSharpAPIs.cs

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

@ -170,6 +170,13 @@ namespace BBWY.Server.Business
break; break;
pageIndex++; pageIndex++;
} }
if (searchProductSkuRequest.IsCheckSkuCount &&
!string.IsNullOrEmpty(searchProductSkuRequest.Sku) &&
skuIdList.Count() != skuList.Count())
{
throw new BusinessException($"{searchProductSkuRequest.CheckStep}-sku条件数量和查询结果数量不一致");
}
return skuList; return skuList;
} }
@ -703,24 +710,33 @@ namespace BBWY.Server.Business
var req = new SellerPromotionSkuAddRequest(); var req = new SellerPromotionSkuAddRequest();
req.promoId = promotionId; req.promoId = promotionId;
foreach (var sku in skuList) var pageIndex = 1;
var pageSize = 100;
var totalPage = (skuList.Count() - 1) / pageSize + 1;
for (var i = 0; i < totalPage; i++)
{ {
req.skuIds = $"{req.skuIds}{sku.Id},"; var currentPageList = skuList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
req.jdPrices = $"{req.jdPrices}{sku.Price},";
req.bindType = $"{req.bindType}{(isGift ? 2 : 1)},";
req.num = $"{req.num}1,";
req.promoPrices = $"{req.promoPrices}{(isGift ? 0 : sku.Price)},";
}
req.skuIds = req.skuIds.Substring(0, req.skuIds.Length - 1); foreach (var sku in currentPageList)
req.jdPrices = req.jdPrices.Substring(0, req.jdPrices.Length - 1); {
req.bindType = req.bindType.Substring(0, req.bindType.Length - 1); req.skuIds = $"{req.skuIds}{sku.Id},";
req.num = req.num.Substring(0, req.num.Length - 1); req.jdPrices = $"{req.jdPrices}{sku.Price},";
req.promoPrices = req.promoPrices.Substring(0, req.promoPrices.Length - 1); req.bindType = $"{req.bindType}{(isGift ? 2 : 1)},";
req.num = $"{req.num}1,";
req.promoPrices = $"{req.promoPrices}{(isGift ? 0 : sku.Price)},";
}
var res = jdClient.Execute(req, token, DateTime.Now.ToLocalTime()); req.skuIds = req.skuIds.Substring(0, req.skuIds.Length - 1);
if (res.IsError) req.jdPrices = req.jdPrices.Substring(0, req.jdPrices.Length - 1);
throw new BusinessException($"添加活动sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); req.bindType = req.bindType.Substring(0, req.bindType.Length - 1);
req.num = req.num.Substring(0, req.num.Length - 1);
req.promoPrices = req.promoPrices.Substring(0, req.promoPrices.Length - 1);
var res = jdClient.Execute(req, token, DateTime.Now.ToLocalTime());
if (res.IsError)
throw new BusinessException($"添加活动sku失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
}
} }
public override long StartJDPromotionTask(StartPromotionTaskRequest2 request) public override long StartJDPromotionTask(StartPromotionTaskRequest2 request)
@ -736,6 +752,71 @@ namespace BBWY.Server.Business
var brandName = string.Empty; var brandName = string.Empty;
var haveGiftTemplateSku = request.GiftTemplateSkuList != null && request.GiftTemplateSkuList.Count() > 0; var haveGiftTemplateSku = request.GiftTemplateSkuList != null && request.GiftTemplateSkuList.Count() > 0;
#region 前置检查各项sku
var searchProductSkuRequest = new SearchProductSkuRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
IsCheckSkuCount = true
};
IList<ProductSkuResponse> motherTemplateSkuList = null;
IList<ProductSkuResponse> customerMotherSkuList = null;
IList<ProductSkuResponse> mainProductSkuList = null;
IList<ProductSkuResponse> giftSkuList = null;
#region 查询奶妈模板SKU
if (!string.IsNullOrEmpty(request.MotherTemplateSku))
{
stepText = "查询奶妈模板SKU";
searchProductSkuRequest.Sku = request.MotherTemplateSku;
searchProductSkuRequest.CheckStep = "奶妈模板";
motherTemplateSkuList = GetProductSkuList(searchProductSkuRequest);
}
#endregion
#region 查询自定义奶妈SKU
if (!string.IsNullOrEmpty(request.CustomMotherSku))
{
stepText = "查询自定义奶妈SKU";
searchProductSkuRequest.Sku = request.CustomMotherSku;
searchProductSkuRequest.CheckStep = "自定义奶妈";
customerMotherSkuList = GetProductSkuList(searchProductSkuRequest);
}
#endregion
#region 查询主商品sku
if (!string.IsNullOrEmpty(request.MainProductSku))
{
stepText = "查询主商品SKU";
searchProductSkuRequest.Sku = request.MainProductSku;
searchProductSkuRequest.CheckStep = "主商品";
mainProductSkuList = GetProductSkuList(searchProductSkuRequest);
//stepText = "添加主商品SKU";
//AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false);
}
#endregion
#region 查询主商品赠品sku
if (!string.IsNullOrEmpty(request.MainProductGiftSku))
{
stepText = "查询主商品赠品SKU";
searchProductSkuRequest.Sku = request.MainProductGiftSku;
searchProductSkuRequest.CheckStep = "主商品赠品";
giftSkuList = GetProductSkuList(searchProductSkuRequest);
giftSkuIdList = giftSkuList.Select(gs => gs.Id).ToList();
//stepText = "添加赠品SKU";
//AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, true);
}
#endregion
#endregion
#region 获取主商品品牌 #region 获取主商品品牌
{ {
stepText = "获取主商品品牌"; stepText = "获取主商品品牌";
@ -794,19 +875,6 @@ namespace BBWY.Server.Business
} }
#endregion #endregion
//#region 获取赠品sku信息
//stepText = "获取赠品sku信息";
//var selectGiftSkuList = GetProductSkuList(new SearchProductSkuRequest()
//{
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// IsContainSource = true,
// Platform = request.Platform,
// Sku = request.GiftTemplateSku
//});
//#endregion
#region 获取销售属性 #region 获取销售属性
stepText = "获取销售属性"; stepText = "获取销售属性";
IList<JToken> colorSaleAttrs = null; IList<JToken> colorSaleAttrs = null;
@ -938,14 +1006,25 @@ namespace BBWY.Server.Business
#endregion #endregion
#endregion #endregion
}
else #region 查询上架的赠品
{ stepText = "查询上架的赠品SKU";
var skuList = request.MainProductGiftSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); searchProductSkuRequest.Sku = string.Join(",", giftSkuIdList);
giftSkuIdList.AddRange(skuList); searchProductSkuRequest.CheckStep = "上架的赠品";
giftSkuList = GetProductSkuList(searchProductSkuRequest);
#endregion
} }
#region 创建活动 #region 创建活动
var deleteGiftSkuRequest = new DeleteSkuListRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
SkuList = giftSkuIdList
};
{ {
stepText = "创建活动"; stepText = "创建活动";
var req = new SellerPromotionAddRequest(); var req = new SellerPromotionAddRequest();
@ -966,16 +1045,7 @@ namespace BBWY.Server.Business
if (res.IsError) if (res.IsError)
{ {
if (haveGiftTemplateSku) if (haveGiftTemplateSku)
{ DeleteSkuList(deleteGiftSkuRequest);
DeleteSkuList(new DeleteSkuListRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
SkuList = giftSkuIdList
});
}
throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
@ -986,57 +1056,29 @@ namespace BBWY.Server.Business
#region 添加活动sku #region 添加活动sku
{ {
var searchProductSkuRequest = new SearchProductSkuRequest() if (motherTemplateSkuList != null && motherTemplateSkuList.Count() > 0)
{ {
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
};
#region 添加奶妈模板SKU
if (!string.IsNullOrEmpty(request.MotherTemplateSku))
{
stepText = "查询奶妈模板SKU";
searchProductSkuRequest.Sku = request.MotherTemplateSku;
var skuList = GetProductSkuList(searchProductSkuRequest);
stepText = "添加奶妈模板SKU"; stepText = "添加奶妈模板SKU";
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false); AddJDPromotionSku(jdClient, request.AppToken, promotionId, motherTemplateSkuList, false);
} }
#endregion
#region 添加自定义奶妈SKU if (customerMotherSkuList != null && customerMotherSkuList.Count() > 0)
if (!string.IsNullOrEmpty(request.CustomMotherSku))
{ {
stepText = "查询自定义奶妈SKU";
searchProductSkuRequest.Sku = request.CustomMotherSku;
var skuList = GetProductSkuList(searchProductSkuRequest);
stepText = "添加自定义奶妈SKU"; stepText = "添加自定义奶妈SKU";
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false); AddJDPromotionSku(jdClient, request.AppToken, promotionId, customerMotherSkuList, false);
} }
#endregion
#region 添加主商品sku if (mainProductSkuList != null && mainProductSkuList.Count() > 0)
if (!string.IsNullOrEmpty(request.MainProductSku))
{ {
stepText = "查询主商品SKU";
searchProductSkuRequest.Sku = request.MainProductSku;
var skuList = GetProductSkuList(searchProductSkuRequest);
stepText = "添加主商品SKU"; stepText = "添加主商品SKU";
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, false); AddJDPromotionSku(jdClient, request.AppToken, promotionId, mainProductSkuList, false);
} }
#endregion
#region 添加赠品sku if (giftSkuList != null && giftSkuList.Count() > 0)
if (giftSkuIdList.Count() > 0)
{ {
stepText = "查询赠品SKU";
searchProductSkuRequest.Sku = string.Join(",", giftSkuIdList);
var skuList = GetProductSkuList(searchProductSkuRequest);
stepText = "添加赠品SKU"; stepText = "添加赠品SKU";
AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, true); AddJDPromotionSku(jdClient, request.AppToken, promotionId, giftSkuList, true);
} }
#endregion
} }
#endregion #endregion
@ -1050,16 +1092,7 @@ namespace BBWY.Server.Business
if (res.IsError) if (res.IsError)
{ {
if (haveGiftTemplateSku) if (haveGiftTemplateSku)
{ DeleteSkuList(deleteGiftSkuRequest);
DeleteSkuList(new DeleteSkuListRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
SkuList = giftSkuIdList
});
}
throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"创建活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
} }
@ -1076,16 +1109,7 @@ namespace BBWY.Server.Business
if (res.IsError) if (res.IsError)
{ {
if (haveGiftTemplateSku) if (haveGiftTemplateSku)
{ DeleteSkuList(deleteGiftSkuRequest);
DeleteSkuList(new DeleteSkuListRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
SkuList = giftSkuIdList
});
}
throw new BusinessException($"审核活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}"); throw new BusinessException($"审核活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
} }
@ -1095,14 +1119,7 @@ namespace BBWY.Server.Business
#region 下架赠品sku #region 下架赠品sku
stepText = "下架赠品sku"; stepText = "下架赠品sku";
Thread.Sleep(3000); Thread.Sleep(3000);
DeleteSkuList(new DeleteSkuListRequest() DeleteSkuList(deleteGiftSkuRequest);
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
SkuList = giftSkuIdList
});
#endregion #endregion
#region 设置完整标题 #region 设置完整标题

10
BBWY.Server.Model/Dto/Request/Product/SearchProductSkuRequest.cs

@ -18,5 +18,15 @@ namespace BBWY.Server.Model.Dto
/// 是否包含源 /// 是否包含源
/// </summary> /// </summary>
public bool IsContainSource { get; set; } public bool IsContainSource { get; set; }
/// <summary>
/// 检查sku数量是否匹配,仅在使用sku条件查询时生效
/// </summary>
public bool IsCheckSkuCount { get; set; }
/// <summary>
/// 检查环节
/// </summary>
public string CheckStep { get; set; }
} }
} }

8
DongDongInJection/InDll/CSharpAPIs.cs

@ -153,10 +153,10 @@ namespace QYDongDongTool
GWL_ID = (-12) GWL_ID = (-12)
} }
public static nint SetWindowStyle(IntPtr hwnd) //public static nint SetWindowStyle(IntPtr hwnd)
{ //{
return SetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE, (GetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE) | 0x00000004)); // return SetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE, (GetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE) | 0x00000004));
} //}
public static bool ReSetParent(IntPtr hWnd) public static bool ReSetParent(IntPtr hWnd)
{ {

Loading…
Cancel
Save