PrizeDo.cs 143 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529
  1. using System.Data;
  2. using Common;
  3. using Infrastructure;
  4. using LitJson;
  5. using Microsoft.Extensions.Localization;
  6. using Model;
  7. using Model.Customer;
  8. using NuGet.Packaging;
  9. using Services;
  10. using System.Linq;
  11. using System.Net.Mime;
  12. namespace Util
  13. {
  14. public class PrizeDo
  15. {
  16. public static string batchNo = "";
  17. public static string publicStep = "";
  18. public static bool logFlag = true;
  19. //发奖入口
  20. public static void sendPrize(string queueName, string content)
  21. {
  22. batchNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Function.get_Random(3);
  23. publicStep = "";
  24. string priObjString = prizeInSet(queueName);
  25. if(!string.IsNullOrEmpty(priObjString))
  26. {
  27. string[] priObjData = priObjString.Split('|');
  28. string priListIds = priObjData[0];
  29. int projectId = int.Parse(priObjData[1]);
  30. int prizeInId = int.Parse(priObjData[2]);
  31. var projectService = App.GetService<IPriProjectService>();
  32. var project = projectService.GetFirst(m => m.id == projectId) ?? new PriProject();
  33. logFlag = project.logFlag;
  34. prizeSend(projectId, prizeInId, priListIds, content, queueName);
  35. }
  36. }
  37. //接收入参
  38. public static Dictionary<string, string> getRequestParams(int projectId, string content)
  39. {
  40. Dictionary<string, string> dic = new();
  41. JsonData jsonData = JsonMapper.ToObject(content);
  42. var paramService = App.GetService<IPriProjectParamService>();
  43. var paramList = paramService.GetList(m => m.projectId == projectId);
  44. foreach(var param in paramList)
  45. {
  46. if(content.Contains("\"" + param.fieldEnName + "\"")) dic.Add(param.fieldEnName, jsonData[param.fieldEnName].ToString());
  47. }
  48. return dic;
  49. }
  50. //数据库链接
  51. public static SqlSugarClient initDb(int id)
  52. {
  53. var databaseSetService = App.GetService<IPriDatabaseSetService>();
  54. var connectionString = databaseSetService.GetFirst(m => m.id == id);
  55. string server = connectionString.ipAddress;
  56. int port = connectionString.port;
  57. string user = connectionString.userId;
  58. string password = connectionString.password;
  59. string database = connectionString.databaseName;
  60. var db = new SqlSugarClient(new ConnectionConfig()
  61. {
  62. ConnectionString = "server=" + server + ";port=" + port + ";user=" + user + ";password=" + password + ";database=" + database + ";charset=utf8;",
  63. DbType = SqlSugar.DbType.MySql,
  64. IsAutoCloseConnection = true,
  65. });
  66. return db;
  67. }
  68. //查询条件匹配数据
  69. public static List<QueryCondition> condition(int listId, int projectId, List<int> ids, string content, Dictionary<string, string> startData)
  70. {
  71. List<QueryCondition> dic = new();
  72. var queryTableService = App.GetService<IPriQueryTableService>();
  73. var queryFieldService = App.GetService<IPriQueryFieldService>();
  74. var returnFieldService = App.GetService<IPriReturnFieldService>();
  75. //查询表
  76. var queryTables = queryTableService.GetList(m => ids.Contains(m.id) && m.startDataFlag == false);
  77. foreach(var queryTable in queryTables)
  78. {
  79. //查询返回字段
  80. string fields = "";
  81. Dictionary<string, string> fieldDic = new();
  82. var returnFields = returnFieldService.GetList(m => m.queryTableId == queryTable.id);
  83. foreach(var returnField in returnFields)
  84. {
  85. if(returnField.fieldReturnKind == "2")
  86. {
  87. fields += "count(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  88. }
  89. else if(returnField.fieldReturnKind == "3")
  90. {
  91. fields += "sum(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  92. }
  93. else if(returnField.fieldReturnKind == "4")
  94. {
  95. fields += "avg(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  96. }
  97. else
  98. {
  99. fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  100. }
  101. fieldDic.Add(queryTable.tableEnName + "_" + returnField.fieldEnName, returnField.fieldName);
  102. }
  103. fields = fields.TrimEnd(',');
  104. //查询匹配条件
  105. string condi = "";
  106. var queryFields = queryFieldService.GetList(m => m.queryTableId == queryTable.id);
  107. foreach(var queryField in queryFields)
  108. {
  109. string fieldEnName = queryField.fieldEnName;
  110. string fieldQueryKind = queryField.fieldQueryKind;
  111. string fieldQueryModel = queryField.fieldQueryModel;
  112. string fieldQueryValue = queryField.fieldQueryValue;
  113. string fieldQueryValueType = queryField.fieldQueryValueType;
  114. if(fieldQueryKind == "1") //模糊匹配
  115. {
  116. condi += " and " + fieldEnName + " like ";
  117. if(fieldQueryModel == "request_param")
  118. {
  119. Dictionary<string, string> req = getRequestParams(projectId, content);
  120. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  121. condi += "'%" + val + "%'";
  122. }
  123. else if(fieldQueryModel == "fixed_value")
  124. {
  125. condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
  126. }
  127. else if(fieldQueryModel == "db_field")
  128. {
  129. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  130. }
  131. else if(fieldQueryModel == "query_field")
  132. {
  133. string val = GetQueryTableData(dic, fieldQueryValue);
  134. condi += "'%" + val + "%'";
  135. }
  136. else if(fieldQueryModel == "start_list_field")
  137. {
  138. string val = GetStartData(startData, fieldQueryValue);
  139. condi += "'%" + val + "%'";
  140. }
  141. }
  142. else if(fieldQueryKind == "2") //精确匹配
  143. {
  144. if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is null";
  145. else
  146. {
  147. condi += " and " + fieldEnName + "=";
  148. string val = "";
  149. if(fieldQueryModel == "request_param")
  150. {
  151. Dictionary<string, string> req = getRequestParams(projectId, content);
  152. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  153. }
  154. else if(fieldQueryModel == "fixed_value")
  155. {
  156. val = GetExpressionVal(fieldQueryValue);
  157. }
  158. else if(fieldQueryModel == "db_field")
  159. {
  160. val = GetDbExpressionVal(fieldQueryValue);
  161. }
  162. else if(fieldQueryModel == "query_field")
  163. {
  164. val = GetQueryTableData(dic, fieldQueryValue);
  165. }
  166. else if(fieldQueryModel == "start_list_field")
  167. {
  168. val = GetStartData(startData, fieldQueryValue);
  169. }
  170. if(fieldQueryValueType == "text")
  171. {
  172. val = "'" + val + "'";
  173. }
  174. condi += val;
  175. }
  176. }
  177. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  178. {
  179. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  180. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  181. string val = "";
  182. string[] valList = fieldQueryValue.Split(',');
  183. if(fieldQueryModel == "request_param")
  184. {
  185. Dictionary<string, string> req = getRequestParams(projectId, content);
  186. foreach(string sub in valList)
  187. {
  188. if(fieldQueryValueType == "text")
  189. {
  190. val += "'" + req[sub] + "',";
  191. }
  192. else
  193. {
  194. val += req[sub] + ",";
  195. }
  196. }
  197. }
  198. else if(fieldQueryModel == "fixed_value")
  199. {
  200. foreach(string sub in valList)
  201. {
  202. if(fieldQueryValueType == "text")
  203. {
  204. val += "'" + GetExpressionVal(sub) + "',";
  205. }
  206. else
  207. {
  208. val += GetExpressionVal(sub) + ",";
  209. }
  210. }
  211. }
  212. else if(fieldQueryModel == "db_field")
  213. {
  214. foreach(string sub in valList)
  215. {
  216. if(fieldQueryValueType == "text")
  217. {
  218. val += "'" + GetDbExpressionVal(sub) + "',";
  219. }
  220. else
  221. {
  222. val += GetDbExpressionVal(sub) + ",";
  223. }
  224. }
  225. }
  226. else if(fieldQueryModel == "query_field")
  227. {
  228. foreach(string sub in valList)
  229. {
  230. string dicVal = GetQueryTableData(dic, sub);
  231. if(fieldQueryValueType == "text")
  232. {
  233. val += "'" + dicVal + "',";
  234. }
  235. else
  236. {
  237. val += dicVal + ",";
  238. }
  239. }
  240. }
  241. else if(fieldQueryModel == "start_list_field")
  242. {
  243. foreach(string sub in valList)
  244. {
  245. string dicVal = GetStartData(startData, sub);
  246. if(fieldQueryValueType == "text")
  247. {
  248. val += "'" + dicVal + "',";
  249. }
  250. else
  251. {
  252. val += dicVal + ",";
  253. }
  254. }
  255. }
  256. val = val.TrimEnd(',');
  257. condi += val + ")";
  258. }
  259. else if(fieldQueryKind == "3") //范围匹配
  260. {
  261. string[] val = fieldQueryValue.Split(':');
  262. if(fieldQueryModel == "request_param")
  263. {
  264. Dictionary<string, string> req = getRequestParams(projectId, content);
  265. if(fieldQueryValueType == "number")
  266. {
  267. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  268. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  269. }
  270. else
  271. {
  272. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  273. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  274. }
  275. }
  276. else if(fieldQueryModel == "fixed_value")
  277. {
  278. if(fieldQueryValueType == "number")
  279. {
  280. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  281. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  282. }
  283. else
  284. {
  285. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  286. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  287. }
  288. }
  289. else if(fieldQueryModel == "db_field")
  290. {
  291. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + GetDbExpressionVal(val[0]);
  292. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + GetDbExpressionVal(val[1]);
  293. }
  294. else if(fieldQueryModel == "query_field")
  295. {
  296. string valLeft = val[0];
  297. string valRight = val[1];
  298. string dicValLeft = GetQueryTableData(dic, valLeft);
  299. string dicValRight = GetQueryTableData(dic, valRight);
  300. if(fieldQueryValueType == "number")
  301. {
  302. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">=" + dicValLeft;
  303. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<=" + dicValRight;
  304. }
  305. else
  306. {
  307. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">='" + GetExpressionVal(dicValLeft) + "'";
  308. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<='" + GetExpressionVal(dicValRight) + "'";
  309. }
  310. }
  311. else if(fieldQueryModel == "start_list_field")
  312. {
  313. string valLeft = val[0];
  314. string valRight = val[1];
  315. string dicValLeft = GetStartData(startData, valLeft);
  316. string dicValRight = GetStartData(startData, valRight);
  317. if(fieldQueryValueType == "number")
  318. {
  319. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">=" + dicValLeft;
  320. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<=" + dicValRight;
  321. }
  322. else
  323. {
  324. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">='" + GetExpressionVal(dicValLeft) + "'";
  325. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<='" + GetExpressionVal(dicValRight) + "'";
  326. }
  327. }
  328. }
  329. else if(fieldQueryKind == "4") //取反匹配
  330. {
  331. if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is not null";
  332. else
  333. {
  334. condi += " and " + fieldEnName + "!=";
  335. string val = "";
  336. if(fieldQueryModel == "request_param")
  337. {
  338. Dictionary<string, string> req = getRequestParams(projectId, content);
  339. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  340. }
  341. else if(fieldQueryModel == "fixed_value")
  342. {
  343. val = GetExpressionVal(fieldQueryValue);
  344. }
  345. else if(fieldQueryModel == "db_field")
  346. {
  347. val = GetDbExpressionVal(fieldQueryValue);
  348. }
  349. else if(fieldQueryModel == "query_field")
  350. {
  351. val = GetQueryTableData(dic, fieldQueryValue);
  352. }
  353. else if(fieldQueryModel == "start_list_field")
  354. {
  355. val = GetStartData(startData, fieldQueryValue);
  356. }
  357. if(fieldQueryValueType == "text")
  358. {
  359. val = "'" + val + "'";
  360. }
  361. condi += val;
  362. }
  363. }
  364. }
  365. var db = initDb(queryTable.databaseId);
  366. string sql = "select " + fields + " from " + queryTable.tableEnName + " where 1=1" + condi;
  367. var items = db.Ado.GetDataTable(sql);
  368. if(items.Rows.Count > 0)
  369. {
  370. foreach(string field in fieldDic.Keys)
  371. {
  372. if(!dic.Any(m => m.FieldEnName == field)) dic.Add(new QueryCondition()
  373. {
  374. FieldName = fieldDic[field],
  375. FieldEnName = field,
  376. Value = items.Rows[0][field].ToString()
  377. });
  378. }
  379. }
  380. }
  381. return dic;
  382. }
  383. public static DataTable conditionList(int listId, int projectId, List<int> ids, string content, int skip = 0, int size = 1000)
  384. {
  385. List<QueryCondition> dic = new();
  386. var queryTableService = App.GetService<IPriQueryTableService>();
  387. var queryFieldService = App.GetService<IPriQueryFieldService>();
  388. var returnFieldService = App.GetService<IPriReturnFieldService>();
  389. //查询表
  390. var queryTable = queryTableService.GetFirst(m => ids.Contains(m.id) && m.startDataFlag == true);
  391. if (queryTable != null)
  392. {
  393. string groupBy = "";
  394. //查询返回字段
  395. string fields = "";
  396. Dictionary<string, string> fieldDic = new();
  397. var returnFields = returnFieldService.GetList(m => m.queryTableId == queryTable.id);
  398. foreach(var returnField in returnFields)
  399. {
  400. if(returnField.fieldReturnKind == "2")
  401. {
  402. fields += "count(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName.Split('+')[0] + ",";
  403. }
  404. else if(returnField.fieldReturnKind == "3")
  405. {
  406. fields += "sum(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName.Split('+')[0] + ",";
  407. }
  408. else if(returnField.fieldReturnKind == "4")
  409. {
  410. fields += "avg(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName.Split('+')[0] + ",";
  411. }
  412. else
  413. {
  414. fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  415. }
  416. fieldDic.Add(queryTable.tableEnName + "_" + returnField.fieldEnName, returnField.fieldName);
  417. }
  418. fields = fields.TrimEnd(',');
  419. //查询匹配条件
  420. string condi = "";
  421. var queryFields = queryFieldService.GetList(m => m.queryTableId == queryTable.id);
  422. foreach(var queryField in queryFields)
  423. {
  424. string fieldEnName = queryField.fieldEnName;
  425. string fieldQueryKind = queryField.fieldQueryKind;
  426. string fieldQueryModel = queryField.fieldQueryModel;
  427. string fieldQueryValue = queryField.fieldQueryValue;
  428. string fieldQueryValueType = queryField.fieldQueryValueType;
  429. if(fieldQueryKind == "1") //模糊匹配
  430. {
  431. condi += " and " + fieldEnName + " like ";
  432. if(fieldQueryModel == "request_param")
  433. {
  434. Dictionary<string, string> req = getRequestParams(projectId, content);
  435. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  436. condi += "'%" + val + "%'";
  437. }
  438. else if(fieldQueryModel == "fixed_value")
  439. {
  440. condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
  441. }
  442. else if(fieldQueryModel == "db_field")
  443. {
  444. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  445. }
  446. else if(fieldQueryModel == "query_field")
  447. {
  448. string val = GetQueryTableData(dic, fieldQueryValue);
  449. condi += "'%" + val + "%'";
  450. }
  451. }
  452. else if(fieldQueryKind == "2") //精确匹配
  453. {
  454. if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is null";
  455. else
  456. {
  457. condi += " and " + fieldEnName + "=";
  458. string val = "";
  459. if(fieldQueryModel == "request_param")
  460. {
  461. Dictionary<string, string> req = getRequestParams(projectId, content);
  462. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  463. }
  464. else if(fieldQueryModel == "fixed_value")
  465. {
  466. val = GetExpressionVal(fieldQueryValue);
  467. }
  468. else if(fieldQueryModel == "db_field")
  469. {
  470. val = GetDbExpressionVal(fieldQueryValue);
  471. }
  472. else if(fieldQueryModel == "query_field")
  473. {
  474. val = GetQueryTableData(dic, fieldQueryValue);
  475. }
  476. if(fieldQueryValueType == "text")
  477. {
  478. val = "'" + val + "'";
  479. }
  480. condi += val;
  481. }
  482. }
  483. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  484. {
  485. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  486. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  487. string val = "";
  488. string[] valList = fieldQueryValue.Split(',');
  489. if(fieldQueryModel == "request_param")
  490. {
  491. Dictionary<string, string> req = getRequestParams(projectId, content);
  492. foreach(string sub in valList)
  493. {
  494. if(fieldQueryValueType == "text")
  495. {
  496. val += "'" + req[sub] + "',";
  497. }
  498. else
  499. {
  500. val += req[sub] + ",";
  501. }
  502. }
  503. }
  504. else if(fieldQueryModel == "fixed_value")
  505. {
  506. foreach(string sub in valList)
  507. {
  508. if(fieldQueryValueType == "text")
  509. {
  510. val += "'" + GetExpressionVal(sub) + "',";
  511. }
  512. else
  513. {
  514. val += GetExpressionVal(sub) + ",";
  515. }
  516. }
  517. }
  518. else if(fieldQueryModel == "db_field")
  519. {
  520. foreach(string sub in valList)
  521. {
  522. if(fieldQueryValueType == "text")
  523. {
  524. val += "'" + GetDbExpressionVal(sub) + "',";
  525. }
  526. else
  527. {
  528. val += GetDbExpressionVal(sub) + ",";
  529. }
  530. }
  531. }
  532. else if(fieldQueryModel == "query_field")
  533. {
  534. foreach(string sub in valList)
  535. {
  536. string dicVal = GetQueryTableData(dic, sub);
  537. if(fieldQueryValueType == "text")
  538. {
  539. val += "'" + dicVal + "',";
  540. }
  541. else
  542. {
  543. val += dicVal + ",";
  544. }
  545. }
  546. }
  547. val = val.TrimEnd(',');
  548. condi += val + ")";
  549. }
  550. else if(fieldQueryKind == "3") //范围匹配
  551. {
  552. string[] val = fieldQueryValue.Split(':');
  553. if(fieldQueryModel == "request_param")
  554. {
  555. Dictionary<string, string> req = getRequestParams(projectId, content);
  556. if(fieldQueryValueType == "number")
  557. {
  558. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  559. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  560. }
  561. else
  562. {
  563. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  564. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  565. }
  566. }
  567. else if(fieldQueryModel == "fixed_value")
  568. {
  569. if(fieldQueryValueType == "number")
  570. {
  571. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  572. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  573. }
  574. else
  575. {
  576. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  577. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  578. }
  579. }
  580. else if(fieldQueryModel == "db_field")
  581. {
  582. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + GetDbExpressionVal(val[0]);
  583. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + GetDbExpressionVal(val[1]);
  584. }
  585. else if(fieldQueryModel == "query_field")
  586. {
  587. string valLeft = val[0];
  588. string valRight = val[1];
  589. string dicValLeft = GetQueryTableData(dic, valLeft);
  590. string dicValRight = GetQueryTableData(dic, valRight);
  591. if(fieldQueryValueType == "number")
  592. {
  593. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">=" + dicValLeft;
  594. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<=" + dicValRight;
  595. }
  596. else
  597. {
  598. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">='" + GetExpressionVal(dicValLeft) + "'";
  599. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<='" + GetExpressionVal(dicValRight) + "'";
  600. }
  601. }
  602. }
  603. else if(fieldQueryKind == "4") //取反匹配
  604. {
  605. if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is not null";
  606. else
  607. {
  608. condi += " and " + fieldEnName + "!=";
  609. string val = "";
  610. if(fieldQueryModel == "request_param")
  611. {
  612. Dictionary<string, string> req = getRequestParams(projectId, content);
  613. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  614. }
  615. else if(fieldQueryModel == "fixed_value")
  616. {
  617. val = GetExpressionVal(fieldQueryValue);
  618. }
  619. else if(fieldQueryModel == "db_field")
  620. {
  621. val = GetDbExpressionVal(fieldQueryValue);
  622. }
  623. else if(fieldQueryModel == "query_field")
  624. {
  625. val = GetQueryTableData(dic, fieldQueryValue);
  626. }
  627. if(fieldQueryValueType == "text")
  628. {
  629. val = "'" + val + "'";
  630. }
  631. condi += val;
  632. }
  633. }
  634. //拼装聚合字段
  635. if(queryField.groupByFlag) groupBy += queryField.fieldEnName +",";
  636. }
  637. if(!string.IsNullOrEmpty(groupBy)) groupBy = " group by " + groupBy.TrimEnd(',') + " order by " + groupBy.TrimEnd(',');
  638. var db = initDb(queryTable.databaseId);
  639. string sql = "select " + fields + " from " + queryTable.tableEnName + " where 1=1" + condi + groupBy + " limit " + skip + "," + size;
  640. var items = db.Ado.GetDataTable(sql);
  641. return items;
  642. }
  643. return new DataTable();
  644. }
  645. //奖励发放对象
  646. public static string prizeObject(int listId, int prizeObjectTag, string content)
  647. {
  648. Dictionary<string, object> logStepDic = new();
  649. Dictionary<string, object> dic = new();
  650. var prizeObjectTableService = App.GetService<IPriPrizeObjectTableService>();
  651. var prizeObjectFieldService = App.GetService<IPriPrizeObjectFieldService>();
  652. //查询表
  653. var prizeObjectTable = prizeObjectTableService.GetFirst(m => m.id == prizeObjectTag) ?? new PriPrizeObjectTable();
  654. //查询返回字段
  655. string field = prizeObjectTable.selectField;
  656. int projectId = prizeObjectTable.projectId;
  657. logStepDic.Add("奖励发放对象说明", prizeObjectTable.note);
  658. //查询匹配条件
  659. string condi = "";
  660. List<Dictionary<string, object>> condiDics = new();
  661. var queryFields = prizeObjectFieldService.GetList(m => m.objectTableId == prizeObjectTable.id);
  662. foreach(var queryField in queryFields)
  663. {
  664. string fieldName = queryField.fieldName;
  665. string fieldEnName = queryField.fieldEnName;
  666. string fieldQueryKind = queryField.fieldQueryKind;
  667. string fieldQueryModel = queryField.fieldQueryModel;
  668. string fieldQueryValue = queryField.fieldQueryValue;
  669. string fieldQueryValueType = queryField.fieldQueryValueType;
  670. Dictionary<string, object> condiDic = new();
  671. condiDic.Add("字段名称", fieldName);
  672. condiDic.Add("匹配条件", getQueryKind(fieldQueryKind));
  673. condiDic.Add("匹配方式", getQueryModel(fieldQueryModel));
  674. if(fieldQueryKind == "1") //模糊匹配
  675. {
  676. condi += " and " + fieldEnName + " like ";
  677. if(fieldQueryModel == "request_param")
  678. {
  679. Dictionary<string, string> req = getRequestParams(projectId, content);
  680. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  681. condi += "'%" + val + "%'";
  682. condiDic.Add("匹配值", val);
  683. }
  684. else if(fieldQueryModel == "fixed_value")
  685. {
  686. string val = GetExpressionVal(fieldQueryValue);
  687. condi += "'%" + val + "%'";
  688. condiDic.Add("匹配值", val);
  689. }
  690. else if(fieldQueryModel == "db_field")
  691. {
  692. string val = GetDbExpressionVal(fieldQueryValue);
  693. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  694. condiDic.Add("匹配值", val);
  695. }
  696. }
  697. else if(fieldQueryKind == "2") //精确匹配
  698. {
  699. condi += " and " + fieldEnName + "=";
  700. string val = "";
  701. if(fieldQueryModel == "request_param")
  702. {
  703. Dictionary<string, string> req = getRequestParams(projectId, content);
  704. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  705. }
  706. else if(fieldQueryModel == "fixed_value")
  707. {
  708. val = GetExpressionVal(fieldQueryValue);
  709. }
  710. else if(fieldQueryModel == "db_field")
  711. {
  712. val = GetDbExpressionVal(fieldQueryValue);
  713. }
  714. if(fieldQueryValueType == "text")
  715. {
  716. val = "'" + val + "'";
  717. }
  718. condi += val;
  719. condiDic.Add("匹配值", val);
  720. }
  721. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  722. {
  723. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  724. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  725. string val = "";
  726. string[] valList = fieldQueryValue.Split(',');
  727. if(fieldQueryModel == "request_param")
  728. {
  729. Dictionary<string, string> req = getRequestParams(projectId, content);
  730. foreach(string sub in valList)
  731. {
  732. if(fieldQueryValueType == "text")
  733. {
  734. val += "'" + req[sub] + "',";
  735. }
  736. else
  737. {
  738. val += req[sub] + ",";
  739. }
  740. }
  741. }
  742. else if(fieldQueryModel == "fixed_value")
  743. {
  744. foreach(string sub in valList)
  745. {
  746. if(fieldQueryValueType == "text")
  747. {
  748. val += "'" + GetExpressionVal(sub) + "',";
  749. }
  750. else
  751. {
  752. val += GetExpressionVal(sub) + ",";
  753. }
  754. }
  755. }
  756. else if(fieldQueryModel == "db_field")
  757. {
  758. foreach(string sub in valList)
  759. {
  760. if(fieldQueryValueType == "text")
  761. {
  762. val += "'" + GetDbExpressionVal(sub) + "',";
  763. }
  764. else
  765. {
  766. val += GetDbExpressionVal(sub) + ",";
  767. }
  768. }
  769. }
  770. val = val.TrimEnd(',');
  771. condi += val + ")";
  772. condiDic.Add("匹配值", val);
  773. }
  774. else if(fieldQueryKind == "3") //范围匹配
  775. {
  776. string[] val = fieldQueryValue.Split(':');
  777. if(fieldQueryModel == "request_param")
  778. {
  779. Dictionary<string, string> req = getRequestParams(projectId, content);
  780. if(fieldQueryValueType == "number")
  781. {
  782. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  783. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  784. }
  785. else
  786. {
  787. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  788. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  789. }
  790. }
  791. else if(fieldQueryModel == "fixed_value")
  792. {
  793. if(fieldQueryValueType == "number")
  794. {
  795. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  796. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  797. }
  798. else
  799. {
  800. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  801. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  802. }
  803. }
  804. else if(fieldQueryModel == "db_field")
  805. {
  806. if(fieldQueryValueType == "number")
  807. {
  808. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  809. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  810. }
  811. else
  812. {
  813. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetDbExpressionVal(val[0]) + "'";
  814. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetDbExpressionVal(val[1]) + "'";
  815. }
  816. }
  817. condiDic.Add("匹配值", val);
  818. }
  819. else if(fieldQueryKind == "4") //取反匹配
  820. {
  821. condi += " and " + fieldEnName + "!=";
  822. string val = "";
  823. if(fieldQueryModel == "request_param")
  824. {
  825. Dictionary<string, string> req = getRequestParams(projectId, content);
  826. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  827. }
  828. else if(fieldQueryModel == "fixed_value")
  829. {
  830. val = GetExpressionVal(fieldQueryValue);
  831. }
  832. else if(fieldQueryModel == "db_field")
  833. {
  834. val = GetDbExpressionVal(fieldQueryValue);
  835. }
  836. if(fieldQueryValueType == "text")
  837. {
  838. val = "'" + val + "'";
  839. }
  840. condi += val;
  841. condiDic.Add("匹配值", val);
  842. }
  843. condiDics.Add(condiDic);
  844. }
  845. logStepDic.Add("奖励发放对象查询条件", condiDics);
  846. string result = "0";
  847. var db = initDb(prizeObjectTable.databaseId);
  848. var item = db.Ado.GetScalar("select " + field + " from " + prizeObjectTable.tableEnName + " where 1=1" + condi);
  849. if(item != null)
  850. {
  851. result = item.ToString();
  852. }
  853. logStepDic.Add("奖励发放对象", result);
  854. setLogStep(listId, "奖励发放对象", logStepDic);
  855. return result;
  856. }
  857. //奖励发放入口
  858. public static string prizeInSet(string queueName)
  859. {
  860. Dictionary<string, object> dic = new();
  861. var prizeInSetService = App.GetService<IPriPrizeInSetService>();
  862. //查询表
  863. var prizeInSet = prizeInSetService.GetFirst(m => m.mqQueueName == queueName) ?? new PriPrizeInSet();
  864. if(prizeInSet.id > 0)
  865. {
  866. return prizeInSet.prizeListIds + "|" + prizeInSet.projectId + "|" + prizeInSet.id;
  867. }
  868. return "";
  869. }
  870. //奖励列表
  871. public static List<PriList> prizeList(int projectId, string prizeIds)
  872. {
  873. List<int> ids = Tools.SpitIntArrary(prizeIds, ',').ToList();
  874. var priListService = App.GetService<IPriListService>();
  875. var priList = priListService.GetList(m => m.projectId == projectId && ids.Contains(m.id)).ToList();
  876. return priList;
  877. }
  878. //奖励发放
  879. public static void prizeSend(int projectId, int prizeInId, string prizeIds, string content, string queueName)
  880. {
  881. var queryTableService = App.GetService<IPriQueryTableService>();
  882. var priList = prizeList(projectId, prizeIds);
  883. foreach(var sub in priList)
  884. {
  885. try
  886. {
  887. List<int> ids = Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList();
  888. var queryTable = queryTableService.GetFirst(m => ids.Contains(m.id) && m.startDataFlag == true);
  889. if (queryTable != null)
  890. {
  891. int page = 0;
  892. int size = queryTable.stepCount;
  893. if(size == 0) size = 20;
  894. bool op = true;
  895. while(op)
  896. {
  897. int skip = page * size;
  898. DataTable query = conditionList(sub.id, projectId, ids, content, skip, size);
  899. if(query.Rows.Count > 0)
  900. {
  901. foreach(DataRow dr in query.Rows)
  902. {
  903. Dictionary<string, string> startData = new();
  904. foreach(DataColumn dc in query.Columns)
  905. {
  906. startData.Add(dc.ColumnName, dr[dc.ColumnName].ToString());
  907. }
  908. prizeSendSub(sub, projectId, prizeInId, prizeIds, content, queueName, startData);
  909. }
  910. page += 1;
  911. }
  912. else
  913. {
  914. op = false;
  915. }
  916. }
  917. }
  918. else
  919. {
  920. prizeSendSub(sub, projectId, prizeInId, prizeIds, content, queueName, new Dictionary<string, string>());
  921. }
  922. }
  923. catch(Exception ex)
  924. {
  925. setLogFieldValue(sub.id, "errLog", ex.ToString());
  926. }
  927. }
  928. }
  929. //执行每个奖励发放逻辑
  930. public static void prizeSendSub(PriList sub, int projectId, int prizeInId, string prizeIds, string content, string queueName, Dictionary<string, string> startData)
  931. {
  932. var loopSetService = App.GetService<IPriLoopSetService>();
  933. var recursionStartTableService = App.GetService<IPriRecursionStartTableService>();
  934. var recursionStartConditionService = App.GetService<IPriRecursionStartConditionService>();
  935. addLog(projectId, sub.id, prizeInId, content, queueName); //初始化日志
  936. string prizeObjectId = prizeObject(sub.id, sub.prizeObj, content);
  937. var recursionFlag = sub.recursionFlag; //是否递归
  938. setLogStep(sub.id, "是否递归", recursionFlag ? "是" : "否");
  939. if(recursionFlag)
  940. {
  941. List<QueryCondition> queryCondiDic = condition(sub.id, projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content, startData);
  942. setLogStep(sub.id, "查询原始数据", queryCondiDic);
  943. var loopSet = loopSetService.GetFirst(m => m.listId == sub.id) ?? new PriLoopSet();
  944. var recursionStartTable = recursionStartTableService.GetFirst(m => m.listId == sub.id) ?? new PriRecursionStartTable();
  945. var tableEnName = loopSet.tableEnName; //递归查询表
  946. var parentField = loopSet.parentField; //父字段
  947. var sonField = loopSet.sonField; //子字段
  948. var afterPrizeFlag = loopSet.afterPrizeFlag; //发奖后是否继续
  949. var db = initDb(loopSet.databaseId);
  950. string objId = prizeObjectId;
  951. bool op = true;
  952. int index = 0;
  953. loopAmount = 0;
  954. List<Dictionary<string, object>> loopLogDic = new();
  955. while(!string.IsNullOrEmpty(objId) && objId != "0" && op)
  956. {
  957. Dictionary<string, object> loopLog = new();
  958. List<QueryCondition> condiDic = loopCondition(projectId, sub, objId, content);
  959. loopLog.Add("查询" + objId + "匹配数据", condiDic);
  960. if(condiDic.Count > 0)
  961. {
  962. bool prizeFlag = false;
  963. List<Dictionary<string, object>> logStepDics = new();
  964. var groupNos = recursionStartConditionService.GetList(m => m.loopSetId == loopSet.id).ToList().Select(m => m.groupNo).Distinct().ToList();
  965. foreach(var groupNo in groupNos)
  966. {
  967. var conditions = recursionStartConditionService.GetList(m => m.loopSetId == loopSet.id && m.groupNo == groupNo);
  968. if(conditions.Count > 0)
  969. {
  970. int allCount = conditions.Count; //所有奖励条件数
  971. int passCount = 0; //通过条件数
  972. foreach(var condition in conditions)
  973. {
  974. if(condition.startIndex <= index)
  975. {
  976. Dictionary<string, object> logStepDic = new();
  977. var returnFieldId = condition.returnFieldId; //条件返回字段
  978. var fieldQueryKind = condition.fieldQueryKind; //匹配条件
  979. var fieldQueryModel = condition.fieldQueryModel; //匹配方式
  980. var fieldQueryValue = condition.fieldQueryValue; //匹配值
  981. var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
  982. string checkObj = "";
  983. string checkTitle = "";
  984. if(returnFieldId.Contains(","))
  985. {
  986. string[] returnFieldIdList = returnFieldId.Split(',');
  987. foreach(string subField in returnFieldIdList)
  988. {
  989. string val = GetQueryTableData(condiDic, subField);
  990. checkObj += val + ",";
  991. string title = GetQueryTableTitle(condiDic, subField);
  992. checkTitle += title + ",";
  993. }
  994. checkObj = checkObj.TrimEnd(',');
  995. checkTitle = checkTitle.TrimEnd(',');
  996. }
  997. else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
  998. {
  999. string expresssion = returnFieldId;
  1000. checkTitle = returnFieldId;
  1001. string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
  1002. foreach(string returnField in returnFields)
  1003. {
  1004. string val = GetQueryTableData(condiDic, returnField);
  1005. expresssion = expresssion.Replace(returnField, val);
  1006. string title = GetQueryTableTitle(condiDic, returnField);
  1007. checkTitle = checkTitle.Replace(returnField, title);
  1008. }
  1009. DataTable dt = new();
  1010. checkObj = dt.Compute(expresssion, "false").ToString();
  1011. }
  1012. else
  1013. {
  1014. checkObj = GetQueryTableData(condiDic, returnFieldId);
  1015. checkTitle = GetQueryTableTitle(condiDic, returnFieldId);
  1016. }
  1017. logStepDic.Add("标题", checkTitle);
  1018. logStepDic.Add("匹配条件", getQueryKind(fieldQueryKind));
  1019. logStepDic.Add("匹配方式", getQueryModel(fieldQueryModel));
  1020. logStepDic.Add("匹配值", fieldQueryValue);
  1021. logStepDic.Add("实际值", checkObj);
  1022. var checkVal = fieldQueryValue;
  1023. bool passFlag = false;
  1024. if(fieldQueryKind == "1") //模糊匹配
  1025. {
  1026. if(fieldQueryValueType == "text")
  1027. {
  1028. if(checkObj.ToString().Contains(GetExpressionVal(checkVal)))
  1029. {
  1030. passCount += 1; passFlag = true;
  1031. }
  1032. }
  1033. }
  1034. else if(fieldQueryKind == "2") //精确匹配
  1035. {
  1036. if(fieldQueryValueType == "int")
  1037. {
  1038. if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal)))
  1039. {
  1040. passCount += 1; passFlag = true;
  1041. }
  1042. }
  1043. else if(fieldQueryValueType == "number")
  1044. {
  1045. if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal)))
  1046. {
  1047. passCount += 1; passFlag = true;
  1048. }
  1049. }
  1050. else
  1051. {
  1052. if(checkObj.ToString() == GetExpressionVal(checkVal))
  1053. {
  1054. passCount += 1; passFlag = true;
  1055. }
  1056. }
  1057. }
  1058. else if(fieldQueryKind == "3") //范围匹配
  1059. {
  1060. string[] val = checkVal.Split(':');
  1061. string valLeft = val[0];
  1062. string valRight = val[1];
  1063. if(fieldQueryModel == "request_param")
  1064. {
  1065. Dictionary<string, string> req = getRequestParams(projectId, content);
  1066. if(fieldQueryValueType == "number")
  1067. {
  1068. if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
  1069. {
  1070. passCount += 1; passFlag = true;
  1071. }
  1072. else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])))
  1073. {
  1074. passCount += 1; passFlag = true;
  1075. }
  1076. else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
  1077. {
  1078. passCount += 1; passFlag = true;
  1079. }
  1080. }
  1081. else if(fieldQueryValueType == "int")
  1082. {
  1083. if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
  1084. {
  1085. passCount += 1; passFlag = true;
  1086. }
  1087. else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])))
  1088. {
  1089. passCount += 1; passFlag = true;
  1090. }
  1091. else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
  1092. {
  1093. passCount += 1; passFlag = true;
  1094. }
  1095. }
  1096. else if(fieldQueryValueType.StartsWith("date"))
  1097. {
  1098. if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
  1099. {
  1100. passCount += 1; passFlag = true;
  1101. }
  1102. else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]))
  1103. {
  1104. passCount += 1; passFlag = true;
  1105. }
  1106. else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
  1107. {
  1108. passCount += 1; passFlag = true;
  1109. }
  1110. }
  1111. }
  1112. else if(fieldQueryModel == "fixed_value")
  1113. {
  1114. string checkValLeft = valLeft.Replace("#{", "").Replace("}#", "");
  1115. string checkValRight = valRight.Replace("#{", "").Replace("}#", "");
  1116. if(checkValLeft.Contains(",")) checkValLeft = checkValLeft.Split(',')[0];
  1117. if(checkValRight.Contains(",")) checkValRight = checkValRight.Split(',')[0];
  1118. valLeft = GetExpressionVal(valLeft);
  1119. valRight = GetExpressionVal(valRight);
  1120. if(fieldQueryValueType == "number")
  1121. {
  1122. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1123. {
  1124. passCount += 1; passFlag = true;
  1125. }
  1126. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
  1127. {
  1128. passCount += 1; passFlag = true;
  1129. }
  1130. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1131. {
  1132. passCount += 1; passFlag = true;
  1133. }
  1134. }
  1135. else if(fieldQueryValueType == "int")
  1136. {
  1137. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1138. {
  1139. passCount += 1; passFlag = true;
  1140. }
  1141. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
  1142. {
  1143. passCount += 1; passFlag = true;
  1144. }
  1145. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1146. {
  1147. passCount += 1; passFlag = true;
  1148. }
  1149. }
  1150. else if(fieldQueryValueType.StartsWith("date"))
  1151. {
  1152. if(valLeft == "0") valLeft = "";
  1153. if(valRight == "0") valRight = "";
  1154. if(checkObj != "0" && checkObj != "")
  1155. {
  1156. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
  1157. {
  1158. passCount += 1; passFlag = true;
  1159. }
  1160. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)))
  1161. {
  1162. passCount += 1; passFlag = true;
  1163. }
  1164. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
  1165. {
  1166. passCount += 1; passFlag = true;
  1167. }
  1168. }
  1169. }
  1170. }
  1171. else if(fieldQueryModel == "query_field")
  1172. {
  1173. valLeft = GetComputeVal(queryCondiDic, valLeft);
  1174. valRight = GetComputeVal(queryCondiDic, valRight);
  1175. if(fieldQueryValueType == "number")
  1176. {
  1177. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1178. {
  1179. passCount += 1; passFlag = true;
  1180. }
  1181. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
  1182. {
  1183. passCount += 1; passFlag = true;
  1184. }
  1185. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1186. {
  1187. passCount += 1; passFlag = true;
  1188. }
  1189. }
  1190. else if(fieldQueryValueType == "int")
  1191. {
  1192. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1193. {
  1194. passCount += 1; passFlag = true;
  1195. }
  1196. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
  1197. {
  1198. passCount += 1; passFlag = true;
  1199. }
  1200. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1201. {
  1202. passCount += 1; passFlag = true;
  1203. }
  1204. }
  1205. else if(fieldQueryValueType.StartsWith("date"))
  1206. {
  1207. if(valLeft == "0") valLeft = "";
  1208. if(valRight == "0") valRight = "";
  1209. if(checkObj != "0" && checkObj != "")
  1210. {
  1211. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
  1212. {
  1213. passCount += 1; passFlag = true;
  1214. }
  1215. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(valLeft)))
  1216. {
  1217. passCount += 1; passFlag = true;
  1218. }
  1219. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(valRight)))
  1220. {
  1221. passCount += 1; passFlag = true;
  1222. }
  1223. }
  1224. }
  1225. }
  1226. }
  1227. else if(fieldQueryKind == "4") //取反匹配
  1228. {
  1229. if(fieldQueryValueType == "int")
  1230. {
  1231. if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal)))
  1232. {
  1233. passCount += 1; passFlag = true;
  1234. }
  1235. }
  1236. else if(fieldQueryValueType == "number")
  1237. {
  1238. if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal)))
  1239. {
  1240. passCount += 1; passFlag = true;
  1241. }
  1242. }
  1243. else if(fieldQueryValueType == "text")
  1244. {
  1245. if(checkObj.ToString() != GetExpressionVal(checkVal))
  1246. {
  1247. passCount += 1; passFlag = true;
  1248. }
  1249. }
  1250. }
  1251. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  1252. {
  1253. string val = ",";
  1254. string[] valList = checkVal.Split(',');
  1255. if(fieldQueryModel == "request_param")
  1256. {
  1257. Dictionary<string, string> req = getRequestParams(projectId, content);
  1258. foreach(string subVal in valList)
  1259. {
  1260. val += req[subVal] + ",";
  1261. }
  1262. }
  1263. else if(fieldQueryModel == "fixed_value")
  1264. {
  1265. foreach(string subVal in valList)
  1266. {
  1267. val += GetExpressionVal(subVal) + ",";
  1268. }
  1269. }
  1270. else if(fieldQueryModel == "db_field")
  1271. {
  1272. foreach(string subVal in valList)
  1273. {
  1274. val += GetDbExpressionVal(subVal) + ",";
  1275. }
  1276. }
  1277. if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ","))
  1278. {
  1279. passCount += 1; passFlag = true;
  1280. }
  1281. if(fieldQueryKind == "6" && !val.Contains("," + checkObj.ToString() + ","))
  1282. {
  1283. passCount += 1; passFlag = true;
  1284. }
  1285. }
  1286. logStepDic.Add("状态", passFlag ? "通过" : "未通过");
  1287. logStepDics.Add(logStepDic);
  1288. }
  1289. }
  1290. if(loopSet.conditionMode == "all" && passCount == allCount) prizeFlag = true;
  1291. else if(loopSet.conditionMode == "one" && passCount >= 1) prizeFlag = true;
  1292. else if(loopSet.conditionMode == "two" && passCount >= 2) prizeFlag = true;
  1293. else if(loopSet.conditionMode == "three" && passCount >= 3) prizeFlag = true;
  1294. // else prizeFlag = false;
  1295. }
  1296. // else
  1297. // {
  1298. // prizeFlag = false;
  1299. // }
  1300. }
  1301. loopLog.Add(objId + "匹配情况", logStepDics);
  1302. loopLog.Add("匹配结果", prizeFlag);
  1303. if(prizeFlag)
  1304. {
  1305. decimal prizeAmt = prizeSendDo(projectId, sub, objId, content, loopSet, startData);
  1306. op = afterPrizeFlag;
  1307. }
  1308. }
  1309. loopLogDic.Add(loopLog);
  1310. var parent = db.Ado.GetScalar("select " + parentField + " from " + tableEnName + " where " + sonField + "=" + objId);
  1311. if(parent != null)
  1312. {
  1313. objId = parent.ToString();
  1314. }
  1315. else
  1316. {
  1317. objId = "0";
  1318. }
  1319. index += 1;
  1320. }
  1321. setLogStep(sub.id, "向上递归流程", loopLogDic);
  1322. }
  1323. else
  1324. {
  1325. prizeSendDo(projectId, sub, prizeObjectId, content, new PriLoopSet(), startData);
  1326. }
  1327. }
  1328. static decimal loopAmount = 0;
  1329. public static decimal prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set, Dictionary<string, string> startData)
  1330. {
  1331. var projectService = App.GetService<IPriProjectService>();
  1332. var recordService = App.GetService<IPriRecordService>();
  1333. var conditionService = App.GetService<IPriConditionService>();
  1334. var returnFieldService = App.GetService<IPriReturnFieldService>();
  1335. // var queryTableService = App.GetService<IPriQueryTableService>();
  1336. var amountSetService = App.GetService<IPriListAmountSetService>();
  1337. var project = projectService.GetFirst(m => m.id == projectId) ?? new PriProject();
  1338. //查询匹配条件
  1339. List<QueryCondition> condiDic = condition(sub.id, projectId, Tools.SpitIntArrary(sub.queryTableIdList, ',').ToList(), content, startData);
  1340. if(sub.prizeSourceFieldType == "loop") MergeCondiDic(condiDic, loopCondition(projectId, sub, prizeObjectId, content));
  1341. setLogStep(sub.id, "发放奖励查询来源数据", condiDic);
  1342. var prizeSourceField = sub.prizeSourceField; //奖励金额来源字段(对应条件匹配返回字段)
  1343. var prizePercent = sub.prizePercent; //奖励比例
  1344. var prizeAmount = sub.prizeAmount; //奖励固定值
  1345. var prizeContent = sub.prizeContent; //奖励内容
  1346. var conditionMode = sub.conditionMode; //条件模式
  1347. var recursionFlag = sub.recursionFlag; //是否递归
  1348. bool op = false;
  1349. var groupNos = conditionService.GetList(m => m.listId == sub.id).ToList().Select(m => m.groupNo).Distinct().ToList();
  1350. foreach(var groupNo in groupNos)
  1351. {
  1352. var conditions = conditionService.GetList(m => m.listId == sub.id && m.groupNo == groupNo);
  1353. setLogStep(sub.id, "发放奖励匹配条件", condiDic);
  1354. int allCount = conditions.Count; //所有奖励条件数
  1355. int passCount = 0; //通过条件数
  1356. List<Dictionary<string, object>> logStepDics = new();
  1357. foreach(var condition in conditions)
  1358. {
  1359. Dictionary<string, object> logStepDic = new();
  1360. var returnFieldId = condition.returnFieldId; //条件返回字段
  1361. var fieldQueryKind = condition.fieldQueryKind; //匹配条件
  1362. var fieldQueryModel = condition.fieldQueryModel; //匹配方式
  1363. var fieldQueryValue = condition.fieldQueryValue; //匹配值
  1364. var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
  1365. string checkObj = "";
  1366. string checkTitle = "";
  1367. if(returnFieldId.Contains(","))
  1368. {
  1369. string[] returnFieldIdList = returnFieldId.Split(',');
  1370. foreach(string subField in returnFieldIdList)
  1371. {
  1372. string val = GetQueryTableData(condiDic, subField);
  1373. checkObj += val + ",";
  1374. string title = GetQueryTableTitle(condiDic, subField);
  1375. checkTitle += title + ",";
  1376. }
  1377. checkObj = checkObj.TrimEnd(',');
  1378. checkTitle = checkTitle.TrimEnd(',');
  1379. }
  1380. else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
  1381. {
  1382. string expresssion = returnFieldId;
  1383. checkTitle = returnFieldId;
  1384. string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
  1385. foreach(string returnField in returnFields)
  1386. {
  1387. string val = GetQueryTableData(condiDic, returnField);
  1388. expresssion = expresssion.Replace(returnField, val);
  1389. string title = GetQueryTableTitle(condiDic, returnField);
  1390. checkTitle = checkTitle.Replace(returnField, title);
  1391. }
  1392. DataTable dt = new();
  1393. checkObj = dt.Compute(expresssion, "false").ToString();
  1394. }
  1395. else
  1396. {
  1397. checkObj = GetQueryTableData(condiDic, returnFieldId);
  1398. checkTitle = GetQueryTableTitle(condiDic, returnFieldId);
  1399. }
  1400. // if(!sub.recursionFlag)
  1401. // {
  1402. logStepDic.Add("标题", checkTitle);
  1403. logStepDic.Add("匹配条件", getQueryKind(fieldQueryKind));
  1404. logStepDic.Add("匹配方式", getQueryModel(fieldQueryModel));
  1405. logStepDic.Add("匹配值", fieldQueryValue);
  1406. logStepDic.Add("实际值", checkObj);
  1407. // }
  1408. string checkVal = fieldQueryValue;
  1409. bool passFlag = false;
  1410. if(fieldQueryKind == "1") //模糊匹配
  1411. {
  1412. if(fieldQueryValueType == "text")
  1413. {
  1414. if(checkObj.ToString().Contains(GetExpressionVal(checkVal)))
  1415. {
  1416. passCount += 1; passFlag = true;
  1417. }
  1418. }
  1419. }
  1420. else if(fieldQueryKind == "2") //精确匹配
  1421. {
  1422. if(fieldQueryValueType == "int")
  1423. {
  1424. if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal)))
  1425. {
  1426. passCount += 1; passFlag = true;
  1427. }
  1428. }
  1429. else if(fieldQueryValueType == "number")
  1430. {
  1431. if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal)))
  1432. {
  1433. passCount += 1; passFlag = true;
  1434. }
  1435. }
  1436. else
  1437. {
  1438. if(checkObj.ToString() == GetExpressionVal(checkVal))
  1439. {
  1440. passCount += 1; passFlag = true;
  1441. }
  1442. }
  1443. }
  1444. else if(fieldQueryKind == "3") //范围匹配
  1445. {
  1446. string[] val = checkVal.Split(':');
  1447. string valLeft = val[0];
  1448. string valRight = val[1];
  1449. if(fieldQueryModel == "request_param")
  1450. {
  1451. Dictionary<string, string> req = getRequestParams(projectId, content);
  1452. if(fieldQueryValueType == "number")
  1453. {
  1454. if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
  1455. {
  1456. passCount += 1; passFlag = true;
  1457. }
  1458. else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[valLeft])))
  1459. {
  1460. passCount += 1; passFlag = true;
  1461. }
  1462. else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[valRight])))
  1463. {
  1464. passCount += 1; passFlag = true;
  1465. }
  1466. }
  1467. else if(fieldQueryValueType == "int")
  1468. {
  1469. if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
  1470. {
  1471. passCount += 1; passFlag = true;
  1472. }
  1473. else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[valLeft])))
  1474. {
  1475. passCount += 1; passFlag = true;
  1476. }
  1477. else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[valRight])))
  1478. {
  1479. passCount += 1; passFlag = true;
  1480. }
  1481. }
  1482. else if(fieldQueryValueType.StartsWith("date"))
  1483. {
  1484. if(!string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
  1485. {
  1486. passCount += 1; passFlag = true;
  1487. }
  1488. else if(!string.IsNullOrEmpty(req[valLeft]) && string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[valLeft]))
  1489. {
  1490. passCount += 1; passFlag = true;
  1491. }
  1492. else if(string.IsNullOrEmpty(req[valLeft]) && !string.IsNullOrEmpty(req[valRight]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[valRight]))
  1493. {
  1494. passCount += 1; passFlag = true;
  1495. }
  1496. }
  1497. }
  1498. else if(fieldQueryModel == "fixed_value")
  1499. {
  1500. valLeft = GetExpressionVal(valLeft);
  1501. valRight = GetExpressionVal(valRight);
  1502. if(fieldQueryValueType == "number")
  1503. {
  1504. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1505. {
  1506. passCount += 1; passFlag = true;
  1507. }
  1508. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
  1509. {
  1510. passCount += 1; passFlag = true;
  1511. }
  1512. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1513. {
  1514. passCount += 1; passFlag = true;
  1515. }
  1516. }
  1517. else if(fieldQueryValueType == "int")
  1518. {
  1519. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckNum(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1520. {
  1521. passCount += 1; passFlag = true;
  1522. }
  1523. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
  1524. {
  1525. passCount += 1; passFlag = true;
  1526. }
  1527. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1528. {
  1529. passCount += 1; passFlag = true;
  1530. }
  1531. }
  1532. else if(fieldQueryValueType.StartsWith("date"))
  1533. {
  1534. if(valLeft == "0") valLeft = "";
  1535. if(valRight == "0") valRight = "";
  1536. if(checkObj != "0" && checkObj != "")
  1537. {
  1538. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(valRight)))
  1539. {
  1540. passCount += 1; passFlag = true;
  1541. }
  1542. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(valLeft)))
  1543. {
  1544. passCount += 1; passFlag = true;
  1545. }
  1546. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(valRight)))
  1547. {
  1548. passCount += 1; passFlag = true;
  1549. }
  1550. }
  1551. }
  1552. }
  1553. else if(fieldQueryModel == "query_field")
  1554. {
  1555. string checkValLeft = valLeft.Replace("#{", "").Replace("}#", "");
  1556. string checkValRight = valRight.Replace("#{", "").Replace("}#", "");
  1557. if(checkValLeft.Contains(",")) checkValLeft = checkValLeft.Split(',')[0];
  1558. if(checkValRight.Contains(",")) checkValRight = checkValRight.Split(',')[0];
  1559. if(!string.IsNullOrEmpty(valLeft)) valLeft = valLeft.Replace(checkValLeft, GetQueryTableData(condiDic, checkValLeft));
  1560. if(!string.IsNullOrEmpty(valRight)) valRight = valRight.Replace(checkValRight, GetQueryTableData(condiDic, checkValRight));
  1561. valLeft = GetExpressionVal(valLeft);
  1562. valRight = GetExpressionVal(valRight);
  1563. if(fieldQueryValueType == "number")
  1564. {
  1565. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1566. {
  1567. passCount += 1; passFlag = true;
  1568. }
  1569. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(valLeft)))
  1570. {
  1571. passCount += 1; passFlag = true;
  1572. }
  1573. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(valRight)))
  1574. {
  1575. passCount += 1; passFlag = true;
  1576. }
  1577. }
  1578. else if(fieldQueryValueType == "int")
  1579. {
  1580. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckNum(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1581. {
  1582. passCount += 1; passFlag = true;
  1583. }
  1584. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(valLeft)))
  1585. {
  1586. passCount += 1; passFlag = true;
  1587. }
  1588. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(valRight)))
  1589. {
  1590. passCount += 1; passFlag = true;
  1591. }
  1592. }
  1593. else if(fieldQueryValueType.StartsWith("date"))
  1594. {
  1595. if(valLeft == "0") valLeft = "";
  1596. if(valRight == "0") valRight = "";
  1597. if(checkObj != "0" && checkObj != "")
  1598. {
  1599. if(!string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(valLeft)) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(valRight)))
  1600. {
  1601. passCount += 1; passFlag = true;
  1602. }
  1603. else if(!string.IsNullOrEmpty(valLeft) && string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(valLeft)))
  1604. {
  1605. passCount += 1; passFlag = true;
  1606. }
  1607. else if(string.IsNullOrEmpty(valLeft) && !string.IsNullOrEmpty(valRight) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(valRight)))
  1608. {
  1609. passCount += 1; passFlag = true;
  1610. }
  1611. }
  1612. }
  1613. }
  1614. }
  1615. else if(fieldQueryKind == "4") //取反匹配
  1616. {
  1617. if(fieldQueryValueType == "int")
  1618. {
  1619. if(int.Parse(Function.CheckNum(checkObj.ToString())) != int.Parse(Function.CheckInt(checkVal)))
  1620. {
  1621. passCount += 1; passFlag = true;
  1622. }
  1623. }
  1624. else if(fieldQueryValueType == "number")
  1625. {
  1626. if(decimal.Parse(Function.CheckNum(checkObj.ToString())) != decimal.Parse(Function.CheckNum(checkVal)))
  1627. {
  1628. passCount += 1; passFlag = true;
  1629. }
  1630. }
  1631. else if(fieldQueryValueType == "text")
  1632. {
  1633. if(checkObj.ToString() != GetExpressionVal(checkVal))
  1634. {
  1635. passCount += 1; passFlag = true;
  1636. }
  1637. }
  1638. }
  1639. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  1640. {
  1641. string val = ",";
  1642. string[] valList = checkVal.Split(',');
  1643. if(fieldQueryModel == "request_param")
  1644. {
  1645. Dictionary<string, string> req = getRequestParams(projectId, content);
  1646. foreach(string subVal in valList)
  1647. {
  1648. val += req[subVal] + ",";
  1649. }
  1650. }
  1651. else if(fieldQueryModel == "fixed_value")
  1652. {
  1653. foreach(string subVal in valList)
  1654. {
  1655. val += GetExpressionVal(subVal) + ",";
  1656. }
  1657. }
  1658. else if(fieldQueryModel == "db_field")
  1659. {
  1660. foreach(string subVal in valList)
  1661. {
  1662. val += GetDbExpressionVal(subVal) + ",";
  1663. }
  1664. }
  1665. if (fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ","))
  1666. {
  1667. passCount += 1; passFlag = true;
  1668. }
  1669. if(fieldQueryKind == "6" && !val.Contains("," + checkObj.ToString() + ","))
  1670. {
  1671. passCount += 1; passFlag = true;
  1672. }
  1673. }
  1674. // if(!sub.recursionFlag)
  1675. // {
  1676. logStepDic.Add("状态", passFlag ? "通过" : "未通过");
  1677. logStepDics.Add(logStepDic);
  1678. // }
  1679. }
  1680. setLogStep(sub.id, "匹配结果", logStepDics);
  1681. if(conditionMode == "all" && passCount == allCount && passCount > 0) op = true;
  1682. else if(conditionMode == "one" && passCount >= 1) op = true;
  1683. else if(conditionMode == "two" && passCount >= 2) op = true;
  1684. else if(conditionMode == "three" && passCount >= 3) op = true;
  1685. }
  1686. decimal prizeAmt = 0;
  1687. setLogStep(sub.id, "是否通过", op ? "是" : "否");
  1688. if(op) //满足条件
  1689. {
  1690. decimal number = 0;
  1691. if(prizeSourceField.Contains("/"))
  1692. {
  1693. number = decimal.Parse(prizeSourceField.Split('/')[1]);
  1694. prizeSourceField = prizeSourceField.Split('/')[0];
  1695. }
  1696. string prizeSourceData = "";
  1697. if(prizeSourceField.Contains(","))
  1698. {
  1699. string[] prizeSourceFieldList = prizeSourceField.Split(',');
  1700. foreach(string subField in prizeSourceFieldList)
  1701. {
  1702. string val = GetQueryTableData(condiDic, subField);
  1703. prizeSourceData += val + ",";
  1704. }
  1705. prizeSourceData = prizeSourceData.TrimEnd(',');
  1706. }
  1707. else
  1708. {
  1709. prizeSourceData = GetQueryTableData(condiDic, prizeSourceField);
  1710. }
  1711. if(string.IsNullOrEmpty(prizeSourceData)) prizeSourceData = "0";
  1712. if(prizeSourceField.Contains("/") && number > 0)
  1713. {
  1714. decimal prizeSourceDataNum = decimal.Parse(prizeSourceData) / number;
  1715. prizeSourceData = prizeSourceDataNum.ToString("f2");
  1716. }
  1717. var amountSet = amountSetService.GetFirst(m => m.listId == sub.id && m.prizeSourceField == prizeSourceData);
  1718. if(amountSet != null)
  1719. {
  1720. prizePercent = amountSet.prizePercent;
  1721. prizeAmount = amountSet.prizeAmount;
  1722. }
  1723. if(prizeSourceData.Contains(","))
  1724. {
  1725. string checkField = prizeSourceData.Split(',')[0] + ",";
  1726. amountSet = amountSetService.GetFirst(m => m.listId == sub.id && m.prizeSourceField.StartsWith(checkField) && m.prizeSourceField.EndsWith(",%"));
  1727. if(amountSet != null)
  1728. {
  1729. prizePercent = amountSet.prizePercent;
  1730. prizeAmount = amountSet.prizeAmount;
  1731. prizeSourceData = prizeSourceData.Split(',')[1];
  1732. }
  1733. }
  1734. if(prizePercent > 0) prizeAmt += decimal.Parse(Function.CheckNum(prizeSourceData)) * prizePercent;
  1735. if(prizeAmount > 0) prizeAmt += prizeAmount;
  1736. decimal getPrizeAmount = prizeAmt;
  1737. if(set.levelDiffFlag) prizeAmt -= loopAmount;
  1738. setLogStep(sub.id, "发放金额", prizeAmt);
  1739. if(prizeAmt > 0)
  1740. {
  1741. setLogPrizeAmount(sub.id, prizeAmt);
  1742. var req = getRequestParams(projectId, content);
  1743. var requestParamField = req[sub.requestParamField];
  1744. var sendFlag = recordService.Any(m => m.prizeObjId == prizeObjectId && m.listId == sub.id && m.requestParamField == content);
  1745. if(!sendFlag)
  1746. {
  1747. PriRecord item = new PriRecord()
  1748. {
  1749. createDate = DateTime.Now,
  1750. projectId = projectId,
  1751. listId = sub.id,
  1752. prizeAmount = prizeAmt,
  1753. prizeObjId = prizeObjectId,
  1754. requestParamField = content,
  1755. batchNo = batchNo,
  1756. };
  1757. recordService.Add(item);
  1758. Dictionary<string, object> prizeItem = new Dictionary<string, object>();
  1759. prizeItem.Add("prize_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1760. prizeItem.Add("prize_name", sub.prizeName);
  1761. prizeItem.Add("prize_code", sub.prizeCode);
  1762. prizeItem.Add("batch_no", batchNo);
  1763. prizeItem.Add("request_param_field", content);
  1764. List<Dictionary<string, object>> prizeItemList = new List<Dictionary<string, object>>();
  1765. Dictionary<string, object> prizeItemSub = new Dictionary<string, object>();
  1766. prizeItemSub.Add("prize_amount", prizeAmt);
  1767. prizeItemSub.Add("prize_obj", prizeObjectId);
  1768. prizeItemList.Add(prizeItemSub);
  1769. prizeItem.Add("prize_list", prizeItemList);
  1770. string prizeOutContent = Newtonsoft.Json.JsonConvert.SerializeObject(prizeItem);
  1771. setLogFieldValue(sub.id, "prizeOutContent", prizeOutContent);
  1772. setLogFieldValue(sub.id, "prizeOutUrl", project.noticeUrl);
  1773. loopAmount = getPrizeAmount;
  1774. if(project.requestMode == "http" && !string.IsNullOrEmpty(project.noticeUrl))
  1775. {
  1776. int status = -1;
  1777. string noticeJson = Function.PostWebRequest(project.noticeUrl, prizeOutContent, "application/json");
  1778. Function.WriteLog(noticeJson, "通知返回报文");
  1779. JsonData jsonObj = JsonMapper.ToObject(noticeJson);
  1780. if(jsonObj["status"].ToString() == "1")
  1781. {
  1782. status = 1;
  1783. }
  1784. Function.WriteLog(status.ToString(), "通知返回报文");
  1785. var sendItem = recordService.GetFirst(m => m.prizeObjId == prizeObjectId && m.listId == sub.id && m.requestParamField == content);
  1786. if(sendItem != null)
  1787. {
  1788. Function.WriteLog("in", "通知返回报文");
  1789. sendItem.status = status;
  1790. recordService.Update(sendItem);
  1791. Function.WriteLog("end", "通知返回报文");
  1792. }
  1793. }
  1794. else if(project.requestMode == "mq")
  1795. {}
  1796. else if(project.requestMode == "db")
  1797. {
  1798. prizeToDatabase(projectId, sub.id, content, condiDic, prizeAmt, startData); //入库
  1799. }
  1800. }
  1801. }
  1802. }
  1803. // if(!sub.recursionFlag)
  1804. // {
  1805. setLogStatus(sub.id, op ? 1 : 0);
  1806. // }
  1807. return prizeAmt;
  1808. }
  1809. //递归条件判断
  1810. public static List<QueryCondition> loopCondition(int projectId, PriList sub, string objId, string content)
  1811. {
  1812. List<QueryCondition> dic = new();
  1813. var queryTableService = App.GetService<IPriRecursionStartTableService>();
  1814. var queryFieldService = App.GetService<IPriRecursionStartFieldService>();
  1815. var queryReturnFieldService = App.GetService<IPriRecursionStartReturnFieldService>();
  1816. int passCount = 0;
  1817. //查询表
  1818. var queryTables = queryTableService.GetList(m => m.listId == sub.id);
  1819. int allCount = queryTables.Count;
  1820. foreach(var queryTable in queryTables)
  1821. {
  1822. //查询返回字段
  1823. string fields = "1";
  1824. Dictionary<string, string> fieldDic = new();
  1825. var returnFields = queryReturnFieldService.GetList(m => m.objectTableId == queryTable.id);
  1826. if(returnFields.Count > 0)
  1827. {
  1828. fields = "";
  1829. foreach(var returnField in returnFields)
  1830. {
  1831. if(returnField.fieldReturnKind == "2")
  1832. {
  1833. fields += "count(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1834. }
  1835. else if(returnField.fieldReturnKind == "3")
  1836. {
  1837. fields += "sum(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1838. }
  1839. else if(returnField.fieldReturnKind == "4")
  1840. {
  1841. fields += "avg(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1842. }
  1843. else
  1844. {
  1845. fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1846. }
  1847. fieldDic.Add(queryTable.tableEnName + "_" + returnField.fieldEnName, returnField.fieldName);
  1848. }
  1849. fields = fields.TrimEnd(',');
  1850. }
  1851. //查询匹配条件
  1852. string condi = "";
  1853. var queryFields = queryFieldService.GetList(m => m.objectTableId == queryTable.id);
  1854. foreach(var queryField in queryFields)
  1855. {
  1856. string fieldEnName = queryField.fieldEnName;
  1857. string fieldQueryKind = queryField.fieldQueryKind;
  1858. string fieldQueryModel = queryField.fieldQueryModel;
  1859. string fieldQueryValue = queryField.fieldQueryValue;
  1860. if(fieldQueryModel == "loop_field") fieldQueryValue = objId;
  1861. string fieldQueryValueType = queryField.fieldQueryValueType;
  1862. if(fieldQueryKind == "1") //模糊匹配
  1863. {
  1864. condi += " and " + fieldEnName + " like ";
  1865. if(fieldQueryModel == "request_param")
  1866. {
  1867. Dictionary<string, string> req = getRequestParams(projectId, content);
  1868. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1869. condi += "'%" + val + "%'";
  1870. }
  1871. else if(fieldQueryModel == "fixed_value")
  1872. {
  1873. condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
  1874. }
  1875. else if(fieldQueryModel == "db_field")
  1876. {
  1877. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  1878. }
  1879. }
  1880. else if(fieldQueryKind == "2") //精确匹配
  1881. {
  1882. condi += " and " + fieldEnName + "=";
  1883. string val = fieldQueryValue;
  1884. if(fieldQueryModel == "request_param")
  1885. {
  1886. Dictionary<string, string> req = getRequestParams(projectId, content);
  1887. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1888. }
  1889. else if(fieldQueryModel == "fixed_value")
  1890. {
  1891. val = GetExpressionVal(fieldQueryValue);
  1892. }
  1893. else if(fieldQueryModel == "db_field")
  1894. {
  1895. val = GetDbExpressionVal(fieldQueryValue);
  1896. }
  1897. if(fieldQueryValueType == "text")
  1898. {
  1899. val = "'" + val + "'";
  1900. }
  1901. condi += val;
  1902. }
  1903. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  1904. {
  1905. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  1906. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  1907. string val = "";
  1908. string[] valList = fieldQueryValue.Split(',');
  1909. if(fieldQueryModel == "request_param")
  1910. {
  1911. Dictionary<string, string> req = getRequestParams(projectId, content);
  1912. foreach(string subval in valList)
  1913. {
  1914. if(fieldQueryValueType == "text")
  1915. {
  1916. val += "'" + req[subval] + "',";
  1917. }
  1918. else
  1919. {
  1920. val += req[subval] + ",";
  1921. }
  1922. }
  1923. }
  1924. else if(fieldQueryModel == "fixed_value")
  1925. {
  1926. foreach(string subval in valList)
  1927. {
  1928. if(fieldQueryValueType == "text")
  1929. {
  1930. val += "'" + GetExpressionVal(subval) + "',";
  1931. }
  1932. else
  1933. {
  1934. val += GetExpressionVal(subval) + ",";
  1935. }
  1936. }
  1937. }
  1938. else if(fieldQueryModel == "db_field")
  1939. {
  1940. foreach(string subval in valList)
  1941. {
  1942. if(fieldQueryValueType == "text")
  1943. {
  1944. val += "'" + GetDbExpressionVal(subval) + "',";
  1945. }
  1946. else
  1947. {
  1948. val += GetDbExpressionVal(subval) + ",";
  1949. }
  1950. }
  1951. }
  1952. val = val.TrimEnd(',');
  1953. condi += val + ")";
  1954. }
  1955. else if(fieldQueryKind == "3") //范围匹配
  1956. {
  1957. string[] val = fieldQueryValue.Split(':');
  1958. if(fieldQueryModel == "request_param")
  1959. {
  1960. Dictionary<string, string> req = getRequestParams(projectId, content);
  1961. if(fieldQueryValueType == "number")
  1962. {
  1963. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  1964. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  1965. }
  1966. else
  1967. {
  1968. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  1969. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  1970. }
  1971. }
  1972. else if(fieldQueryModel == "fixed_value")
  1973. {
  1974. if(fieldQueryValueType == "number")
  1975. {
  1976. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  1977. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  1978. }
  1979. else
  1980. {
  1981. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  1982. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  1983. }
  1984. }
  1985. else if(fieldQueryModel == "db_field")
  1986. {
  1987. if(fieldQueryValueType == "number")
  1988. {
  1989. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  1990. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  1991. }
  1992. else
  1993. {
  1994. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetDbExpressionVal(val[0]) + "'";
  1995. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetDbExpressionVal(val[1]) + "'";
  1996. }
  1997. }
  1998. }
  1999. else if(fieldQueryKind == "4") //取反匹配
  2000. {
  2001. condi += " and " + fieldEnName + "!=";
  2002. string val = "";
  2003. if(fieldQueryModel == "request_param")
  2004. {
  2005. Dictionary<string, string> req = getRequestParams(projectId, content);
  2006. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  2007. }
  2008. else if(fieldQueryModel == "fixed_value")
  2009. {
  2010. val = GetExpressionVal(fieldQueryValue);
  2011. }
  2012. else if(fieldQueryModel == "db_field")
  2013. {
  2014. val = GetDbExpressionVal(fieldQueryValue);
  2015. }
  2016. if(fieldQueryValueType == "text")
  2017. {
  2018. val = "'" + val + "'";
  2019. }
  2020. condi += val;
  2021. }
  2022. }
  2023. var db = initDb(queryTable.databaseId);
  2024. string sql = "select " + fields + " from " + queryTable.tableEnName + " where 1=1" + condi;
  2025. var items = db.Ado.GetDataTable(sql);
  2026. if(items.Rows.Count > 0)
  2027. {
  2028. foreach(string field in fieldDic.Keys)
  2029. {
  2030. if(!dic.Any(m => m.FieldEnName == field)) dic.Add(new QueryCondition()
  2031. {
  2032. FieldName = fieldDic[field],
  2033. FieldEnName = field,
  2034. Value = items.Rows[0][field].ToString()
  2035. });
  2036. }
  2037. }
  2038. }
  2039. return dic;
  2040. }
  2041. //奖励入库
  2042. public static void prizeToDatabase(int projectId, int listId, string content, List<QueryCondition> condiDic, decimal prize_amt, Dictionary<string, string> startData)
  2043. {
  2044. var prizeInTableService = App.GetService<IPriPrizeInTableService>();
  2045. var prizeInFieldService = App.GetService<IPriPrizeInFieldService>();
  2046. var prizeInQueryFieldService = App.GetService<IPriPrizeInQueryFieldService>();
  2047. //入库表
  2048. var prizeInTables = prizeInTableService.GetList(m => m.listId == listId);
  2049. foreach(var prizeInTable in prizeInTables)
  2050. {
  2051. var db = initDb(prizeInTable.databaseId);
  2052. Dictionary<string, object> doFields = new();
  2053. //入库字段
  2054. var prizeInFields = prizeInFieldService.GetList(m => m.inTableId == prizeInTable.id);
  2055. foreach(var prizeInField in prizeInFields)
  2056. {
  2057. string fieldEnName = prizeInField.fieldEnName;
  2058. string fieldQueryModel = prizeInField.fieldQueryModel;
  2059. string fieldQueryValue = prizeInField.fieldQueryValue;
  2060. string fieldQueryValueType = prizeInField.fieldQueryValueType;
  2061. if(fieldQueryModel == "request_param")
  2062. {
  2063. Dictionary<string, string> req = getRequestParams(projectId, content);
  2064. fieldQueryValue = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  2065. }
  2066. else if(fieldQueryModel == "query_field")
  2067. {
  2068. fieldQueryValue = GetQueryTableData(condiDic, fieldQueryValue);
  2069. }
  2070. else if(fieldQueryModel == "querystart_list_field")
  2071. {
  2072. fieldQueryValue = GetStartData(startData, fieldQueryValue);
  2073. }
  2074. else if(fieldQueryModel == "query_all_field")
  2075. {
  2076. if (fieldQueryValue.Contains("+") || fieldQueryValue.Contains("-") || fieldQueryValue.Contains("*") || fieldQueryValue.Contains("/") || fieldQueryValue.Contains("(") || fieldQueryValue.Contains(")"))
  2077. {
  2078. string[] texts = fieldQueryValue.Split(new char[] { '+', '-', '*', '/', '(', ')' });
  2079. foreach (string text in texts)
  2080. {
  2081. string val = GetStartData(startData, text);
  2082. if(string.IsNullOrEmpty(val)) val = GetQueryTableData(condiDic, text);
  2083. fieldQueryValue = fieldQueryValue.Replace(text, val);
  2084. }
  2085. DataTable dt = new();
  2086. fieldQueryValue = dt.Compute(fieldQueryValue, "false").ToString();
  2087. }
  2088. else
  2089. {
  2090. string val = GetStartData(startData, fieldQueryValue);
  2091. if(string.IsNullOrEmpty(val)) val = GetQueryTableData(condiDic, fieldQueryValue);
  2092. fieldQueryValue = val;
  2093. }
  2094. }
  2095. else if(fieldQueryModel == "fixed_value")
  2096. {
  2097. fieldQueryValue = GetExpressionVal(fieldQueryValue);
  2098. }
  2099. else if(fieldQueryModel == "db_field")
  2100. {
  2101. fieldQueryValue = GetDbExpressionVal(fieldQueryValue);
  2102. }
  2103. else if(fieldQueryModel == "prize_amt")
  2104. {
  2105. fieldQueryValue = prize_amt.ToString();
  2106. }
  2107. if(fieldQueryValueType == "text") doFields.Add(fieldEnName, fieldQueryValue);
  2108. if(fieldQueryValueType == "int") doFields.Add(fieldEnName, int.Parse(fieldQueryValue));
  2109. if(fieldQueryValueType == "number") doFields.Add(fieldEnName, decimal.Parse(fieldQueryValue));
  2110. if(fieldQueryValueType == "datetime") doFields.Add(fieldEnName, DateTime.Parse(fieldQueryValue));
  2111. if(fieldQueryValueType == "bool") doFields.Add(fieldEnName, bool.Parse(fieldQueryValue));
  2112. }
  2113. //查询匹配条件
  2114. string condi = "";
  2115. var queryFields = prizeInQueryFieldService.GetList(m => m.inTableId == prizeInTable.id);
  2116. foreach(var queryField in queryFields)
  2117. {
  2118. string fieldEnName = queryField.fieldEnName;
  2119. string fieldQueryKind = queryField.fieldQueryKind;
  2120. string fieldQueryModel = queryField.fieldQueryModel;
  2121. string fieldQueryValue = queryField.fieldQueryValue;
  2122. string fieldQueryValueType = queryField.fieldQueryValueType;
  2123. if(fieldQueryKind == "1") //模糊匹配
  2124. {
  2125. condi += " and " + fieldEnName + " like ";
  2126. if(fieldQueryModel == "request_param")
  2127. {
  2128. Dictionary<string, string> req = getRequestParams(projectId, content);
  2129. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  2130. condi += "'%" + val + "%'";
  2131. }
  2132. else if(fieldQueryModel == "fixed_value")
  2133. {
  2134. condi += "'%" + fieldQueryValue + "%'";
  2135. }
  2136. else if(fieldQueryModel == "query_field")
  2137. {
  2138. condi += "'%" + GetQueryTableData(condiDic, fieldQueryValue) + "%'";
  2139. }
  2140. else if(fieldQueryModel == "start_list_field")
  2141. {
  2142. condi += "'%" + GetStartData(startData, fieldQueryValue) + "%'";
  2143. }
  2144. }
  2145. else if(fieldQueryKind == "2") //精确匹配
  2146. {
  2147. condi += " and " + fieldEnName + "=";
  2148. string val = "";
  2149. if(fieldQueryModel == "request_param")
  2150. {
  2151. Dictionary<string, string> req = getRequestParams(projectId, content);
  2152. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  2153. }
  2154. else if(fieldQueryModel == "fixed_value")
  2155. {
  2156. val = fieldQueryValue;
  2157. }
  2158. else if(fieldQueryModel == "query_field")
  2159. {
  2160. val = GetQueryTableData(condiDic, fieldQueryValue);
  2161. }
  2162. else if(fieldQueryModel == "start_list_field")
  2163. {
  2164. val = GetStartData(startData, fieldQueryValue);
  2165. }
  2166. if(fieldQueryValueType == "text")
  2167. {
  2168. val = "'" + val + "'";
  2169. }
  2170. condi += val;
  2171. }
  2172. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  2173. {
  2174. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  2175. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  2176. string val = "";
  2177. string[] valList = fieldQueryValue.Split(',');
  2178. if(fieldQueryModel == "request_param")
  2179. {
  2180. Dictionary<string, string> req = getRequestParams(projectId, content);
  2181. foreach(string sub in valList)
  2182. {
  2183. if(fieldQueryValueType == "text")
  2184. {
  2185. val += "'" + req[sub] + "',";
  2186. }
  2187. else
  2188. {
  2189. val += req[sub] + ",";
  2190. }
  2191. }
  2192. }
  2193. else if(fieldQueryModel == "fixed_value")
  2194. {
  2195. foreach(string sub in valList)
  2196. {
  2197. if(fieldQueryValueType == "text")
  2198. {
  2199. val += "'" + GetExpressionVal(sub) + "',";
  2200. }
  2201. else
  2202. {
  2203. val += GetExpressionVal(sub) + ",";
  2204. }
  2205. }
  2206. }
  2207. else if(fieldQueryModel == "query_field")
  2208. {
  2209. foreach(string sub in valList)
  2210. {
  2211. if(fieldQueryValueType == "text")
  2212. {
  2213. val += "'" + GetQueryTableData(condiDic, sub) + "',";
  2214. }
  2215. else
  2216. {
  2217. val += GetQueryTableData(condiDic, sub) + ",";
  2218. }
  2219. }
  2220. }
  2221. else if(fieldQueryModel == "start_list_field")
  2222. {
  2223. foreach(string sub in valList)
  2224. {
  2225. if(fieldQueryValueType == "text")
  2226. {
  2227. val += "'" + GetStartData(startData, sub) + "',";
  2228. }
  2229. else
  2230. {
  2231. val += GetStartData(startData, sub) + ",";
  2232. }
  2233. }
  2234. }
  2235. else if(fieldQueryModel == "db_field")
  2236. {
  2237. foreach(string sub in valList)
  2238. {
  2239. if(fieldQueryValueType == "text")
  2240. {
  2241. val += "'" + GetDbExpressionVal(sub) + "',";
  2242. }
  2243. else
  2244. {
  2245. val += GetDbExpressionVal(sub) + ",";
  2246. }
  2247. }
  2248. }
  2249. val = val.TrimEnd(',');
  2250. condi += val + ")";
  2251. }
  2252. else if(fieldQueryKind == "3") //范围匹配
  2253. {
  2254. string[] val = fieldQueryValue.Split(':');
  2255. if(fieldQueryModel == "request_param")
  2256. {
  2257. Dictionary<string, string> req = getRequestParams(projectId, content);
  2258. if(fieldQueryValueType == "number")
  2259. {
  2260. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  2261. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  2262. }
  2263. else
  2264. {
  2265. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  2266. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  2267. }
  2268. }
  2269. else if(fieldQueryModel == "fixed_value")
  2270. {
  2271. if(fieldQueryValueType == "number")
  2272. {
  2273. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  2274. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  2275. }
  2276. else
  2277. {
  2278. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + val[0] + "'";
  2279. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + val[1] + "'";
  2280. }
  2281. }
  2282. }
  2283. else if(fieldQueryKind == "4") //取反匹配
  2284. {
  2285. condi += " and " + fieldEnName + "!=";
  2286. string val = "";
  2287. if(fieldQueryModel == "request_param")
  2288. {
  2289. Dictionary<string, string> req = getRequestParams(projectId, content);
  2290. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  2291. }
  2292. else if(fieldQueryModel == "fixed_value")
  2293. {
  2294. val = fieldQueryValue;
  2295. }
  2296. if(fieldQueryValueType == "text")
  2297. {
  2298. val = "'" + val + "'";
  2299. }
  2300. condi += val;
  2301. }
  2302. }
  2303. // if(prizeInTable.excuteKind == "add") db.Insertable(doFields).AS(prizeInTable.tableEnName).ExecuteCommand();
  2304. // if(prizeInTable.excuteKind == "update") db.Updateable(doFields).AS(prizeInTable.tableEnName).Where("1=1" + condi).ExecuteCommand();
  2305. Function.WriteLog(DateTime.Now.ToString() + "\n" + prizeInTable.excuteKind + "\n" + prizeInTable.tableEnName + "\n" + Newtonsoft.Json.JsonConvert.SerializeObject(doFields) + "\n" + condi + "\n\n", "奖励入库数据");
  2306. }
  2307. }
  2308. //固定值表达式
  2309. public static string GetExpressionVal(string str)
  2310. {
  2311. if(str == "#{now}#") return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2312. if(str == "#{today}#") return DateTime.Now.ToString("yyyy-MM-dd");
  2313. if(str == "#{this_month}#") return DateTime.Now.ToString("yyyy-MM");
  2314. if(str.StartsWith("#{now") && str.EndsWith("DAY}#")) return DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
  2315. if(str.StartsWith("#{now") && str.EndsWith("MONTH}#")) return DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
  2316. if(str.StartsWith("#{today") && str.EndsWith("DAY}#")) return DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd");
  2317. if(str.StartsWith("#{today") && str.EndsWith("MONTH}#")) return DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd");
  2318. if(str.StartsWith("#{this_month") && str.EndsWith("DAY}#")) return DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM");
  2319. if(str.StartsWith("#{this_month") && str.EndsWith("MONTH}#")) return DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM");
  2320. if(str.StartsWith("#{") && str.EndsWith("DAY}#")) return DateTime.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[0]).AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
  2321. if(str.StartsWith("#{") && str.EndsWith("MONTH}#")) return DateTime.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[0]).AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
  2322. return str;
  2323. }
  2324. //库内字段值表达式
  2325. public static string GetDbExpressionVal(string str)
  2326. {
  2327. string[] data = str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',');
  2328. if(str.StartsWith("#{") && str.EndsWith("DAY}#")) str = "DATE_ADD(" + data[0] + ",INTERVAL " + data[1] + " DAY)";
  2329. if(str.StartsWith("#{") && str.EndsWith("MONTH}#")) str = "DATE_ADD(" + data[0] + ",INTERVAL " + data[1] + " MONTH)";
  2330. return str;
  2331. }
  2332. //四则混合运算
  2333. public static string GetComputeVal(List<QueryCondition> condiDic, string expresssion)
  2334. {
  2335. if (expresssion.Contains("+") || expresssion.Contains("-") || expresssion.Contains("*") || expresssion.Contains("/") || expresssion.Contains("(") || expresssion.Contains(")"))
  2336. {
  2337. string[] returnFields = expresssion.Split(new char[] { '+', '-', '*', '/', '(', ')' });
  2338. foreach (string returnField in returnFields)
  2339. {
  2340. if(condiDic.Any(m => m.FieldEnName == returnField))
  2341. {
  2342. string val = GetQueryTableData(condiDic, returnField);
  2343. expresssion = expresssion.Replace(returnField, val);
  2344. }
  2345. }
  2346. DataTable dt = new();
  2347. return dt.Compute(expresssion, "false").ToString();
  2348. }
  2349. return expresssion;
  2350. }
  2351. //获取查询条件数据
  2352. public static string GetQueryTableData(List<QueryCondition> condiDic, string key)
  2353. {
  2354. return condiDic.Any(m => m.FieldEnName == key) ? condiDic.FirstOrDefault(m => m.FieldEnName == key).Value.ToString() : "0";
  2355. }
  2356. public static string GetQueryTableTitle(List<QueryCondition> condiDic, string key)
  2357. {
  2358. return condiDic.Any(m => m.FieldEnName == key) ? condiDic.FirstOrDefault(m => m.FieldEnName == key).FieldName : "";
  2359. }
  2360. public static string GetStartData(Dictionary<string, string> startData, string key)
  2361. {
  2362. return startData.ContainsKey(key) ? startData[key] : "";
  2363. }
  2364. //合并字典
  2365. public static void MergeCondiDic(List<QueryCondition> condiDic, List<QueryCondition> condiDic1)
  2366. {
  2367. foreach(QueryCondition sub in condiDic1)
  2368. {
  2369. condiDic.Add(sub);
  2370. }
  2371. }
  2372. //记录日志
  2373. public static void addLog(int projectId, int listId, int prizeIn, string requestParam, string prizeInUrl)
  2374. {
  2375. if(!logFlag) return;
  2376. var logService = App.GetService<IPriLogService>();
  2377. logService.Add(new PriLog()
  2378. {
  2379. createDate = DateTime.Now,
  2380. projectId = projectId,
  2381. listId = listId,
  2382. batchNo = batchNo,
  2383. prizeIn = prizeIn,
  2384. requestParam = requestParam,
  2385. prizeInUrl = prizeInUrl,
  2386. });
  2387. }
  2388. public static void setLogPrizeAmount(int listId, decimal prizeAmount)
  2389. {
  2390. if(!logFlag) return;
  2391. var logService = App.GetService<IPriLogService>();
  2392. var log = logService.GetFirst(m => m.batchNo == batchNo && m.listId == listId);
  2393. if(log != null)
  2394. {
  2395. log.prizeAmount = prizeAmount;
  2396. logService.Update(log);
  2397. }
  2398. }
  2399. public static void setLogStep(int listId, Dictionary<string, object> step)
  2400. {
  2401. if(!logFlag) return;
  2402. var logService = App.GetService<IPriLogService>();
  2403. var log = logService.GetFirst(m => m.batchNo == batchNo && m.listId == listId);
  2404. if(log != null)
  2405. {
  2406. log.stepList += Newtonsoft.Json.JsonConvert.SerializeObject(step) + ",";
  2407. logService.Update(log);
  2408. }
  2409. }
  2410. public static void setLogStep(int listId, string key, object val)
  2411. {
  2412. if(!logFlag) return;
  2413. var logService = App.GetService<IPriLogService>();
  2414. var log = logService.GetFirst(m => m.batchNo == batchNo && m.listId == listId);
  2415. if(log != null)
  2416. {
  2417. log.stepList += "\"" + key + "\":" + Newtonsoft.Json.JsonConvert.SerializeObject(val) + ",";
  2418. logService.Update(log);
  2419. }
  2420. }
  2421. public static void setLogStatus(int listId, int status)
  2422. {
  2423. if(!logFlag) return;
  2424. var logService = App.GetService<IPriLogService>();
  2425. var log = logService.GetFirst(m => m.batchNo == batchNo && m.listId == listId);
  2426. if(log != null)
  2427. {
  2428. log.status = status;
  2429. logService.Update(log);
  2430. }
  2431. }
  2432. public static void setLogFieldValue(int listId, string field, string content)
  2433. {
  2434. if(!logFlag) return;
  2435. var logService = App.GetService<IPriLogService>();
  2436. var log = logService.GetFirst(m => m.batchNo == batchNo && m.listId == listId);
  2437. if(log != null)
  2438. {
  2439. if(field == "errLog") log.errLog = content;
  2440. if(field == "prizeOutContent") log.prizeOutContent = content;
  2441. if(field == "prizeOutUrl") log.prizeOutUrl = content;
  2442. if(field == "stepListIndex") log.stepListIndex = content;
  2443. logService.Update(log);
  2444. }
  2445. }
  2446. public static string getQueryKind(string kind)
  2447. {
  2448. if(kind == "1") return "模糊匹配";
  2449. if(kind == "2") return "精确匹配";
  2450. if(kind == "4") return "取反匹配";
  2451. if(kind == "5") return "数组匹配";
  2452. if(kind == "6") return "数组排除";
  2453. if(kind == "3") return "范围匹配";
  2454. return kind;
  2455. }
  2456. public static string getQueryModel(string model)
  2457. {
  2458. if(model == "request_param") return "入参";
  2459. if(model == "query_field") return "条件匹配返回字段";
  2460. if(model == "loop_field") return "循环递归字段";
  2461. if(model == "loop_condition_field") return "循环递归条件字段";
  2462. if(model == "fixed_value") return "固定值";
  2463. if(model == "db_field") return "库内字段";
  2464. return model;
  2465. }
  2466. }
  2467. }