diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index a56ad710..a42a072d 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/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 insertPromotionTaskSkuRecordList = new List(); IList jobDoneTaskIdList = new List(); IList jobDoneTaskList = new List(); + var host = GetPlatformRelayAPIHost(Enums.Platform.京东); foreach (var promotionTask in runningTaskList) { var productSkuList = new List(); @@ -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 开始后续任务 diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index ede8554e..e31ebdd3 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/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("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 deleteSkuList, - string mainProductSpu, - string fullTitle, - string brandName, - bool haveGiftTemplateSku, - int isNewProduct) + private void DisableGiftSku(string appKey, + string appSecret, + string appToken, + IList 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 } /// @@ -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) diff --git a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs b/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs index cfa8ac30..126e04b7 100644 --- a/BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs +++ b/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(); diff --git a/BBWY.Server.Model/Dto/Request/JD/SetProductTitleRequest.cs b/BBWY.Server.Model/Dto/Request/JD/SetProductTitleRequest.cs new file mode 100644 index 00000000..65bc30e1 --- /dev/null +++ b/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; } + } +} diff --git a/JD.API/Controllers/PlatformSDKController.cs b/JD.API/Controllers/PlatformSDKController.cs index 4b650cd0..58b67864 100644 --- a/JD.API/Controllers/PlatformSDKController.cs +++ b/JD.API/Controllers/PlatformSDKController.cs @@ -300,6 +300,16 @@ namespace JD.API.API.Controllers return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumBySku(request); } + /// + /// 设置商品标题 + /// + /// + [HttpPost] + public void SetProductTitle([FromBody] SetProductTitleRequest request) + { + platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).SetProductTitle(request); + } + /// /// 开始促销活动任务 /// @@ -430,7 +440,7 @@ namespace JD.API.API.Controllers /// /// [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 /// /// [HttpPost] - public JToken QueryDept([FromBody] PlatformRequest request) + public JToken QueryDept([FromBody] PlatformRequest request) { return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).QueryDept(request); } - + /// /// 通过仓库id 获取对应的sku库存状态数据() @@ -455,7 +465,7 @@ namespace JD.API.API.Controllers /// /// [HttpPost] - public JToken GetStockNumByWareHouseNo([FromBody] GetStockNumByWareHouseNoRequest request) + public JToken GetStockNumByWareHouseNo([FromBody] GetStockNumByWareHouseNoRequest request) { return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumByWareHouseNo(request); }