Переглянути джерело

队列按照入口分开
条件查询分别绑定到奖励配置

lcl 5 місяців тому
батько
коміт
fb5b3cd0d6

+ 16 - 4
Common/RabbitMQClient.cs

@@ -8,6 +8,8 @@ using Infrastructure.Model;
 using Base;
 using Common;
 using Util;
+using Infrastructure;
+using Services;
 
 namespace MySystem
 {
@@ -47,7 +49,7 @@ namespace MySystem
             }
             _connection = factory.CreateConnection(p);
         }
-        public void StartReceive(string QueueName, string Exchange = "", string RoutingKey = "")
+        public void StartReceive(int QueueId, string Exchange = "", string RoutingKey = "")
         {
             if (_connection == null)
             {
@@ -58,7 +60,8 @@ namespace MySystem
                 CreateConn();
             }
             var channel = _connection.CreateModel();
-            channel.QueueBind(QueueName, Exchange, RoutingKey);
+            channel.QueueDeclare("PRIZE_SEND_QUEUE_" + QueueId, true, false, false, null);
+            channel.QueueBind("PRIZE_SEND_QUEUE_" + QueueId, Exchange, RoutingKey);
             channel.BasicQos(0, 1, false);
             EventingBasicConsumer consumer = new EventingBasicConsumer(channel);
             consumer.Received += (a, e) =>
@@ -67,7 +70,7 @@ namespace MySystem
                 try
                 {
                     Function.WriteLog(DateTime.Now.ToString() + "-" + MsgContent, "接收mq数据队列");
-                    PrizeDo.sendPrize(MsgContent);
+                    PrizeDo.sendPrize(QueueId, MsgContent);
                     Function.WriteLog(DateTime.Now.ToString() + "-end", "接收mq数据队列");
                 }
                 catch(Exception ex)
@@ -76,7 +79,16 @@ namespace MySystem
                 }
                 channel.BasicAck(e.DeliveryTag, false); //收到回复后,RabbitMQ会直接在队列中删除这条消息
             };
-            channel.BasicConsume(QueueName, false, consumer);
+            channel.BasicConsume("PRIZE_SEND_QUEUE_" + QueueId, false, consumer);
+        }
+        public void Start()
+        {
+            var setService = App.GetService<IPriPrizeInSetService>();
+            var list = setService.GetList(m => m.status == 1);
+            foreach(var sub in list)
+            {
+                StartReceive(sub.id, "PRIZE_SEND_QUEUE", "/");
+            }
         }
         #endregion
 

+ 7 - 0
Model/Database/PriList.cs

@@ -136,6 +136,13 @@ namespace Model
         public int prizeObj { get; set; }
 
 
+        /// <summary>
+        /// 条件匹配列表
+        /// </summary>
+        [SugarColumn(ColumnDescription = "条件匹配列表", Length = 200, ColumnName = "query_table_id_list")]
+        public string? queryTableIdList { get; set; }
+
+
 
     }
 }

+ 23 - 9
Model/Database/PriLog.cs

@@ -67,24 +67,38 @@ namespace Model
 
 
         /// <summary>
-        /// 发放对象
+        /// 批次号
         /// </summary>
-        [SugarColumn(ColumnDescription = "发放对象", Length = 50, ColumnName = "prize_obj_id")]
-        public string? prizeObjId { get; set; }
+        [SugarColumn(ColumnDescription = "批次号", Length = 50, ColumnName = "batch_no")]
+        public string? batchNo { get; set; }
 
 
         /// <summary>
-        /// 日志说明
+        /// 入口
         /// </summary>
-        [SugarColumn(ColumnDescription = "日志说明", Length = 200, ColumnName = "log_summary")]
-        public string? logSummary { get; set; }
+        [SugarColumn(ColumnDescription = "入口", ColumnName = "prize_in")]
+        public int prizeIn { get; set; }
 
 
         /// <summary>
-        /// 批次号
+        /// 奖励金额
         /// </summary>
