|
|
@ -28,6 +28,7 @@ namespace BBWY.Server.Business |
|
|
|
private List<Enums.OrderState> validOrderStateList; |
|
|
|
private List<Enums.PromitionTaskStatus> preTaskStateList; |
|
|
|
private ProductBusiness productBusiness; |
|
|
|
private char[] spliter; |
|
|
|
|
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness) : base(restApiService, options, yunDingBusiness) |
|
|
|
{ |
|
|
@ -52,6 +53,7 @@ namespace BBWY.Server.Business |
|
|
|
Enums.PromitionTaskStatus.等待, |
|
|
|
Enums.PromitionTaskStatus.进行中 |
|
|
|
}; |
|
|
|
spliter = new char[] { ',' }; |
|
|
|
} |
|
|
|
|
|
|
|
#region 赠品模板
|
|
|
@ -190,7 +192,7 @@ namespace BBWY.Server.Business |
|
|
|
if (!spuResponse.Success) |
|
|
|
throw new BusinessException(spuResponse.Msg) { Code = spuResponse.Code }; |
|
|
|
|
|
|
|
var sort = fsql.Select<PromotionTask>().ToAggregate(p => p.Max(p.Key.Sort)); |
|
|
|
var sort = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == request.ShopId).ToAggregate(p => p.Max(p.Key.Sort)); |
|
|
|
var promotionTask = new PromotionTask() |
|
|
|
{ |
|
|
|
Id = idGenerator.NewLong(), |
|
|
@ -249,9 +251,15 @@ namespace BBWY.Server.Business |
|
|
|
/// <returns></returns>
|
|
|
|
public PromotionTaskResponse GetPromotionTaskList(QueryPromotionTaskRequest request) |
|
|
|
{ |
|
|
|
var list = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == request.ShopId) |
|
|
|
var list = fsql.Select<PromotionTask>().As("pt") |
|
|
|
.Where(pt => pt.ShopId == request.ShopId) |
|
|
|
.OrderBy(pt => SqlExt.Case().When(pt.Status == Enums.PromitionTaskStatus.进行中, 0) |
|
|
|
.When(pt.Status == Enums.PromitionTaskStatus.等待, 1) |
|
|
|
.When(pt.Status == Enums.PromitionTaskStatus.已完成, 2) |
|
|
|
.When(pt.Status == Enums.PromitionTaskStatus.已停止, 3) |
|
|
|
.End()) |
|
|
|
//.OrderBy("case when pt.status=1 then 0 when pt.status=0 then 1 when pt.status=2 then 2 when pt.status=3 then 3 end asc")
|
|
|
|
.OrderByDescending(pt => pt.Sort) |
|
|
|
.OrderByDescending(pt => pt.UpdateSortTime) |
|
|
|
.Page(request.PageIndex, request.PageSize) |
|
|
|
.Count(out long count) |
|
|
|
.ToList<PromotionTaskItemResponse>(); |
|
|
@ -264,10 +272,17 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
public PromotionTaskResponse GetPrePromotionTaskList(long shopId) |
|
|
|
{ |
|
|
|
var list = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId) |
|
|
|
var list = fsql.Select<PromotionTask>().As("pt") |
|
|
|
.Where(pt => pt.ShopId == shopId) |
|
|
|
.Where(pt => preTaskStateList.Contains(pt.Status.Value)) |
|
|
|
.OrderBy(pt => SqlExt.Case().When(pt.Status == Enums.PromitionTaskStatus.进行中, 0) |
|
|
|
.When(pt.Status == Enums.PromitionTaskStatus.等待, 1) |
|
|
|
.When(pt.Status == Enums.PromitionTaskStatus.已完成, 2) |
|
|
|
.When(pt.Status == Enums.PromitionTaskStatus.已停止, 3) |
|
|
|
.End()) |
|
|
|
//.OrderBy("case when pt.status=1 then 0 when pt.status=0 then 1 when pt.status=2 then 2 when pt.status=3 then 3 end asc")
|
|
|
|
.OrderByDescending(pt => pt.Sort) |
|
|
|
.Page(1, 100) |
|
|
|
.Page(1, 1000) |
|
|
|
.Count(out long count) |
|
|
|
.ToList<PromotionTaskItemResponse>(); |
|
|
|
return new PromotionTaskResponse() |
|
|
@ -277,6 +292,50 @@ namespace BBWY.Server.Business |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 设置前置任务
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public void EditPreTask(EditPreTaskRequest request) |
|
|
|
{ |
|
|
|
var pt = fsql.Select<PromotionTask>(request.TaskId).ToOne(); |
|
|
|
if (pt == null) |
|
|
|
throw new BusinessException($"{request.TaskId}任务不存在"); |
|
|
|
|
|
|
|
var prpt = fsql.Select<PromotionTask>(request.PreTaskId).ToOne(); |
|
|
|
if (prpt == null) |
|
|
|
throw new BusinessException($"{request.PreTaskId}前置任务不存在"); |
|
|
|
|
|
|
|
if (pt.Id == prpt.Id) |
|
|
|
throw new BusinessException("前置任务不能设置为自己"); |
|
|
|
|
|
|
|
if (pt.Status != Enums.PromitionTaskStatus.等待) |
|
|
|
throw new BusinessException("任务状态必须为等待"); |
|
|
|
|
|
|
|
if (prpt.Status != Enums.PromitionTaskStatus.等待 && prpt.Status != Enums.PromitionTaskStatus.进行中) |
|
|
|
throw new BusinessException("前置任务状态必须为等待或进行中"); |
|
|
|
|
|
|
|
var ptSkuList = new List<string>(); |
|
|
|
var prptSkuList = new List<string>(); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(pt.MainProductSku)) |
|
|
|
ptSkuList.AddRange(pt.MainProductSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
if (!string.IsNullOrEmpty(pt.CustomMotherSku)) |
|
|
|
ptSkuList.AddRange(pt.CustomMotherSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(prpt.MainProductSku)) |
|
|
|
prptSkuList.AddRange(prpt.MainProductSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
if (!string.IsNullOrEmpty(prpt.CustomMotherSku)) |
|
|
|
prptSkuList.AddRange(prpt.CustomMotherSku.Split(spliter, StringSplitOptions.RemoveEmptyEntries)); |
|
|
|
|
|
|
|
var intersectSkuList = ptSkuList.Intersect(prptSkuList).ToList(); |
|
|
|
if (intersectSkuList != null && intersectSkuList.Count() > 0) |
|
|
|
throw new BusinessException($"{string.Join(",", intersectSkuList)}存在重复"); |
|
|
|
|
|
|
|
fsql.Update<PromotionTask>(request.TaskId).Set(pt1 => pt1.PreTaskId, request.PreTaskId).ExecuteAffrows(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改任务排序
|
|
|
|
/// </summary>
|
|
|
|