Browse Source

任务结束设置完整标题

pjzs_starttask_update
sanji 1 year ago
parent
commit
f31a92bb53
  1. 37
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  2. 73
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  3. 2
      BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
  4. 9
      BBWY.Server.Model/Dto/Request/JD/SetProductTitleRequest.cs
  5. 18
      JD.API/Controllers/PlatformSDKController.cs

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

@ -175,11 +175,11 @@ namespace BBWY.Server.Business
if (string.IsNullOrEmpty(request.SimpleTitle))
throw new BusinessException("缺少精简标题");
}
else if (request.IsNewProduct == 0)
{
if (string.IsNullOrEmpty(request.FullTitle))
throw new BusinessException("缺少完整标题");
}
//else if (request.IsNewProduct == 0)
//{
// if (string.IsNullOrEmpty(request.FullTitle))
// throw new BusinessException("缺少完整标题");
//}
if (string.IsNullOrEmpty(request.ActivityName))
throw new BusinessException("缺少任务名称");
@ -964,6 +964,7 @@ namespace BBWY.Server.Business
List<PromotionTaskSkuRecord> insertPromotionTaskSkuRecordList = new List<PromotionTaskSkuRecord>();
IList<long> jobDoneTaskIdList = new List<long>();
IList<PromotionTask> jobDoneTaskList = new List<PromotionTask>();
var host = GetPlatformRelayAPIHost(Enums.Platform.);
foreach (var promotionTask in runningTaskList)
{
var productSkuList = new List<string>();
@ -1098,13 +1099,25 @@ namespace BBWY.Server.Business
});
#region 任务结束之后的处理
#endregion
#region 钉钉通知结束
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
foreach (var jobDoneTask in jobDoneTaskList)
{
foreach (var jobDoneTask in jobDoneTaskList)
#region 恢复新品任务的完整标题
if (jobDoneTask.IsNewProduct == 1)
{
var httpResult = restApiService.SendRequest(host, "/api/platformsdk/SetProductTitle", new SetProductTitleRequest()
{
AppKey = shop.AppKey2,
AppSecret = shop.AppSecret2,
AppToken = shop.AppToken2,
Platform = Enums.Platform.,
Spu = jobDoneTask.MainProductSpu,
Title = jobDoneTask.FullTitle
}, null, HttpMethod.Post);
}
#endregion
#region 通知该任务结束
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
{
try
{
@ -1112,8 +1125,8 @@ namespace BBWY.Server.Business
}
catch { }
}
#endregion
}
#endregion
#region 开始后续任务

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