-        [SugarColumn(ColumnDescription = "批次号", Length = 50, ColumnName = "batch_no")]
-        public string? batchNo { get; set; }
+        [SugarColumn(ColumnDescription = "奖励金额", ColumnName = "prize_amount")]
+        public decimal prizeAmount { get; set; }
+
+
+        /// <summary>
+        /// 请求参数
+        /// </summary>
+        [SugarColumn(ColumnDescription = "请求参数", Length = 200, ColumnName = "request_param")]
+        public string? requestParam { get; set; }
+
+
+        /// <summary>
+        /// 奖励条件明细
+        /// </summary>
+        [SugarColumn(ColumnDescription = "奖励条件明细", ColumnName = "step_list")]
+        public string? stepList { get; set; }
 
 
 

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

@@ -73,6 +73,12 @@ namespace Vo.Admin
         public string? prizeSourceFieldType { get; set; }
 
 
+        /// <summary>
+        /// 条件匹配列表
+        /// </summary>
+        public string? queryTableIdList { get; set; }
+
+
 
     }
 }

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

@@ -85,6 +85,12 @@ namespace Vo.Admin
         public int prizeObj { get; set; }
 
 
+        /// <summary>
+        /// 条件匹配列表
+        /// </summary>
+        public string? queryTableIdList { 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.Start();
 
 // PrizeDo.sendPrize("{\"prize_tag\":\"1\",\"content\":\"{\\\"PosSn\\\":\\\"00002402045980195457\\\"}\"}");
 

+ 324 - 88
Util/PrizeDo.cs

@@ -4,8 +4,11 @@ using Infrastructure;
 using LitJson;
 using Microsoft.Extensions.Localization;
 using Model;
+using Model.Customer;
 using NuGet.Packaging;
 using Services;
+using System.Linq;
+using System.Net.Mime;
 
 namespace Util
 {
@@ -13,17 +16,16 @@ namespace Util
     {
         public static string batchNo = "";
         //发奖入口
-        public static void sendPrize(string content)
+        public static void sendPrize(int prizeInId, string content)
         {
             batchNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Function.get_Random(3);
-            JsonData jsonObj = JsonMapper.ToObject(content);
-            string priObjString = prizeInSet(int.Parse(Function.CheckInt(jsonObj["prize_tag"].ToString())));
-            content = jsonObj["content"].ToString();
+            string priObjString = prizeInSet(prizeInId);
             if(!string.IsNullOrEmpty(priObjString))
             {
                 string[] priObjData = priObjString.Split('|');
                 string priListIds = priObjData[0];
                 int projectId = int.Parse(priObjData[1]);
+                addLog(projectId, prizeInId, content); //初始化日志
                 prizeSend(projectId, priListIds, content);
             }
         }
@@ -63,18 +65,19 @@ namespace Util
         }
 
         //查询条件匹配数据
-        public static Dictionary<string, object> condition(int projectId, string content)
+        public static List<QueryCondition> condition(int projectId, List<int> ids, string content)
         {
-            Dictionary<string, object> dic = new Dictionary<string, object>();
+            List<QueryCondition> dic = new List<QueryCondition>();
             var queryTableService = App.GetService<IPriQueryTableService>();
             var queryFieldService = App.GetService<IPriQueryFieldService>();
             var returnFieldService = App.GetService<IPriReturnFieldService>();
             //查询表
-            var queryTables = queryTableService.GetList(m => m.projectId == projectId);
+            var queryTables = queryTableService.GetList(m => ids.Contains(m.id));
             foreach(var queryTable in queryTables)
             {
                 //查询返回字段
                 string fields = "";
+                Dictionary<string, string> fieldDic = new Dictionary<string, string>();
                 var returnFields = returnFieldService.GetList(m => m.queryTableId == queryTable.id);
                 foreach(var returnField in returnFields)
                 {
@@ -94,6 +97,7 @@ namespace Util
                     {
                         fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
                     }
+                    fieldDic.Add(queryTable.tableEnName + "_" + returnField.fieldEnName, returnField.fieldName);
                 }
                 fields = fields.TrimEnd(',');
 
@@ -126,7 +130,7 @@ namespace Util
                         }
                         else if(fieldQueryModel == "query_field")
                         {
-                            string val = dic.ContainsKey(fieldQueryValue) ? dic[fieldQueryValue].ToString() : "0";
+                            string val = GetQueryTableData(dic, fieldQueryValue);
                             condi += "'%" + val + "%'";                            
                         }
                     }
@@ -152,7 +156,7 @@ namespace Util
                             }
                             else if(fieldQueryModel == "query_field")
                             {
-                                val = dic.ContainsKey(fieldQueryValue) ? dic[fieldQueryValue].ToString() : "0";
+                                val = GetQueryTableData(dic, fieldQueryValue);
                             }
                             if(fieldQueryValueType == "text")
                             {
@@ -214,7 +218,7 @@ namespace Util
                         {
                             foreach(string sub in valList)
                             {
-                                string dicVal = dic.ContainsKey(sub) ? dic[sub].ToString() : "0";
+                                string dicVal = GetQueryTableData(dic, sub);
                                 if(fieldQueryValueType == "text")
                                 {
                                     val += "'" + dicVal + "',";
@@ -265,8 +269,10 @@ namespace Util
                         }
                         else if(fieldQueryModel == "query_field")
                         {
-                            string dicValLeft = dic.ContainsKey(val[0]) ? dic[val[0]].ToString() : "0";
-                            string dicValRight = dic.ContainsKey(val[1]) ? dic[val[1]].ToString() : "0";
+                            string valLeft = val[0];
+                            string valRight = val[1];
+                            string dicValLeft = GetQueryTableData(dic, valLeft);
+                            string dicValRight = GetQueryTableData(dic, valRight);
                             if(fieldQueryValueType == "number")
                             {
                                 if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">=" + dicValLeft;
@@ -301,7 +307,7 @@ namespace Util
                             }
                             else if(fieldQueryModel == "query_field")
                             {
-                                val = dic.ContainsKey(fieldQueryValue) ? dic[fieldQueryValue].ToString() : "0";
+                                val = GetQueryTableData(dic, fieldQueryValue);
                             }
                             if(fieldQueryValueType == "text")
                             {
@@ -317,9 +323,14 @@ namespace Util
                 var items = db.Ado.GetDataTable(sql);
                 if(items.Rows.Count > 0)
                 {
-                    foreach(System.Data.DataColumn item in items.Columns)
+                    foreach(string field in fieldDic.Keys)
                     {
-                        if(!dic.ContainsKey(item.ColumnName)) dic.Add(item.ColumnName, items.Rows[0][item.ColumnName].ToString());
+                        if(!dic.Any(m => m.FieldEnName == field)) dic.Add(new QueryCondition()
+                        {
+                            FieldName = fieldDic[field],
+                            FieldEnName = field,
+                            Value = items.Rows[0][field].ToString()
+                        });
                     }
                 }
             }
@@ -567,9 +578,11 @@ namespace Util
                     bool op = true;
                     int index = 0;
                     loopAmount = 0;
+                    Dictionary<string, object> topStepDic = new Dictionary<string, object>(); //递归日志数据
                     while(!string.IsNullOrEmpty(objId) && objId != "0" && op)
                     {
-                        Dictionary<string, object> condiDic = loopCondition(projectId, sub, objId, content);
+                        List<Dictionary<string, string>> logStepDics = new List<Dictionary<string, string>>(); //条件日志数据
+                        List<QueryCondition> condiDic = loopCondition(projectId, sub, objId, content);
                         if(condiDic.Count > 0)
                         {
                             bool prizeFlag = true;                            
@@ -582,6 +595,8 @@ namespace Util
                                 {
                                     if(condition.startIndex <= index)
                                     {
+                                        Dictionary<string, string> logStepDic = new Dictionary<string, string>();
+                                        
                                         var returnFieldId = condition.returnFieldId; //条件返回字段
                                         var fieldQueryKind = condition.fieldQueryKind; //匹配条件
                                         var fieldQueryModel = condition.fieldQueryModel; //匹配方式
@@ -589,54 +604,69 @@ namespace Util
                                         var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
 
                                         string checkObj = "";
+                                        string checkTitle = "";
                                         if(returnFieldId.Contains(","))
                                         {
                                             string[] returnFieldIdList = returnFieldId.Split(',');
                                             foreach(string subField in returnFieldIdList)
                                             {
-                                                string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
+                                                string val = GetQueryTableData(condiDic, subField);
                                                 checkObj += val + ",";
+                                                string title = GetQueryTableTitle(condiDic, subField);
+                                                checkTitle += title + ",";
                                             }
                                             checkObj = checkObj.TrimEnd(',');
+                                            checkTitle = checkTitle.TrimEnd(',');
                                         }
                                         else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
                                         {
                                             string expresssion = returnFieldId;
+                                            checkTitle = returnFieldId;
                                             string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
                                             foreach(string returnField in returnFields)
                                             {
-                                                string val = condiDic.ContainsKey(returnField) ? condiDic[returnField].ToString() : "0";
+                                                string val = GetQueryTableData(condiDic, returnField);
                                                 expresssion = expresssion.Replace(returnField, val);
+
+                                                string title = GetQueryTableTitle(condiDic, returnField);
+                                                checkTitle = checkTitle.Replace(returnField, title);
                                             }
                                             DataTable dt = new DataTable();
                                             checkObj = dt.Compute(expresssion, "false").ToString();
                                         }
                                         else
                                         {
-                                            checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
+                                            checkObj = GetQueryTableData(condiDic, returnFieldId);
+                                            checkTitle = GetQueryTableTitle(condiDic, returnFieldId);
                                         }
+                                        
+                                        logStepDic.Add("标题", checkTitle);
+                                        logStepDic.Add("匹配值", fieldQueryValue);
+                                        logStepDic.Add("实际值", checkObj);
+
                                         var checkVal = fieldQueryValue;
+                                        bool passFlag = false;
 
                                         if(fieldQueryKind == "1") //模糊匹配
                                         {
                                             if(fieldQueryValueType == "text")
                                             {
-                                                if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1;
+                                                if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1; passFlag = true;
                                             }
                                         }
                                         else if(fieldQueryKind == "2") //精确匹配
                                         {
                                             if(fieldQueryValueType == "int")
                                             {
-                                                if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1;
+                                                if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1; passFlag = true;
                                             }
                                             else if(fieldQueryValueType == "number")
                                             {
-                                                if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
+                                                if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1; passFlag = true;
                                             }
                                             else
                                             {
-                                                if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1;
+                                                if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1; passFlag = true;
                                             }
                                         }
                                         else if(fieldQueryKind == "3") //范围匹配
@@ -647,42 +677,96 @@ namespace Util
                                                 Dictionary<string, string> req = getRequestParams(projectId, content);
                                                 if(fieldQueryValueType == "number")
                                                 {
-                                                    if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
-                                                    else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]]))) passCount += 1;
-                                                    else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
+                                                    if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
                                                 }
                                                 else if(fieldQueryValueType == "int")
                                                 {
-                                                    if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
-                                                    else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]]))) passCount += 1;
-                                                    else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
+                                                    if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
                                                 }
                                                 else if(fieldQueryValueType.StartsWith("date"))
                                                 {
-                                                    if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
-                                                    else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]])) passCount += 1;
-                                                    else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
+                                                    if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]])) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
                                                 }
                                             }
                                             else if(fieldQueryModel == "fixed_value")
                                             {
                                                 if(fieldQueryValueType == "number")
                                                 {
-                                                    if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(val[0])) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
-                                                    else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0]))) passCount += 1;
-                                                    else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
+                                                    if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(val[0])) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
                                                 }
                                                 else if(fieldQueryValueType == "int")
                                                 {
-                                                    if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(val[0])) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
-                                                    else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0]))) passCount += 1;
-                                                    else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
+                                                    if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(val[0])) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
                                                 }
                                                 else if(fieldQueryValueType.StartsWith("date"))
                                                 {
-                                                    if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(val[0])) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
-                                                    else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(val[0]))) passCount += 1;
-                                                    else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
+                                                    if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(val[0])) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(val[1]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(val[0]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
+                                                    else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(val[1]))) 
+                                                    {
+                                                        passCount += 1; passFlag = true;
+                                                    }
                                                 }
                                             }
                                         }
