From 0564723253d447bd4273ba7f2840989330da069f Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Sun, 25 Dec 2022 13:29:32 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B4=BB=E5=8A=A8=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../EvaluationAssistantController.cs | 31 ++++++
.../EvaluationAssistantBusiness.cs | 76 ++++++++++++++-
.../Db/EvaluationAssistant/PromotionTask.cs | 96 +++++++++++++++++++
.../AddOrEditPromotionTaskRequest.cs | 45 +++++++++
.../EditPromotionTaskSortRequest.cs | 12 +++
.../QueryPromotionTaskRequest.cs | 21 ++++
.../PromotionTask/PromotionTaskResponse.cs | 17 ++++
BBWY.Server.Model/Enums.cs | 10 ++
BBWY.Server.Model/MappingProfiles.cs | 2 +
9 files changed, 309 insertions(+), 1 deletion(-)
create mode 100644 BBWY.Server.Model/Db/EvaluationAssistant/PromotionTask.cs
create mode 100644 BBWY.Server.Model/Dto/Request/PromotionTask/AddOrEditPromotionTaskRequest.cs
create mode 100644 BBWY.Server.Model/Dto/Request/PromotionTask/EditPromotionTaskSortRequest.cs
create mode 100644 BBWY.Server.Model/Dto/Request/PromotionTask/QueryPromotionTaskRequest.cs
create mode 100644 BBWY.Server.Model/Dto/Response/PromotionTask/PromotionTaskResponse.cs
diff --git a/BBWY.Server.API/Controllers/EvaluationAssistantController.cs b/BBWY.Server.API/Controllers/EvaluationAssistantController.cs
index b944591a..c6b6f0ad 100644
--- a/BBWY.Server.API/Controllers/EvaluationAssistantController.cs
+++ b/BBWY.Server.API/Controllers/EvaluationAssistantController.cs
@@ -46,5 +46,36 @@ namespace BBWY.Server.API.Controllers
{
evaluationAssistantBusiness.DeleteGiftTemplate(giftTemplateId);
}
+
+ ///
+ /// 新增或修改活动任务
+ ///
+ ///
+ [HttpPost]
+ public void AddOrEditPromotionTask([FromBody] AddOrEditPromotionTaskRequest request)
+ {
+ evaluationAssistantBusiness.AddOrEditPromotionTask(request);
+ }
+
+ ///
+ /// 获取活动列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ public PromotionTaskResponse GetPromotionTaskList([FromBody] QueryPromotionTaskRequest request)
+ {
+ return evaluationAssistantBusiness.GetPromotionTaskList(request);
+ }
+
+ ///
+ /// 修改活动排序
+ ///
+ ///
+ [HttpPost]
+ public void EditPromotionTaskSort([FromBody] EditPromotionTaskSortRequest request)
+ {
+ evaluationAssistantBusiness.EditPromotionTaskSort(request);
+ }
}
}
diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
index 02df5847..43312158 100644
--- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
+++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
@@ -1,4 +1,5 @@
-using BBWY.Common.Http;
+using BBWY.Common.Extensions;
+using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
@@ -62,5 +63,78 @@ namespace BBWY.Server.Business
fsql.Delete(giftTemplateId).ExecuteAffrows();
}
#endregion
+
+ #region 评价助手任务
+ public void AddOrEditPromotionTask(AddOrEditPromotionTaskRequest request)
+ {
+ if (request.Id == 0)
+ {
+ var sort = fsql.Select().ToAggregate(p => p.Max(p.Key.Sort));
+ var promotionTask = new PromotionTask()
+ {
+ Id = idGenerator.NewLong(),
+ ActivityName = request.ActivityName,
+ CreateTime = DateTime.Now,
+ FullTitle = request.FullTitle,
+ ShopId = request.ShopId,
+ SimpleTitle = request.SimpleTitle,
+ GiftTemplateId = request.GiftTemplateId,
+ MainProductGiftSku = request.MainProductGiftSku,
+ MainProductSku = request.MainProductSku,
+ MainProductSpu = request.MainProductSpu,
+ MotherTemplateId = request.MotherTemplateId,
+ IsEnabled = true,
+ Status = Enums.PromitionTaskStatus.等待,
+ PromotionId = 0,
+ Sort = sort + 1,
+ UpdateSortTime = DateTime.Now
+ };
+ fsql.Insert(promotionTask).ExecuteAffrows();
+ }
+ else
+ {
+ var dbPromotionTask = fsql.Select(request.Id).ToOne();
+ if (dbPromotionTask == null)
+ throw new BusinessException("活动任务不存在");
+ if (dbPromotionTask.Status != Enums.PromitionTaskStatus.等待)
+ throw new BusinessException("只能在活动处于等待状态时才能修改");
+
+ request.Map(dbPromotionTask);
+ fsql.Update().SetSource(dbPromotionTask)
+ .IgnoreColumns(new string[] { "UpdateSortTime", "Sort", "Status", "CreateTime" })
+ .ExecuteAffrows();
+ }
+ }
+
+ ///
+ /// 获取活动列表
+ ///
+ ///
+ ///
+ public PromotionTaskResponse GetPromotionTaskList(QueryPromotionTaskRequest request)
+ {
+ var list = fsql.Select().Where(pt => pt.ShopId == request.ShopId)
+ .Page(request.PageIndex, request.PageSize)
+ .Count(out long count)
+ .OrderByDescending(pt => new { pt.Sort, pt.UpdateSortTime })
+ .ToList();
+ return new PromotionTaskResponse()
+ {
+ Count = count,
+ ItemList = list
+ };
+ }
+
+ ///
+ /// 修改活动排序
+ ///
+ ///
+ public void EditPromotionTaskSort(EditPromotionTaskSortRequest request)
+ {
+ fsql.Update(request.Id).Set(pt => pt.Sort + request.MoveType)
+ .Set(pt => pt.UpdateSortTime, DateTime.Now)
+ .ExecuteAffrows();
+ }
+ #endregion
}
}
diff --git a/BBWY.Server.Model/Db/EvaluationAssistant/PromotionTask.cs b/BBWY.Server.Model/Db/EvaluationAssistant/PromotionTask.cs
new file mode 100644
index 00000000..d8a70c6c
--- /dev/null
+++ b/BBWY.Server.Model/Db/EvaluationAssistant/PromotionTask.cs
@@ -0,0 +1,96 @@
+using FreeSql.DatabaseModel;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using FreeSql.DataAnnotations;
+
+namespace BBWY.Server.Model.Db
+{
+
+ [JsonObject(MemberSerialization.OptIn), Table(Name = "promotiontask", DisableSyncStructure = true)]
+ public partial class PromotionTask
+ {
+
+ [Column(IsPrimary = true)]
+ public long Id { get; set; }
+
+ ///
+ /// 活动名称
+ ///
+ [Column(StringLength = 100)]
+ public string ActivityName { get; set; }
+
+ [Column(DbType = "datetime")]
+ public DateTime? CreateTime { get; set; }
+
+ ///
+ /// 完整标题
+ ///
+
+ public string FullTitle { get; set; }
+
+ ///
+ /// 赠品模板Id 可空
+ ///
+
+ public long? GiftTemplateId { get; set; }
+
+ ///
+ /// 主商品的赠品sku,逗号间隔,可空
+ ///
+
+ public string MainProductGiftSku { get; set; }
+
+ ///
+ /// 主商品sku,逗号间隔,可空
+ ///
+
+ public string MainProductSku { get; set; }
+
+ ///
+ /// 主商品SPU
+ ///
+ [Column(StringLength = 50)]
+ public string MainProductSpu { get; set; }
+
+ ///
+ /// 奶妈模板Id 可空
+ ///
+
+ public long? MotherTemplateId { get; set; }
+
+ ///
+ /// 促销活动Id
+ ///
+
+ public int? PromotionId { get; set; }
+
+
+ public long? ShopId { get; set; }
+
+ ///
+ /// 精简标题
+ ///
+ [Column(StringLength = 100)]
+ public string SimpleTitle { get; set; }
+
+ ///
+ /// 任务状态
+ ///
+ [Column(MapType = typeof(int?))]
+ public Enums.PromitionTaskStatus? Status { get; set; }
+
+ [Column(DbType = "bit")]
+ public bool IsEnabled { get; set; } = true;
+
+ public int Sort { get; set; }
+
+ [Column(DbType = "datetime")]
+ public DateTime? UpdateSortTime { get; set; }
+ }
+
+}
diff --git a/BBWY.Server.Model/Dto/Request/PromotionTask/AddOrEditPromotionTaskRequest.cs b/BBWY.Server.Model/Dto/Request/PromotionTask/AddOrEditPromotionTaskRequest.cs
new file mode 100644
index 00000000..45393d3e
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/PromotionTask/AddOrEditPromotionTaskRequest.cs
@@ -0,0 +1,45 @@
+namespace BBWY.Server.Model.Dto
+{
+ public class AddOrEditPromotionTaskRequest
+ {
+ ///
+ /// 如果Id=0 则视为新增
+ ///
+ public long Id { get; set; }
+
+ public long ShopId { get; set; }
+
+ public string ActivityName { get; set; }
+
+ public string SimpleTitle { get; set; }
+
+ public string FullTitle { get; set; }
+
+ ///
+ /// 主商品spu
+ ///
+ public string MainProductSpu { get; set; }
+
+ ///
+ /// 赠品模板Id, 未选择赠品模板时传0
+ ///
+ public long GiftTemplateId { get; set; }
+
+ ///
+ /// 主商品的赠品sku, 逗号间隔
+ ///
+ public string MainProductGiftSku { get; set; }
+
+ ///
+ /// 奶妈模板Id, 未选择奶妈模板时传0
+ ///
+ public long MotherTemplateId { get; set; }
+
+ ///
+ /// 主商品的【非赠品】sku, 逗号间隔
+ ///
+ public string MainProductSku { get; set; }
+
+
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Request/PromotionTask/EditPromotionTaskSortRequest.cs b/BBWY.Server.Model/Dto/Request/PromotionTask/EditPromotionTaskSortRequest.cs
new file mode 100644
index 00000000..5f960cf5
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/PromotionTask/EditPromotionTaskSortRequest.cs
@@ -0,0 +1,12 @@
+namespace BBWY.Server.Model.Dto
+{
+ public class EditPromotionTaskSortRequest
+ {
+ public long Id { get; set; }
+
+ ///
+ /// 上移传1,下移传-1
+ ///
+ public int MoveType { get; set; }
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Request/PromotionTask/QueryPromotionTaskRequest.cs b/BBWY.Server.Model/Dto/Request/PromotionTask/QueryPromotionTaskRequest.cs
new file mode 100644
index 00000000..aad0f567
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Request/PromotionTask/QueryPromotionTaskRequest.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BBWY.Server.Model.Dto
+{
+ public class QueryPromotionTaskRequest
+ {
+ ///
+ /// 页数,从1开始
+ ///
+ public int PageIndex { get; set; }
+
+ ///
+ /// 页码,每页条数
+ ///
+ public int PageSize { get; set; }
+
+ public long ShopId { get; set; }
+ }
+}
diff --git a/BBWY.Server.Model/Dto/Response/PromotionTask/PromotionTaskResponse.cs b/BBWY.Server.Model/Dto/Response/PromotionTask/PromotionTaskResponse.cs
new file mode 100644
index 00000000..d2036081
--- /dev/null
+++ b/BBWY.Server.Model/Dto/Response/PromotionTask/PromotionTaskResponse.cs
@@ -0,0 +1,17 @@
+using BBWY.Server.Model.Db;
+using System.Collections.Generic;
+
+namespace BBWY.Server.Model.Dto
+{
+ public class PromotionTaskItemResponse: PromotionTask
+ {
+
+ }
+
+ public class PromotionTaskResponse
+ {
+ public long Count { get; set; }
+
+ public IList ItemList { get; set; }
+ }
+}
diff --git a/BBWY.Server.Model/Enums.cs b/BBWY.Server.Model/Enums.cs
index 6465c019..8272280a 100644
--- a/BBWY.Server.Model/Enums.cs
+++ b/BBWY.Server.Model/Enums.cs
@@ -235,5 +235,15 @@
稳定日销期 = 2,
策马奔腾期 = 3
}
+
+ ///
+ /// 促销任务状态
+ ///
+ public enum PromitionTaskStatus
+ {
+ 等待 = 0,
+ 进行中 = 1,
+ 已完成 = 2
+ }
}
}
diff --git a/BBWY.Server.Model/MappingProfiles.cs b/BBWY.Server.Model/MappingProfiles.cs
index e2b16fc5..7427348d 100644
--- a/BBWY.Server.Model/MappingProfiles.cs
+++ b/BBWY.Server.Model/MappingProfiles.cs
@@ -58,6 +58,8 @@ namespace BBWY.Server.Model
.ForPath(t => t.OrderCost.RefundPurchaseAmount, opt => opt.MapFrom(f => f.RefundPurchaseAmount))
.ForPath(t => t.OrderCost.AfterTotalCost, opt => opt.MapFrom(f => f.AfterTotalCost));
+ CreateMap();
+
}
}
}