@ -7,6 +7,7 @@ using BBWY.Server.Model.Dto.Request.JD;
using Jd.ACES;
using Jd.ACES.Common;
using Jd.Api;
using Jd.Api.Domain;
using Jd.Api.Request;
using Jd.Api.Response;
using Microsoft.Extensions.Caching.Memory;
@ -796,6 +797,43 @@ namespace BBWY.Server.Business
}
}
public override void SetProductTitle(SetProductTitleRequest request)
{
var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var wareId = long.Parse(request.Spu);
string brandName;
#region 获取主商品品牌
{
var req = new WareReadFindWareByIdRequest();
req.wareId = wareId;
req.field = "barCode,categoryId,brandName";
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.IsError)
throw new BusinessException($"获取主商品品牌失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
if (res.Json == null)
res.Json = JObject.Parse(res.Body);
brandName = res.Json["jingdong_ware_read_findWareById_responce"]["ware"].Value<string>("brandName");
}
#endregion
#region 设置标题
{
if (string.IsNullOrEmpty(brandName))
return;
var req = new WareWriteUpdateWareTitleRequest() { wareId = wareId };
if (!request.Title.StartsWith(brandName))
req.title = $"{brandName}{request.Title}";
else
req.title = request.Title;
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (response.IsError)
throw new BusinessException($"设置完整标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}");
}
#endregion
}
private void RollBackWhenStartPromotionError(string appKey,
string appSecret,
string appToken,
@ -835,15 +873,15 @@ namespace BBWY.Server.Business
#endregion
}
private void DisableGiftSkuAndRecoverFullTitle(string appKey,
string appSecret,
string appToken,
IList<string> deleteSkuList,
string mainProductSpu,
string fullTitle,
string brandName,
bool haveGiftTemplateSku,
int isNewProduct)
private void DisableGiftSku(string appKey,
string appSecret,
string appToken,
IList<string> deleteSkuList,
string mainProductSpu,
string fullTitle,
string brandName,
bool haveGiftTemplateSku,
int isNewProduct)
{
var jdClient = GetJdClient(appKey, appSecret);
var wareId = long.Parse(mainProductSpu);
@ -885,21 +923,6 @@ namespace BBWY.Server.Business
throw new BusinessException($"禁用赠品sku失败-{errorMsg}");
}
}
//#region 设置完整标题
//{
// if (string.IsNullOrEmpty(brandName))
// return;
// var req = new WareWriteUpdateWareTitleRequest() { wareId = wareId };
// if (!fullTitle.StartsWith(brandName))
// req.title = $"{brandName}{fullTitle}";
// else
// req.title = fullTitle;
// var response = jdClient.Execute(req, appToken, DateTime.Now.ToLocalTime());
// if (response.IsError)
// throw new BusinessException($"设置完整标题出错-{(string.IsNullOrEmpty(response.ErrorMsg) ? response.ErrMsg : response.ErrorMsg)}");
//}
//#endregion
}
/// <summary>
@ -1679,7 +1702,7 @@ namespace BBWY.Server.Business
catch { }
#endregion
DisableGiftSkuAndRecoverFullTitle(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, true, request.IsNewProduct);
DisableGiftSku(request.AppKey, request.AppSecret, request.AppToken, request.DeleteGiftSkuList, request.MainProductSpu, request.FullTitle, request.BrandName, true, request.IsNewProduct);
}
public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request)

2
BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs

@ -190,6 +190,8 @@ namespace BBWY.Server.Business
throw new NotImplementedException();
}
public virtual void SetProductTitle(SetProductTitleRequest request) { throw new NotImplementedException(); }
public virtual void DeleteSku(DeleteSkuRequest request)
{
throw new NotImplementedException();

9
BBWY.Server.Model/Dto/Request/JD/SetProductTitleRequest.cs

@ -0,0 +1,9 @@
namespace BBWY.Server.Model.Dto
{
public class SetProductTitleRequest: PlatformRequest
{
public string Spu { get; set; }
public string Title { get; set; }
}
}

18
JD.API/Controllers/PlatformSDKController.cs

@ -300,6 +300,16 @@ namespace JD.API.API.Controllers
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumBySku(request);
}
/// <summary>
/// 设置商品标题
/// </summary>
/// <param name="request"></param>
[HttpPost]
public void SetProductTitle([FromBody] SetProductTitleRequest request)
{
platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).SetProductTitle(request);
}
/// <summary>
/// 开始促销活动任务
/// </summary>
@ -430,7 +440,7 @@ namespace JD.API.API.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public JToken GetOrderCouponDetail([FromBody] QueryOrderCouponDetailRequest request)
public JToken GetOrderCouponDetail([FromBody] QueryOrderCouponDetailRequest request)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetOrderCouponDetail(request);
}
@ -442,12 +452,12 @@ namespace JD.API.API.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public JToken QueryDept([FromBody] PlatformRequest request)
public JToken QueryDept([FromBody] PlatformRequest request)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).QueryDept(request);
}
/// <summary>
/// 通过仓库id 获取对应的sku库存状态数据()
@ -455,7 +465,7 @@ namespace JD.API.API.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public JToken GetStockNumByWareHouseNo([FromBody] GetStockNumByWareHouseNoRequest request)
public JToken GetStockNumByWareHouseNo([FromBody] GetStockNumByWareHouseNoRequest request)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumByWareHouseNo(request);
}

Loading…
Cancel
Save