@@ -690,15 +774,15 @@ namespace Util
                                         {
                                             if(fieldQueryValueType == "int")
                                             {
-                                                if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal))) passCount += 1;
+                                                if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal))) passCount += 1; passFlag = true;
                                             }
                                             else if(fieldQueryValueType == "number")
                                             {
-                                                if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
+                                                if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1; passFlag = true;
                                             }
                                             else if(fieldQueryValueType == "text")
                                             {
-                                                if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1;
+                                                if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1; passFlag = true;
                                             }
                                         }
                                         else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
@@ -727,9 +811,11 @@ namespace Util
                                                     val += GetDbExpressionVal(subVal) + ",";
                                                 }
                                             }
-                                            if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
-                                            if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
+                                            if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1; passFlag = true;
+                                            if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1; passFlag = true;
                                         }
+                                        logStepDic.Add("状态", passFlag ? "通过" : "未通过");
+                                        logStepDics.Add(logStepDic);
                                     }
                                 }
                                 if(loopSet.conditionMode == "all" && passCount == allCount) prizeFlag = true;
@@ -742,10 +828,11 @@ namespace Util
                             }
                             if(prizeFlag)
                             {
-                                prizeSendDo(projectId, sub, objId, content, loopSet);
+                                decimal prizeAmt = prizeSendDo(projectId, sub, objId, content, loopSet);
                                 op = afterPrizeFlag;
                             }
                         }
