Przeglądaj źródła

入口和奖励对象分离

lcl 5 miesięcy temu
rodzic
commit
acef3ced0a

+ 2 - 2
Common/RabbitMQClient.cs

@@ -63,8 +63,8 @@ namespace MySystem
             consumer.Received += (a, e) =>
             {
                 string MsgContent = Encoding.Default.GetString(e.Body.ToArray());
-                Function.WriteLog(MsgContent, "接收mq数据队列");
-                // PrizeDo.sendPrize(MsgContent);
+                Function.WriteLog(DateTime.Now.ToString() + "\n" + MsgContent + "\n\n", "接收mq数据队列");
+                PrizeDo.sendPrize(MsgContent);
                 channel.BasicAck(e.DeliveryTag, true); //收到回复后,RabbitMQ会直接在队列中删除这条消息
             };
             channel.BasicConsume(QueueName, false, consumer);

+ 109 - 0
Controllers/Admin/Pri/PriPrizeInSetController.cs

@@ -0,0 +1,109 @@
+using Vo;
+using Microsoft.AspNetCore.Mvc;
+using Model;
+using Services;
+using Model.Base;
+using Vo.Admin;
+using Mapster;
+using Infrastructure;
+
+
+namespace Controllers.Admin
+{
+    /// <summary>
+    /// PriPrizeInSet)Controller
+    /// </summary>
+    // [Route("${Router}$")]
+    // [ApiExplorerSettings(GroupName = "PriPrizeInSet")]
+    public class PriPrizeInSetController : BaseController
+    {
+        /// <summary>
+        /// api分组接口
+        /// </summary>
+        private readonly IPriPrizeInSetService _PriPrizeInSetService;
+
+
+        public PriPrizeInSetController(IPriPrizeInSetService PriPrizeInSetService)
+        {
+            _PriPrizeInSetService = PriPrizeInSetService;
+
+        }
+
+          /// <param name="page">分页参数</param>
+        /// <summary>
+        /// 列表
+        /// </summary>
+        /// <param name="page">分页对象</param>
+        /// <param name="param">参数请求体</param>
+        /// <returns>列表</returns>
+        [HttpGet]
+        [Route("/v1/pri/PriPrizeInSet/getPriPrizeInSetList")]
+        public IActionResult getPriPrizeInSetList([FromQuery] PagerInfo page, [FromQuery] PriPrizeInSet param)
+        {
+            var response = _PriPrizeInSetService.getPriPrizeInSetList(page, param);
+            return SUCCESS(response);
+        }
+
+
+        /// <summary>
+        /// 详情
+        /// </summary>
+        /// <param name="param">参数请求体</param>
+        /// <returns>详情</returns>
+        [HttpGet]
+        [Route("/v1/pri/PriPrizeInSet/getPriPrizeInSetQuery")]
+        public IActionResult getPriPrizeInSetQuery([FromQuery] PriPrizeInSet param)
+        {
+            var response = _PriPrizeInSetService.GetFirst(m => m.id == param.id).Adapt<GetPriPrizeInSetQueryVo>();
+            return SUCCESS(response);
+        }
+
+
+        /// <summary>
+        /// 添加
+        /// </summary>
+        /// <param name="param">参数请求体</param>
+        /// <returns>添加</returns>
+        [HttpPost]
+        [Route("/v1/pri/PriPrizeInSet/addPriPrizeInSet")]
+        public IActionResult addPriPrizeInSet([FromBody] PriPrizeInSet param)
+        {
+            var modal = param.Adapt<PriPrizeInSet>().ToCreate(HttpContext);
+            var response = _PriPrizeInSetService.Add(modal);
+            return SUCCESS(response);
+        }
+
+
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="param">参数请求体</param>
+        /// <returns>修改</returns>
+        [HttpPut]
+        [Route("/v1/pri/PriPrizeInSet/updatePriPrizeInSet")]
+        public IActionResult updatePriPrizeInSet([FromBody] PriPrizeInSet param)
+        {
+            var modal = param.Adapt<PriPrizeInSet>().ToCreate(HttpContext);
+            var response = _PriPrizeInSetService.Update(modal);
+            return SUCCESS(response);
+        }
+
+
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="id">ID</param>
+        /// <returns>删除</returns>
+        [HttpDelete]
+        [Route("/v1/pri/PriPrizeInSet/deletePriPrizeInSet/{id}")]
+        public IActionResult deletePriPrizeInSet(int id)
+        {
+            var response = _PriPrizeInSetService.Delete(id);
+            return SUCCESS(response);
+        }
+
+
+
+
+    }
+}

