Browse Source

pjzs验证机制改变

AddValidOverTime
彭聪 2 years ago
parent
commit
fb886aad89
  1. 6
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  2. 52
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  3. 1
      JD.API/Startup.cs

6
BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs

@ -526,6 +526,7 @@ namespace BBWY.Server.Business
}
var joinSkuCount = 0;
var joinSkuNoGiftList = new List<string>();
var host = GetPlatformRelayAPIHost(Enums.Platform.);
var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0;
string barCode = string.Empty, categoryId = string.Empty;
@ -546,10 +547,10 @@ namespace BBWY.Server.Business
var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content);
if (!mainSkuListResponse.Success)
throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}");
joinSkuCount = mainSkuListResponse.Data.Count();
joinSkuNoGiftList.AddRange(mainSkuListResponse.Data.Select(s => s.Id));
//开启延迟任务
if (!string.IsNullOrEmpty(dbPromotionTask.CustomMotherSku))
joinSkuCount += dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count();
joinSkuNoGiftList.AddRange(dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
if (haveGiftTemplateSku)
{
@ -638,6 +639,7 @@ namespace BBWY.Server.Business
.Set(pt => pt.Status, Enums.PromitionTaskStatus.)
.ExecuteAffrows();
joinSkuCount = joinSkuNoGiftList.Distinct().Count();
Task.Factory.StartNew(() => StartPromotionDelayTask(request, startResponse, dbPromotionTask, shop, joinSkuCount), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionDelayTaskScheduler);
}

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

@ -21,6 +21,7 @@ namespace BBWY.Server.Business
{
public class JDBusiness : PlatformSDKBusiness
{
private DingDingBusiness dingDingBusiness;
public override Enums.Platform Platform => Enums.Platform.;
private readonly string searchFields = "orderId,venderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,orderState,orderStateRemark,orderRemark,orderStartTime,orderEndTime,modified,consigneeInfo,itemInfoList,couponDetailList,taxFee,venderRemark,pin,waybill,storeOrder,storeId,sellerDiscount";
@ -36,7 +37,10 @@ namespace BBWY.Server.Business
};
public JDBusiness(IMemoryCache memoryCache, NLogManager nLogManager) : base(memoryCache, nLogManager) { }
public JDBusiness(IMemoryCache memoryCache, NLogManager nLogManager, DingDingBusiness dingDingBusiness) : base(memoryCache, nLogManager)
{
this.dingDingBusiness = dingDingBusiness;
}
private IJdClient GetJdClient(string appKey, string appSecret)
{
@ -1294,7 +1298,7 @@ namespace BBWY.Server.Business
}
}
public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request
public override void StartJDPromotionDelayTask(StartPromotionTaskDelayRequest request)
{
Thread.Sleep(60 * 1000);
try
@ -1307,23 +1311,53 @@ namespace BBWY.Server.Business
throw;
}
Thread.Sleep(30 * 1000);
Thread.Sleep(10000);
#region 检查奶妈sku是否完全生效
var lastQueryJoinCount = 0;
var isJoinCompleted = false;
{
var i = 0;
while (i < 2)
var repeatCount = 0;
while (true)
{
i++;
var promotionTaskSkuList = GetPromotionTaskSku(request.AppKey, request.AppSecret, request.AppToken, request.JDPromotionId);
if (promotionTaskSkuList.Any(s => s.Value<int>("bind_type") == 1 && s.Value<int>("sku_status") == 0))
var currentQueryJoinCount = promotionTaskSkuList.Count(s => s.Value<int>("bind_type") == 1 && s.Value<int>("sku_status") == 1);
if (currentQueryJoinCount == request.JoinSkuCount)
{
Thread.Sleep(30000);
continue;
isJoinCompleted = true;
break;
}
if (lastQueryJoinCount == 0)
lastQueryJoinCount = currentQueryJoinCount;
else if (lastQueryJoinCount == currentQueryJoinCount)
{
repeatCount++;
if (repeatCount > 2)
break;
}
lastQueryJoinCount = currentQueryJoinCount;
Thread.Sleep(30000);
}
}
#endregion
#region 发送钉钉消息
try
{
var ddMsg = new StringBuilder();
ddMsg.AppendLine($"活动名称:{request.ActivityName}");
ddMsg.AppendLine("任务状态:开始");
if (!isJoinCompleted)
{
ddMsg.AppendLine($"任务奶妈数:{request.JoinSkuCount}");
ddMsg.AppendLine($"参与奶妈数:{lastQueryJoinCount}");
ddMsg.AppendLine("参与任务的奶妈数异常请检查");
}
if (!string.IsNullOrEmpty(request.PJZSDingDingKey) && !string.IsNullOrEmpty(request.PJZSDingDingWebHook))
dingDingBusiness.SendDingDingBotMessage(request.PJZSDingDingKey, request.PJZSDingDingWebHook, ddMsg.ToString());
}
catch { }
#endregion
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, true);

1
JD.API/Startup.cs

@ -67,6 +67,7 @@ namespace JD.API
});
services.AddSingleton<YunDingFilter>();
services.AddSingleton<RestApiService>();
services.AddSingleton<DingDingBusiness>();
services.AddSingleton<PlatformSDKBusiness, JDBusiness>();
services.AddSingleton<PlatformSDKBusiness, _1688Business>();
services.AddSingleton<YunDingBusiness>();

Loading…
Cancel
Save