+                        topStepDic.Add(objId, logStepDics);
                         var parent = db.Ado.GetScalar("select " + parentField + " from " + tableEnName + " where " + sonField + "=" + objId);
                         if(parent != null)
                         {
@@ -753,6 +840,7 @@ namespace Util
                         }
                         index += 1;
                     }
+                    setLogStep(Newtonsoft.Json.JsonConvert.SerializeObject(topStepDic));
                 }
                 else
                 {
@@ -762,7 +850,7 @@ namespace Util
         }
 
         static decimal loopAmount = 0;
-        public static void prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set)
+        public static decimal prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set)
         {
             var recordService = App.GetService<IPriRecordService>();
             var conditionService = App.GetService<IPriConditionService>();
@@ -770,8 +858,8 @@ namespace Util
             var queryTableService = App.GetService<IPriQueryTableService>();
             var amountSetService = App.GetService<IPriListAmountSetService>();
             //查询匹配条件
-            Dictionary<string, object> condiDic = new Dictionary<string, object>();
-            if(sub.prizeSourceFieldType == "condi") condiDic = condition(projectId, content);
+            List<QueryCondition> condiDic = new List<QueryCondition>();
+            if(sub.prizeSourceFieldType == "condi") condiDic = condition(projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content);
             if(sub.prizeSourceFieldType == "loop") condiDic = loopCondition(projectId, sub, prizeObjectId, content);
 
             var prizeSourceField = sub.prizeSourceField; //奖励金额来源字段(对应条件匹配返回字段)
@@ -784,8 +872,10 @@ namespace Util
             var conditions = conditionService.GetList(m => m.listId == sub.id);
             int allCount = conditions.Count; //所有奖励条件数
             int passCount = 0; //通过条件数
+            List<Dictionary<string, string>> logStepDics = new List<Dictionary<string, string>>();
             foreach(var condition in conditions)
             {
+                Dictionary<string, string> logStepDic = new Dictionary<string, string>();
                 var returnFieldId = condition.returnFieldId; //条件返回字段
                 var fieldQueryKind = condition.fieldQueryKind; //匹配条件
                 var fieldQueryModel = condition.fieldQueryModel; //匹配方式
@@ -793,54 +883,71 @@ namespace Util
                 var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
 
                 string checkObj = "";
+                string checkTitle = "";
                 if(returnFieldId.Contains(","))
                 {
                     string[] returnFieldIdList = returnFieldId.Split(',');
                     foreach(string subField in returnFieldIdList)
                     {
-                        string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
+                        string val = GetQueryTableData(condiDic, subField);
                         checkObj += val + ",";
+                        string title = GetQueryTableTitle(condiDic, subField);
+                        checkTitle += title + ",";
                     }
                     checkObj = checkObj.TrimEnd(',');
+                    checkTitle = checkTitle.TrimEnd(',');
                 }
                 else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
                 {
                     string expresssion = returnFieldId;
+                    checkTitle = returnFieldId;
                     string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
                     foreach(string returnField in returnFields)
                     {
-                        string val = condiDic.ContainsKey(returnField) ? condiDic[returnField].ToString() : "0";
+                        string val = GetQueryTableData(condiDic, returnField);
                         expresssion = expresssion.Replace(returnField, val);
+
+                        string title = GetQueryTableTitle(condiDic, returnField);
+                        checkTitle = checkTitle.Replace(returnField, title);
                     }
                     DataTable dt = new DataTable();
                     checkObj = dt.Compute(expresssion, "false").ToString();
                 }
                 else
                 {
-                    checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
-                }                
+                    checkObj = GetQueryTableData(condiDic, returnFieldId);
+                    checkTitle = GetQueryTableTitle(condiDic, returnFieldId);
+                }
+                if(!sub.recursionFlag)
+                {
+                    logStepDic.Add("标题", checkTitle);
+                    logStepDic.Add("匹配值", fieldQueryValue);
+                    logStepDic.Add("实际值", checkObj);
+                }
+
                 string checkVal = fieldQueryValue;
+                bool passFlag = false;
 
                 if(fieldQueryKind == "1") //模糊匹配
                 {
                     if(fieldQueryValueType == "text")
                     {
-                        if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1;
+                        if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1; passFlag = true;
                     }
                 }
                 else if(fieldQueryKind == "2") //精确匹配
                 {
                     if(fieldQueryValueType == "int")
                     {
-                        if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1;
+                        if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1; passFlag = true;
                     }
                     else if(fieldQueryValueType == "number")
                     {
-                        if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
+                        if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1; passFlag = true;
                     }
                     else
                     {
-                        if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1;
+                        if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1; passFlag = true;
                     }
                 }
                 else if(fieldQueryKind == "3") //范围匹配
@@ -851,42 +958,96 @@ namespace Util
                         Dictionary<string, string> req = getRequestParams(projectId, content);
                         if(fieldQueryValueType == "number")
                         {
-                            if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
-                            else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]]))) passCount += 1;
-                            else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
+                            if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
                         }
                         else if(fieldQueryValueType == "int")
                         {
-                            if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
-                            else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]]))) passCount += 1;
-                            else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
+                            if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
                         }
                         else if(fieldQueryValueType.StartsWith("date"))
                         {
-                            if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
-                            else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]])) passCount += 1;
-                            else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
+                            if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]])) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
                         }
                     }
                     else if(fieldQueryModel == "fixed_value")
                     {
                         if(fieldQueryValueType == "number")
                         {
-                            if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0])) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
-                            else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0]))) passCount += 1;
-                            else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
+                            if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0])) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
                         }
                         else if(fieldQueryValueType == "int")
                         {
-                            if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckNum(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0])) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
-                            else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0]))) passCount += 1;
-                            else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
+                            if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckNum(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0])) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
                         }
                         else if(fieldQueryValueType.StartsWith("date"))
                         {
-                            if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(val[0])) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
-                            else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(val[0]))) passCount += 1;
-                            else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
+                            if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(val[0])) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(val[1]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(val[0]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
+                            else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(val[1]))) 
+                            {
+                                passCount += 1; passFlag = true;
+                            }
                         }
                     }
                 }
