PrizeDo.cs 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. using System.Data;
  2. using Common;
  3. using Infrastructure;
  4. using LitJson;
  5. using Microsoft.Extensions.Localization;
  6. using Model;
  7. using NuGet.Packaging;
  8. using Services;
  9. namespace Util
  10. {
  11. public class PrizeDo
  12. {
  13. public static string batchNo = "";
  14. //发奖入口
  15. public static void sendPrize(int prizeObjectTableId, string content)
  16. {
  17. batchNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Function.get_Random(3);
  18. string priObjString = prizeObject(prizeObjectTableId, content);
  19. if(!string.IsNullOrEmpty(priObjString))
  20. {
  21. string[] priObjData = priObjString.Split('|');
  22. string priObj = priObjData[0];
  23. string priListIds = priObjData[1];
  24. int projectId = int.Parse(priObjData[2]);
  25. prizeSend(projectId, priListIds, priObj, content);
  26. }
  27. }
  28. //接收入参
  29. public static Dictionary<string, string> getRequestParams(int projectId, string content)
  30. {
  31. Dictionary<string, string> dic = new Dictionary<string, string>();
  32. JsonData jsonData = JsonMapper.ToObject(content);
  33. var paramService = App.GetService<IPriProjectParamService>();
  34. var paramList = paramService.GetList(m => m.projectId == projectId);
  35. foreach(var param in paramList)
  36. {
  37. if(content.Contains("\"" + param.fieldEnName + "\"")) dic.Add(param.fieldEnName, jsonData[param.fieldEnName].ToString());
  38. }
  39. return dic;
  40. }
  41. //数据库链接
  42. public static SqlSugarClient initDb(int id)
  43. {
  44. var databaseSetService = App.GetService<IPriDatabaseSetService>();
  45. var connectionString = databaseSetService.GetFirst(m => m.id == id);
  46. string server = connectionString.ipAddress;
  47. int port = connectionString.port;
  48. string user = connectionString.userId;
  49. string password = connectionString.password;
  50. string database = connectionString.databaseName;
  51. var db = new SqlSugarClient(new ConnectionConfig()
  52. {
  53. ConnectionString = "server=" + server + ";port=" + port + ";user=" + user + ";password=" + password + ";database=" + database + ";charset=utf8;",
  54. DbType = SqlSugar.DbType.MySql,
  55. IsAutoCloseConnection = true,
  56. });
  57. return db;
  58. }
  59. //查询条件匹配数据
  60. public static Dictionary<string, object> condition(int projectId, string content)
  61. {
  62. Dictionary<string, object> dic = new Dictionary<string, object>();
  63. var queryTableService = App.GetService<IPriQueryTableService>();
  64. var queryFieldService = App.GetService<IPriQueryFieldService>();
  65. var returnFieldService = App.GetService<IPriReturnFieldService>();
  66. //查询表
  67. var queryTables = queryTableService.GetList(m => m.projectId == projectId);
  68. foreach(var queryTable in queryTables)
  69. {
  70. //查询返回字段
  71. string fields = "";
  72. var returnFields = returnFieldService.GetList(m => m.queryTableId == queryTable.id);
  73. foreach(var returnField in returnFields)
  74. {
  75. if(returnField.fieldReturnKind == "2")
  76. {
  77. fields += "count(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  78. }
  79. else if(returnField.fieldReturnKind == "3")
  80. {
  81. fields += "sum(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  82. }
  83. else if(returnField.fieldReturnKind == "4")
  84. {
  85. fields += "avg(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  86. }
  87. else
  88. {
  89. fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  90. }
  91. }
  92. fields = fields.TrimEnd(',');
  93. //查询匹配条件
  94. string condi = "";
  95. var queryFields = queryFieldService.GetList(m => m.queryTableId == queryTable.id);
  96. foreach(var queryField in queryFields)
  97. {
  98. string fieldEnName = queryField.fieldEnName;
  99. string fieldQueryKind = queryField.fieldQueryKind;
  100. string fieldQueryModel = queryField.fieldQueryModel;
  101. string fieldQueryValue = queryField.fieldQueryValue;
  102. string fieldQueryValueType = queryField.fieldQueryValueType;
  103. if(fieldQueryKind == "1") //模糊匹配
  104. {
  105. condi += " and " + fieldEnName + " like ";
  106. if(fieldQueryModel == "request_param")
  107. {
  108. Dictionary<string, string> req = getRequestParams(projectId, content);
  109. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  110. condi += "'%" + val + "%'";
  111. }
  112. else if(fieldQueryModel == "fixed_value")
  113. {
  114. condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
  115. }
  116. else if(fieldQueryModel == "db_field")
  117. {
  118. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  119. }
  120. else if(fieldQueryModel == "query_field")
  121. {
  122. string val = dic.ContainsKey(fieldQueryValue) ? dic[fieldQueryValue].ToString() : "0";
  123. condi += "'%" + val + "%'";
  124. }
  125. }
  126. else if(fieldQueryKind == "2") //精确匹配
  127. {
  128. if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is null";
  129. else
  130. {
  131. condi += " and " + fieldEnName + "=";
  132. string val = "";
  133. if(fieldQueryModel == "request_param")
  134. {
  135. Dictionary<string, string> req = getRequestParams(projectId, content);
  136. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  137. }
  138. else if(fieldQueryModel == "fixed_value")
  139. {
  140. val = GetExpressionVal(fieldQueryValue);
  141. }
  142. else if(fieldQueryModel == "db_field")
  143. {
  144. val = GetDbExpressionVal(fieldQueryValue);
  145. }
  146. else if(fieldQueryModel == "query_field")
  147. {
  148. val = dic.ContainsKey(fieldQueryValue) ? dic[fieldQueryValue].ToString() : "0";
  149. }
  150. if(fieldQueryValueType == "text")
  151. {
  152. val = "'" + val + "'";
  153. }
  154. condi += val;
  155. }
  156. }
  157. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  158. {
  159. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  160. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  161. string val = "";
  162. string[] valList = fieldQueryValue.Split(',');
  163. if(fieldQueryModel == "request_param")
  164. {
  165. Dictionary<string, string> req = getRequestParams(projectId, content);
  166. foreach(string sub in valList)
  167. {
  168. if(fieldQueryValueType == "text")
  169. {
  170. val += "'" + req[sub] + "',";
  171. }
  172. else
  173. {
  174. val += req[sub] + ",";
  175. }
  176. }
  177. }
  178. else if(fieldQueryModel == "fixed_value")
  179. {
  180. foreach(string sub in valList)
  181. {
  182. if(fieldQueryValueType == "text")
  183. {
  184. val += "'" + GetExpressionVal(sub) + "',";
  185. }
  186. else
  187. {
  188. val += GetExpressionVal(sub) + ",";
  189. }
  190. }
  191. }
  192. else if(fieldQueryModel == "db_field")
  193. {
  194. foreach(string sub in valList)
  195. {
  196. if(fieldQueryValueType == "text")
  197. {
  198. val += "'" + GetDbExpressionVal(sub) + "',";
  199. }
  200. else
  201. {
  202. val += GetDbExpressionVal(sub) + ",";
  203. }
  204. }
  205. }
  206. else if(fieldQueryModel == "query_field")
  207. {
  208. foreach(string sub in valList)
  209. {
  210. string dicVal = dic.ContainsKey(sub) ? dic[sub].ToString() : "0";
  211. if(fieldQueryValueType == "text")
  212. {
  213. val += "'" + dicVal + "',";
  214. }
  215. else
  216. {
  217. val += dicVal + ",";
  218. }
  219. }
  220. }
  221. val = val.TrimEnd(',');
  222. condi += val + ")";
  223. }
  224. else if(fieldQueryKind == "3") //范围匹配
  225. {
  226. string[] val = fieldQueryValue.Split(':');
  227. if(fieldQueryModel == "request_param")
  228. {
  229. Dictionary<string, string> req = getRequestParams(projectId, content);
  230. if(fieldQueryValueType == "number")
  231. {
  232. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  233. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  234. }
  235. else
  236. {
  237. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  238. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  239. }
  240. }
  241. else if(fieldQueryModel == "fixed_value")
  242. {
  243. if(fieldQueryValueType == "number")
  244. {
  245. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  246. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  247. }
  248. else
  249. {
  250. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  251. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  252. }
  253. }
  254. else if(fieldQueryModel == "db_field")
  255. {
  256. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + GetDbExpressionVal(val[0]);
  257. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + GetDbExpressionVal(val[1]);
  258. }
  259. else if(fieldQueryModel == "query_field")
  260. {
  261. string dicValLeft = dic.ContainsKey(val[0]) ? dic[val[0]].ToString() : "0";
  262. string dicValRight = dic.ContainsKey(val[1]) ? dic[val[1]].ToString() : "0";
  263. if(fieldQueryValueType == "number")
  264. {
  265. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">=" + dicValLeft;
  266. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<=" + dicValRight;
  267. }
  268. else
  269. {
  270. if(!string.IsNullOrEmpty(dicValLeft)) condi += " and " + fieldEnName + ">='" + GetExpressionVal(dicValLeft) + "'";
  271. if(!string.IsNullOrEmpty(dicValRight)) condi += " and " + fieldEnName + "<='" + GetExpressionVal(dicValRight) + "'";
  272. }
  273. }
  274. }
  275. else if(fieldQueryKind == "4") //取反匹配
  276. {
  277. if(fieldQueryValue == "null" && fieldQueryValueType == "text") condi += " and " + fieldEnName + " is not null";
  278. else
  279. {
  280. condi += " and " + fieldEnName + "!=";
  281. string val = "";
  282. if(fieldQueryModel == "request_param")
  283. {
  284. Dictionary<string, string> req = getRequestParams(projectId, content);
  285. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  286. }
  287. else if(fieldQueryModel == "fixed_value")
  288. {
  289. val = GetExpressionVal(fieldQueryValue);
  290. }
  291. else if(fieldQueryModel == "db_field")
  292. {
  293. val = GetDbExpressionVal(fieldQueryValue);
  294. }
  295. else if(fieldQueryModel == "query_field")
  296. {
  297. val = dic.ContainsKey(fieldQueryValue) ? dic[fieldQueryValue].ToString() : "0";
  298. }
  299. if(fieldQueryValueType == "text")
  300. {
  301. val = "'" + val + "'";
  302. }
  303. condi += val;
  304. }
  305. }
  306. }
  307. var db = initDb(queryTable.databaseId);
  308. string sql = "select " + fields + " from " + queryTable.tableEnName + " where 1=1" + condi;
  309. var items = db.Ado.GetDataTable(sql);
  310. if(items.Rows.Count > 0)
  311. {
  312. foreach(System.Data.DataColumn item in items.Columns)
  313. {
  314. if(!dic.ContainsKey(item.ColumnName)) dic.Add(item.ColumnName, items.Rows[0][item.ColumnName].ToString());
  315. }
  316. }
  317. }
  318. return dic;
  319. }
  320. //奖励发放对象(奖励发放入口)
  321. public static string prizeObject(int prizeObjectTableId, string content)
  322. {
  323. Dictionary<string, object> dic = new Dictionary<string, object>();
  324. var prizeObjectTableService = App.GetService<IPriPrizeObjectTableService>();
  325. var prizeObjectFieldService = App.GetService<IPriPrizeObjectFieldService>();
  326. //查询表
  327. var prizeObjectTable = prizeObjectTableService.GetFirst(m => m.id == prizeObjectTableId) ?? new PriPrizeObjectTable();
  328. //查询返回字段
  329. string field = prizeObjectTable.selectField;
  330. int projectId = prizeObjectTable.projectId;
  331. //查询匹配条件
  332. string condi = "";
  333. var queryFields = prizeObjectFieldService.GetList(m => m.objectTableId == prizeObjectTable.id);
  334. foreach(var queryField in queryFields)
  335. {
  336. string fieldEnName = queryField.fieldEnName;
  337. string fieldQueryKind = queryField.fieldQueryKind;
  338. string fieldQueryModel = queryField.fieldQueryModel;
  339. string fieldQueryValue = queryField.fieldQueryValue;
  340. string fieldQueryValueType = queryField.fieldQueryValueType;
  341. if(fieldQueryKind == "1") //模糊匹配
  342. {
  343. condi += " and " + fieldEnName + " like ";
  344. if(fieldQueryModel == "request_param")
  345. {
  346. Dictionary<string, string> req = getRequestParams(projectId, content);
  347. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  348. condi += "'%" + val + "%'";
  349. }
  350. else if(fieldQueryModel == "fixed_value")
  351. {
  352. condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
  353. }
  354. else if(fieldQueryModel == "db_field")
  355. {
  356. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  357. }
  358. }
  359. else if(fieldQueryKind == "2") //精确匹配
  360. {
  361. condi += " and " + fieldEnName + "=";
  362. string val = "";
  363. if(fieldQueryModel == "request_param")
  364. {
  365. Dictionary<string, string> req = getRequestParams(projectId, content);
  366. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  367. }
  368. else if(fieldQueryModel == "fixed_value")
  369. {
  370. val = GetExpressionVal(fieldQueryValue);
  371. }
  372. else if(fieldQueryModel == "db_field")
  373. {
  374. val = GetDbExpressionVal(fieldQueryValue);
  375. }
  376. if(fieldQueryValueType == "text")
  377. {
  378. val = "'" + val + "'";
  379. }
  380. condi += val;
  381. }
  382. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  383. {
  384. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  385. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  386. string val = "";
  387. string[] valList = fieldQueryValue.Split(',');
  388. if(fieldQueryModel == "request_param")
  389. {
  390. Dictionary<string, string> req = getRequestParams(projectId, content);
  391. foreach(string sub in valList)
  392. {
  393. if(fieldQueryValueType == "text")
  394. {
  395. val += "'" + req[sub] + "',";
  396. }
  397. else
  398. {
  399. val += req[sub] + ",";
  400. }
  401. }
  402. }
  403. else if(fieldQueryModel == "fixed_value")
  404. {
  405. foreach(string sub in valList)
  406. {
  407. if(fieldQueryValueType == "text")
  408. {
  409. val += "'" + GetExpressionVal(sub) + "',";
  410. }
  411. else
  412. {
  413. val += GetExpressionVal(sub) + ",";
  414. }
  415. }
  416. }
  417. else if(fieldQueryModel == "db_field")
  418. {
  419. foreach(string sub in valList)
  420. {
  421. if(fieldQueryValueType == "text")
  422. {
  423. val += "'" + GetDbExpressionVal(sub) + "',";
  424. }
  425. else
  426. {
  427. val += GetDbExpressionVal(sub) + ",";
  428. }
  429. }
  430. }
  431. val = val.TrimEnd(',');
  432. condi += val + ")";
  433. }
  434. else if(fieldQueryKind == "3") //范围匹配
  435. {
  436. string[] val = fieldQueryValue.Split(':');
  437. if(fieldQueryModel == "request_param")
  438. {
  439. Dictionary<string, string> req = getRequestParams(projectId, content);
  440. if(fieldQueryValueType == "number")
  441. {
  442. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  443. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  444. }
  445. else
  446. {
  447. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  448. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  449. }
  450. }
  451. else if(fieldQueryModel == "fixed_value")
  452. {
  453. if(fieldQueryValueType == "number")
  454. {
  455. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  456. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  457. }
  458. else
  459. {
  460. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  461. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  462. }
  463. }
  464. else if(fieldQueryModel == "db_field")
  465. {
  466. if(fieldQueryValueType == "number")
  467. {
  468. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  469. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  470. }
  471. else
  472. {
  473. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetDbExpressionVal(val[0]) + "'";
  474. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetDbExpressionVal(val[1]) + "'";
  475. }
  476. }
  477. }
  478. else if(fieldQueryKind == "4") //取反匹配
  479. {
  480. condi += " and " + fieldEnName + "!=";
  481. string val = "";
  482. if(fieldQueryModel == "request_param")
  483. {
  484. Dictionary<string, string> req = getRequestParams(projectId, content);
  485. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  486. }
  487. else if(fieldQueryModel == "fixed_value")
  488. {
  489. val = GetExpressionVal(fieldQueryValue);
  490. }
  491. else if(fieldQueryModel == "db_field")
  492. {
  493. val = GetDbExpressionVal(fieldQueryValue);
  494. }
  495. if(fieldQueryValueType == "text")
  496. {
  497. val = "'" + val + "'";
  498. }
  499. condi += val;
  500. }
  501. }
  502. var db = initDb(prizeObjectTable.databaseId);
  503. var item = db.Ado.GetScalar("select " + field + " from " + prizeObjectTable.tableEnName + " where 1=1" + condi);
  504. if(item != null)
  505. {
  506. return item.ToString() + "|" + prizeObjectTable.prizeListIds + "|" + projectId;
  507. }
  508. return "";
  509. }
  510. //奖励列表
  511. public static List<PriList> prizeList(int projectId, string prizeIds)
  512. {
  513. List<int> ids = Tools.SpitIntArrary(prizeIds, ',').ToList();
  514. var priListService = App.GetService<IPriListService>();
  515. var priList = priListService.GetList(m => m.projectId == projectId && ids.Contains(m.id)).ToList();
  516. return priList;
  517. }
  518. //奖励发放
  519. public static void prizeSend(int projectId, string prizeIds, string prizeObjectId, string content)
  520. {
  521. var loopSetService = App.GetService<IPriLoopSetService>();
  522. var recursionStartTableService = App.GetService<IPriRecursionStartTableService>();
  523. var recursionStartConditionService = App.GetService<IPriRecursionStartConditionService>();
  524. var priList = prizeList(projectId, prizeIds);
  525. foreach(var sub in priList)
  526. {
  527. var recursionFlag = sub.recursionFlag; //是否递归
  528. if(recursionFlag)
  529. {
  530. var loopSet = loopSetService.GetFirst(m => m.listId == sub.id) ?? new PriLoopSet();
  531. var recursionStartTable = recursionStartTableService.GetFirst(m => m.listId == sub.id) ?? new PriRecursionStartTable();
  532. var tableEnName = loopSet.tableEnName; //递归查询表
  533. var parentField = loopSet.parentField; //父字段
  534. var sonField = loopSet.sonField; //子字段
  535. var afterPrizeFlag = loopSet.afterPrizeFlag; //发奖后是否继续
  536. var db = initDb(recursionStartTable.databaseId);
  537. string objId = prizeObjectId;
  538. bool op = true;
  539. int index = 0;
  540. loopAmount = 0;
  541. while(!string.IsNullOrEmpty(objId) && objId != "0" && op)
  542. {
  543. Dictionary<string, object> condiDic = loopCondition(projectId, sub, objId, content);
  544. if(condiDic.Count > 0)
  545. {
  546. bool prizeFlag = true;
  547. var conditions = recursionStartConditionService.GetList(m => m.loopSetId == loopSet.id);
  548. if(conditions.Count > 0)
  549. {
  550. int allCount = conditions.Count; //所有奖励条件数
  551. int passCount = 0; //通过条件数
  552. foreach(var condition in conditions)
  553. {
  554. if(condition.startIndex <= index)
  555. {
  556. var returnFieldId = condition.returnFieldId; //条件返回字段
  557. var fieldQueryKind = condition.fieldQueryKind; //匹配条件
  558. var fieldQueryModel = condition.fieldQueryModel; //匹配方式
  559. var fieldQueryValue = condition.fieldQueryValue; //匹配值
  560. var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
  561. string checkObj = "";
  562. if(returnFieldId.Contains(","))
  563. {
  564. string[] returnFieldIdList = returnFieldId.Split(',');
  565. foreach(string subField in returnFieldIdList)
  566. {
  567. string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
  568. checkObj += val + ",";
  569. }
  570. checkObj = checkObj.TrimEnd(',');
  571. }
  572. else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
  573. {
  574. string expresssion = returnFieldId;
  575. string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
  576. foreach(string returnField in returnFields)
  577. {
  578. string val = condiDic.ContainsKey(returnField) ? condiDic[returnField].ToString() : "0";
  579. expresssion = expresssion.Replace(returnField, val);
  580. }
  581. DataTable dt = new DataTable();
  582. checkObj = dt.Compute(expresssion, "false").ToString();
  583. }
  584. else
  585. {
  586. checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
  587. }
  588. var checkVal = fieldQueryValue;
  589. if(fieldQueryKind == "1") //模糊匹配
  590. {
  591. if(fieldQueryValueType == "text")
  592. {
  593. if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1;
  594. }
  595. }
  596. else if(fieldQueryKind == "2") //精确匹配
  597. {
  598. if(fieldQueryValueType == "int")
  599. {
  600. if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1;
  601. }
  602. else if(fieldQueryValueType == "number")
  603. {
  604. if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
  605. }
  606. else
  607. {
  608. if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1;
  609. }
  610. }
  611. else if(fieldQueryKind == "3") //范围匹配
  612. {
  613. string[] val = checkVal.Split(':');
  614. if(fieldQueryModel == "request_param")
  615. {
  616. Dictionary<string, string> req = getRequestParams(projectId, content);
  617. if(fieldQueryValueType == "number")
  618. {
  619. if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
  620. else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]]))) passCount += 1;
  621. else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
  622. }
  623. else if(fieldQueryValueType == "int")
  624. {
  625. if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
  626. else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]]))) passCount += 1;
  627. else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
  628. }
  629. else if(fieldQueryValueType.StartsWith("date"))
  630. {
  631. if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
  632. else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]])) passCount += 1;
  633. else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
  634. }
  635. }
  636. else if(fieldQueryModel == "fixed_value")
  637. {
  638. if(fieldQueryValueType == "number")
  639. {
  640. if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(val[0])) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
  641. else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0]))) passCount += 1;
  642. else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
  643. }
  644. else if(fieldQueryValueType == "int")
  645. {
  646. if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(val[0])) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
  647. else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0]))) passCount += 1;
  648. else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
  649. }
  650. else if(fieldQueryValueType.StartsWith("date"))
  651. {
  652. if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(val[0])) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
  653. else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) >= DateTime.Parse(GetExpressionVal(val[0]))) passCount += 1;
  654. else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
  655. }
  656. }
  657. }
  658. else if(fieldQueryKind == "4") //取反匹配
  659. {
  660. if(fieldQueryValueType == "int")
  661. {
  662. if(int.Parse(checkObj) != int.Parse(Function.CheckInt(checkVal))) passCount += 1;
  663. }
  664. else if(fieldQueryValueType == "number")
  665. {
  666. if(decimal.Parse(checkObj) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
  667. }
  668. else if(fieldQueryValueType == "text")
  669. {
  670. if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1;
  671. }
  672. }
  673. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  674. {
  675. string val = ",";
  676. string[] valList = checkVal.Split(',');
  677. if(fieldQueryModel == "request_param")
  678. {
  679. Dictionary<string, string> req = getRequestParams(projectId, content);
  680. foreach(string subVal in valList)
  681. {
  682. val += req[subVal] + ",";
  683. }
  684. }
  685. else if(fieldQueryModel == "fixed_value")
  686. {
  687. foreach(string subVal in valList)
  688. {
  689. val += GetExpressionVal(subVal) + ",";
  690. }
  691. }
  692. else if(fieldQueryModel == "db_field")
  693. {
  694. foreach(string subVal in valList)
  695. {
  696. val += GetDbExpressionVal(subVal) + ",";
  697. }
  698. }
  699. if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
  700. if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
  701. }
  702. }
  703. }
  704. if(loopSet.conditionMode == "all" && passCount == allCount) prizeFlag = true;
  705. else if(loopSet.conditionMode == "one" && passCount >= 1) prizeFlag = true;
  706. else prizeFlag = false;
  707. }
  708. else
  709. {
  710. prizeFlag = false;
  711. }
  712. if(prizeFlag)
  713. {
  714. prizeSendDo(projectId, sub, objId, content, loopSet);
  715. op = afterPrizeFlag;
  716. }
  717. }
  718. var parent = db.Ado.GetScalar("select " + parentField + " from " + tableEnName + " where " + sonField + "=" + objId);
  719. if(parent != null)
  720. {
  721. objId = parent.ToString();
  722. }
  723. index += 1;
  724. }
  725. }
  726. else
  727. {
  728. prizeSendDo(projectId, sub, prizeObjectId, content, new PriLoopSet());
  729. }
  730. }
  731. }
  732. static decimal loopAmount = 0;
  733. public static void prizeSendDo(int projectId, PriList sub, string prizeObjectId, string content, PriLoopSet set)
  734. {
  735. var recordService = App.GetService<IPriRecordService>();
  736. var conditionService = App.GetService<IPriConditionService>();
  737. var returnFieldService = App.GetService<IPriReturnFieldService>();
  738. var queryTableService = App.GetService<IPriQueryTableService>();
  739. var amountSetService = App.GetService<IPriListAmountSetService>();
  740. //查询匹配条件
  741. Dictionary<string, object> condiDic = new Dictionary<string, object>();
  742. if(sub.prizeSourceFieldType == "condi") condiDic = condition(projectId, content);
  743. if(sub.prizeSourceFieldType == "loop") condiDic = loopCondition(projectId, sub, prizeObjectId, content);
  744. var prizeSourceField = sub.prizeSourceField; //奖励金额来源字段(对应条件匹配返回字段)
  745. var prizePercent = sub.prizePercent; //奖励比例
  746. var prizeAmount = sub.prizeAmount; //奖励固定值
  747. var prizeContent = sub.prizeContent; //奖励内容
  748. var conditionMode = sub.conditionMode; //条件模式
  749. var recursionFlag = sub.recursionFlag; //是否递归
  750. var conditions = conditionService.GetList(m => m.listId == sub.id);
  751. int allCount = conditions.Count; //所有奖励条件数
  752. int passCount = 0; //通过条件数
  753. foreach(var condition in conditions)
  754. {
  755. var returnFieldId = condition.returnFieldId; //条件返回字段
  756. var fieldQueryKind = condition.fieldQueryKind; //匹配条件
  757. var fieldQueryModel = condition.fieldQueryModel; //匹配方式
  758. var fieldQueryValue = condition.fieldQueryValue; //匹配值
  759. var fieldQueryValueType = condition.fieldQueryValueType; //匹配值类型
  760. string checkObj = "";
  761. if(returnFieldId.Contains(","))
  762. {
  763. string[] returnFieldIdList = returnFieldId.Split(',');
  764. foreach(string subField in returnFieldIdList)
  765. {
  766. string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
  767. checkObj += val + ",";
  768. }
  769. checkObj = checkObj.TrimEnd(',');
  770. }
  771. else if (returnFieldId.Contains("+") || returnFieldId.Contains("-") || returnFieldId.Contains("*") || returnFieldId.Contains("/") || returnFieldId.Contains("(") || returnFieldId.Contains(")"))
  772. {
  773. string expresssion = returnFieldId;
  774. string[] returnFields = returnFieldId.Split(new char[] { '+', '-', '*', '/', '(', ')' });
  775. foreach(string returnField in returnFields)
  776. {
  777. string val = condiDic.ContainsKey(returnField) ? condiDic[returnField].ToString() : "0";
  778. expresssion = expresssion.Replace(returnField, val);
  779. }
  780. DataTable dt = new DataTable();
  781. checkObj = dt.Compute(expresssion, "false").ToString();
  782. }
  783. else
  784. {
  785. checkObj = condiDic.ContainsKey(returnFieldId) ? condiDic[returnFieldId].ToString() : "0";
  786. }
  787. string checkVal = fieldQueryValue;
  788. if(fieldQueryKind == "1") //模糊匹配
  789. {
  790. if(fieldQueryValueType == "text")
  791. {
  792. if(checkObj.ToString().Contains(GetExpressionVal(checkVal))) passCount += 1;
  793. }
  794. }
  795. else if(fieldQueryKind == "2") //精确匹配
  796. {
  797. if(fieldQueryValueType == "int")
  798. {
  799. if(int.Parse(Function.CheckInt(checkObj.ToString())) == int.Parse(Function.CheckNum(checkVal))) passCount += 1;
  800. }
  801. else if(fieldQueryValueType == "number")
  802. {
  803. if(decimal.Parse(Function.CheckNum(checkObj.ToString())) == decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
  804. }
  805. else
  806. {
  807. if(checkObj.ToString() == GetExpressionVal(checkVal)) passCount += 1;
  808. }
  809. }
  810. else if(fieldQueryKind == "3") //范围匹配
  811. {
  812. string[] val = checkVal.Split(':');
  813. if(fieldQueryModel == "request_param")
  814. {
  815. Dictionary<string, string> req = getRequestParams(projectId, content);
  816. if(fieldQueryValueType == "number")
  817. {
  818. if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]])) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
  819. else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) >= decimal.Parse(Function.CheckNum(req[val[0]]))) passCount += 1;
  820. else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && decimal.Parse(checkObj) <= decimal.Parse(Function.CheckNum(req[val[1]]))) passCount += 1;
  821. }
  822. else if(fieldQueryValueType == "int")
  823. {
  824. if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]])) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
  825. else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) >= int.Parse(Function.CheckInt(req[val[0]]))) passCount += 1;
  826. else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && int.Parse(checkObj) <= int.Parse(Function.CheckInt(req[val[1]]))) passCount += 1;
  827. }
  828. else if(fieldQueryValueType.StartsWith("date"))
  829. {
  830. if(!string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
  831. else if(!string.IsNullOrEmpty(req[val[0]]) && string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) >= DateTime.Parse(req[val[0]])) passCount += 1;
  832. else if(string.IsNullOrEmpty(req[val[0]]) && !string.IsNullOrEmpty(req[val[1]]) && DateTime.Parse(checkObj) <= DateTime.Parse(req[val[1]])) passCount += 1;
  833. }
  834. }
  835. else if(fieldQueryModel == "fixed_value")
  836. {
  837. if(fieldQueryValueType == "number")
  838. {
  839. if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0])) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
  840. else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) >= decimal.Parse(Function.CheckNum(val[0]))) passCount += 1;
  841. else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && decimal.Parse(Function.CheckNum(checkObj.ToString())) <= decimal.Parse(Function.CheckNum(val[1]))) passCount += 1;
  842. }
  843. else if(fieldQueryValueType == "int")
  844. {
  845. if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckNum(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0])) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
  846. else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) >= int.Parse(Function.CheckInt(val[0]))) passCount += 1;
  847. else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && int.Parse(Function.CheckInt(checkObj.ToString())) <= int.Parse(Function.CheckInt(val[1]))) passCount += 1;
  848. }
  849. else if(fieldQueryValueType.StartsWith("date"))
  850. {
  851. if(!string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(val[0])) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
  852. else if(!string.IsNullOrEmpty(val[0]) && string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) >= DateTime.Parse(GetExpressionVal(val[0]))) passCount += 1;
  853. else if(string.IsNullOrEmpty(val[0]) && !string.IsNullOrEmpty(val[1]) && DateTime.Parse(checkObj.ToString()) <= DateTime.Parse(GetExpressionVal(val[1]))) passCount += 1;
  854. }
  855. }
  856. }
  857. else if(fieldQueryKind == "4") //取反匹配
  858. {
  859. if(fieldQueryValueType == "int")
  860. {
  861. if(int.Parse(Function.CheckNum(checkObj.ToString())) != int.Parse(Function.CheckInt(checkVal))) passCount += 1;
  862. }
  863. else if(fieldQueryValueType == "number")
  864. {
  865. if(decimal.Parse(Function.CheckNum(checkObj.ToString())) != decimal.Parse(Function.CheckNum(checkVal))) passCount += 1;
  866. }
  867. else if(fieldQueryValueType == "text")
  868. {
  869. if(checkObj.ToString() != GetExpressionVal(checkVal)) passCount += 1;
  870. }
  871. }
  872. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  873. {
  874. string val = ",";
  875. string[] valList = checkVal.Split(',');
  876. if(fieldQueryModel == "request_param")
  877. {
  878. Dictionary<string, string> req = getRequestParams(projectId, content);
  879. foreach(string subVal in valList)
  880. {
  881. val += req[subVal] + ",";
  882. }
  883. }
  884. else if(fieldQueryModel == "fixed_value")
  885. {
  886. foreach(string subVal in valList)
  887. {
  888. val += GetExpressionVal(subVal) + ",";
  889. }
  890. }
  891. else if(fieldQueryModel == "db_field")
  892. {
  893. foreach(string subVal in valList)
  894. {
  895. val += GetDbExpressionVal(subVal) + ",";
  896. }
  897. }
  898. if(fieldQueryKind == "5" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
  899. if(fieldQueryKind == "6" && val.Contains("," + checkObj.ToString() + ",")) passCount += 1;
  900. }
  901. }
  902. bool op = false;
  903. if(conditionMode == "all" && passCount == allCount && passCount > 0) op = true;
  904. else if(conditionMode == "one" && passCount >= 1) op = true;
  905. if(op) //满足条件
  906. {
  907. decimal number = 0;
  908. if(prizeSourceField.Contains("/"))
  909. {
  910. number = decimal.Parse(prizeSourceField.Split('/')[1]);
  911. prizeSourceField = prizeSourceField.Split('/')[0];
  912. }
  913. string prizeSourceData = "";
  914. if(prizeSourceField.Contains(","))
  915. {
  916. string[] prizeSourceFieldList = prizeSourceField.Split(',');
  917. foreach(string subField in prizeSourceFieldList)
  918. {
  919. string val = condiDic.ContainsKey(subField) ? condiDic[subField].ToString() : "0";
  920. prizeSourceData += val + ",";
  921. }
  922. prizeSourceData = prizeSourceData.TrimEnd(',');
  923. }
  924. else
  925. {
  926. prizeSourceData = condiDic.ContainsKey(prizeSourceField) ? condiDic[prizeSourceField].ToString() : "0";
  927. }
  928. if(string.IsNullOrEmpty(prizeSourceData)) prizeSourceData = "0";
  929. if(prizeSourceField.Contains("/") && number > 0)
  930. {
  931. decimal prizeSourceDataNum = decimal.Parse(prizeSourceData) / number;
  932. prizeSourceData = prizeSourceDataNum.ToString("f2");
  933. }
  934. decimal prizeAmt = 0;
  935. var amountSet = amountSetService.GetFirst(m => m.listId == sub.id && m.prizeSourceField == prizeSourceData);
  936. if(amountSet != null)
  937. {
  938. prizePercent = amountSet.prizePercent;
  939. prizeAmount = amountSet.prizeAmount;
  940. }
  941. if(prizeSourceData.Contains(","))
  942. {
  943. string checkField = prizeSourceData.Split(',')[0] + ",";
  944. amountSet = amountSetService.GetFirst(m => m.listId == sub.id && m.prizeSourceField.StartsWith(checkField) && m.prizeSourceField.EndsWith(",%"));
  945. if(amountSet != null)
  946. {
  947. prizePercent = amountSet.prizePercent;
  948. prizeAmount = amountSet.prizeAmount;
  949. prizeSourceData = prizeSourceData.Split(',')[1];
  950. }
  951. }
  952. if(prizePercent > 0) prizeAmt += decimal.Parse(Function.CheckNum(prizeSourceData)) * prizePercent;
  953. if(prizeAmount > 0) prizeAmt += prizeAmount;
  954. decimal getPrizeAmount = prizeAmt;
  955. if(set.levelDiffFlag) prizeAmt -= loopAmount;
  956. if(prizeAmt > 0)
  957. {
  958. var req = getRequestParams(projectId, content);
  959. var requestParamField = req[sub.requestParamField];
  960. var sendFlag = recordService.Any(m => m.prizeObjId == prizeObjectId && m.listId == sub.id && m.requestParamField == requestParamField);
  961. if(!sendFlag)
  962. {
  963. recordService.Add(new PriRecord()
  964. {
  965. createDate = DateTime.Now,
  966. projectId = projectId,
  967. listId = sub.id,
  968. prizeAmount = prizeAmt,
  969. prizeObjId = prizeObjectId,
  970. requestParamField = requestParamField,
  971. batchNo = batchNo,
  972. });
  973. loopAmount = getPrizeAmount;
  974. // prizeToDatabase(projectId, content); //入库
  975. }
  976. }
  977. }
  978. }
  979. //递归条件判断
  980. public static Dictionary<string, object> loopCondition(int projectId, PriList sub, string objId, string content)
  981. {
  982. Dictionary<string, object> dic = new Dictionary<string, object>();
  983. var queryTableService = App.GetService<IPriRecursionStartTableService>();
  984. var queryFieldService = App.GetService<IPriRecursionStartFieldService>();
  985. var queryReturnFieldService = App.GetService<IPriRecursionStartReturnFieldService>();
  986. int passCount = 0;
  987. //查询表
  988. var queryTables = queryTableService.GetList(m => m.listId == sub.id);
  989. int allCount = queryTables.Count;
  990. foreach(var queryTable in queryTables)
  991. {
  992. //查询返回字段
  993. string fields = "1";
  994. var returnFields = queryReturnFieldService.GetList(m => m.objectTableId == queryTable.id);
  995. if(returnFields.Count > 0)
  996. {
  997. fields = "";
  998. foreach(var returnField in returnFields)
  999. {
  1000. if(returnField.fieldReturnKind == "2")
  1001. {
  1002. fields += "count(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1003. }
  1004. else if(returnField.fieldReturnKind == "3")
  1005. {
  1006. fields += "sum(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1007. }
  1008. else if(returnField.fieldReturnKind == "4")
  1009. {
  1010. fields += "avg(" + returnField.fieldEnName + ") " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1011. }
  1012. else
  1013. {
  1014. fields += returnField.fieldEnName + " " + queryTable.tableEnName + "_" + returnField.fieldEnName + ",";
  1015. }
  1016. }
  1017. fields = fields.TrimEnd(',');
  1018. }
  1019. //查询匹配条件
  1020. string condi = "";
  1021. var queryFields = queryFieldService.GetList(m => m.objectTableId == queryTable.id);
  1022. foreach(var queryField in queryFields)
  1023. {
  1024. string fieldEnName = queryField.fieldEnName;
  1025. string fieldQueryKind = queryField.fieldQueryKind;
  1026. string fieldQueryModel = queryField.fieldQueryModel;
  1027. string fieldQueryValue = queryField.fieldQueryValue;
  1028. if(fieldQueryModel == "loop_field") fieldQueryValue = objId;
  1029. string fieldQueryValueType = queryField.fieldQueryValueType;
  1030. if(fieldQueryKind == "1") //模糊匹配
  1031. {
  1032. condi += " and " + fieldEnName + " like ";
  1033. if(fieldQueryModel == "request_param")
  1034. {
  1035. Dictionary<string, string> req = getRequestParams(projectId, content);
  1036. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1037. condi += "'%" + val + "%'";
  1038. }
  1039. else if(fieldQueryModel == "fixed_value")
  1040. {
  1041. condi += "'%" + GetExpressionVal(fieldQueryValue) + "%'";
  1042. }
  1043. else if(fieldQueryModel == "db_field")
  1044. {
  1045. condi += "'%" + GetDbExpressionVal(fieldQueryValue) + "%'";
  1046. }
  1047. }
  1048. else if(fieldQueryKind == "2") //精确匹配
  1049. {
  1050. condi += " and " + fieldEnName + "=";
  1051. string val = fieldQueryValue;
  1052. if(fieldQueryModel == "request_param")
  1053. {
  1054. Dictionary<string, string> req = getRequestParams(projectId, content);
  1055. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1056. }
  1057. else if(fieldQueryModel == "fixed_value")
  1058. {
  1059. val = GetExpressionVal(fieldQueryValue);
  1060. }
  1061. else if(fieldQueryModel == "db_field")
  1062. {
  1063. val = GetDbExpressionVal(fieldQueryValue);
  1064. }
  1065. if(fieldQueryValueType == "text")
  1066. {
  1067. val = "'" + val + "'";
  1068. }
  1069. condi += val;
  1070. }
  1071. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  1072. {
  1073. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  1074. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  1075. string val = "";
  1076. string[] valList = fieldQueryValue.Split(',');
  1077. if(fieldQueryModel == "request_param")
  1078. {
  1079. Dictionary<string, string> req = getRequestParams(projectId, content);
  1080. foreach(string subval in valList)
  1081. {
  1082. if(fieldQueryValueType == "text")
  1083. {
  1084. val += "'" + req[subval] + "',";
  1085. }
  1086. else
  1087. {
  1088. val += req[subval] + ",";
  1089. }
  1090. }
  1091. }
  1092. else if(fieldQueryModel == "fixed_value")
  1093. {
  1094. foreach(string subval in valList)
  1095. {
  1096. if(fieldQueryValueType == "text")
  1097. {
  1098. val += "'" + GetExpressionVal(subval) + "',";
  1099. }
  1100. else
  1101. {
  1102. val += GetExpressionVal(subval) + ",";
  1103. }
  1104. }
  1105. }
  1106. else if(fieldQueryModel == "db_field")
  1107. {
  1108. foreach(string subval in valList)
  1109. {
  1110. if(fieldQueryValueType == "text")
  1111. {
  1112. val += "'" + GetDbExpressionVal(subval) + "',";
  1113. }
  1114. else
  1115. {
  1116. val += GetDbExpressionVal(subval) + ",";
  1117. }
  1118. }
  1119. }
  1120. val = val.TrimEnd(',');
  1121. condi += val + ")";
  1122. }
  1123. else if(fieldQueryKind == "3") //范围匹配
  1124. {
  1125. string[] val = fieldQueryValue.Split(':');
  1126. if(fieldQueryModel == "request_param")
  1127. {
  1128. Dictionary<string, string> req = getRequestParams(projectId, content);
  1129. if(fieldQueryValueType == "number")
  1130. {
  1131. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  1132. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  1133. }
  1134. else
  1135. {
  1136. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  1137. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  1138. }
  1139. }
  1140. else if(fieldQueryModel == "fixed_value")
  1141. {
  1142. if(fieldQueryValueType == "number")
  1143. {
  1144. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  1145. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  1146. }
  1147. else
  1148. {
  1149. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetExpressionVal(val[0]) + "'";
  1150. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetExpressionVal(val[1]) + "'";
  1151. }
  1152. }
  1153. else if(fieldQueryModel == "db_field")
  1154. {
  1155. if(fieldQueryValueType == "number")
  1156. {
  1157. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  1158. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  1159. }
  1160. else
  1161. {
  1162. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + GetDbExpressionVal(val[0]) + "'";
  1163. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + GetDbExpressionVal(val[1]) + "'";
  1164. }
  1165. }
  1166. }
  1167. else if(fieldQueryKind == "4") //取反匹配
  1168. {
  1169. condi += " and " + fieldEnName + "!=";
  1170. string val = "";
  1171. if(fieldQueryModel == "request_param")
  1172. {
  1173. Dictionary<string, string> req = getRequestParams(projectId, content);
  1174. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1175. }
  1176. else if(fieldQueryModel == "fixed_value")
  1177. {
  1178. val = GetExpressionVal(fieldQueryValue);
  1179. }
  1180. else if(fieldQueryModel == "db_field")
  1181. {
  1182. val = GetDbExpressionVal(fieldQueryValue);
  1183. }
  1184. if(fieldQueryValueType == "text")
  1185. {
  1186. val = "'" + val + "'";
  1187. }
  1188. condi += val;
  1189. }
  1190. }
  1191. var db = initDb(queryTable.databaseId);
  1192. string sql = "select " + fields + " from " + queryTable.tableEnName + " where 1=1" + condi;
  1193. var items = db.Ado.GetDataTable(sql);
  1194. if(items.Rows.Count > 0)
  1195. {
  1196. foreach(System.Data.DataColumn item in items.Columns)
  1197. {
  1198. if(!dic.ContainsKey(item.ColumnName)) dic.Add(item.ColumnName, items.Rows[0][item.ColumnName].ToString());
  1199. }
  1200. }
  1201. }
  1202. return dic;
  1203. }
  1204. //奖励入库
  1205. public static void prizeToDatabase(int projectId, string content)
  1206. {
  1207. var prizeInTableService = App.GetService<IPriPrizeInTableService>();
  1208. var prizeInFieldService = App.GetService<IPriPrizeInFieldService>();
  1209. var prizeInQueryFieldService = App.GetService<IPriPrizeInQueryFieldService>();
  1210. //入库表
  1211. var prizeInTables = prizeInTableService.GetList(m => m.projectId == projectId);
  1212. foreach(var prizeInTable in prizeInTables)
  1213. {
  1214. var db = initDb(prizeInTable.databaseId);
  1215. Dictionary<string, object> doFields = new Dictionary<string, object>();
  1216. //入库字段
  1217. var prizeInFields = prizeInFieldService.GetList(m => m.inTableId == prizeInTable.id);
  1218. foreach(var prizeInField in prizeInFields)
  1219. {
  1220. string fieldEnName = prizeInField.fieldEnName;
  1221. string fieldQueryModel = prizeInField.fieldQueryModel;
  1222. string fieldQueryValue = prizeInField.fieldQueryValue;
  1223. string fieldQueryValueType = prizeInField.fieldQueryValueType;
  1224. if(fieldQueryModel == "request_param")
  1225. {
  1226. Dictionary<string, string> req = getRequestParams(projectId, content);
  1227. fieldQueryValue = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1228. }
  1229. else if(fieldQueryModel == "fixed_value")
  1230. {
  1231. fieldQueryValue = GetExpressionVal(fieldQueryValue);
  1232. }
  1233. else if(fieldQueryModel == "db_field")
  1234. {
  1235. fieldQueryValue = GetDbExpressionVal(fieldQueryValue);
  1236. }
  1237. if(fieldQueryValueType == "text") doFields.Add(fieldEnName, fieldQueryValue);
  1238. if(fieldQueryValueType == "int") doFields.Add(fieldEnName, int.Parse(fieldQueryValue));
  1239. if(fieldQueryValueType == "number") doFields.Add(fieldEnName, decimal.Parse(fieldQueryValue));
  1240. if(fieldQueryValueType == "datetime") doFields.Add(fieldEnName, DateTime.Parse(fieldQueryValue));
  1241. if(fieldQueryValueType == "bool") doFields.Add(fieldEnName, bool.Parse(fieldQueryValue));
  1242. }
  1243. //查询匹配条件
  1244. string condi = "";
  1245. var queryFields = prizeInQueryFieldService.GetList(m => m.inTableId == prizeInTable.id);
  1246. foreach(var queryField in queryFields)
  1247. {
  1248. string fieldEnName = queryField.fieldEnName;
  1249. string fieldQueryKind = queryField.fieldQueryKind;
  1250. string fieldQueryModel = queryField.fieldQueryModel;
  1251. string fieldQueryValue = queryField.fieldQueryValue;
  1252. string fieldQueryValueType = queryField.fieldQueryValueType;
  1253. if(fieldQueryKind == "1") //模糊匹配
  1254. {
  1255. condi += " and " + fieldEnName + " like ";
  1256. if(fieldQueryModel == "request_param")
  1257. {
  1258. Dictionary<string, string> req = getRequestParams(projectId, content);
  1259. string val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1260. condi += "'%" + val + "%'";
  1261. }
  1262. else if(fieldQueryModel == "fixed_value")
  1263. {
  1264. condi += "'%" + fieldQueryValue + "%'";
  1265. }
  1266. }
  1267. else if(fieldQueryKind == "2") //精确匹配
  1268. {
  1269. condi += " and " + fieldEnName + "=";
  1270. string val = "";
  1271. if(fieldQueryModel == "request_param")
  1272. {
  1273. Dictionary<string, string> req = getRequestParams(projectId, content);
  1274. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1275. }
  1276. else if(fieldQueryModel == "fixed_value")
  1277. {
  1278. val = fieldQueryValue;
  1279. }
  1280. if(fieldQueryValueType == "text")
  1281. {
  1282. val = "'" + val + "'";
  1283. }
  1284. condi += val;
  1285. }
  1286. else if(fieldQueryKind == "5" || fieldQueryKind == "6") //数组匹配/排除
  1287. {
  1288. if(fieldQueryKind == "5") condi += " and " + fieldEnName + " in (";
  1289. else if(fieldQueryKind == "6") condi += " and " + fieldEnName + " not in (";
  1290. string val = "";
  1291. string[] valList = fieldQueryValue.Split(',');
  1292. if(fieldQueryModel == "request_param")
  1293. {
  1294. Dictionary<string, string> req = getRequestParams(projectId, content);
  1295. foreach(string sub in valList)
  1296. {
  1297. if(fieldQueryValueType == "text")
  1298. {
  1299. val += "'" + req[sub] + "',";
  1300. }
  1301. else
  1302. {
  1303. val += req[sub] + ",";
  1304. }
  1305. }
  1306. }
  1307. else if(fieldQueryModel == "fixed_value")
  1308. {
  1309. foreach(string sub in valList)
  1310. {
  1311. if(fieldQueryValueType == "text")
  1312. {
  1313. val += "'" + GetExpressionVal(sub) + "',";
  1314. }
  1315. else
  1316. {
  1317. val += GetExpressionVal(sub) + ",";
  1318. }
  1319. }
  1320. }
  1321. else if(fieldQueryModel == "db_field")
  1322. {
  1323. foreach(string sub in valList)
  1324. {
  1325. if(fieldQueryValueType == "text")
  1326. {
  1327. val += "'" + GetDbExpressionVal(sub) + "',";
  1328. }
  1329. else
  1330. {
  1331. val += GetDbExpressionVal(sub) + ",";
  1332. }
  1333. }
  1334. }
  1335. val = val.TrimEnd(',');
  1336. condi += val + ")";
  1337. }
  1338. else if(fieldQueryKind == "3") //范围匹配
  1339. {
  1340. string[] val = fieldQueryValue.Split(':');
  1341. if(fieldQueryModel == "request_param")
  1342. {
  1343. Dictionary<string, string> req = getRequestParams(projectId, content);
  1344. if(fieldQueryValueType == "number")
  1345. {
  1346. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">=" + req[val[0]];
  1347. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<=" + req[val[1]];
  1348. }
  1349. else
  1350. {
  1351. if(!string.IsNullOrEmpty(req[val[0]])) condi += " and " + fieldEnName + ">='" + req[val[0]] + "'";
  1352. if(!string.IsNullOrEmpty(req[val[1]])) condi += " and " + fieldEnName + "<='" + req[val[1]] + "'";
  1353. }
  1354. }
  1355. else if(fieldQueryModel == "fixed_value")
  1356. {
  1357. if(fieldQueryValueType == "number")
  1358. {
  1359. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">=" + val[0];
  1360. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<=" + val[1];
  1361. }
  1362. else
  1363. {
  1364. if(!string.IsNullOrEmpty(val[0])) condi += " and " + fieldEnName + ">='" + val[0] + "'";
  1365. if(!string.IsNullOrEmpty(val[1])) condi += " and " + fieldEnName + "<='" + val[1] + "'";
  1366. }
  1367. }
  1368. }
  1369. else if(fieldQueryKind == "4") //取反匹配
  1370. {
  1371. condi += " and " + fieldEnName + "!=";
  1372. string val = "";
  1373. if(fieldQueryModel == "request_param")
  1374. {
  1375. Dictionary<string, string> req = getRequestParams(projectId, content);
  1376. val = req.ContainsKey(fieldQueryValue) ? req[fieldQueryValue] : "0";
  1377. }
  1378. else if(fieldQueryModel == "fixed_value")
  1379. {
  1380. val = fieldQueryValue;
  1381. }
  1382. if(fieldQueryValueType == "text")
  1383. {
  1384. val = "'" + val + "'";
  1385. }
  1386. condi += val;
  1387. }
  1388. }
  1389. if(prizeInTable.excuteKind == "add") db.Insertable(doFields).ExecuteCommand();
  1390. if(prizeInTable.excuteKind == "update") db.Updateable(doFields).Where("1=1" + condi).ExecuteCommand();
  1391. }
  1392. }
  1393. //固定值表达式
  1394. public static string GetExpressionVal(string str)
  1395. {
  1396. if(str == "#{now}#") str = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1397. if(str == "#{today}#") str = DateTime.Now.ToString("yyyy-MM-dd");
  1398. if(str == "#{this_month}#") str = DateTime.Now.ToString("yyyy-MM");
  1399. if(str.StartsWith("#{now") && str.EndsWith("DAY}#")) str = DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
  1400. if(str.StartsWith("#{now") && str.EndsWith("MONTH}#")) str = DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd HH:mm:ss");
  1401. if(str.StartsWith("#{today") && str.EndsWith("DAY}#")) str = DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd");
  1402. if(str.StartsWith("#{today") && str.EndsWith("MONTH}#")) str = DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM-dd");
  1403. if(str.StartsWith("#{this_month") && str.EndsWith("DAY}#")) str = DateTime.Now.AddDays(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM");
  1404. if(str.StartsWith("#{this_month") && str.EndsWith("MONTH}#")) str = DateTime.Now.AddMonths(int.Parse(str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',')[1])).ToString("yyyy-MM");
  1405. return str;
  1406. }
  1407. //库内字段值表达式
  1408. public static string GetDbExpressionVal(string str)
  1409. {
  1410. string[] data = str.Replace("#", "").Replace("{", "").Replace("}", "").Split(',');
  1411. if(str.StartsWith("#{") && str.EndsWith("DAY}#")) str = "DATE_ADD(" + data[0] + ",INTERVAL " + data[1] + " DAY)";
  1412. if(str.StartsWith("#{") && str.EndsWith("MONTH}#")) str = "DATE_ADD(" + data[0] + ",INTERVAL " + data[1] + " MONTH)";
  1413. return str;
  1414. }
  1415. }
  1416. }