TkController.cs 26 KB

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