@@ -894,15 +1055,15 @@ namespace Util
                 {
                     if(fieldQueryValueType == "int")
                     {
-                        if(int.Parse(Function.CheckNum(checkObj.ToString())) != int.Parse(Function.CheckInt(checkVal))) passCount += 1;
+                        if(int.Parse(Function.CheckNum(checkObj.ToString())) != int.Parse(Function.CheckInt(checkVal))) passCount += 1; passFlag = true;
                     }
                     else if(fieldQueryValueType == "number")
                     {
-                        if(decimal.Parse(Function.CheckNum(checkObj.ToString())) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
+                        if(decimal.Parse(Function.CheckNum(checkObj.ToString())) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1; passFlag = true;
                     }
                     else if(fieldQueryValueType == "text")
                     {
-                        if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1;
+                        if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1; passFlag = true;
                     }
                 }
                 else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
@@ -931,11 +1092,18 @@ namespace Util
                             val += GetDbExpressionVal(subVal) + ",";
                         }
                     }
-                    if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
-                    if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
+                    if (fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1; passFlag = true;
+                    if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1; passFlag = true;
+                }
+
+                if(!sub.recursionFlag)
+                {
+                    logStepDic.Add("状态", passFlag ? "通过" : "未通过");
+                    logStepDics.Add(logStepDic);
                 }
             }
             bool op = false;
