TkLogCore.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc.Controllers;
  3. using Microsoft.AspNetCore.Mvc.Filters;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using dodohold.core;
  9. using static dodohold.core.ZTOExpress.CreateOrderArgs;
  10. using System.Net;
  11. using System.Security.Cryptography;
  12. using Spire.Pdf.Exporting.XPS.Schema;
  13. using System.Xml.Linq;
  14. using static QRCoder.PayloadGenerator;
  15. namespace molilian.core
  16. {
  17. public class TkLogCore
  18. {
  19. static string queue_tb_key = "queue:logs:tb";
  20. static string queue_jd_key = "queue:logs:jd";
  21. static string queue_parse_tb_key = "queue:parse_logs:tb";
  22. static string queue_parse_jd_key = "queue:parse_logs:jd";
  23. static string queue_parse_dy_key = "queue:parse_logs:dy";
  24. static string queue_parse_tool_key = "queue:parse_logs:tool";
  25. static string queue_coupon_key = "queue:coupon_logs";
  26. public static int BatchInsertLogDB(int limit)
  27. {
  28. int total = 0;
  29. using var connection = DBContext.GetOpenConnection();
  30. connection.Open();
  31. using var transaction = connection.BeginTransaction();
  32. try
  33. {
  34. for (int i = 0; i < limit; i++)
  35. {
  36. var data = RedisHelper.LPop<TkDataDTO>(queue_tb_key);
  37. if (data == null) break;
  38. data.id = new DBContext.Table(connection, "tk_logs")
  39. .Add("channel", (int)data.channel)
  40. .Add("accountId", data.accountId)
  41. .Add("accountName", data.accountName)
  42. .Add("rawContent", data.rawContent)
  43. .Add("rawContent2", data.rawContent2)
  44. .Add("success", data.success)
  45. .Add("message", data.message)
  46. .Add("reason", data.reason)
  47. .Add("content", data.content)
  48. .Add("couponAmount", data.couponAmount)
  49. .Add("itemId", data.itemId)
  50. .Add("itemName", data.itemName)
  51. .Add("pic", data.pic)
  52. .Add("promotionPrice", data.promotionPrice)
  53. .Add("taoToken", data.taoToken)
  54. .Add("shortLinkurl", data.shortLinkurl)
  55. .Add("deeplink_url", data.deeplink_url)
  56. .Add("num_iid", data.num_iid)
  57. .Add("elapsedTime", data.elapsedTime)
  58. .Add("ip", data.ip)
  59. .Add("oaid", data.oaid)
  60. .Add("create_time", data.create_time)
  61. .Create(DBContext.InsertType.NORMAL, transaction);
  62. if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
  63. total++;
  64. }
  65. for (int i = 0; i < limit; i++)
  66. {
  67. var data = RedisHelper.LPop<JdDataDTO>(queue_jd_key);
  68. if (data == null) break;
  69. new DBContext.Table(connection, "tk_logs")
  70. .Add("channel", (int)data.channel)
  71. .Add("accountId", data.accountId)
  72. .Add("accountName", data.accountName)
  73. .Add("rawContent", data.rawContent)
  74. .Add("rawContent2", data.rawContent2)
  75. .Add("success", data.success)
  76. .Add("message", data.message)
  77. .Add("reason", data.reason)
  78. .Add("shortLinkurl", data.shortLinkurl)
  79. .Add("deeplink_url", data.deeplink_url)
  80. .Add("elapsedTime", data.elapsedTime)
  81. .Add("ip", data.ip)
  82. .Add("oaid", data.oaid)
  83. .Add("create_time", data.create_time)
  84. .Create(DBContext.InsertType.NORMAL, transaction);
  85. total++;
  86. }
  87. for (int i = 0; i < limit; i++)
  88. {
  89. var data = RedisHelper.LPop<TkDataDTO>(queue_parse_tb_key);
  90. if (data == null) break;
  91. data.id = new DBContext.Table(connection, "tk_parse_logs")
  92. .Add("channel", (int)data.channel)
  93. .Add("accountId", data.accountId)
  94. .Add("accountName", data.accountName)
  95. .Add("rawContent", data.rawContent)
  96. .Add("success", data.success)
  97. .Add("message", data.message)
  98. .Add("reason", data.reason)
  99. .Add("content", data.content)
  100. .Add("itemId", data.itemId)
  101. .Add("itemName", data.itemName)
  102. .Add("pic", data.pic)
  103. .Add("couponAmount", data.couponAmount)
  104. .Add("promotionPrice", data.promotionPrice)
  105. .Add("taoToken", data.taoToken)
  106. .Add("shortLinkurl", data.shortLinkurl)
  107. .Add("deeplink_url", data.deeplink_url)
  108. .Add("num_iid", data.num_iid)
  109. .Add("elapsedTime", data.elapsedTime)
  110. .Add("elapsedTime2", data.elapsedTime2)
  111. .Add("elapsedTime3", data.elapsedTime3)
  112. .Add("ip", data.ip)
  113. .Add("oaid", data.oaid)
  114. .Add("create_time", data.create_time)
  115. .Create(DBContext.InsertType.NORMAL, transaction);
  116. if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
  117. total++;
  118. }
  119. for (int i = 0; i < limit; i++)
  120. {
  121. var data = RedisHelper.LPop<JdDataDTO>(queue_parse_jd_key);
  122. if (data == null) break;
  123. new DBContext.Table(connection, "tk_parse_logs")
  124. .Add("channel", (int)data.channel)
  125. .Add("accountId", data.accountId)
  126. .Add("accountName", data.accountName)
  127. .Add("rawContent", data.rawContent)
  128. .Add("success", data.success)
  129. .Add("message", data.message)
  130. .Add("reason", data.reason)
  131. .Add("content", data.content)
  132. .Add("itemId", data.itemId)
  133. .Add("itemName", data.itemName)
  134. .Add("pic", data.pic)
  135. .Add("couponAmount", data.couponAmount)
  136. .Add("promotionPrice", data.promotionPrice)
  137. .Add("taoToken", data.taoToken)
  138. .Add("shortLinkurl", data.shortLinkurl)
  139. .Add("deeplink_url", data.deeplink_url)
  140. .Add("elapsedTime", data.elapsedTime)
  141. .Add("ip", data.ip)
  142. .Add("oaid", data.oaid)
  143. .Add("create_time", data.create_time)
  144. .Create(DBContext.InsertType.NORMAL, transaction);
  145. total++;
  146. }
  147. for (int i = 0; i < limit; i++)
  148. {
  149. var data = RedisHelper.LPop<DyDataDTO>(queue_parse_dy_key);
  150. if (data == null) break;
  151. new DBContext.Table(connection, "tk_parse_logs")
  152. .Add("channel", (int)data.channel)
  153. .Add("accountId", data.accountId)
  154. .Add("accountName", data.accountName)
  155. .Add("rawContent", data.rawContent)
  156. .Add("success", data.success)
  157. .Add("message", data.message)
  158. .Add("reason", data.reason)
  159. .Add("content", data.content)
  160. .Add("itemId", data.itemId)
  161. .Add("itemName", data.itemName)
  162. .Add("pic", data.pic)
  163. .Add("couponAmount", data.couponAmount)
  164. .Add("promotionPrice", data.promotionPrice)
  165. .Add("taoToken", data.taoToken)
  166. .Add("shortLinkurl", data.shortLinkurl)
  167. .Add("deeplink_url", data.deeplink_url)
  168. .Add("elapsedTime", data.elapsedTime)
  169. .Add("ip", data.ip)
  170. .Add("oaid", data.oaid)
  171. .Add("create_time", data.create_time)
  172. .Create(DBContext.InsertType.NORMAL, transaction);
  173. total++;
  174. }
  175. for (int i = 0; i < limit; i++)
  176. {
  177. var data = RedisHelper.LPop<ToolParseDataDTO>(queue_parse_tool_key);
  178. if (data == null) break;
  179. new DBContext.Table(connection, "tool_parse_logs")
  180. .Add("channel", (int)data.channel)
  181. .Add("rawContent", data.rawContent)
  182. .Add("success", data.success)
  183. .Add("message", data.message)
  184. .Add("reason", data.reason)
  185. .Add("content", data.content)
  186. .Add("taoToken", data.taoToken)
  187. .Add("shortLinkurl", data.shortLinkurl)
  188. .Add("deeplink_url", data.deeplink_url)
  189. .Add("elapsedTime", data.elapsedTime)
  190. .Add("ip", data.ip)
  191. .Add("oaid", data.oaid)
  192. .Add("create_time", data.create_time)
  193. .Create(DBContext.InsertType.NORMAL, transaction);
  194. total++;
  195. }
  196. for (int i = 0; i < limit; i++)
  197. {
  198. var data = RedisHelper.LPop<UnionCouponDTO>(queue_coupon_key);
  199. if (data == null) break;
  200. connection.Insert(data);
  201. total++;
  202. }
  203. transaction.Commit();
  204. }
  205. catch (Exception ex)
  206. {
  207. transaction.Rollback();
  208. _ = new LoggerLibrary("database_error", "parse_log")
  209. .Info(ex.Message, ex.StackTrace)
  210. .SaveAsync();
  211. NotifyCore.Notify(new NifyMessage
  212. {
  213. message = $"【写入日志异常】\n{ex.Message}\n{ex.StackTrace}",
  214. priority = NifyMessagePriority.high,
  215. tags = ["red_circle"]
  216. });
  217. }
  218. finally
  219. {
  220. connection.Close();
  221. }
  222. return total;
  223. }
  224. public static async Task LogAsync(JdDataDTO response)
  225. {
  226. try
  227. {
  228. var ts = DateTime.Now - response.create_time;
  229. response.elapsedTime = (int)ts.TotalMilliseconds;
  230. RedisHelper.RPush(queue_jd_key, response);
  231. saveCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
  232. }
  233. catch (Exception ex) { }
  234. }
  235. public static async Task LogAsync(TkDataDTO response, AlimamaPlus? alimamaPlus = null)
  236. {
  237. try
  238. {
  239. var ts = DateTime.Now - response.create_time;
  240. response.elapsedTime = (int)ts.TotalMilliseconds;
  241. RedisHelper.RPush(queue_tb_key, response);
  242. saveCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
  243. if (!response.success && "nologin".Equals(response.message))
  244. {
  245. switch (response.channel)
  246. {
  247. case TkChannelEnum.tb:
  248. await Task.Run(() =>
  249. {
  250. if (alimamaPlus != null)
  251. {
  252. (bool success, string message) = alimamaPlus.RenewCookie();
  253. if (success) return;
  254. }
  255. TkPoolCore.Disabled(response.accountName, $"{response.rawContent}\n{response.rawContent2}");
  256. });
  257. break;
  258. }
  259. }
  260. if ("没有匹配账号".Equals(response.reason))
  261. {
  262. TkPoolCore.AccountExhausted();
  263. }
  264. }
  265. catch (Exception ex)
  266. {
  267. _ = new LoggerLibrary("unionParse", "database_error")
  268. .Info(response.rawContent, response.rawContent2)
  269. .Info(response.Convert2Json())
  270. .Info(ex.Message, ex.StackTrace)
  271. .SaveAsync();
  272. }
  273. }
  274. public static async Task ParseLogAsync(TkDataDTO response, AlimamaPlus? alimamaPlus = null)
  275. {
  276. #if DEBUG
  277. //return;
  278. #endif
  279. try
  280. {
  281. var ts = DateTime.Now - response.create_time;
  282. response.elapsedTime = (int)ts.TotalMilliseconds;
  283. RedisHelper.RPush(queue_parse_tb_key, response);
  284. saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
  285. if (!string.IsNullOrEmpty(response.itemId)) TkOrderTrackingCore.SaveLinkSummary(response);
  286. if (!response.success && "nologin".Equals(response.message))
  287. {
  288. switch (response.channel)
  289. {
  290. case TkChannelEnum.tb:
  291. await Task.Run(() =>
  292. {
  293. if (alimamaPlus != null)
  294. {
  295. (bool success, string message) = alimamaPlus.RenewCookie();
  296. if (success) return;
  297. }
  298. TkPoolCore.Disabled(response.accountName, $"{response.rawContent}");
  299. }); break;
  300. }
  301. }
  302. }
  303. catch (Exception ex)
  304. {
  305. _ = new LoggerLibrary("unionParse", "database_error")
  306. .Info(response.rawContent)
  307. .Info(response.Convert2Json())
  308. .Info(ex.Message, ex.StackTrace)
  309. .SaveAsync();
  310. }
  311. }
  312. public static async Task CouponLogAsync(UnionCouponDTO response, AlimamaPlus? alimamaPlus = null)
  313. {
  314. try
  315. {
  316. var ts = DateTime.Now - response.create_time;
  317. response.elapsedTime = (int)ts.TotalMilliseconds;
  318. RedisHelper.RPush(queue_coupon_key, response);
  319. saveCouponCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
  320. if (!response.success && "nologin".Equals(response.message))
  321. {
  322. switch (response.channel)
  323. {
  324. case TkChannelEnum.tb:
  325. await Task.Run(() =>
  326. {
  327. if (alimamaPlus != null)
  328. {
  329. (bool success, string message) = alimamaPlus.RenewCookie();
  330. if (success) return;
  331. }
  332. TkPoolCore.Disabled(response.accountName, $"{response.rawContent}");
  333. }); break;
  334. }
  335. }
  336. }
  337. catch (Exception ex)
  338. {
  339. _ = new LoggerLibrary("unionCoupon", "database_error")
  340. .Info(response.rawContent)
  341. .Info(response.Convert2Json())
  342. .Info(ex.Message, ex.StackTrace)
  343. .SaveAsync();
  344. }
  345. }
  346. public static async Task ParseLogAsync(JdDataDTO response)
  347. {
  348. try
  349. {
  350. var ts = DateTime.Now - response.create_time;
  351. response.elapsedTime = (int)ts.TotalMilliseconds;
  352. RedisHelper.RPush(queue_parse_jd_key, response);
  353. saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
  354. }
  355. catch (Exception ex) { }
  356. }
  357. public static async Task ParseLogAsync(DyDataDTO response)
  358. {
  359. try
  360. {
  361. var ts = DateTime.Now - response.create_time;
  362. response.elapsedTime = (int)ts.TotalMilliseconds;
  363. RedisHelper.RPush(queue_parse_dy_key, response);
  364. saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
  365. }
  366. catch (Exception ex) { }
  367. }
  368. public static async Task ParseLogAsync(ToolParseDataDTO response)
  369. {
  370. try
  371. {
  372. var ts = DateTime.Now - response.create_time;
  373. response.elapsedTime = (int)ts.TotalMilliseconds;
  374. RedisHelper.RPush(queue_parse_tool_key, response);
  375. saveParseCache(response.channel.ToString(), 0, "tool", response.success, response.message, response.reason);
  376. }
  377. catch (Exception ex) { }
  378. }
  379. private static void saveCache(string channel, int accountId, string accountName, bool success, string message, string reason)
  380. {
  381. saveAccountCache("all", success, message, reason);
  382. saveAccountCache($"{channel}", success, message, reason);
  383. saveAccountCache($"{accountName}", success, message, reason);
  384. if (accountId != 0)
  385. {
  386. //todo 放着跑两天,要将读取的地方改成读取accountid
  387. saveAccountCache($"{channel}_{accountId}", success, message, reason);
  388. }
  389. }
  390. private static void saveAccountCache(string accountName, bool success, string message, string reason)
  391. {
  392. RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMM}");
  393. RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMMdd}");
  394. RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMMddHH}");
  395. string result = success ? "success" : "fail";
  396. RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
  397. RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
  398. RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
  399. if (!string.IsNullOrEmpty(message))
  400. {
  401. RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
  402. RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
  403. RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
  404. RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
  405. RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
  406. RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
  407. }
  408. if (!string.IsNullOrEmpty(reason))
  409. {
  410. RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
  411. RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
  412. RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
  413. RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
  414. RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
  415. RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
  416. }
  417. }
  418. private static void saveParseCache(string channel, int accountId, string accountName, bool success, string message, string reason)
  419. {
  420. saveParseAccountCache("all", success, message, reason);
  421. saveParseAccountCache($"{channel}", success, message, reason);
  422. saveParseAccountCache($"{accountName}", success, message, reason);
  423. if (accountId != 0)
  424. {
  425. //todo 放着跑两天,要将读取的地方改成读取accountid
  426. saveParseAccountCache($"{channel}_{accountId}", success, message, reason);
  427. }
  428. }
  429. private static void saveParseAccountCache(string accountName, bool success, string message, string reason)
  430. {
  431. RedisHelper.IncrBy($":parse_total:{accountName}:{DateTime.Now:yyyyMM}");
  432. RedisHelper.IncrBy($":parse_total:{accountName}:{DateTime.Now:yyyyMMdd}");
  433. RedisHelper.IncrBy($":parse_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
  434. string result = success ? "success" : "fail";
  435. RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
  436. RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
  437. RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
  438. if (!string.IsNullOrEmpty(message))
  439. {
  440. RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
  441. RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
  442. RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
  443. RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
  444. RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
  445. RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
  446. }
  447. if (!string.IsNullOrEmpty(reason))
  448. {
  449. RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
  450. RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
  451. RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
  452. RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
  453. RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
  454. RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
  455. }
  456. }
  457. private static void saveCouponCache(string channel, int accountId, string accountName, bool success, string message, string reason)
  458. {
  459. saveAccountCouponCache("all", success, message, reason);
  460. saveAccountCouponCache($"{channel}", success, message, reason);
  461. if (accountId != 0)
  462. {
  463. //todo 放着跑两天,要将读取的地方改成读取accountid
  464. saveAccountCouponCache($"{channel}_{accountId}", success, message, reason);
  465. }
  466. }
  467. private static void saveAccountCouponCache(string accountName, bool success, string message, string reason)
  468. {
  469. RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMM}");
  470. RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMMdd}");
  471. RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
  472. string result = success ? "success" : "fail";
  473. RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
  474. RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
  475. RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
  476. if (!string.IsNullOrEmpty(message))
  477. {
  478. RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
  479. RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
  480. RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
  481. RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
  482. RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
  483. RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
  484. }
  485. if (!string.IsNullOrEmpty(reason))
  486. {
  487. RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
  488. RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
  489. RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
  490. RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
  491. RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
  492. RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
  493. }
  494. }
  495. }
  496. }