Browse Source

任务结束设置完整标题

pjzs_starttask_update
sanji 1 year ago
parent
commit
f31a92bb53
  1. 33
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  2. 57
      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. 10
      JD.API/Controllers/PlatformSDKController.cs

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

@ -175,11 +175,11 @@ namespace BBWY.Server.Business
if (string.IsNullOrEmpty(request.SimpleTitle)) if (string.IsNullOrEmpty(request.SimpleTitle))
throw new BusinessException("缺少精简标题"); throw new BusinessException("缺少精简标题");
} }
else if (request.IsNewProduct == 0) //else if (request.IsNewProduct == 0)
{ //{
if (string.IsNullOrEmpty(request.FullTitle)) // if (string.IsNullOrEmpty(request.FullTitle))
throw new BusinessException("缺少完整标题"); // throw new BusinessException("缺少完整标题");
} //}
if (string.IsNullOrEmpty(request.ActivityName)) if (string.IsNullOrEmpty(request.ActivityName))
throw new BusinessException("缺少任务名称"); throw new BusinessException("缺少任务名称");
@ -964,6 +964,7 @@ namespace BBWY.Server.Business
List<PromotionTaskSkuRecord> insertPromotionTaskSkuRecordList = new List<PromotionTaskSkuRecord>(); List<PromotionTaskSkuRecord> insertPromotionTaskSkuRecordList = new List<PromotionTaskSkuRecord>();
IList<long> jobDoneTaskIdList = new List<long>(); IList<long> jobDoneTaskIdList = new List<long>();
IList<PromotionTask> jobDoneTaskList = new List<PromotionTask>(); IList<PromotionTask> jobDoneTaskList = new List<PromotionTask>();
var host = GetPlatformRelayAPIHost(Enums.Platform.);
foreach (var promotionTask in runningTaskList) foreach (var promotionTask in runningTaskList)
{ {
var productSkuList = new List<string>(); var productSkuList = new List<string>();
@ -1098,13 +1099,25 @@ namespace BBWY.Server.Business
}); });
#region 任务结束之后的处理 #region 任务结束之后的处理
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 #endregion
#region 钉钉通知结束 #region 通知该任务结束
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook)) if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
{
foreach (var jobDoneTask in jobDoneTaskList)
{ {
try try
{ {
@ -1112,8 +1125,8 @@ namespace BBWY.Server.Business
} }
catch { } catch { }
} }
#endregion
} }
#endregion #endregion
#region 开始后续任务 #region 开始后续任务

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

@ -7,6 +7,7 @@ using BBWY.Server.Model.Dto.Request.JD;
using Jd.ACES; using Jd.ACES;
using Jd.ACES.Common; using Jd.ACES.Common;
using Jd.Api; using Jd.Api;
using Jd.Api.Domain;
using Jd.Api.Request; using Jd.Api.Request;
using Jd.Api.Response; using Jd.Api.Response;
using Microsoft.Extensions.Caching.Memory; 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, private void RollBackWhenStartPromotionError(string appKey,
string appSecret, string appSecret,
string appToken, string appToken,
@ -835,7 +873,7 @@ namespace BBWY.Server.Business
#endregion #endregion
} }
private void DisableGiftSkuAndRecoverFullTitle(string appKey, private void DisableGiftSku(string appKey,
string appSecret, string appSecret,
string appToken, string appToken,
IList<string> deleteSkuList, IList<string> deleteSkuList,
@ -885,21 +923,6 @@ namespace BBWY.Server.Business
throw new BusinessException($"禁用赠品sku失败-{errorMsg}"); 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> /// <summary>
@ -1679,7 +1702,7 @@ namespace BBWY.Server.Business
catch { } catch { }
#endregion #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) public override void DeleteJDPromotionTask(DeleteJDPromotionTaskRequest request)

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

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

10
JD.API/Controllers/PlatformSDKController.cs

@ -300,6 +300,16 @@ namespace JD.API.API.Controllers
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetStockNumBySku(request); 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>
/// 开始促销活动任务 /// 开始促销活动任务
/// </summary> /// </summary>

Loading…
Cancel
Save