+            decimal prizeAmt = 0;
             if(conditionMode == "all" && passCount == allCount && passCount > 0) op = true;
             else if(conditionMode == "one" && passCount >= 1) op = true;
             if(op) //满足条件
@@ -952,14 +1120,14 @@ namespace Util
                     string[] prizeSourceFieldList = prizeSourceField.Split(',');
                     foreach(string subField in prizeSourceFieldList)
                     {
-                        string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
+                        string val = GetQueryTableData(condiDic, subField);
                         prizeSourceData += val + ",";
                     }
                     prizeSourceData = prizeSourceData.TrimEnd(',');
                 }
                 else
                 {
-                    prizeSourceData = condiDic.ContainsKey(prizeSourceField) ? condiDic[prizeSourceField].ToString() : "0";
+                    prizeSourceData = GetQueryTableData(condiDic, prizeSourceField);
                 }
                 if(string.IsNullOrEmpty(prizeSourceData)) prizeSourceData = "0";
                 if(prizeSourceField.Contains("/") && number > 0)
@@ -967,7 +1135,6 @@ namespace Util
                     decimal prizeSourceDataNum = decimal.Parse(prizeSourceData) / number;
                     prizeSourceData = prizeSourceDataNum.ToString("f2");
                 }
-                decimal prizeAmt = 0;
                 var amountSet = amountSetService.GetFirst(m => m.listId == sub.id && m.prizeSourceField == prizeSourceData);
                 if(amountSet != null)
                 {
@@ -991,6 +1158,7 @@ namespace Util
                 if(set.levelDiffFlag) prizeAmt -= loopAmount;
                 if(prizeAmt > 0)
                 {
+                    setLogPrizeAmount(prizeAmt);
                     var req = getRequestParams(projectId, content);
                     var requestParamField = req[sub.requestParamField];
                     var sendFlag = recordService.Any(m => m.prizeObjId == prizeObjectId && m.listId == sub.id && m.requestParamField == requestParamField);
@@ -1011,12 +1179,19 @@ namespace Util
                     }
                 }
             }