+ 1 - 0
Extensions/AppServiceExtensions.cs

@@ -69,6 +69,7 @@ namespace Infrastructure
             services.AddTransient<IPriPrizeInFieldService, PriPrizeInFieldService>(); 
             services.AddTransient<IPriPrizeInTableService, PriPrizeInTableService>(); 
             services.AddTransient<IPriPrizeInQueryFieldService, PriPrizeInQueryFieldService>(); 
+            services.AddTransient<IPriPrizeInSetService, PriPrizeInSetService>(); 
         }
 
         private static void Register(IServiceCollection services, string item)

+ 7 - 0
Model/Database/PriList.cs

@@ -129,6 +129,13 @@ namespace Model
         public string? prizeSourceFieldType { get; set; }
 
 
+        /// <summary>
+        /// 奖励发放对象
+        /// </summary>
+        [SugarColumn(ColumnDescription = "奖励发放对象", ColumnName = "prize_obj")]
+        public int prizeObj { get; set; }
+
+
 
     }
 }

+ 78 - 0
Model/Database/PriPrizeInSet.cs

@@ -0,0 +1,78 @@
+using Mapster;
+
+
+namespace Model
+{
+    /// <summary>
+    /// 奖励入口配置表 pri_prize_in_set
+    /// </summary>
+    [SugarTable("pri_prize_in_set", "奖励入口配置表")]
+    [Tenant("0")]
+    public class PriPrizeInSet
+    {
+        /// <summary>
+        /// 项目
+        /// </summary>
+        [SugarColumn(ColumnDescription = "项目", ColumnName = "project_id")]
+        public int projectId { get; set; }
+
+
+        /// <summary>
+        /// 更新时间
+        /// </summary>
+        [SugarColumn(ColumnDescription = "更新时间", ColumnName = "update_date")]
+        public DateTime? updateDate { get; set; }
+
+
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        [SugarColumn(ColumnDescription = "创建时间", ColumnName = "create_date")]
+        public DateTime? createDate { get; set; }
+
+
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        [SugarColumn(ColumnDescription = "版本号", ColumnName = "version")]
+        public int version { get; set; }
+
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        [SugarColumn(ColumnDescription = "排序", ColumnName = "sort")]
+        public int sort { get; set; }
+
+
+        /// <summary>
+        /// 状态
+        /// </summary>
+        [SugarColumn(ColumnDescription = "状态", ColumnName = "status")]
+        public int status { get; set; }
+
+
+        /// <summary>
+        /// ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "ID", IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
+        public int id { get; set; }
+
+
+        /// <summary>
+        /// 指定奖励配置
+        /// </summary>
+        [SugarColumn(ColumnDescription = "指定奖励配置", Length = 200, ColumnName = "prize_list_ids")]
+        public string? prizeListIds { get; set; }
+
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [SugarColumn(ColumnDescription = "备注", Length = 200, ColumnName = "note")]
+        public string? note { get; set; }
+
+
+
+    }
+}

+ 6 - 0
Model/Vo/Admin/GetPriListQueryVo.cs

@@ -79,6 +79,12 @@ namespace Vo.Admin
         public string? prizeSourceFieldType { get; set; }
 
 
+        /// <summary>
+        /// 奖励发放对象
+        /// </summary>
+        public int prizeObj { get; set; }
+
+
 
     }
 }

+ 30 - 0
Model/Vo/Admin/GetPriPrizeInSetListVo.cs

