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

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

@ -18,5 +18,15 @@ namespace BBWY.Server.Model.Dto
/// 是否包含源
/// </summary>
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)
}
public static nint SetWindowStyle(IntPtr hwnd)
{
return SetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE, (GetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE) | 0x00000004));
}
//public static nint SetWindowStyle(IntPtr hwnd)
//{
// return SetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE, (GetWindowLong(hwnd, (int)GWL.GWL_EXSTYLE) | 0x00000004));
//}
public static bool ReSetParent(IntPtr hWnd)
{

Loading…
Cancel
Save