TkController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. using molilian.core;
  2. using dodohold.core;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Org.BouncyCastle.Ocsp;
  5. using System.Text.Json;
  6. using System.Runtime.InteropServices;
  7. using System.Net;
  8. using System.Security.Cryptography;
  9. using Microsoft.AspNetCore.Authentication;
  10. using TencentCloud.Ecm.V20190719.Models;
  11. using COSXML.Network;
  12. using System.Linq;
  13. using static dodohold.core.ZTOExpress.CreateOrderArgs;
  14. using MySqlX.XDevAPI;
  15. namespace molilian.api.Controllers
  16. {
  17. [ApiController]
  18. [Route("[controller]/[action]")]
  19. public class TkController : ControllerBase
  20. {
  21. protected IHttpContextAccessor _accessor;
  22. public TkController(IHttpContextAccessor accessor)
  23. {
  24. _accessor = accessor;
  25. }
  26. /// <summary>
  27. /// oppo调用
  28. /// </summary>
  29. /// <param name="s">正文</param>
  30. /// <param name="c">渠道。tb/jd</param>
  31. /// <param name="a">分配的客户端账号</param>
  32. /// <param name="t">11位时间戳</param>
  33. /// <param name="sign">签名</param>
  34. /// <param name="ip">客户的IP</param>
  35. /// <param name="oaid">客户的唯一ID</param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. public async Task<ActionResult> unionParse([FromBody] JsonElement form, [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
  39. {
  40. //正文
  41. var content = form.Read("s", string.Empty);
  42. var channel = form.Read("c", string.Empty);
  43. var ip = form.Read("ip", string.Empty);
  44. var oaid = form.Read("oaid", string.Empty);
  45. //验证签名
  46. if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(sign))
  47. {
  48. return new APIResult(new { success = false, message = "验证错误" }, APIResultCodeEnum.Unauthorized);
  49. }
  50. DateTime time1 = t.Convert2Datetime();
  51. if (time1 < DateTime.Now.AddMinutes(-10))
  52. {
  53. return new APIResult(new { success = false, message = "验证错误2" }, APIResultCodeEnum.Unauthorized);
  54. }
  55. var account = ApiAccountCore.GetOne(a);
  56. if (account == null)
  57. {
  58. return new APIResult(new { success = false, message = "验证错误3" }, APIResultCodeEnum.Unauthorized);
  59. }
  60. string app_sign = $"{account.api_secret}@{t}".MD5();
  61. if (sign != app_sign)
  62. {
  63. return new APIResult(new { success = false, message = "验证错误4" }, APIResultCodeEnum.Unauthorized);
  64. }
  65. return await UnionParseCore.UnionParseAsync(content, channel, ip, oaid);
  66. }
  67. [HttpPost]
  68. public async Task<ActionResult> unsafeParse([FromBody] JsonElement form)
  69. {
  70. var content = form.Read("s", string.Empty);
  71. var channel = form.Read("c", string.Empty);
  72. var ip = form.Read("ip", string.Empty);
  73. var oaid = form.Read("oaid", string.Empty);
  74. int accountid = form.Read("aid", 0);
  75. #if DEBUG
  76. ip = "127.0.0.1";
  77. oaid = "test-oaid";
  78. #endif
  79. return await UnionParseCore.UnionParseAsync(content, channel, ip, oaid, accountid);
  80. }
  81. [HttpGet]
  82. public async Task<ActionResult> tesjd(int aid, int num = 100)
  83. {
  84. var channel = "jd";
  85. string ip = "127.0.0.1";
  86. string oaid = "test-oaid";
  87. var list = new DBContext.Table("jd_parse_logs_success").Order("RAND()").Limit(num).Select<dynamic>();
  88. foreach (var item in list)
  89. {
  90. await UnionParseCore.UnionParseAsync(item.rawContent, channel, ip, oaid, aid);
  91. }
  92. return new APIResult(new { success = true, message = "ok" });
  93. }
  94. [HttpPost]
  95. public async Task<ActionResult> unionCoupon([FromBody] JsonElement form, [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
  96. {
  97. //正文
  98. var content = form.Read("s", string.Empty);
  99. var dplink = form.Read("dp", string.Empty);
  100. var channel = form.Read("c", string.Empty);
  101. var ip = form.Read("ip", string.Empty);
  102. var oaid = form.Read("oaid", string.Empty);
  103. //验证签名
  104. if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(sign))
  105. {
  106. return new APIResult(new { success = false, message = "验证错误" }, APIResultCodeEnum.Unauthorized);
  107. }
  108. DateTime time1 = t.Convert2Datetime();
  109. if (time1 < DateTime.Now.AddMinutes(-10))
  110. {
  111. return new APIResult(new { success = false, message = "验证错误2" }, APIResultCodeEnum.Unauthorized);
  112. }
  113. var account = ApiAccountCore.GetOne(a);
  114. if (account == null)
  115. {
  116. return new APIResult(new { success = false, message = "验证错误3" }, APIResultCodeEnum.Unauthorized);
  117. }
  118. string app_sign = $"{account.api_secret}@{t}".MD5();
  119. if (sign != app_sign)
  120. {
  121. return new APIResult(new { success = false, message = "验证错误4" }, APIResultCodeEnum.Unauthorized);
  122. }
  123. return await UnionCouponCore.UnionCouponAsync(content, dplink, channel, ip, oaid);
  124. }
  125. [HttpPost]
  126. public async Task<ActionResult> unsafeCoupon([FromBody] JsonElement form)
  127. {
  128. var content = form.Read("s", string.Empty);
  129. var dplink = form.Read("dp", string.Empty);
  130. var channel = form.Read("c", string.Empty);
  131. var ip = form.Read("ip", string.Empty);
  132. var oaid = form.Read("oaid", string.Empty);
  133. #if DEBUG
  134. ip = "127.0.0.1";
  135. oaid = "test-oaid";
  136. #endif
  137. return await UnionCouponCore.UnionCouponAsync(content, dplink, channel, ip, oaid);
  138. }
  139. /// <summary>
  140. /// 第三方调用
  141. /// </summary>
  142. /// <param name="s"></param>
  143. /// <param name="s2"></param>
  144. /// <returns></returns>
  145. [HttpGet]
  146. public async Task<ActionResult> parse(string s, string s2 = "", string ip = "", string oaid = "")
  147. {
  148. AlimamaPlus alimama = null;
  149. ip = AlimamaPlus.OppoDecode(ip);
  150. oaid = AlimamaPlus.OppoDecode(oaid);
  151. var result = AlimamaPlus.GetFormattedObject(s, ip, oaid);
  152. string body = "";
  153. string content = s.UrlDecode();
  154. string content2 = s2.UrlDecode();
  155. string account_name = string.Empty;
  156. result.rawContent = content;
  157. result.rawContent2 = content2;
  158. try
  159. {
  160. if (AlimamaPlus.ShouldIgnoreRequest(ip, oaid, out string reason))
  161. {
  162. result.success = false;
  163. result.message = "放弃转链";
  164. result.reason = reason;
  165. _ = TkLogCore.LogAsync(result);
  166. return new APIResult(new
  167. {
  168. result.success,
  169. result.message,
  170. result.content,
  171. result.couponAmount,
  172. result.taoToken,
  173. result.shortLinkurl,
  174. result.deeplink_url,
  175. });
  176. }
  177. var account = TkPoolCore.GetOne(TkPoolCore.TkAction.parse);
  178. if (account == null)
  179. {
  180. result.success = false;
  181. result.message = "放弃转链";
  182. result.reason = "没有匹配账号";
  183. _ = TkLogCore.LogAsync(result);
  184. return new APIResult(new
  185. {
  186. result.success,
  187. result.message,
  188. result.content,
  189. result.couponAmount,
  190. result.taoToken,
  191. result.shortLinkurl,
  192. result.deeplink_url,
  193. });
  194. }
  195. result.accountId = account.id;
  196. result.accountName = account.company;
  197. account_name = account.name;
  198. alimama = new AlimamaPlus(account);
  199. if (alimama.ShouldIgnoreOtherAff(s2))
  200. {
  201. result.success = false;
  202. result.message = "放弃转链";
  203. result.reason = "其他推广链接";
  204. _ = TkLogCore.LogAsync(result);
  205. return new APIResult(new
  206. {
  207. result.success,
  208. result.message,
  209. result.content,
  210. result.couponAmount,
  211. result.taoToken,
  212. result.shortLinkurl,
  213. result.deeplink_url,
  214. });
  215. }
  216. result = await alimama.UnionParseAsync(content, result);
  217. }
  218. catch (Exception ex)
  219. {
  220. if (ex.Message.Contains("was canceled"))
  221. {
  222. result.success = false;
  223. result.message = "放弃转链";
  224. result.reason = "请求超时";
  225. }
  226. else
  227. {
  228. //new LoggerLibrary("api_error", "parse")
  229. //.Info(s, s2)
  230. //.Info($"【taobao】{account_name}", body)
  231. //.Info(ex.Message, ex.StackTrace)
  232. //.SaveAsync();
  233. NotifyCore.Notify(new NifyMessage
  234. {
  235. message = $"【转链接口异常】{result.accountName}\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
  236. priority = NifyMessagePriority.high,
  237. tags = ["red_circle"]
  238. });
  239. result.success = false;
  240. result.message = "放弃转链";
  241. result.reason = "转链接口异常";
  242. }
  243. }
  244. _ = TkLogCore.LogAsync(result, alimama);
  245. return new APIResult(new
  246. {
  247. result.success,
  248. result.message,
  249. result.content,
  250. result.couponAmount,
  251. result.taoToken,
  252. result.shortLinkurl,
  253. result.deeplink_url,
  254. });
  255. }
  256. [HttpGet]
  257. public ActionResult parse2(string s, string s2 = "", string ip = "", string oaid = "")
  258. {
  259. AlimamaPlus alimama = null;
  260. ip = AlimamaPlus.OppoDecode(ip);
  261. oaid = AlimamaPlus.OppoDecode(oaid);
  262. var result = AlimamaPlus.GetFormattedObject(s, ip, oaid);
  263. string body = "";
  264. string content = s.UrlDecode();
  265. string content2 = s2.UrlDecode();
  266. string account_name = string.Empty;
  267. result.rawContent = content;
  268. result.rawContent2 = content2;
  269. try
  270. {
  271. if (AlimamaPlus.ShouldIgnoreRequest(ip, oaid, out string reason))
  272. {
  273. result.success = false;
  274. result.message = "放弃转链";
  275. result.reason = reason;
  276. _ = TkLogCore.LogAsync(result);
  277. return new APIResult(new
  278. {
  279. result.success,
  280. result.message,
  281. result.content,
  282. result.couponAmount,
  283. result.taoToken,
  284. result.shortLinkurl,
  285. result.deeplink_url,
  286. });
  287. }
  288. var account = TkPoolCore.GetOne(TkPoolCore.TkAction.parse);
  289. if (account == null)
  290. {
  291. result.success = false;
  292. result.message = "放弃转链";
  293. result.reason = "没有匹配账号";
  294. _ = TkLogCore.LogAsync(result);
  295. return new APIResult(new
  296. {
  297. result.success,
  298. result.message,
  299. result.content,
  300. result.couponAmount,
  301. result.taoToken,
  302. result.shortLinkurl,
  303. result.deeplink_url,
  304. });
  305. }
  306. account_name = account.name;
  307. alimama = new AlimamaPlus(account);
  308. if (alimama.ShouldIgnoreOtherAff(s2))
  309. {
  310. result.success = false;
  311. result.message = "放弃转链";
  312. result.reason = "其他推广链接";
  313. _ = TkLogCore.LogAsync(result);
  314. return new APIResult(new
  315. {
  316. result.success,
  317. result.message,
  318. result.content,
  319. result.couponAmount,
  320. result.taoToken,
  321. result.shortLinkurl,
  322. result.deeplink_url,
  323. });
  324. }
  325. alimama.UnionParse(content, ref result);
  326. //result.ip = ip;
  327. //result.oaid = oaid;
  328. }
  329. catch (Exception ex)
  330. {
  331. _ = new LoggerLibrary("api_error", "parse")
  332. .Info(s, s2)
  333. .Info($"【taobao】{account_name}", body)
  334. .Info(ex.Message, ex.StackTrace)
  335. .SaveAsync();
  336. NotifyCore.Notify(new NifyMessage
  337. {
  338. message = $"【转链接口异常】{account_name}\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
  339. priority = NifyMessagePriority.high,
  340. tags = ["red_circle"]
  341. });
  342. result.success = false;
  343. result.message = "放弃转链";
  344. result.reason = "转链接口异常";
  345. }
  346. _ = TkLogCore.LogAsync(result, alimama);
  347. return new APIResult(new
  348. {
  349. result.success,
  350. result.message,
  351. result.content,
  352. result.couponAmount,
  353. result.taoToken,
  354. result.shortLinkurl,
  355. result.deeplink_url,
  356. });
  357. }
  358. [HttpGet]
  359. public ActionResult jd_parse(string s, string s2 = "", string ip = "", string oaid = "")
  360. {
  361. var result = JdUnionPlus.GetFormattedObject(s, ip, oaid);
  362. string body = "";
  363. string content = s.UrlDecode();
  364. string content2 = s2.UrlDecode();
  365. try
  366. {
  367. if (AlimamaPlus.ShouldIgnoreRequest(ip, oaid, out string reason))
  368. {
  369. result.success = false;
  370. result.message = "放弃转链";
  371. result.reason = reason;
  372. result.rawContent = content;
  373. result.rawContent2 = content2;
  374. _ = TkLogCore.LogAsync(result);
  375. return new APIResult(result);
  376. }
  377. var api = DataokeCore.GetOne();
  378. if (api == null)
  379. {
  380. result.success = false;
  381. result.message = "放弃转链";
  382. result.reason = "没有匹配账号";
  383. result.rawContent = content;
  384. result.rawContent2 = content2;
  385. _ = TkLogCore.LogAsync(result);
  386. return new APIResult(result);
  387. }
  388. var account = JdPoolCore.GetOne();
  389. if (account == null)
  390. {
  391. result.success = false;
  392. result.message = "放弃转链";
  393. result.reason = "没有匹配账号";
  394. result.rawContent = content;
  395. result.rawContent2 = content2;
  396. _ = TkLogCore.LogAsync(result);
  397. return new APIResult(result);
  398. }
  399. result = DataokeCore.JdParse(result, api, account, content);
  400. }
  401. catch (Exception ex)
  402. {
  403. _ = new LoggerLibrary("api_error")
  404. .Info(s, s2)
  405. .Info("【jd】", body)
  406. .Info(ex.Message, ex.StackTrace)
  407. .SaveAsync();
  408. NotifyCore.Notify(new NifyMessage
  409. {
  410. message = $"【转链接口异常】\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
  411. priority = NifyMessagePriority.high,
  412. tags = ["red_circle"]
  413. });
  414. result.success = false;
  415. result.message = "放弃转链";
  416. result.reason = "转链接口异常";
  417. }
  418. result.rawContent = content;
  419. result.rawContent2 = content2;
  420. _ = TkLogCore.LogAsync(result);
  421. return new APIResult(new
  422. {
  423. result.success,
  424. result.message,
  425. result.shortLinkurl,
  426. result.itemId,
  427. result.itemName,
  428. result.deeplink_url,
  429. });
  430. }
  431. [HttpGet]
  432. public async Task<ActionResult> Reload()
  433. {
  434. await EndPointCore.NotifyReload();
  435. return new APIResult(new
  436. {
  437. success = true,
  438. message = "ok",
  439. });
  440. }
  441. [HttpGet]
  442. public async Task<ActionResult> dplist([FromQuery] string query = "", [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
  443. {
  444. #if DEBUG
  445. #else
  446. //验证签名
  447. if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(sign))
  448. {
  449. return new APIResult(new { success = false, message = "验证错误" }, APIResultCodeEnum.Unauthorized);
  450. }
  451. DateTime time1 = t.Convert2Datetime();
  452. if (time1 < DateTime.Now.AddMinutes(-10))
  453. {
  454. return new APIResult(new { success = false, message = "验证错误2" }, APIResultCodeEnum.Unauthorized);
  455. }
  456. var account = ApiAccountCore.GetOne(a);
  457. if (account == null)
  458. {
  459. return new APIResult(new { success = false, message = "验证错误3" }, APIResultCodeEnum.Unauthorized);
  460. }
  461. string app_sign = $"{account.api_secret}@{t}".MD5();
  462. if (sign != app_sign)
  463. {
  464. return new APIResult(new { success = false, message = "验证错误4" }, APIResultCodeEnum.Unauthorized);
  465. }
  466. if (string.IsNullOrEmpty(query))
  467. {
  468. return new APIResult(new { success = false, message = "查询条件不能为空" });
  469. }
  470. #endif
  471. string filter = $"batchId=@query";
  472. var account_list = TkPoolCore.List();
  473. List<int> account_ids = [];
  474. if (account_list.Any())
  475. {
  476. account_ids = account_list.Where(e => e.enable_fake_click).Select(e => e.id).ToList();
  477. filter += $" AND accountId IN @account_ids";
  478. }
  479. string orderBy = "paid_time ASC";
  480. var data = new DBContext.Table("tk_order_tracking")
  481. .Where(filter, new { query, account_ids })
  482. .Order(orderBy)
  483. .Select<TkOrderTrackingDTO>();
  484. List<object> list = [];
  485. foreach (var item in data)
  486. {
  487. list.Add(new { item.accountId, url = item.deeplinkUrl, item.shortLinkUrl, count = item.click_num, time = item.exp_time });
  488. }
  489. var clientIp = _accessor.HttpContext.GetUserIp();
  490. LoggerLibrary log = new LoggerLibrary("api", "dplist");
  491. log.Info($"{clientIp}\t{query}\tcount:{list.Count}");
  492. var ids = data.Select(e => e.Id).ToArray();
  493. log.Info(string.Join(',', ids));
  494. _ = log.SaveAsync();
  495. var update = new DBContext.Table("tk_order_tracking")
  496. .Add("clicked_num:", "clicked_num+1")
  497. .Where("id IN @ids", new { ids })
  498. .Update();
  499. return new APIResult(new
  500. {
  501. success = true,
  502. message = list.Count == 0 ? "none" : "ok",
  503. count = list.Count,
  504. data = list,
  505. });
  506. }
  507. [HttpGet]
  508. public async Task<ActionResult> unsafeParseDpList([FromQuery] string query = "")
  509. {
  510. string filter = $"batchId=@query";
  511. var account_list = TkPoolCore.List();
  512. List<int> account_ids = [];
  513. if (account_list.Any())
  514. {
  515. account_ids = account_list.Where(e => e.enable_fake_click).Select(e => e.id).ToList();
  516. filter += $" AND accountId IN @account_ids";
  517. }
  518. string orderBy = "paid_time ASC";
  519. var data = new DBContext.Table("tk_order_tracking")
  520. .Where(filter, new { query, account_ids })
  521. .Order(orderBy)
  522. .Select<TkOrderTrackingDTO>();
  523. List<object> list = [];
  524. foreach (var item in data)
  525. {
  526. list.Add(new { item.accountId, url = item.deeplinkUrl, item.shortLinkUrl, count = item.click_num, time = item.exp_time });
  527. }
  528. var clientIp = _accessor.HttpContext.GetUserIp();
  529. LoggerLibrary log = new LoggerLibrary("api", "unsafeParseDpList");
  530. log.Info($"{clientIp}\t{query}\tcount:{list.Count}");
  531. var ids = data.Select(e => e.Id).ToArray();
  532. log.Info(string.Join(',', ids));
  533. _ = log.SaveAsync();
  534. return new APIResult(new
  535. {
  536. success = true,
  537. message = list.Count == 0 ? "none" : "ok",
  538. count = list.Count,
  539. data = list,
  540. });
  541. }
  542. [HttpPost]
  543. public async Task<ActionResult> dataReport([FromBody] JsonElement form, [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
  544. {
  545. bool debug = form.Read("debug", false);
  546. var clientIp = _accessor.HttpContext.GetUserIp();
  547. var log = new LoggerLibrary("ApiReportCore", "dataReport");
  548. log.Info(clientIp);
  549. //验证签名
  550. if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(sign))
  551. {
  552. _ = log.Info($"a:{a}\tt:{t}\tsign:{sign}\t", $"message:验证错误")
  553. .Info(form.GetRawText())
  554. .SaveAsync();
  555. return new APIResult(new { success = false, message = "验证错误" }, APIResultCodeEnum.Unauthorized);
  556. }
  557. DateTime time1 = t.Convert2Datetime();
  558. if (time1 < DateTime.Now.AddMinutes(-10))
  559. {
  560. _ = log.Info($"a:{a}\tt:{t}\tsign:{sign}\t", $"message:验证错误2")
  561. .Info(form.GetRawText())
  562. .SaveAsync();
  563. return new APIResult(new { success = false, message = "验证错误2" }, APIResultCodeEnum.Unauthorized);
  564. }
  565. var account = ApiAccountCore.GetOne(a);
  566. if (account == null || !account.enable_report)
  567. {
  568. _ = log.Info($"a:{a}\tt:{t}\tsign:{sign}\t", $"message:验证错误3")
  569. .Info(form.GetRawText())
  570. .SaveAsync();
  571. return new APIResult(new { success = false, message = "验证错误3" }, APIResultCodeEnum.Unauthorized);
  572. }
  573. string app_sign = $"{account.api_secret}@{t}".MD5();
  574. if (sign != app_sign)
  575. {
  576. _ = log.Info($"a:{a}\tt:{t}\tsign:{sign}\tapp_sign:{app_sign}", $"message:验证错误4")
  577. .Info(form.GetRawText())
  578. .SaveAsync();
  579. return new APIResult(new { success = false, message = "验证错误4" }, APIResultCodeEnum.Unauthorized);
  580. }
  581. try
  582. {
  583. var data = await ApiReportCore.ReportDailysAsync(form, clientIp, debug);
  584. _ = log.Info(form.GetRawText(), data.Convert2Json()).SaveAsync();
  585. return new APIResult(new { success = true, data });
  586. }
  587. catch (Exception ex)
  588. {
  589. _ = log.Info(form.GetRawText()).Info(ex.Message, ex.StackTrace).SaveAsync();
  590. return new APIResult(new { success = false, message = "内部错误" });
  591. }
  592. }
  593. [HttpPost]
  594. public async Task<ActionResult> unsafeDataReport([FromBody] JsonElement form)
  595. {
  596. bool debug = form.Read("debug", false);
  597. var clientIp = _accessor.HttpContext.GetUserIp();
  598. var log = new LoggerLibrary("ApiReportCore", "unsafeDataReport");
  599. log.Info(clientIp);
  600. try
  601. {
  602. var data = await ApiReportCore.ReportDailysAsync(form, clientIp, debug);
  603. _ = log.Info(form.GetRawText(), data.Convert2Json()).SaveAsync();
  604. return new APIResult(new { success = true, data });
  605. }
  606. catch (Exception ex)
  607. {
  608. _ = log.Info(form.GetRawText()).Info(ex.Message, ex.StackTrace).SaveAsync();
  609. return new APIResult(new { success = false, message = "内部错误" });
  610. }
  611. }
  612. }
  613. }