TkController.cs 25 KB

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