+
+            if(!sub.recursionFlag)
+            {
+                setLogStatus(op ? 1 : 0);
+                setLogStep(Newtonsoft.Json.JsonConvert.SerializeObject(logStepDics));
+            }
+            return prizeAmt;
         }
 
         //递归条件判断
-        public static Dictionary<string, object> loopCondition(int projectId, PriList sub, string objId, string content)
+        public static List<QueryCondition> loopCondition(int projectId, PriList sub, string objId, string content)
         {
-            Dictionary<string, object> dic = new Dictionary<string, object>();
+            List<QueryCondition> dic = new List<QueryCondition>();
             var queryTableService = App.GetService<IPriRecursionStartTableService>();
             var queryFieldService = App.GetService<IPriRecursionStartFieldService>();
             var queryReturnFieldService = App.GetService<IPriRecursionStartReturnFieldService>();
@@ -1028,6 +1203,7 @@ namespace Util
             {
                 //查询返回字段
                 string fields = "1";
+                Dictionary<string, string> fieldDic = new Dictionary<string, string>();
                 var returnFields = queryReturnFieldService.GetList(m => m.objectTableId == queryTable.id);
                 if(returnFields.Count > 0)
                 {
@@ -1050,6 +1226,7 @@ namespace Util
                         {
                             fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
                         }
+                        fieldDic.Add(queryTable.tableEnName + "_" + returnField.fieldEnName, returnField.fieldName);
                     }
                     fields = fields.TrimEnd(',');
                 }
@@ -1232,9 +1409,14 @@ namespace Util
                 var items = db.Ado.GetDataTable(sql);
                 if(items.Rows.Count > 0)
                 {
-                    foreach(System.Data.DataColumn item in items.Columns)
+                    foreach(string field in fieldDic.Keys)
                     {
-                        if(!dic.ContainsKey(item.ColumnName)) dic.Add(item.ColumnName, items.Rows[0][item.ColumnName].ToString());
+                        if(!dic.Any(m => m.FieldEnName == field)) dic.Add(new QueryCondition()
+                        {
+                            FieldName = fieldDic[field],
+                            FieldEnName = field,
+                            Value = items.Rows[0][field].ToString()
+                        });
                     }
                 }
             }