@@ -0,0 +1,30 @@
+using Newtonsoft.Json;
+
+namespace Vo.Admin
+{
+    /// <summary>
+    /// 列表
+    /// </summary>
+    public class GetPriPrizeInSetListVo
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int id { get; set; }
+
+
+        /// <summary>
+        /// 指定奖励配置
+        /// </summary>
+        public string prizeListIds { get; set; }
+
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string note { get; set; }
+
+
+
+    }
+}

+ 36 - 0
Model/Vo/Admin/GetPriPrizeInSetQueryVo.cs

@@ -0,0 +1,36 @@
+using Newtonsoft.Json;
+
+namespace Vo.Admin
+{
+    /// <summary>
+    /// 详情
+    /// </summary>
+    public class GetPriPrizeInSetQueryVo
+    {
+        /// <summary>
+        /// 项目
+        /// </summary>
+        public int projectId { get; set; }
+
+
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int id { get; set; }
+
+
+        /// <summary>
+        /// 指定奖励配置
+        /// </summary>
+        public string prizeListIds { get; set; }
+
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string note { get; set; }
+
+
+
+    }
+}

+ 6 - 0
Model/Vo/Admin/GetPriPrizeInTableDicVo.cs

@@ -19,6 +19,12 @@ namespace Vo.Admin
         public string tableEnName { get; set; }
 
 
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? note { get; set; }
+
+
 
     }
 }

+ 6 - 0
Model/Vo/Admin/GetPriPrizeObjectTableDicVo.cs

@@ -19,6 +19,12 @@ namespace Vo.Admin
         public int id { get; set; }
 
 
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? note { get; set; }
+
+
 
     }
 }

+ 1 - 1
Program.cs

@@ -129,7 +129,7 @@ app.MapControllers();
 // PrizeDo.sendPrize(7, "{\"OrderNo\":\"BM2024090817330511847441249\"}");
 // PrizeDo.sendPrize(7, "{\"OrderNo\":\"BM2024090817360962275551251\"}");
 
-RabbitMQClient.Instance.StartReceive("PRIZE_SEND_QUEUE", "PRIZE_SEND_QUEUE", "/");
+// RabbitMQClient.Instance.StartReceive("PRIZE_SEND_QUEUE", "PRIZE_SEND_QUEUE", "/");
 
 
 app.Run();

+ 19 - 0
Services/IService/IPriPrizeInSetService.cs

@@ -0,0 +1,19 @@
+using Model;
+using Model.Base;
+using Microsoft.AspNetCore.Mvc;
+using Vo.Admin;
+
+
+namespace Services
+{
+    public interface IPriPrizeInSetService : IBaseService<PriPrizeInSet>
+    {
+        /// <summary>
+        /// 奖励入库表-列表
+        /// </summary>
+        /// <param name="param">参数请求体</param>
+        /// <param name="page">分页参数</param>
+        /// <returns>列表</returns>
+        PagedInfo<GetPriPrizeInSetListVo> getPriPrizeInSetList([FromQuery] PagerInfo page, [FromQuery] PriPrizeInSet param);
+    }
+}

+ 36 - 0
Services/PriPrizeInSetService.cs

@@ -0,0 +1,36 @@
+using Attribute;
+using Model;
+using Model.Base;
+using Repository;
+using Service;
+using Microsoft.AspNetCore.Mvc;
+using Vo.Admin;
+
+
+namespace Services
+{
+    /// <summary>
+    /// 奖励入口配置表Service业务层处理
+    /// </summary>
+    [AppService(ServiceType = typeof(IPriPrizeInSetService), ServiceLifetime = LifeTime.Transient)]
+    public class PriPrizeInSetService : BaseService<PriPrizeInSet>, IPriPrizeInSetService
+    {
+        /// <summary>
+        /// 奖励入库表-列表
+        /// </summary>
+        /// <param name="param">参数请求体</param>
+        /// <param name="page">分页参数</param>
+        /// <returns>列表</returns>
+        public PagedInfo<GetPriPrizeInSetListVo> getPriPrizeInSetList([FromQuery] PagerInfo page, [FromQuery] PriPrizeInSet param)
+        {
+            //拼装查询条件
+            var predicate = Expressionable.Create<PriPrizeInSet>();
+            predicate = predicate.AndIF(param.projectId > 0, m => m.projectId == param.projectId);
+            var response = Queryable()
+                .Where(predicate.ToExpression())
+                .OrderByDescending(m => m.id)
+                .ToPage<PriPrizeInSet, GetPriPrizeInSetListVo>(page);
+            return response;
+        }
+    }
+}

