|
@@ -548,6 +548,8 @@ namespace Util
|
|
|
var db = initDb(recursionStartTable.databaseId);
|
|
|
string objId = prizeObjectId;
|
|
|
bool op = true;
|
|
|
+ int index = 0;
|
|
|
+ loopAmount = 0;
|
|
|
while(!string.IsNullOrEmpty(objId) && objId != "0" && op)
|
|
|
{
|
|
|
Dictionary<string, object> condiDic = loopCondition(projectId, sub, objId, content);
|
|
@@ -561,157 +563,160 @@ namespace Util
|
|
|
int passCount = 0; //通过条件数
|
|
|
foreach(var condition in conditions)
|
|
|
{
|
|
|
- var returnFieldId = condition.returnFieldId; //条件返回字段
|
|
|
- var fieldQueryKind = condition.fieldQueryKind; //匹配条件
|
|
|
- var fieldQueryModel = condition.fieldQueryModel; //匹配方式
|
|
|
- var fieldQueryValue = condition.fieldQueryValue; //匹配值
|
|
|
- var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
|
|
|
-
|
|
|
- string checkObj = "";
|
|
|
- if(returnFieldId.Contains(","))
|
|
|
- {
|
|
|
- string[] returnFieldIdList = returnFieldId.Split(',');
|
|
|
- foreach(string subField in returnFieldIdList)
|
|
|
- {
|
|
|
- string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
|
|
|
- checkObj += val + ",";
|
|
|
- }
|
|
|
- checkObj = checkObj.TrimEnd(',');
|
|
|
- }
|
|
|
- else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
|
|
|
+ if(condition.startIndex <= index)
|
|
|
{
|
|
|
- string expresssion = returnFieldId;
|
|
|
- string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
|
|
|
- foreach(string returnField in returnFields)
|
|
|
- {
|
|
|
- string val = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
|
|
|
- expresssion = expresssion.Replace(returnField, val);
|
|
|
- }
|
|
|
- DataTable dt = new DataTable();
|
|
|
- checkObj = dt.Compute(expresssion, "false").ToString();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
|
|
|
- }
|
|
|
- var checkVal = fieldQueryValue;
|
|
|
+ var returnFieldId = condition.returnFieldId; //条件返回字段
|
|
|
+ var fieldQueryKind = condition.fieldQueryKind; //匹配条件
|
|
|
+ var fieldQueryModel = condition.fieldQueryModel; //匹配方式
|
|
|
+ var fieldQueryValue = condition.fieldQueryValue; //匹配值
|
|
|
+ var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
|
|
|
|
|
|
- if(fieldQueryKind == "1") //模糊匹配
|
|
|
- {
|
|
|
- if(fieldQueryValueType == "text")
|
|
|
+ string checkObj = "";
|
|
|
+ if(returnFieldId.Contains(","))
|
|
|
{
|
|
|
- if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1;
|
|
|
+ string[] returnFieldIdList = returnFieldId.Split(',');
|
|
|
+ foreach(string subField in returnFieldIdList)
|
|
|
+ {
|
|
|
+ string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
|
|
|
+ checkObj += val + ",";
|
|
|
+ }
|
|
|
+ checkObj = checkObj.TrimEnd(',');
|
|
|
}
|
|
|
- }
|
|
|
- else if(fieldQueryKind == "2") //精确匹配
|
|
|
- {
|
|
|
- if(fieldQueryValueType == "int")
|
|
|
+ else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
|
|
|
{
|
|
|
- if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1;
|
|
|
+ string expresssion = returnFieldId;
|
|
|
+ string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
|
|
|
+ foreach(string returnField in returnFields)
|
|
|
+ {
|
|
|
+ string val = condiDic.ContainsKey(returnField) ? condiDic[returnField].ToString() : "0";
|
|
|
+ expresssion = expresssion.Replace(returnField, val);
|
|
|
+ }
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ checkObj = dt.Compute(expresssion, "false").ToString();
|
|
|
}
|
|
|
- else if(fieldQueryValueType == "number")
|
|
|
+ else
|
|
|
{
|
|
|
- if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
|
|
|
+ checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
|
|
|
}
|
|
|
- else
|
|
|
+ var checkVal = fieldQueryValue;
|
|
|
+
|
|
|
+ if(fieldQueryKind == "1") //模糊匹配
|
|
|
{
|
|
|
- if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1;
|
|
|
+ if(fieldQueryValueType == "text")
|
|
|
+ {
|
|
|
+ if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else if(fieldQueryKind == "3") //范围匹配
|
|
|
- {
|
|
|
- string[] val = checkVal.Split(':');
|
|
|
- if(fieldQueryModel == "request_param")
|
|
|
+ else if(fieldQueryKind == "2") //精确匹配
|
|
|
{
|
|
|
- Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
- if(fieldQueryValueType == "number")
|
|
|
+ if(fieldQueryValueType == "int")
|
|
|
{
|
|
|
- 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(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1;
|
|
|
}
|
|
|
- else if(fieldQueryValueType == "int")
|
|
|
+ else if(fieldQueryValueType == "number")
|
|
|
{
|
|
|
- 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(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
|
|
|
}
|
|
|
- else if(fieldQueryValueType.StartsWith("date"))
|
|
|
+ else
|
|
|
{
|
|
|
- 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(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1;
|
|
|
}
|
|
|
}
|
|
|
- else if(fieldQueryModel == "fixed_value")
|
|
|
+ else if(fieldQueryKind == "3") //范围匹配
|
|
|
{
|
|
|
- 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;
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "int")
|
|
|
+ string[] val = checkVal.Split(':');
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
{
|
|
|
- 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;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
- else if(fieldQueryValueType.StartsWith("date"))
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
{
|
|
|
- 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(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;
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else if(fieldQueryKind == "4") //取反匹配
|
|
|
- {
|
|
|
- if(fieldQueryValueType == "int")
|
|
|
+ else if(fieldQueryKind == "4") //取反匹配
|
|
|
{
|
|
|
- if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal))) passCount += 1;
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "number")
|
|
|
- {
|
|
|
- if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
|
|
|
- }
|
|
|
- else if(fieldQueryValueType == "text")
|
|
|
- {
|
|
|
- if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
|
|
|
- {
|
|
|
- string val = ",";
|
|
|
- string[] valList = checkVal.Split(',');
|
|
|
- if(fieldQueryModel == "request_param")
|
|
|
- {
|
|
|
- Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
- foreach(string subVal in valList)
|
|
|
+ if(fieldQueryValueType == "int")
|
|
|
{
|
|
|
- val += req[subVal] + ",";
|
|
|
+ if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal))) passCount += 1;
|
|
|
}
|
|
|
- }
|
|
|
- else if(fieldQueryModel == "fixed_value")
|
|
|
- {
|
|
|
- foreach(string subVal in valList)
|
|
|
+ else if(fieldQueryValueType == "number")
|
|
|
+ {
|
|
|
+ if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
|
|
|
+ }
|
|
|
+ else if(fieldQueryValueType == "text")
|
|
|
{
|
|
|
- val += GetExpressionVal(subVal) + ",";
|
|
|
+ if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1;
|
|
|
}
|
|
|
}
|
|
|
- else if(fieldQueryModel == "db_field")
|
|
|
+ else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
|
|
|
{
|
|
|
- foreach(string subVal in valList)
|
|
|
+ string val = ",";
|
|
|
+ string[] valList = checkVal.Split(',');
|
|
|
+ if(fieldQueryModel == "request_param")
|
|
|
+ {
|
|
|
+ Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
+ foreach(string subVal in valList)
|
|
|
+ {
|
|
|
+ val += req[subVal] + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "fixed_value")
|
|
|
+ {
|
|
|
+ foreach(string subVal in valList)
|
|
|
+ {
|
|
|
+ val += GetExpressionVal(subVal) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(fieldQueryModel == "db_field")
|
|
|
{
|
|
|
- val += GetDbExpressionVal(subVal) + ",";
|
|
|
+ foreach(string subVal in valList)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
- if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
|
|
|
}
|
|
|
}
|
|
|
if(loopSet.conditionMode == "all" && passCount == allCount) prizeFlag = true;
|
|
|
- else if(loopSet.conditionMode == "one" && passCount == 1) prizeFlag = true;
|
|
|
+ else if(loopSet.conditionMode == "one" && passCount >= 1) prizeFlag = true;
|
|
|
else prizeFlag = false;
|
|
|
}
|
|
|
else
|
|
@@ -720,7 +725,7 @@ namespace Util
|
|
|
}
|
|
|
if(prizeFlag)
|
|
|
{
|
|
|
- prizeSendDo(projectId, sub, objId, content);
|
|
|
+ prizeSendDo(projectId, sub, objId, content, loopSet);
|
|
|
op = afterPrizeFlag;
|
|
|
}
|
|
|
}
|
|
@@ -729,16 +734,18 @@ namespace Util
|
|
|
{
|
|
|
objId = parent.ToString();
|
|
|
}
|
|
|
+ index += 1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- prizeSendDo(projectId, sub, prizeObjectId, content);
|
|
|
+ prizeSendDo(projectId, sub, prizeObjectId, content, new PriLoopSet());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public static void prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content)
|
|
|
+
|
|
|
+ static decimal loopAmount = 0;
|
|
|
+ public static void prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set)
|
|
|
{
|
|
|
var recordService = App.GetService<IPriRecordService>();
|
|
|
var conditionService = App.GetService<IPriConditionService>();
|
|
@@ -746,7 +753,9 @@ namespace Util
|
|
|
var queryTableService = App.GetService<IPriQueryTableService>();
|
|
|
var amountSetService = App.GetService<IPriListAmountSetService>();
|
|
|
//查询匹配条件
|
|
|
- var condiDic = condition(projectId, content);
|
|
|
+ Dictionary<string, object> condiDic = new Dictionary<string, object>();
|
|
|
+ if(sub.prizeSourceFieldType == "condi") condiDic = condition(projectId, content);
|
|
|
+ if(sub.prizeSourceFieldType == "loop") condiDic = loopCondition(projectId, sub, prizeObjectId, content);
|
|
|
|
|
|
var prizeSourceField = sub.prizeSourceField; //奖励金额来源字段(对应条件匹配返回字段)
|
|
|
var prizePercent = sub.prizePercent; //奖励比例
|
|
@@ -766,8 +775,34 @@ namespace Util
|
|
|
var fieldQueryValue = condition.fieldQueryValue; //匹配值
|
|
|
var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
|
|
|
|
|
|
- var checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId] : "0";
|
|
|
- var checkVal = fieldQueryValue;
|
|
|
+ string checkObj = "";
|
|
|
+ if(returnFieldId.Contains(","))
|
|
|
+ {
|
|
|
+ string[] returnFieldIdList = returnFieldId.Split(',');
|
|
|
+ foreach(string subField in returnFieldIdList)
|
|
|
+ {
|
|
|
+ string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
|
|
|
+ checkObj += val + ",";
|
|
|
+ }
|
|
|
+ checkObj = checkObj.TrimEnd(',');
|
|
|
+ }
|
|
|
+ else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
|
|
|
+ {
|
|
|
+ string expresssion = returnFieldId;
|
|
|
+ string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
|
|
|
+ foreach(string returnField in returnFields)
|
|
|
+ {
|
|
|
+ string val = condiDic.ContainsKey(returnField) ? condiDic[returnField].ToString() : "0";
|
|
|
+ expresssion = expresssion.Replace(returnField, val);
|
|
|
+ }
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ checkObj = dt.Compute(expresssion, "false").ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
|
|
|
+ }
|
|
|
+ string checkVal = fieldQueryValue;
|
|
|
|
|
|
if(fieldQueryKind == "1") //模糊匹配
|
|
|
{
|
|
@@ -799,21 +834,21 @@ namespace Util
|
|
|
Dictionary<string, string> req = getRequestParams(projectId, content);
|
|
|
if(fieldQueryValueType == "number")
|
|
|
{
|
|
|
- if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && (decimal)checkObj >= decimal.Parse(Function.CheckNum(req[val[0]])) && (decimal)checkObj <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
|
|
|
- else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && (decimal)checkObj >= decimal.Parse(Function.CheckNum(req[val[0]]))) passCount += 1;
|
|
|
- else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && (decimal)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;
|
|
|
+ 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;
|
|
|
}
|
|
|
else if(fieldQueryValueType == "int")
|
|
|
{
|
|
|
- if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && (int)checkObj >= int.Parse(Function.CheckInt(req[val[0]])) && (int)checkObj <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
|
|
|
- else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && (int)checkObj >= int.Parse(Function.CheckInt(req[val[0]]))) passCount += 1;
|
|
|
- else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && (int)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;
|
|
|
+ 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;
|
|
|
}
|
|
|
else if(fieldQueryValueType.StartsWith("date"))
|
|
|
{
|
|
|
- if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && (DateTime)checkObj >= DateTime.Parse(req[val[0]]) && (DateTime)checkObj <= DateTime.Parse(req[val[1]])) passCount += 1;
|
|
|
- else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && (DateTime)checkObj >= DateTime.Parse(req[val[0]])) passCount += 1;
|
|
|
- else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && (DateTime)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;
|
|
|
+ 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;
|
|
|
}
|
|
|
}
|
|
|
else if(fieldQueryModel == "fixed_value")
|
|
@@ -885,7 +920,7 @@ namespace Util
|
|
|
}
|
|
|
bool op = false;
|
|
|
if(conditionMode == "all" && passCount == allCount && passCount > 0) op = true;
|
|
|
- else if(conditionMode == "one" && passCount == 1) op = true;
|
|
|
+ else if(conditionMode == "one" && passCount >= 1) op = true;
|
|
|
if(op) //满足条件
|
|
|
{
|
|
|
decimal number = 0;
|
|
@@ -935,6 +970,8 @@ namespace Util
|
|
|
}
|
|
|
if(prizePercent > 0) prizeAmt += decimal.Parse(Function.CheckNum(prizeSourceData)) * prizePercent;
|
|
|
if(prizeAmount > 0) prizeAmt += prizeAmount;
|
|
|
+ decimal getPrizeAmount = prizeAmt;
|
|
|
+ if(set.levelDiffFlag) prizeAmt -= loopAmount;
|
|
|
if(prizeAmt > 0)
|
|
|
{
|
|
|
var req = getRequestParams(projectId, content);
|
|
@@ -952,6 +989,7 @@ namespace Util
|
|
|
requestParamField = requestParamField,
|
|
|
batchNo = batchNo,
|
|
|
});
|
|
|
+ loopAmount = getPrizeAmount;
|
|
|
// prizeToDatabase(projectId, content); //入库
|
|
|
}
|
|
|
}
|