@@ -1464,5 +1646,59 @@ namespace Util
             if(str.StartsWith("#{") && str.EndsWith("MONTH}#")) str = "DATE_ADD(" + data[0] + ",INTERVAL " + data[1] + " MONTH)";
             return str;
         }
+    
+        //获取查询条件数据
+        public static string GetQueryTableData(List<QueryCondition> condiDic, string key)
+        {
+            return condiDic.Any(m => m.FieldEnName == key) ? condiDic.FirstOrDefault(m => m.FieldEnName == key).Value.ToString() : "0";
+        }
+        public static string GetQueryTableTitle(List<QueryCondition> condiDic, string key)
+        {
+            return condiDic.Any(m => m.FieldEnName == key) ? condiDic.FirstOrDefault(m => m.FieldEnName == key).FieldName : "";
+        }
+
+        //记录日志
+        public static void addLog(int projectId, int prizeIn, string requestParam)
+        {
+            var logService = App.GetService<IPriLogService>();
+            logService.Add(new PriLog()
+            {
+                createDate = DateTime.Now,
+                projectId = projectId,
+                batchNo = batchNo,
+                prizeIn = prizeIn,
+                requestParam = requestParam,
+            });
+        }
+        public static void setLogPrizeAmount(decimal prizeAmount)
+        {
+            var logService = App.GetService<IPriLogService>();
+            var log = logService.GetFirst(m => m.batchNo == batchNo);
+            if(log != null)
+            {
+                log.prizeAmount = prizeAmount;
+                logService.Update(log);
+            }
+        }
+        public static void setLogStep(string step)
+        {
+            var logService = App.GetService<IPriLogService>();
+            var log = logService.GetFirst(m => m.batchNo == batchNo);
+            if(log != null)
+            {
+                log.stepList = step;
+                logService.Update(log);
+            }
+        }
+        public static void setLogStatus(int status)
+        {
+            var logService = App.GetService<IPriLogService>();
+            var log = logService.GetFirst(m => m.batchNo == batchNo);
+            if(log != null)
+            {
+                log.status = status;
+                logService.Update(log);
+            }
+        }
     }
 }