+ 22 - 11
Util/PrizeDo.cs

@@ -17,14 +17,13 @@ namespace Util
         {
             batchNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Function.get_Random(3);
             JsonData jsonObj = JsonMapper.ToObject(content);
-            string priObjString = prizeObject(jsonObj["prize_tag"].ToString(), jsonObj["content"].ToJson());
+            string priObjString = prizeInSet(jsonObj["prize_tag"].ToString());
             if(!string.IsNullOrEmpty(priObjString))
             {
                 string[] priObjData = priObjString.Split('|');
-                string priObj = priObjData[0];
-                string priListIds = priObjData[1];
-                int projectId = int.Parse(priObjData[2]);
-                prizeSend(projectId, priListIds, priObj, content);
+                string priListIds = priObjData[0];
+                int projectId = int.Parse(priObjData[1]);
+                prizeSend(projectId, priListIds, content);
             }
         }
 
@@ -326,14 +325,14 @@ namespace Util
             return dic;
         }
 
-        //奖励发放对象(奖励发放入口)
-        public static string prizeObject(string prizeObjectTag, string content)
+        //奖励发放对象
+        public static string prizeObject(int prizeObjectTag, string content)
         {
             Dictionary<string, object> dic = new Dictionary<string, object>();
             var prizeObjectTableService = App.GetService<IPriPrizeObjectTableService>();
             var prizeObjectFieldService = App.GetService<IPriPrizeObjectFieldService>();
             //查询表
-            var prizeObjectTable = prizeObjectTableService.GetFirst(m => m.prizeListIds == prizeObjectTag) ?? new PriPrizeObjectTable();
+            var prizeObjectTable = prizeObjectTableService.GetFirst(m => m.id == prizeObjectTag) ?? new PriPrizeObjectTable();
             //查询返回字段
             string field = prizeObjectTable.selectField;
             int projectId = prizeObjectTable.projectId;
@@ -514,9 +513,20 @@ namespace Util
             var item = db.Ado.GetScalar("select " + field + " from " + prizeObjectTable.tableEnName + " where 1=1" + condi);
             if(item != null)
             {
-                return item.ToString() + "|" + prizeObjectTable.prizeListIds + "|" + projectId;
+                return item.ToString();
             }
-            return "";
+            return "0";
+        }
+
+        //奖励发放入口
+        public static string prizeInSet(string prizeObjectTag)
+        {
+            Dictionary<string, object> dic = new Dictionary<string, object>();
+            var prizeInSetService = App.GetService<IPriPrizeInSetService>();
+            //查询表
+            var prizeInSet = prizeInSetService.GetFirst(m => m.prizeListIds == prizeObjectTag) ?? new PriPrizeInSet();
+            int projectId = prizeInSet.projectId;
+            return prizeInSet.prizeListIds + "|" + projectId;
         }
 
         //奖励列表
@@ -529,7 +539,7 @@ namespace Util
         }
 
         //奖励发放
-        public static void prizeSend(int projectId, string prizeIds, string prizeObjectId, string content)
+        public static void prizeSend(int projectId, string prizeIds, string content)
         {
             var loopSetService = App.GetService<IPriLoopSetService>();
             var recursionStartTableService = App.GetService<IPriRecursionStartTableService>();
@@ -537,6 +547,7 @@ namespace Util
             var priList = prizeList(projectId, prizeIds);
             foreach(var sub in priList)
             {
+                string prizeObjectId = prizeObject(sub.prizeObj, content);
                 var recursionFlag = sub.recursionFlag; //是否递归
                 if(recursionFlag)
                 {