orders.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. using dodohold.core;
  2. using Spire.Pdf.Xmp;
  3. using System.Data;
  4. using System.Drawing.Printing;
  5. using System.Runtime.InteropServices;
  6. using System.Text.Json;
  7. using System.Text.RegularExpressions;
  8. using static System.Runtime.InteropServices.JavaScript.JSType;
  9. namespace molilian.core
  10. {
  11. public partial class AlimamaPlus
  12. {
  13. private const string base_orders_url = "https://pub.alimama.com/openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json";
  14. public int GetHistoryOrders(int sleep, DateTime startTime, DateTime endTime)
  15. {
  16. //DateTime endTime = DateTime.Now;
  17. //DateTime startTime = endTime.AddDays(-90);
  18. //if (_accountId == 3) endTime = DateTime.Parse("2024-04-07");
  19. #if DEBUG
  20. startTime = DateTime.Parse("2024-03-21");
  21. endTime = DateTime.Parse("2024-06-01");
  22. int total = 0;
  23. List<DateTime> orderTimes = new List<DateTime>();
  24. for (DateTime date = startTime; date <= endTime; date = date.AddDays(1))
  25. {
  26. orderTimes.Add(date);
  27. }
  28. #else
  29. //当日往前查询
  30. (int total, DateTime max_modifiedTime, List<DateTime> orderTimes) = GetTkOrders(startTime, endTime, DateTime.MinValue, false, sleep);
  31. #endif
  32. string sql = @"
  33. UPDATE tk_report tr
  34. JOIN (
  35. SELECT
  36. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  37. COUNT(*) AS order_ord_num, SUM(pubShareFeeForCommission) AS order_ord_tfee
  38. FROM tk_order_details
  39. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=3 AND accountId=@accountId
  40. GROUP BY DATE(tbPaidTime), accountId
  41. ) AS sub
  42. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  43. SET tr.order_ord_amt = sub.order_ord_amt, tr.order_ord_num_3 = sub.order_ord_num,
  44. tr.order_ord_tfee = sub.order_ord_tfee;";
  45. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  46. sql = @"
  47. UPDATE tk_report tr
  48. JOIN (
  49. SELECT
  50. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  51. COUNT(*) AS order_ord_num, SUM(pubSharePreFeeForCommission) AS order_ord_tfee
  52. FROM tk_order_details
  53. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=12 AND accountId=@accountId
  54. GROUP BY DATE(tbPaidTime), accountId
  55. ) AS sub
  56. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  57. SET tr.order_ord_amt_12 = sub.order_ord_amt, tr.order_ord_num_12 = sub.order_ord_num,
  58. tr.order_ord_tfee_12 = sub.order_ord_tfee;";
  59. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  60. sql = @"
  61. UPDATE tk_report tr
  62. JOIN (
  63. SELECT
  64. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  65. COUNT(*) AS order_ord_num, SUM(pubSharePreFeeForCommission) AS order_ord_tfee
  66. FROM tk_order_details
  67. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=13 AND accountId=@accountId
  68. GROUP BY DATE(tbPaidTime), accountId
  69. ) AS sub
  70. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  71. SET tr.order_ord_amt_13 = sub.order_ord_amt, tr.order_ord_num_13 = sub.order_ord_num,
  72. tr.order_ord_tfee_13 = sub.order_ord_tfee;";
  73. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  74. sql = @"
  75. UPDATE tk_report tr
  76. JOIN (
  77. SELECT
  78. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  79. COUNT(*) AS order_ord_num, SUM(pubSharePreFeeForCommission) AS order_ord_tfee
  80. FROM tk_order_details
  81. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=14 AND accountId=@accountId
  82. GROUP BY DATE(tbPaidTime), accountId
  83. ) AS sub
  84. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  85. SET tr.order_ord_amt_14 = sub.order_ord_amt, tr.order_ord_num_14 = sub.order_ord_num,
  86. tr.order_ord_tfee_14 = sub.order_ord_tfee;";
  87. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  88. sql = @"UPDATE tk_report
  89. SET order_ord_num = order_ord_num_3 + order_ord_num_12 + order_ord_num_13 + order_ord_num_14
  90. WHERE DATE(report_date) IN @orderTimes AND accountId=@accountId;";
  91. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  92. return total;
  93. }
  94. public int GetIncyOrders(int sleep)
  95. {
  96. string cacheKey = $":cache:GetIncyOrders:{_accountName}";
  97. DateTime endTime = DateTime.Now;
  98. DateTime startTime = endTime.AddDays(-1);
  99. DateTime last_modifiedTime = RedisHelper.Get<DateTime>(cacheKey);
  100. ////找出数据库最新的一天
  101. //var last = new DBContext.Table("tk_order_details")
  102. // .Order("modifiedTime DESC")
  103. // .Get<TkOrderDetailDTO>("accountId=@accountId", new { accountId = _accountId });
  104. if (last_modifiedTime != DateTime.MinValue)
  105. {
  106. startTime = last_modifiedTime;
  107. }
  108. else
  109. {
  110. last_modifiedTime = startTime;
  111. }
  112. //当日往前查询
  113. (int total, DateTime max_modifiedTime, List<DateTime> orderTimes) = GetTkOrders(startTime, endTime, last_modifiedTime, true, sleep);
  114. if (max_modifiedTime != DateTime.MinValue)
  115. {
  116. RedisHelper.Set(cacheKey, max_modifiedTime);
  117. }
  118. //todo 根据orderTimes、settlementTimes 更新被影响的相关行
  119. string sql = @"
  120. UPDATE tk_report tr
  121. JOIN (
  122. SELECT
  123. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  124. COUNT(*) AS order_ord_num, SUM(pubShareFeeForCommission) AS order_ord_tfee
  125. FROM tk_order_details
  126. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=3 AND accountId=@accountId
  127. GROUP BY DATE(tbPaidTime), accountId
  128. ) AS sub
  129. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  130. SET tr.order_ord_amt = sub.order_ord_amt, tr.order_ord_num_3 = sub.order_ord_num,
  131. tr.order_ord_tfee = sub.order_ord_tfee;";
  132. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  133. sql = @"
  134. UPDATE tk_report tr
  135. JOIN (
  136. SELECT
  137. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  138. COUNT(*) AS order_ord_num, SUM(pubSharePreFeeForCommission) AS order_ord_tfee
  139. FROM tk_order_details
  140. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=12 AND accountId=@accountId
  141. GROUP BY DATE(tbPaidTime), accountId
  142. ) AS sub
  143. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  144. SET tr.order_ord_amt_12 = sub.order_ord_amt, tr.order_ord_num_12 = sub.order_ord_num,
  145. tr.order_ord_tfee_12 = sub.order_ord_tfee;";
  146. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  147. sql = @"
  148. UPDATE tk_report tr
  149. JOIN (
  150. SELECT
  151. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  152. COUNT(*) AS order_ord_num, SUM(pubSharePreFeeForCommission) AS order_ord_tfee
  153. FROM tk_order_details
  154. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=13 AND accountId=@accountId
  155. GROUP BY DATE(tbPaidTime), accountId
  156. ) AS sub
  157. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  158. SET tr.order_ord_amt_13 = sub.order_ord_amt, tr.order_ord_num_13 = sub.order_ord_num,
  159. tr.order_ord_tfee_13 = sub.order_ord_tfee;";
  160. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  161. sql = @"
  162. UPDATE tk_report tr
  163. JOIN (
  164. SELECT
  165. accountId, DATE(tbPaidTime) AS date, SUM(alipayTotalPrice) AS order_ord_amt,
  166. COUNT(*) AS order_ord_num, SUM(pubSharePreFeeForCommission) AS order_ord_tfee
  167. FROM tk_order_details
  168. WHERE DATE(tbPaidTime) IN @orderTimes AND tkStatus=14 AND accountId=@accountId
  169. GROUP BY DATE(tbPaidTime), accountId
  170. ) AS sub
  171. ON tr.accountId = sub.accountId AND tr.report_date = sub.date
  172. SET tr.order_ord_amt_14 = sub.order_ord_amt, tr.order_ord_num_14 = sub.order_ord_num,
  173. tr.order_ord_tfee_14 = sub.order_ord_tfee;";
  174. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  175. sql = @"UPDATE tk_report
  176. SET order_ord_num = order_ord_num_3 + order_ord_num_12 + order_ord_num_13 + order_ord_num_14
  177. WHERE DATE(report_date) IN @orderTimes AND accountId=@accountId;";
  178. DBContext.Execute(sql, new { accountId = _accountId, orderTimes });
  179. return total;
  180. }
  181. public (int, DateTime, List<DateTime>) GetTkOrders(DateTime startTime, DateTime endTime, DateTime last_modifiedTime, bool desc = true, int sleep = 100)
  182. {
  183. List<DateTime> orderTimes = [];
  184. // 确保 startTime 小于 endTime
  185. if (startTime > endTime)
  186. {
  187. (startTime, endTime) = (endTime, startTime);
  188. }
  189. DateTime max_modifiedTime = last_modifiedTime;
  190. int pageNo = 1;
  191. string positionIndex = string.Empty;
  192. int pageSize = 100;
  193. bool hasNext = true;
  194. int total = 0;
  195. while (hasNext)
  196. {
  197. var ts = DateTime.Now.Convert2UnixTimestamp(true);
  198. //string jumpType = desc ? pageNo == 1 ? "0" : "1" : "-1";
  199. string jumpType = pageNo == 1 ? "0" : "1";
  200. #if DEBUG
  201. jumpType = pageNo == 1 ? "0" : "1";
  202. #endif
  203. //string queryType = "1";
  204. //1 创建时间;3结算时间 2付款时间 4更新时间
  205. //string queryType = "2";
  206. string queryType = desc ? "4" : "2";
  207. string url = $"{base_orders_url}?t={ts}&_tb_token_={_tb_token}&pageNo={pageNo}&pageSize={pageSize}&startTime={startTime:yyyy-MM-dd}&endTime={endTime:yyyy-MM-dd}&payStatus=&queryType={queryType}&jumpType={jumpType}&tkTradeId=&positionIndex={positionIndex.UrlEncode()}";
  208. //https://pub.alimama.com/openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json?t=1719477837298&_tb_token_=7537e7ed93338&pageNo=92&pageSize=20&startTime=2024-03-31&endTime=2024-03-31&payStatus=&queryType=2&jumpType=1&tkTradeId=&positionIndex=1711883373_2vtPPr7CyYX2%7C1711883522_4zcICUeUevh2
  209. //https://pub.alimama.com/openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json?t=1719477942492&_tb_token_=7537e7ed93338&pageNo=7&pageSize=20&startTime=2024-03-31&endTime=2024-03-31&payStatus=&queryType=2&jumpType=1&tkTradeId=&positionIndex=1711899163_4zdpOH1mbTQ2%7C1711899483_4zbH9BHqgl82
  210. string body = "";
  211. JsonElement data;
  212. try
  213. {
  214. for (var i = 1; i <= 5; i++)
  215. {
  216. var client = new WebClientUtility().SetContentType("application/json;charset=utf-8")
  217. .AddHeaders("X-Requested-With", "XMLHttpRequest")
  218. .AddHeaders("Cookie", _cookies);
  219. #if DEBUG
  220. #else
  221. client.Proxy = _proxy;
  222. #endif
  223. if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
  224. var response = client.Request(url);
  225. if (response.ResponseException != null)
  226. {
  227. _ = new LoggerLibrary("api_error", "fail")
  228. .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
  229. .SaveAsync();
  230. throw response.ResponseException;
  231. }
  232. body = response.Body();
  233. #if DEBUG
  234. _ = new LoggerLibrary("debug", "GetTkOrders")
  235. .Info(body)
  236. .SaveAsync();
  237. #endif
  238. if (body.Contains("{\"action\":\"captcha\""))
  239. {
  240. string message = $"【GetTkOrders】【{_accountId}:{_accountName}】第 {i} 次出现滑动验证码";
  241. NotifyCore.Notify(new NifyMessage
  242. {
  243. message = message,
  244. priority = NifyMessagePriority.high,
  245. tags = ["red_circle"]
  246. });
  247. Thread.Sleep(i * 60 * 1000);
  248. continue;
  249. }
  250. if (body.Contains("\"resultCode\":500"))
  251. {
  252. //{"success":false,"resultCode":500,"bizErrorDesc":"系统繁忙,请稍后重试!","bizErrorCode":3001}
  253. string message = $"【GetTkOrders】【{_accountId}:{_accountName}】第 {i} 次出现错误\n{body}";
  254. NotifyCore.Notify(new NifyMessage
  255. {
  256. message = message,
  257. priority = NifyMessagePriority.high,
  258. tags = ["red_circle"]
  259. });
  260. Thread.Sleep(i * 60 * 1000);
  261. continue;
  262. }
  263. break;
  264. }
  265. /*
  266. <script>sessionStorage.x5referer = window.location.href;var url = window.location.protocol + "//pub.alimama.com//openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json/_____tmd_____/punish?x5secdata=xc1iwR0XfHknuQ2tGhtadtTAvEt14YScfTDHt2ZiSRqroaYZK98uykgsVOy7o75Rw8uuycKT3Rpx30%2fB5H0gRc0%2fJVGQUcV5g%2fsAmZ%2bc46eyD7DXSdA4R3mLnmtbp9wuZ1vmrG3ZPlH7brUilFbXBdZ7EBrru1X7wPfC05Eq3g4mhDFiGq39xUtwQcC%2f%2bPbtekcm8%2fVJ%2brVt8aExunwzXzJPJJTAvEt14YScfTDHt2ZiSRqroaYZK98uykgsiXIkw%2ffMWwebJ3zxCja5CzSu%2ffTA%3d%3d__bx__pub.alimama.com%2fopenapi%2fparam2%2f1%2fgateway.unionpub%2freport.getTbkOrderDetails.json&x5step=1";window.location.replace(url);window._config_ = {"action":"captcha","url":"https://pub.alimama.com//openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json/_____tmd_____/punish?x5secdata=xc1iwR0XfHknuQ2tGhtadtTAvEt14YScfTDHt2ZiSRqroaYZK98uykgsVOy7o75Rw8uuycKT3Rpx30%2fB5H0gRc0%2fJVGQUcV5g%2fsAmZ%2bc46eyD7DXSdA4R3mLnmtbp9wuZ1vmrG3ZPlH7brUilFbXBdZ7EBrru1X7wPfC05Eq3g4mhDFiGq39xUtwQcC%2f%2bPbtekcm8%2fVJ%2brVt8aExunwzXzJPJJTAvEt14YScfTDHt2ZiSRqroaYZK98uykgsiXIkw%2ffMWwebJ3zxCja5CzSu%2ffTA%3d%3d__bx__pub.alimama.com%2fopenapi%2fparam2%2f1%2fgateway.unionpub%2freport.getTbkOrderDetails.json&x5step=1"};</script><!--rgv587_flag:sm--> */
  267. var root = body.Convert2JsonElement();
  268. var success = root.Read<bool>("success");
  269. data = root.ElementRead("data");
  270. //{"code":601,"info":{"ok":false,"message":"nologin"}}
  271. if (!success && body.Contains("nologin"))
  272. {
  273. (success, string message) = RenewCookie();
  274. if (!success)
  275. {
  276. TkPoolCore.Disabled(_accountId, _accountName, $"{body}");
  277. }
  278. return (0, DateTime.MinValue, new List<DateTime>());
  279. }
  280. if (!success)
  281. {
  282. throw new APIException(body);
  283. }
  284. }
  285. catch (Exception ex)
  286. {
  287. throw new APIException(body);
  288. }
  289. using var conn = DBContext.GetOpenConnection();
  290. conn.Open();
  291. try
  292. {
  293. foreach (var order in data.ElementRead("result").EnumerateArray())
  294. {
  295. TkOrderDetailDTO item = order.GetRawText().Convert2Object<TkOrderDetailDTO>();
  296. // 处理每个订单数据
  297. item.accountId = _accountId;
  298. item.accountName = _company;
  299. if (item.modifiedTime > max_modifiedTime) max_modifiedTime = item.modifiedTime;
  300. if (last_modifiedTime != DateTime.MinValue && last_modifiedTime >= item.modifiedTime)
  301. {
  302. return (total, max_modifiedTime, orderTimes);
  303. }
  304. //进行订单和转链匹配
  305. item.itemId = GetRawItemId(item.mktId);
  306. if (item.tkStatus == 3 && item.tbPaidTime != DateTime.MinValue) orderTimes.Add(item.tbPaidTime.Date);
  307. int? id = conn.Replace(item);
  308. if (id != null)
  309. {
  310. item.id = (int)id;
  311. TkOrderTrackingCore.MatchOrder(item, conn);
  312. }
  313. total++;
  314. }
  315. }
  316. catch (Exception ex)
  317. {
  318. throw;
  319. }
  320. finally
  321. {
  322. conn.Dispose();
  323. }
  324. pageNo++;
  325. hasNext = data.Read<bool>("hasNext");
  326. positionIndex = data.Read<string>("positionIndex");
  327. if (sleep > 0) Thread.Sleep(sleep);
  328. }
  329. return (total, max_modifiedTime, orderTimes);
  330. }
  331. string GetRawItemId(string mktId)
  332. {
  333. try
  334. {
  335. string cacheKey = $":cache:mkt2itemId:{mktId}";
  336. string itemId = RedisHelper.Get(cacheKey);
  337. if (itemId != null) return itemId;
  338. var ts = DateTime.Now.Convert2UnixTimestamp(true);
  339. string url = "https://pub.alimama.com/openapi/param2/1/gateway.unionpub/union.moose.content.entry";
  340. //string url = $"{base_orders_url}?t={ts}&_tb_token_={_tb_token}&pageNo={pageNo}&pageSize={pageSize}&startTime={startTime:yyyy-MM-dd}&endTime={endTime:yyyy-MM-dd}&payStatus=&queryType={queryType}&jumpType={jumpType}&tkTradeId=&positionIndex={positionIndex}";
  341. var client = new WebClientUtility()
  342. .SetContentType("application/x-www-form-urlencoded")
  343. .AddHeaders("Cookie", _cookies)
  344. .AddHeaders("Origin", "https://pub.alimama.com")
  345. .Post("_tb_token_", _tb_token)
  346. .Post("t", ts.ToString())
  347. .Post("bizType", "detailPage")
  348. .Post("bizParam", $"{{\"itemId\":\"{mktId}\"}}");
  349. //_tb_token_=3b88755bbe3f7&t=1718896771391&bizType=detailPage&bizParam=%7B%22itemId%22%3A%22JbtMUqkGMQvagTNb2Fvta-9ag242pu7MOX5e0bsrY%22%7D
  350. //_tb_token_=361e383eb61e5&t=1718895935097&bizType=detailPage&bizParam=%7B%22itemId%22%3A%22JbtMUqkGMQvagTNb2Fvta-9ag242pu7MOX5e0bsrY%22%7D
  351. #if DEBUG
  352. #else
  353. client.Proxy = _proxy;
  354. #endif
  355. if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
  356. var response = client.Request(url);
  357. if (!response.Successed)
  358. {
  359. throw response.ResponseException;
  360. }
  361. var body = response.Body();
  362. var root = body.Convert2JsonElement();
  363. itemId = root.PathRead<string>("model.item.itemId");
  364. if (!string.IsNullOrEmpty(itemId))
  365. {
  366. RedisHelper.Set(cacheKey, itemId, 86400 * 7);
  367. }
  368. return itemId;
  369. }
  370. catch (Exception ex)
  371. {
  372. string message = $"【GetRawItemId】[{mktId}\n{ex.Message}\n{ex.StackTrace}";
  373. NotifyCore.Notify(new NifyMessage
  374. {
  375. message = message,
  376. priority = NifyMessagePriority.high,
  377. tags = ["red_circle"]
  378. });
  379. }
  380. return null;
  381. }
  382. public void GetTkOrders222()
  383. {
  384. try
  385. {
  386. string url = "https://media.alimama.com/violationu2/warning_instance_page_v2.json?r=mx_208&toPage=1&pageSize=40&params=";
  387. var client = new WebClientUtility().SetContentType("application/json;charset=utf-8")
  388. .AddHeaders("X-Requested-With", "XMLHttpRequest")
  389. .AddHeaders("Cookie", _cookies);
  390. client.Proxy = _proxy;
  391. if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
  392. var response = client.Request(url);
  393. var body = response.Body();
  394. var root = body.Convert2JsonElement();
  395. int resultCode = root.Read<int>("resultCode", 0);
  396. int totalCount = root.PathRead<int>("data.totalCount", 0);
  397. bool success = root.Read("success", false);
  398. if (!success)
  399. {
  400. _ = new LoggerLibrary("violationu", "warning_error")
  401. .Info(url, body)
  402. .SaveAsync();
  403. throw new Exception(body);
  404. }
  405. if (totalCount == 0) return;
  406. _ = new LoggerLibrary("violationu", "warning").Info(url, body).SaveAsync();
  407. var list = root.ElementRead("data").ElementRead("result").EnumerateArray();
  408. foreach (var data in list)
  409. {
  410. var violation_commission = data.PathRead<decimal>("mediaInfo.订单虚假交易违规佣金", 0);
  411. new DBContext.Table("alimama_warning")
  412. .Fill(data)
  413. .Loader<int>("filterRuleId", 0)
  414. .Loader<long>("gmtCreate", 0)
  415. .Loader<long>("id", 0, "ali_id")
  416. .Loader<string>("idStr", string.Empty)
  417. .Loader<int>("mediaDimension", 0)
  418. .Loader<long>("mediaId", 0)
  419. .Loader<int>("mediaInfo.abn_cnt", 0, "abn_cnt")
  420. .Add("violation_commission", violation_commission)
  421. .Loader<int>("mediaInfo.warning_cnt", 0, "warning_cnt")
  422. .Loader<string>("mediaName", string.Empty)
  423. .Loader<long>("memberId", 0)
  424. .Loader<string>("noticeCategory", string.Empty)
  425. .Loader<int>("noticeTemplateId", 0)
  426. .Loader<string>("noticeTemplateName", string.Empty)
  427. .Loader<string>("orderFile", string.Empty)
  428. .Loader<string>("pid", string.Empty)
  429. .Loader<int>("punishRuleId", 0)
  430. .Loader<string>("riskType", string.Empty)
  431. .Loader<string>("roleName", string.Empty)
  432. .Loader<string>("ruleLink", string.Empty)
  433. .Loader<bool>("showOrderDetail", false)
  434. .Loader<int>("status", 0, "ali_status")
  435. .Loader<string>("warningText", string.Empty)
  436. .Add("accountName", _accountName)
  437. .Add("status", true)
  438. .Add("create_time", DateTime.Now)
  439. .Add("last_time", DateTime.Now)
  440. .Create(DBContext.InsertType.REPLACE);
  441. }
  442. }
  443. catch (Exception ex) { }
  444. }
  445. }
  446. }