|
|
@ -91,10 +91,10 @@ namespace BBWY.Server.Business |
|
|
|
throw new BusinessException("缺少完整标题"); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(request.ActivityName)) |
|
|
|
throw new BusinessException("缺少活动名称"); |
|
|
|
throw new BusinessException("缺少任务名称"); |
|
|
|
|
|
|
|
if (request.ActivityName.Length > 10) |
|
|
|
throw new BusinessException("活动名称不能超过10个字"); |
|
|
|
throw new BusinessException("任务名称不能超过10个字"); |
|
|
|
|
|
|
|
if (request.TaskCount == 0) |
|
|
|
throw new BusinessException("任务量不能为0"); |
|
|
@ -147,9 +147,9 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
var dbPromotionTask = fsql.Select<PromotionTask>(request.Id).ToOne(); |
|
|
|
if (dbPromotionTask == null) |
|
|
|
throw new BusinessException("活动任务不存在"); |
|
|
|
throw new BusinessException("任务不存在"); |
|
|
|
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.等待) |
|
|
|
throw new BusinessException("只能在活动处于等待状态时才能修改"); |
|
|
|
throw new BusinessException("只能在任务处于等待状态时才能修改"); |
|
|
|
|
|
|
|
request.Map(dbPromotionTask); |
|
|
|
fsql.Update<PromotionTask>().SetSource(dbPromotionTask) |
|
|
@ -162,6 +162,7 @@ namespace BBWY.Server.Business |
|
|
|
"SpuPublishTime", |
|
|
|
"StartTime", |
|
|
|
"EndTime", |
|
|
|
"StopTime", |
|
|
|
"CompletedTaskCount" |
|
|
|
}) |
|
|
|
.ExecuteAffrows(); |
|
|
@ -169,7 +170,7 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取活动列表
|
|
|
|
/// 获取任务列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
@ -189,7 +190,7 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改活动排序
|
|
|
|
/// 修改任务排序
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
public void EditPromotionTaskSort(EditPromotionTaskSortRequest request) |
|
|
@ -217,7 +218,7 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 检查活动重复sku
|
|
|
|
/// 检查任务重复sku
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="runingTaskList"></param>
|
|
|
|
/// <param name="skuIds"></param>
|
|
|
@ -228,16 +229,20 @@ namespace BBWY.Server.Business |
|
|
|
{ |
|
|
|
foreach (var sku in skuIdList) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(pt.CustomMotherSku) && pt.CustomMotherSku.Contains(sku)) |
|
|
|
//判断奶妈模板sku重复
|
|
|
|
|
|
|
|
//判断自定义奶妈sku重复
|
|
|
|
if ((!string.IsNullOrEmpty(pt.CustomMotherSku) && pt.CustomMotherSku.Contains(sku)) || |
|
|
|
(!string.IsNullOrEmpty(pt.MainProductSku) && pt.MainProductSku.Contains(sku))) |
|
|
|
{ |
|
|
|
throw new BusinessException($"sku[{sku}]已存在于任务[{pt.ActivityName}]中,请删除该sku或等待任务结束"); |
|
|
|
throw new BusinessException($"sku[{sku}]已存在于任务[{pt.ActivityName}]的奶妈sku中,请删除该sku或等待任务结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 开始活动任务
|
|
|
|
/// 开始任务
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
public void StartPromotionTask(StartPromotionTaskRequest request) |
|
|
@ -245,13 +250,12 @@ namespace BBWY.Server.Business |
|
|
|
var dbPromotionTask = fsql.Select<PromotionTask>(request.Id).ToOne(); |
|
|
|
|
|
|
|
if (dbPromotionTask == null) |
|
|
|
throw new BusinessException("活动任务不存在"); |
|
|
|
throw new BusinessException("任务不存在"); |
|
|
|
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.等待) |
|
|
|
throw new BusinessException("只能在活动处于等待状态时才能开始"); |
|
|
|
throw new BusinessException("只能在任务处于等待状态时才能开始"); |
|
|
|
|
|
|
|
|
|
|
|
var giftTemplateSku = string.Empty; //赠品模板sku
|
|
|
|
//var mainProductGiftSku = dbPromotionTask.MainProductGiftSku; //主商品的赠品sku
|
|
|
|
var motherTemplateSku = string.Empty; //奶妈模板的sku
|
|
|
|
|
|
|
|
if (dbPromotionTask.GiftTemplateId != null && dbPromotionTask.GiftTemplateId != 0) |
|
|
@ -276,6 +280,9 @@ namespace BBWY.Server.Business |
|
|
|
if (!string.IsNullOrEmpty(motherTemplateSku)) |
|
|
|
CheckRepeatSkuInRuningTask(runingTaskList, motherTemplateSku); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(dbPromotionTask.MainProductSku)) |
|
|
|
CheckRepeatSkuInRuningTask(runingTaskList, dbPromotionTask.MainProductSku); |
|
|
|
|
|
|
|
var host = GetPlatformRelayAPIHost(Enums.Platform.京东); |
|
|
|
var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionTask", new StartPromotionTaskRequest2() |
|
|
|
{ |
|
|
@ -312,7 +319,7 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 删除任务和京东活动
|
|
|
|
/// 删除任务和京东任务
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
public void DeletePromotionTaskAndJDTask(DeletePromotionTaskRequest request) |
|
|
@ -382,6 +389,40 @@ namespace BBWY.Server.Business |
|
|
|
} |
|
|
|
fsql.Delete<PromotionTask>(request.TaskId).ExecuteAffrows(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 停止任务
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public void StopPromotionTask(StopPromotionTaskRequest request) |
|
|
|
{ |
|
|
|
var dbPromotionTask = fsql.Select<PromotionTask>(request.Id).ToOne(); |
|
|
|
|
|
|
|
if (dbPromotionTask == null) |
|
|
|
throw new BusinessException("任务不存在"); |
|
|
|
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.进行中) |
|
|
|
throw new BusinessException("只能在任务处于进行中时才能停止"); |
|
|
|
|
|
|
|
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东), |
|
|
|
"api/platformsdk/SuspendJDPromotionTask", |
|
|
|
new SuspendDPromotionTaskRequest() |
|
|
|
{ |
|
|
|
AppKey = request.AppKey, |
|
|
|
AppSecret = request.AppSecret, |
|
|
|
AppToken = request.AppToken, |
|
|
|
Platform = Enums.Platform.京东, |
|
|
|
PromotionId = dbPromotionTask.PromotionId.Value |
|
|
|
}, |
|
|
|
GetYunDingRequestHeader(), |
|
|
|
HttpMethod.Post); |
|
|
|
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
|
throw new BusinessException(httpResult.Content); |
|
|
|
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content); |
|
|
|
if (!response.Success) |
|
|
|
throw new BusinessException(response.Msg); |
|
|
|
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.已停止).ExecuteAffrows(); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|