TaskController.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  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.Threading.Channels;
  9. using TencentCloud.Cdwch.V20200915.Models;
  10. using COSXML.Network;
  11. using System.Security.Cryptography;
  12. using System.Threading;
  13. using TencentCloud.Batch.V20170312.Models;
  14. namespace molilian.api.Controllers
  15. {
  16. [ApiController]
  17. [Route("[controller]_70160bd632/[action]")]
  18. public class TaskController : ControllerBase
  19. {
  20. protected IHttpContextAccessor _accessor;
  21. public TaskController(IHttpContextAccessor accessor)
  22. {
  23. _accessor = accessor;
  24. }
  25. [HttpGet]
  26. public ActionResult BatchInsertLogDB(int limit = 100)
  27. {
  28. int total = TkLogCore.BatchInsertLogDB(limit);
  29. return new APIResult(new { success = true, message = "ok", limit, total });
  30. }
  31. [HttpGet]
  32. public async Task<ActionResult> GetSettleBills(int sleep = 2000)
  33. {
  34. var list = TkPoolCore.List();
  35. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  36. string message = string.Empty;
  37. int total = 0;
  38. foreach (var account in list)
  39. {
  40. if (!account.enable_sync_order) continue;
  41. #if DEBUG
  42. if (13 != account.id) continue;
  43. #endif
  44. try
  45. {
  46. var alimama = new AlimamaPlus(account);
  47. total += alimama.GetSettleBills(sleep);
  48. }
  49. catch (Exception ex)
  50. {
  51. message = $"【收益接口异常】\t{account.name}\n{ex.Message}\n{ex.StackTrace}";
  52. NotifyCore.Notify(new NifyMessage
  53. {
  54. message = message,
  55. priority = NifyMessagePriority.high,
  56. tags = ["red_circle"]
  57. });
  58. continue;
  59. }
  60. }
  61. return new APIResult(new { success = true, message = "ok", total });
  62. }
  63. [HttpGet]
  64. public async Task<ActionResult> GetHistoryOrders(int id, int sleep, DateTime startTime, DateTime endTime)
  65. {
  66. var list = TkPoolCore.List();
  67. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  68. if (id == 0) return new APIResult(new { success = false, message = "没有有效账号", });
  69. string message = string.Empty;
  70. int total = 0;
  71. foreach (var account in list)
  72. {
  73. if (id != account.id) continue;
  74. try
  75. {
  76. //DateTime endTime = DateTime.Now;
  77. //DateTime startTime = endTime.AddDays(-90);
  78. if (account.id == 3) endTime = DateTime.Parse("2024-04-07");
  79. var alimama = new AlimamaPlus(account);
  80. total += alimama.GetHistoryOrders(sleep, startTime, endTime);
  81. }
  82. catch (Exception ex)
  83. {
  84. message = $"【历史订单接口异常】[{account.id}]{account.company}\n{ex.Message}\n{ex.StackTrace}";
  85. NotifyCore.Notify(new NifyMessage
  86. {
  87. message = message,
  88. priority = NifyMessagePriority.high,
  89. tags = ["red_circle"]
  90. });
  91. continue;
  92. }
  93. }
  94. return new APIResult(new { success = true, message = "ok", total });
  95. }
  96. [HttpGet]
  97. public async Task<ActionResult> GetIncyOrders(int sleep = 2000)
  98. {
  99. var list = TkPoolCore.List();
  100. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  101. string message = string.Empty;
  102. int total = 0;
  103. foreach (var account in list)
  104. {
  105. #if DEBUG
  106. if (account.id != 17) continue;
  107. #endif
  108. if (!account.enable_sync_order) continue;
  109. try
  110. {
  111. var alimama = new AlimamaPlus(account);
  112. total += alimama.GetIncyOrders(sleep);
  113. }
  114. catch (Exception ex)
  115. {
  116. message = $"【新增订单接口异常】[{account.id}]{account.company}\n{ex.Message}\n{ex.StackTrace}";
  117. NotifyCore.Notify(new NifyMessage
  118. {
  119. message = message,
  120. priority = NifyMessagePriority.high,
  121. tags = ["red_circle"]
  122. });
  123. continue;
  124. }
  125. }
  126. return new APIResult(new { success = true, message = "ok", total });
  127. }
  128. [HttpGet]
  129. public async Task<ActionResult> GetHistoryRefundOrders(int id, int sleep, DateTime startTime, DateTime endTime)
  130. {
  131. var list = TkPoolCore.List();
  132. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  133. if (id == 0) return new APIResult(new { success = false, message = "没有有效账号", });
  134. string message = string.Empty;
  135. int total = 0;
  136. foreach (var account in list)
  137. {
  138. if (id != account.id) continue;
  139. try
  140. {
  141. //DateTime endTime = DateTime.Now;
  142. //DateTime startTime = endTime.AddDays(-90);
  143. if (account.id == 3) endTime = DateTime.Parse("2024-04-07");
  144. var alimama = new AlimamaPlus(account);
  145. total += alimama.GetHistoryRefundOrders(sleep, startTime, endTime);
  146. }
  147. catch (Exception ex)
  148. {
  149. message = $"【维权订单接口异常】[{account.id}]{account.company}\n{ex.Message}\n{ex.StackTrace}";
  150. NotifyCore.Notify(new NifyMessage
  151. {
  152. message = message,
  153. priority = NifyMessagePriority.high,
  154. tags = ["red_circle"]
  155. });
  156. continue;
  157. }
  158. }
  159. return new APIResult(new { success = true, message = "ok", total });
  160. }
  161. [HttpGet]
  162. public async Task<ActionResult> GetIncyRefundOrders(int sleep = 2000)
  163. {
  164. var list = TkPoolCore.List();
  165. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  166. string message = string.Empty;
  167. int total = 0;
  168. foreach (var account in list)
  169. {
  170. #if DEBUG
  171. if (account.id != 17) continue;
  172. #endif
  173. if (!account.enable_sync_order) continue;
  174. try
  175. {
  176. var alimama = new AlimamaPlus(account);
  177. total += alimama.GetIncyRefundOrders(sleep);
  178. }
  179. catch (Exception ex)
  180. {
  181. message = $"【维权订单接口异常】[{account.id}]{account.company}\n{ex.Message}\n{ex.StackTrace}";
  182. NotifyCore.Notify(new NifyMessage
  183. {
  184. message = message,
  185. priority = NifyMessagePriority.high,
  186. tags = ["red_circle"]
  187. });
  188. continue;
  189. }
  190. }
  191. return new APIResult(new { success = true, message = "ok", total });
  192. }
  193. [HttpGet]
  194. public async Task<ActionResult> GetViolationuWarning()
  195. {
  196. var list = TkPoolCore.List();
  197. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  198. string message = string.Empty;
  199. foreach (var account in list)
  200. {
  201. try
  202. {
  203. var alimama = new AlimamaPlus(account);
  204. alimama.GetViolationuWarning();
  205. }
  206. catch (Exception ex)
  207. {
  208. message = $"【报表接口异常】FastReport\n{ex.Message}\n{ex.StackTrace}";
  209. NotifyCore.Notify(new NifyMessage
  210. {
  211. message = message,
  212. priority = NifyMessagePriority.high,
  213. tags = ["red_circle"]
  214. });
  215. continue;
  216. }
  217. }
  218. return new APIResult(new { success = true, message = "ok" });
  219. }
  220. [HttpGet]
  221. public async Task<ActionResult> DailyLogs(int intervalDay = 1)
  222. {
  223. try
  224. {
  225. //本节点统计
  226. AlimamaPlus.NodeDailyLogs(intervalDay, "parse_", "tb");
  227. AlimamaPlus.NodeDailyLogs(intervalDay, "coupon_", "tb");
  228. AlimamaPlus.NodeDailyLogs(intervalDay); //第三方老的统计
  229. if (CenterHub.IsCenter)
  230. {
  231. JdUnionPlus.DailyLogs(intervalDay);
  232. ToolParsePlus.DailyLogs(intervalDay);
  233. //中心服务器统计
  234. AlimamaPlus.AllDailyLogs(intervalDay, "parse_", "tb");
  235. AlimamaPlus.AllDailyLogs(intervalDay, "coupon_", "tb");
  236. AlimamaPlus.AllDailyLogs(intervalDay);
  237. }
  238. }
  239. catch (Exception ex)
  240. {
  241. string message = $"【报表接口异常】DailyLogs\n{ex.Message}\n{ex.StackTrace}";
  242. NotifyCore.Notify(new NifyMessage
  243. {
  244. message = message,
  245. priority = NifyMessagePriority.high,
  246. tags = ["red_circle"]
  247. });
  248. }
  249. if (intervalDay > 0)
  250. {
  251. try
  252. {
  253. AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
  254. AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
  255. }
  256. catch (Exception ex)
  257. {
  258. string message = $"【API报表更新异常】ApiCallStatistics\n{ex.Message}\n{ex.StackTrace}";
  259. NotifyCore.Notify(new NifyMessage
  260. {
  261. message = message,
  262. priority = NifyMessagePriority.high,
  263. tags = ["red_circle"]
  264. });
  265. }
  266. }
  267. return new APIResult(new { success = true, message = "ok" });
  268. }
  269. [HttpGet]
  270. public async Task<ActionResult> DailyTable(int days = 7)
  271. {
  272. try
  273. {
  274. for (int i = 0; i < days; i++)
  275. {
  276. string table_suffix = DateTime.Now.AddDays(i).ToString("yyyyMMdd");
  277. string sql = $"CREATE TABLE IF NOT EXISTS tk_parse_logs_{table_suffix} LIKE tk_parse_logs;";
  278. DBContext.Execute(sql, null);
  279. sql = $"CREATE TABLE IF NOT EXISTS jd_parse_logs_{table_suffix} LIKE jd_parse_logs;";
  280. DBContext.Execute(sql, null);
  281. }
  282. TkLogCore.save_dailys_log = true;
  283. RedisHelper.Set("turn:save_dailys_log", 1, 86400);
  284. }
  285. catch (Exception ex)
  286. {
  287. string message = $"【创建数据标错误】\n{ex.Message}\n{ex.StackTrace}";
  288. NotifyCore.Notify(new NifyMessage
  289. {
  290. message = message,
  291. priority = NifyMessagePriority.high,
  292. tags = ["red_circle"]
  293. });
  294. }
  295. return new APIResult(new { success = true, message = "ok" });
  296. }
  297. [HttpGet]
  298. public async Task<ActionResult> ApiCallStatistics(int intervalDay = 1)
  299. {
  300. try
  301. {
  302. AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
  303. AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
  304. }
  305. catch (Exception ex)
  306. {
  307. string message = $"【API报表更新异常】ApiCallStatistics\n{ex.Message}\n{ex.StackTrace}";
  308. NotifyCore.Notify(new NifyMessage
  309. {
  310. message = message,
  311. priority = NifyMessagePriority.high,
  312. tags = ["red_circle"]
  313. });
  314. }
  315. return new APIResult(new { success = true, message = "ok" });
  316. }
  317. //[HttpGet]
  318. //public async Task<ActionResult> ApiCallStatistics(int intervalDay = 1)
  319. //{
  320. // try
  321. // {
  322. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.tb);
  323. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.tb, "parse_");
  324. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.tb, "coupon_");
  325. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.wemeet, "parse_");
  326. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.bdpan, "parse_");
  327. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.dy, "parse_");
  328. // AlimamaPlus.ApiCallStatistics(intervalDay, TkChannelEnum.jd, "parse_");
  329. // }
  330. // catch (Exception ex)
  331. // {
  332. // string message = $"【报表接口异常】ApiCallStatistics\n{ex.Message}\n{ex.StackTrace}";
  333. // NotifyCore.Notify(new NifyMessage
  334. // {
  335. // message = message,
  336. // priority = NifyMessagePriority.high,
  337. // tags = ["red_circle"]
  338. // });
  339. // }
  340. // return new APIResult(new { success = true, message = "ok" });
  341. //}
  342. [HttpGet]
  343. public async Task<ActionResult> GetDrawBalance()
  344. {
  345. var list = TkPoolCore.List();
  346. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  347. string message = string.Empty;
  348. foreach (var account in list)
  349. {
  350. if (!account.enable_sync_order) continue;
  351. try
  352. {
  353. var alimama = new AlimamaPlus(account);
  354. alimama.GetDrawBalance();
  355. }
  356. catch (Exception ex)
  357. {
  358. message = $"【报表接口异常】GetDrawBalance\n{ex.Message}\n{ex.StackTrace}";
  359. NotifyCore.Notify(new NifyMessage
  360. {
  361. message = message,
  362. priority = NifyMessagePriority.high,
  363. tags = ["red_circle"]
  364. });
  365. continue;
  366. }
  367. }
  368. return new APIResult(new { success = true, message = "ok" });
  369. }
  370. [HttpGet]
  371. public async Task<ActionResult> FastReport()
  372. {
  373. string message = string.Empty;
  374. var list = TkPoolCore.List();
  375. if (list != null)
  376. {
  377. foreach (var account in list)
  378. {
  379. if (!account.enable_sync_order) continue;
  380. try
  381. {
  382. var alimama = new AlimamaPlus(account);
  383. alimama.SaveReportOverview();
  384. }
  385. catch (Exception ex)
  386. {
  387. message = $"【报表接口异常】FastReport\n{ex.Message}\n{ex.StackTrace}";
  388. NotifyCore.Notify(new NifyMessage
  389. {
  390. message = message,
  391. priority = NifyMessagePriority.high,
  392. tags = ["red_circle"]
  393. });
  394. continue;
  395. }
  396. }
  397. }
  398. string filter = "";
  399. #if DEBUG
  400. filter = "id IN (7,8)";
  401. #endif
  402. var jd_list = new DBContext.Table("jd_pool").Where(filter, null).Select<JdPoolDTO>();
  403. if (jd_list != null)
  404. {
  405. bool any_jd_changed = false;
  406. foreach (var account in jd_list)
  407. {
  408. bool changed = false;
  409. try
  410. {
  411. account.current_daily_calls = JdPoolCore.SaveCalls(account.id, DateTime.Now.ToString("yyyyMMdd"));
  412. account.current_hourly_calls = JdPoolCore.SaveCalls(account.id, DateTime.Now.ToString("yyyyMMddHH"));
  413. changed = true;
  414. any_jd_changed = true;
  415. }
  416. catch (Exception ex)
  417. {
  418. message = $"【JD计数异常】SaveCalls\n{ex.Message}\n{ex.StackTrace}";
  419. NotifyCore.Notify(new NifyMessage
  420. {
  421. message = message,
  422. priority = NifyMessagePriority.high,
  423. tags = ["red_circle"]
  424. });
  425. continue;
  426. }
  427. if (!account.status) continue;
  428. if (!string.IsNullOrEmpty(account.cookies))
  429. {
  430. try
  431. {
  432. var plus = new JdUnionPlus(account);
  433. var data = await plus.queryTodaySpreadEffectData();
  434. account.today_clickNum = data.clickNum;
  435. account.today_cosFee = data.cosFee;
  436. account.today_cosPrice = data.cosPrice;
  437. account.today_finishCosFee = data.finishCosFee;
  438. account.today_finishCosPrice = data.finishCosPrice;
  439. account.today_finishOrderNum = data.finishOrderNum;
  440. account.today_orderNum = data.orderNum;
  441. changed = true;
  442. any_jd_changed = true;
  443. }
  444. catch (Exception ex)
  445. {
  446. if (ex.Message.Contains("no login"))
  447. {
  448. account.status = false;
  449. JdPoolCore.Disabled(account.id, account.name, ex.Message);
  450. }
  451. message = $"【JD报表接口异常】{account.id}:{account.name}\tqueryTodaySpreadEffectData\n{account.Convert2Json()}\n{ex.Message}\n{ex.StackTrace}";
  452. NotifyCore.Notify(new NifyMessage
  453. {
  454. message = message,
  455. priority = NifyMessagePriority.high,
  456. tags = ["red_circle"]
  457. });
  458. continue;
  459. }
  460. }
  461. if (changed) JdPoolCore.Update(account);
  462. }
  463. if (any_jd_changed) JdPoolCore.Refresh();
  464. }
  465. await EndPointCore.NotifyReload(true);
  466. return new APIResult(new { success = true, message = "ok" });
  467. }
  468. [HttpGet]
  469. public async Task<ActionResult> SaveReport()
  470. {
  471. string message = string.Empty;
  472. var list = TkPoolCore.List();
  473. if (list != null)
  474. {
  475. foreach (var account in list)
  476. {
  477. if (!account.enable_sync_order) continue;
  478. #if DEBUG
  479. if (account.id != 5) continue;
  480. #endif
  481. try
  482. {
  483. var alimama = new AlimamaPlus(account);
  484. alimama.SaveReportHourtrend(DateTime.Now.AddDays(-1));
  485. alimama.SaveReportHourtrend(DateTime.Now);
  486. if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 16)
  487. {
  488. DateTime date = DateTime.Now.AddDays(-1);
  489. alimama.FixReport(date);
  490. }
  491. }
  492. catch (Exception ex)
  493. {
  494. message = $"【报表接口异常】SaveReport\n{ex.Message}\n{ex.StackTrace}";
  495. NotifyCore.Notify(new NifyMessage
  496. {
  497. message = message,
  498. priority = NifyMessagePriority.high,
  499. tags = ["red_circle"]
  500. });
  501. continue;
  502. }
  503. }
  504. }
  505. return new APIResult(new { success = true, message = "ok" });
  506. }
  507. [HttpGet]
  508. public async Task<ActionResult> JdSaveReport()
  509. {
  510. string message = string.Empty;
  511. var jd_list = new DBContext.Table("jd_pool").Where("", null).Select<JdPoolDTO>();
  512. if (jd_list != null)
  513. {
  514. DateTime startDate = DateTime.Now.AddDays(-1);
  515. DateTime endDate = DateTime.Now;
  516. foreach (var account in jd_list)
  517. {
  518. if (!account.status) continue;
  519. #if DEBUG
  520. if (account.id != 10) continue;
  521. #endif
  522. if (!string.IsNullOrEmpty(account.cookies))
  523. {
  524. try
  525. {
  526. var plus = new JdUnionPlus(account);
  527. _ = await plus.querySpreadEffectData(startDate, endDate);
  528. _ = await plus.queryEstimateCommList();
  529. }
  530. catch (Exception ex)
  531. {
  532. if (ex.Message.Contains("no login"))
  533. {
  534. JdPoolCore.Disabled(account.id, account.name, ex.Message);
  535. }
  536. message = $"【JD报表接口异常】{account.id}:{account.name}\tquerySpreadEffectData\n{ex.Message}\n{ex.StackTrace}";
  537. NotifyCore.Notify(new NifyMessage
  538. {
  539. message = message,
  540. priority = NifyMessagePriority.high,
  541. tags = ["red_circle"]
  542. });
  543. continue;
  544. }
  545. }
  546. }
  547. }
  548. return new APIResult(new { success = true, message = "ok" });
  549. }
  550. [HttpGet]
  551. public async Task<ActionResult> FixReport(int id, string dt)
  552. {
  553. if (!DateTime.TryParse(dt, out DateTime date))
  554. {
  555. return new APIResult(new { success = false, message = "日期错误", });
  556. }
  557. var list = TkPoolCore.List();
  558. if (list == null) return new APIResult(new { success = false, message = "没有有效账号", });
  559. string message = string.Empty;
  560. foreach (var account in list)
  561. {
  562. if (id != account.id) continue;
  563. try
  564. {
  565. var alimama = new AlimamaPlus(account);
  566. while (date.Date < DateTime.Now.Date)
  567. {
  568. alimama.FixReport(date);
  569. date = date.AddDays(1);
  570. }
  571. }
  572. catch (Exception ex)
  573. {
  574. message = $"【报表接口异常】SaveReport\n{ex.Message}\n{ex.StackTrace}";
  575. NotifyCore.Notify(new NifyMessage
  576. {
  577. message = message,
  578. priority = NifyMessagePriority.high,
  579. tags = ["red_circle"]
  580. });
  581. continue;
  582. }
  583. }
  584. return new APIResult(new { success = true, message = "ok" });
  585. }
  586. [HttpGet]
  587. public ActionResult RenewCookie(string name)
  588. {
  589. var account = new DBContext.Table("tk_pool").Get<TkPoolDTO>("name=@name", new { name });
  590. if (account == null) return new APIResult(new { success = false, message = "没有有效账号", });
  591. var alimama = new AlimamaPlus(account);
  592. (bool success, string message) = alimama.RenewCookie();
  593. return new APIResult(new { success, message });
  594. }
  595. [HttpGet]
  596. public ActionResult Reload()
  597. {
  598. TkConfigCore.Refresh();
  599. EndPointCore.Refresh();
  600. ProxyNodesCore.Refresh();
  601. TkPoolCore.Refresh();
  602. VeapiPoolCore.Refresh();
  603. ApiAccountCore.Refresh();
  604. DataokeCore.Refresh();
  605. JdPoolCore.Refresh();
  606. PddPoolCore.Refresh();
  607. PangolinPoolCore.Refresh();
  608. return new APIResult(new
  609. {
  610. success = true,
  611. message = "ok",
  612. });
  613. }
  614. [HttpGet]
  615. public ActionResult ReloadAccount()
  616. {
  617. EndPointCore.Refresh();
  618. ProxyNodesCore.Refresh();
  619. TkPoolCore.Refresh();
  620. VeapiPoolCore.Refresh();
  621. JdPoolCore.Refresh();
  622. return new APIResult(new
  623. {
  624. success = true,
  625. message = "ok",
  626. });
  627. }
  628. [HttpGet]
  629. public async Task<ActionResult> CheckDeepUrl(int accountid)
  630. {
  631. var postContent = "88✔7Fi43dJwWpV£ https://m.tb.cn/h.g92hfR4JLgn7yvG MF7997 我分享给你了一个超赞的内容,快来看看吧";
  632. var channel = "tb";
  633. var ip = "127.0.0.1";
  634. var oaid = "test-oaid";
  635. bool success = false;
  636. string message;
  637. //============================== 放弃转链-没有匹配账号 ==============================
  638. TkPoolDTO? account = TkPoolCore.GetOne(accountid);
  639. if (account == null)
  640. {
  641. return new APIResult(new
  642. {
  643. success = false,
  644. message = "没有匹配账号",
  645. });
  646. }
  647. var alimama = new AlimamaPlus(account);
  648. TkDataDTO result = new TkDataDTO();
  649. string url = AlimamaPlus.GetLink(postContent);
  650. if (string.IsNullOrEmpty(url))
  651. {
  652. return new APIResult(new
  653. {
  654. success = false,
  655. message = "无效URL",
  656. });
  657. }
  658. (success, string content) = await alimama.GetDesiredUrlAsync(url);
  659. if (content.Contains("霸下通用 web 页面-验证码"))
  660. {
  661. message = "霸下验证码";
  662. }
  663. else
  664. {
  665. message = content;
  666. }
  667. return new APIResult(new
  668. {
  669. success = true,
  670. message,
  671. });
  672. }
  673. }
  674. }