|
|
@ -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) |
|
|
|