Просмотр исходного кода

切换大部分csrdis,并且deeplink增加替换规则

dodo hold 1 год назад
Родитель
Сommit
9d1072702b
35 измененных файлов с 1259 добавлено и 874 удалено
  1. 4 7
      molilian.api/Controllers/admin/ReportController.cs
  2. 72 72
      molilian.api/Controllers/admin/TaobaoController.cs
  3. 0 90
      molilian.api/Controllers/public/NewController.cs
  4. 26 26
      molilian.api/Controllers/public/TaskController.cs
  5. 1 1
      molilian.api/Properties/PublishProfiles/tester.pubxml
  6. 0 0
      molilian.api/Properties/PublishProfiles/tester.pubxml.user
  7. 1 1
      molilian.api/molilian.api.csproj
  8. 14 2
      molilian.core/Core/EndPointCore.cs
  9. 28 28
      molilian.core/Core/admin/ChartDataCore.cs
  10. 4 5
      molilian.core/Core/aliyun/AliyunCore.cs
  11. 103 373
      molilian.core/Core/log/base.cs
  12. 55 10
      molilian.core/Core/log/coupon.cs
  13. 47 2
      molilian.core/Core/log/cps.cs
  14. 61 2
      molilian.core/Core/log/deeplink.cs
  15. 64 3
      molilian.core/Core/log/dy.cs
  16. 60 3
      molilian.core/Core/log/jd.cs
  17. 61 8
      molilian.core/Core/log/ks.cs
  18. 60 11
      molilian.core/Core/log/pdd.cs
  19. 78 41
      molilian.core/Core/log/promotion.cs
  20. 83 12
      molilian.core/Core/log/taobao.cs
  21. 78 2
      molilian.core/Core/log/tool.cs
  22. 100 46
      molilian.core/Core/taoke/OrderTrackingCore.cs
  23. 106 44
      molilian.core/Core/taoke/RiskControlCore.cs
  24. 15 1
      molilian.core/Core/taoke/TaokeOpenCore.cs
  25. 0 2
      molilian.core/Core/taoke/UnionParseCore.cs
  26. 15 0
      molilian.core/Core/tool/DeeplinkParseCore.cs
  27. 1 0
      molilian.core/DTO/deeplink/DeeplinkParseRuleDTO.cs
  28. 44 45
      molilian.core/Plus/Alimama/crawler.cs
  29. 2 8
      molilian.core/Plus/Alimama/orders.cs
  30. 10 3
      molilian.core/Plus/Aliyun/ImageSearch.cs
  31. 45 5
      molilian.core/Plus/JDUnion/JdUnionPlus.cs
  32. 4 4
      molilian.core/Plus/Tool/ToolDailyLogs.cs
  33. 8 8
      molilian.core/Plus/ks/KsDailyLogs.cs
  34. 8 8
      molilian.core/Plus/pdd/PddDailyLogs.cs
  35. 1 1
      molilian.core/molilian.core.csproj

+ 4 - 7
molilian.api/Controllers/admin/ReportController.cs

@@ -85,7 +85,7 @@ namespace molilian.api.Controllers
         }
 
         [HttpPost]
-        public ActionResult chartData([FromBody] JsonElement form)
+        public async Task<ActionResult> chartData([FromBody] JsonElement form)
         {
             var result = new ChartDataRes();
 
@@ -107,18 +107,15 @@ namespace molilian.api.Controllers
             switch (total_key)
             {
                 case "tool_total":
-                    result = GetToolData(total_key, accountName, _report_date);
+                    result = await GetToolDataAsync(total_key, accountName, _report_date);
                     break;
                 case "total":
                 case "parse_total":
                 case "coupon_total":
-                    result = GetTaobaoData(total_key, accountName, _report_date);
+                    result = await GetTaobaoDataAsync(total_key, accountName, _report_date);
                     break;
-                //case "coupon_total":
-                //    result = GetTaobaoCouponData(total_key, accountName, _report_date);
-                //    break;
                 case "jd_parse_total":
-                    result = GetJdData(total_key, accountName, _report_date);
+                    result = await GetJdDataAsync(total_key, accountName, _report_date);
 
                     break;
             }

+ 72 - 72
molilian.api/Controllers/admin/TaobaoController.cs

@@ -204,7 +204,7 @@ namespace molilian.api.Controllers
 
 
         [HttpPost]
-        public ActionResult report_dailys([FromBody] JsonElement form)
+        public async Task<ActionResult> report_dailys([FromBody] JsonElement form)
         {
             int page = form.Read("current", 1);
             int size = form.Read("pageSize", 10);
@@ -257,11 +257,11 @@ namespace molilian.api.Controllers
                 if (item.report_date.Date < DateTime.Now.Date) continue;
                 if (item.total_count == 0)
                 {
-                    item.total_count = TkLogCore.GetTotal($":total:tb:{item.report_date:yyyyMMdd}");
+                    item.total_count = await TkLogCore.GetTotalAsync($":total:tb:{item.report_date:yyyyMMdd}");
                     if (item.total_count > 0)
                     {
-                        item.success_count = TkLogCore.GetTotal($":total:tb:success:{item.report_date:yyyyMMdd}");
-                        item.abandon_count = TkLogCore.GetTotal($":total:tb:放弃转链:{item.report_date:yyyyMMdd}");
+                        item.success_count = await TkLogCore.GetTotalAsync($":total:tb:success:{item.report_date:yyyyMMdd}");
+                        item.abandon_count = await TkLogCore.GetTotalAsync($":total:tb:放弃转链:{item.report_date:yyyyMMdd}");
                         if (item.total_count > 0)
                         {
                             item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
@@ -272,11 +272,11 @@ namespace molilian.api.Controllers
 
                 if (item.parse_total_count == 0)
                 {
-                    item.parse_total_count = TkLogCore.GetTotal($":parse_total:tb:{item.report_date:yyyyMMdd}");
+                    item.parse_total_count = await TkLogCore.GetTotalAsync($":parse_total:tb:{item.report_date:yyyyMMdd}");
                     if (item.parse_total_count > 0)
                     {
-                        item.parse_success_count = TkLogCore.GetTotal($":parse_total:tb:success:{item.report_date:yyyyMMdd}");
-                        item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:tb:放弃转链:{item.report_date:yyyyMMdd}");
+                        item.parse_success_count = await TkLogCore.GetTotalAsync($":parse_total:tb:success:{item.report_date:yyyyMMdd}");
+                        item.parse_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:tb:放弃转链:{item.report_date:yyyyMMdd}");
                         if (item.parse_total_count > 0)
                         {
                             item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
@@ -287,11 +287,11 @@ namespace molilian.api.Controllers
 
                 if (item.coupon_total_count == 0)
                 {
-                    item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:tb:{item.report_date:yyyyMMdd}", false);
+                    item.coupon_total_count = await TkLogCore.GetTotalAsync($":coupon_total:tb:{item.report_date:yyyyMMdd}", false);
                     if (item.coupon_total_count > 0)
                     {
-                        item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:tb:success:{item.report_date:yyyyMMdd}", false);
-                        item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:tb:放弃转链:{item.report_date:yyyyMMdd}", false);
+                        item.coupon_success_count = await TkLogCore.GetTotalAsync($":coupon_total:tb:success:{item.report_date:yyyyMMdd}", false);
+                        item.coupon_abandon_count = await TkLogCore.GetTotalAsync($":coupon_total:tb:放弃转链:{item.report_date:yyyyMMdd}", false);
                         if (item.coupon_total_count > 0)
                         {
                             item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
@@ -302,11 +302,11 @@ namespace molilian.api.Controllers
 
                 if (item.tool_total_count == 0)
                 {
-                    item.tool_total_count = TkLogCore.GetTotal($":parse_total:tool:{item.report_date:yyyyMMdd}");
+                    item.tool_total_count = await TkLogCore.GetTotalAsync($":parse_total:tool:{item.report_date:yyyyMMdd}");
                     if (item.tool_total_count > 0)
                     {
-                        item.tool_success_count = TkLogCore.GetTotal($":parse_total:tool:success:{item.report_date:yyyyMMdd}");
-                        item.tool_abandon_count = TkLogCore.GetTotal($":parse_total:tool:放弃转链:{item.report_date:yyyyMMdd}");
+                        item.tool_success_count = await TkLogCore.GetTotalAsync($":parse_total:tool:success:{item.report_date:yyyyMMdd}");
+                        item.tool_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:tool:放弃转链:{item.report_date:yyyyMMdd}");
                         if (item.tool_total_count > 0)
                         {
                             item.tool_success_percentage = $"{item.tool_success_count / (double)item.tool_total_count * 100:f2}%";
@@ -324,7 +324,7 @@ namespace molilian.api.Controllers
 
 
         [HttpPost]
-        public ActionResult report_hourlys([FromBody] JsonElement form)
+        public async Task<ActionResult> report_hourlys([FromBody] JsonElement form)
         {
             int page = form.Read("current", 1);
             int size = form.Read("pageSize", 10);
@@ -383,11 +383,11 @@ namespace molilian.api.Controllers
             {
                 if (item.total_count == 0)
                 {
-                    item.total_count = TkLogCore.GetTotal($":total:tb:{item.report_date:yyyyMMddHH}");
+                    item.total_count = await TkLogCore.GetTotalAsync($":total:tb:{item.report_date:yyyyMMddHH}");
                     if (item.total_count > 0)
                     {
-                        item.success_count = TkLogCore.GetTotal($":total:tb:success:{item.report_date:yyyyMMddHH}");
-                        item.abandon_count = TkLogCore.GetTotal($":total:tb:放弃转链:{item.report_date:yyyyMMddHH}");
+                        item.success_count = await TkLogCore.GetTotalAsync($":total:tb:success:{item.report_date:yyyyMMddHH}");
+                        item.abandon_count = await TkLogCore.GetTotalAsync($":total:tb:放弃转链:{item.report_date:yyyyMMddHH}");
                         if (item.total_count > 0)
                         {
                             item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
@@ -398,11 +398,11 @@ namespace molilian.api.Controllers
 
                 if (item.parse_total_count == 0)
                 {
-                    item.parse_total_count = TkLogCore.GetTotal($":parse_total:tb:{item.report_date:yyyyMMddHH}");
+                    item.parse_total_count = await TkLogCore.GetTotalAsync($":parse_total:tb:{item.report_date:yyyyMMddHH}");
                     if (item.parse_total_count > 0)
                     {
-                        item.parse_success_count = TkLogCore.GetTotal($":parse_total:tb:success:{item.report_date:yyyyMMddHH}");
-                        item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:tb:放弃转链:{item.report_date:yyyyMMddHH}");
+                        item.parse_success_count = await TkLogCore.GetTotalAsync($":parse_total:tb:success:{item.report_date:yyyyMMddHH}");
+                        item.parse_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:tb:放弃转链:{item.report_date:yyyyMMddHH}");
                         if (item.parse_total_count > 0)
                         {
                             item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
@@ -413,11 +413,11 @@ namespace molilian.api.Controllers
 
                 if (item.coupon_total_count == 0)
                 {
-                    item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:tb:{item.report_date:yyyyMMddHH}", false);
+                    item.coupon_total_count = await TkLogCore.GetTotalAsync($":coupon_total:tb:{item.report_date:yyyyMMddHH}", false);
                     if (item.coupon_total_count > 0)
                     {
-                        item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:tb:success:{item.report_date:yyyyMMddHH}", false);
-                        item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:tb:放弃转链:{item.report_date:yyyyMMddHH}", false);
+                        item.coupon_success_count = await TkLogCore.GetTotalAsync($":coupon_total:tb:success:{item.report_date:yyyyMMddHH}", false);
+                        item.coupon_abandon_count = await TkLogCore.GetTotalAsync($":coupon_total:tb:放弃转链:{item.report_date:yyyyMMddHH}", false);
                         if (item.coupon_total_count > 0)
                         {
                             item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
@@ -428,11 +428,11 @@ namespace molilian.api.Controllers
 
                 if (item.tool_total_count == 0)
                 {
-                    item.tool_total_count = TkLogCore.GetTotal($":parse_total:tool:{item.report_date:yyyyMMddHH}");
+                    item.tool_total_count = await TkLogCore.GetTotalAsync($":parse_total:tool:{item.report_date:yyyyMMddHH}");
                     if (item.tool_total_count > 0)
                     {
-                        item.tool_success_count = TkLogCore.GetTotal($":parse_total:tool:success:{item.report_date:yyyyMMddHH}");
-                        item.tool_abandon_count = TkLogCore.GetTotal($":parse_total:tool:放弃转链:{item.report_date:yyyyMMddHH}");
+                        item.tool_success_count = await TkLogCore.GetTotalAsync($":parse_total:tool:success:{item.report_date:yyyyMMddHH}");
+                        item.tool_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:tool:放弃转链:{item.report_date:yyyyMMddHH}");
                         if (item.tool_total_count > 0)
                         {
                             item.tool_success_percentage = $"{item.tool_success_count / (double)item.tool_total_count * 100:f2}%";
@@ -449,7 +449,7 @@ namespace molilian.api.Controllers
         }
 
         [HttpPost]
-        public ActionResult report_list([FromBody] JsonElement form)
+        public async Task<ActionResult> report_list([FromBody] JsonElement form)
         {
             int page = form.Read("current", 1);
             int size = form.Read("pageSize", 10);
@@ -509,17 +509,17 @@ namespace molilian.api.Controllers
 
                 if (item.total_count == 0)
                 {
-                    item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMdd}");
+                    item.total_count = await TkLogCore.GetTotalAsync($":total:{accountName}:{item.report_date:yyyyMMdd}");
                     if (item.total_count > 0)
                     {
                         //todo  过度用, 0613 跑两天就可以删掉
                         accountName = item.accountName;
-                        item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMdd}");
+                        item.total_count = await TkLogCore.GetTotalAsync($":total:{accountName}:{item.report_date:yyyyMMdd}");
                     }
                     if (item.total_count > 0)
                     {
-                        item.success_count = TkLogCore.GetTotal($":total:{accountName}:success:{item.report_date:yyyyMMdd}");
-                        item.abandon_count = TkLogCore.GetTotal($":total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
+                        item.success_count = await TkLogCore.GetTotalAsync($":total:{accountName}:success:{item.report_date:yyyyMMdd}");
+                        item.abandon_count = await TkLogCore.GetTotalAsync($":total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
                         if (item.total_count > 0)
                         {
                             item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
@@ -530,11 +530,11 @@ namespace molilian.api.Controllers
 
                 if (item.parse_total_count == 0)
                 {
-                    item.parse_total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{item.report_date:yyyyMMdd}");
+                    item.parse_total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{item.report_date:yyyyMMdd}");
                     if (item.parse_total_count > 0)
                     {
-                        item.parse_success_count = TkLogCore.GetTotal($":parse_total:{accountName}:success:{item.report_date:yyyyMMdd}");
-                        item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
+                        item.parse_success_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:success:{item.report_date:yyyyMMdd}");
+                        item.parse_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
                         if (item.parse_total_count > 0)
                         {
                             item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
@@ -545,11 +545,11 @@ namespace molilian.api.Controllers
 
                 if (item.coupon_total_count == 0)
                 {
-                    item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:{accountName}:{item.report_date:yyyyMMdd}", false);
+                    item.coupon_total_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:{item.report_date:yyyyMMdd}", false);
                     if (item.coupon_total_count > 0)
                     {
-                        item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:{accountName}:success:{item.report_date:yyyyMMdd}", false);
-                        item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}", false);
+                        item.coupon_success_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:success:{item.report_date:yyyyMMdd}", false);
+                        item.coupon_abandon_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}", false);
                         if (item.coupon_total_count > 0)
                         {
                             item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
@@ -560,11 +560,11 @@ namespace molilian.api.Controllers
 
                 if (item.tool_total_count == 0)
                 {
-                    item.tool_total_count = TkLogCore.GetTotal($":parse_total:tool:{item.report_date:yyyyMMdd}");
+                    item.tool_total_count = await TkLogCore.GetTotalAsync($":parse_total:tool:{item.report_date:yyyyMMdd}");
                     if (item.tool_total_count > 0)
                     {
-                        item.tool_success_count = TkLogCore.GetTotal($":parse_total:tool:success:{item.report_date:yyyyMMdd}");
-                        item.tool_abandon_count = TkLogCore.GetTotal($":parse_total:tool:放弃转链:{item.report_date:yyyyMMdd}");
+                        item.tool_success_count = await TkLogCore.GetTotalAsync($":parse_total:tool:success:{item.report_date:yyyyMMdd}");
+                        item.tool_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:tool:放弃转链:{item.report_date:yyyyMMdd}");
                         if (item.tool_total_count > 0)
                         {
                             item.tool_success_percentage = $"{item.tool_success_count / (double)item.tool_total_count * 100:f2}%";
@@ -577,7 +577,7 @@ namespace molilian.api.Controllers
         }
 
         [HttpPost]
-        public ActionResult report_hourtrend([FromBody] JsonElement form)
+        public async Task<ActionResult> report_hourtrend([FromBody] JsonElement form)
         {
             int page = form.Read("current", 1);
             int size = form.Read("pageSize", 10);
@@ -648,16 +648,16 @@ namespace molilian.api.Controllers
                 accountName = $"{TkChannelEnum.tb}_{item.accountId}";
                 if (item.total_count == 0)
                 {
-                    item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMddHH}");
+                    item.total_count = await TkLogCore.GetTotalAsync($":total:{accountName}:{item.report_date:yyyyMMddHH}");
                     if (item.total_count == 0)
                     {
                         //todo  过度用, 0613 跑两天就可以删掉
                         accountName = item.accountName;
-                        item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMddHH}");
+                        item.total_count = await TkLogCore.GetTotalAsync($":total:{accountName}:{item.report_date:yyyyMMddHH}");
                     }
                     if (item.total_count == 0) continue;
-                    item.success_count = TkLogCore.GetTotal($":total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
-                    item.abandon_count = TkLogCore.GetTotal($":total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
+                    item.success_count = await TkLogCore.GetTotalAsync($":total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
+                    item.abandon_count = await TkLogCore.GetTotalAsync($":total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
                     if (item.total_count > 0)
                     {
                         item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
@@ -667,11 +667,11 @@ namespace molilian.api.Controllers
 
                 if (item.parse_total_count == 0)
                 {
-                    item.parse_total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{item.report_date:yyyyMMddHH}");
+                    item.parse_total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{item.report_date:yyyyMMddHH}");
                     if (item.parse_total_count > 0)
                     {
-                        item.parse_success_count = TkLogCore.GetTotal($":parse_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
-                        item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
+                        item.parse_success_count = await TkLogCore.GetTotalAsync($":parse_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
+                        item.parse_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
                         if (item.parse_total_count > 0)
                         {
                             item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
@@ -682,11 +682,11 @@ namespace molilian.api.Controllers
 
                 if (item.coupon_total_count == 0)
                 {
-                    item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:{accountName}:{item.report_date:yyyyMMddHH}", false);
+                    item.coupon_total_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:{item.report_date:yyyyMMddHH}", false);
                     if (item.coupon_total_count > 0)
                     {
-                        item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}", false);
-                        item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}", false);
+                        item.coupon_success_count = await TkLogCore.GetTotalAsync($":coupon_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}", false);
+                        item.coupon_abandon_count = await TkLogCore.GetTotalAsync($":coupon_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}", false);
                         if (item.coupon_total_count > 0)
                         {
                             item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
@@ -697,11 +697,11 @@ namespace molilian.api.Controllers
 
                 if (item.tool_total_count == 0)
                 {
-                    item.tool_total_count = TkLogCore.GetTotal($":tool_total:{accountName}:{item.report_date:yyyyMMddHH}");
+                    item.tool_total_count = await TkLogCore.GetTotalAsync($":tool_total:{accountName}:{item.report_date:yyyyMMddHH}");
                     if (item.tool_total_count > 0)
                     {
-                        item.tool_success_count = TkLogCore.GetTotal($":tool_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
-                        item.tool_abandon_count = TkLogCore.GetTotal($":tool_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
+                        item.tool_success_count = await TkLogCore.GetTotalAsync($":tool_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
+                        item.tool_abandon_count = await TkLogCore.GetTotalAsync($":tool_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
                         if (item.tool_total_count > 0)
                         {
                             item.tool_success_percentage = $"{item.tool_success_count / (double)item.tool_total_count * 100:f2}%";
@@ -715,7 +715,7 @@ namespace molilian.api.Controllers
 
 
         [HttpPost]
-        public ActionResult chartData([FromBody] JsonElement form)
+        public async Task<ActionResult> chartData([FromBody] JsonElement form)
         {
             var result = new List<dynamic>();
             var reason_result = new List<dynamic>();
@@ -740,7 +740,7 @@ namespace molilian.api.Controllers
                 total_key = "parse_total";
 
                 string cacheKey = $":{total_key}:{accountName}:{_report_date}";
-                double total = TkLogCore.GetTotal(cacheKey);
+                double total = await TkLogCore.GetTotalAsync(cacheKey);
                 if (total > 0)
                 {
                     string[] keys = ["bdpan", "wemeet"];
@@ -750,27 +750,27 @@ namespace molilian.api.Controllers
                         //                    string[] keys = ["bdpan:success", "bdpan:fail", "wemeet:success", "wemeet:fail"];
 
                         cacheKey = $":{total_key}:{keyname}:{_report_date}";
-                        total = TkLogCore.GetTotal(cacheKey);
+                        total = await TkLogCore.GetTotalAsync(cacheKey);
 
                         cacheKey = $":{total_key}:{keyname}:success:{_report_date}";
-                        int value = TkLogCore.GetTotal(cacheKey);
+                        int value = await TkLogCore.GetTotalAsync(cacheKey);
                         if (value == 0) continue;
                         result.Add(new { name = $"{keyname}-成功", value, increases = Math.Round(value / total * 100, 2) });
 
 
                         cacheKey = $":{total_key}:{keyname}:fail:{_report_date}";
-                        value = TkLogCore.GetTotal(cacheKey);
+                        value = await TkLogCore.GetTotalAsync(cacheKey);
                         if (value == 0) continue;
                         result.Add(new { name = $"{keyname}-失败", value, increases = Math.Round(value / total * 100, 2) });
                     }
 
                     cacheKey = $":{total_key}:{accountName}:reason:{_report_date}";
-                    string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey);
+                    string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                     foreach (var keyname in reason_keys)
                     {
                         cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
-                        int value = TkLogCore.GetTotal(cacheKey);
+                        int value = await TkLogCore.GetTotalAsync(cacheKey);
                         if (value == 0) continue;
                         reason_result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
                     }
@@ -781,13 +781,13 @@ namespace molilian.api.Controllers
             else
             {
                 string cacheKey = $":{total_key}:{accountName}:{_report_date}";
-                double total = TkLogCore.GetTotal(cacheKey, false);
+                double total = await TkLogCore.GetTotalAsync(cacheKey, false);
                 if (total > 0)
                 {
                     string[] keys = ["success"];
 
                     cacheKey = $":{total_key}:{accountName}:message:{_report_date}";
-                    string[] message_keys = TkLogCore.GetTotalKeys(cacheKey, false);
+                    string[] message_keys = await TkLogCore.GetTotalKeysAsync(cacheKey, false);
 
                     var combinedKeys = keys.Union(message_keys).ToList();
                     combinedKeys.RemoveAll(item => item == "fail");
@@ -796,20 +796,20 @@ namespace molilian.api.Controllers
                     foreach (var keyname in combinedKeys)
                     {
                         cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
-                        int value = TkLogCore.GetTotal(cacheKey, false);
+                        int value = await TkLogCore.GetTotalAsync(cacheKey, false);
                         if (value == 0) continue;
                         result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
                     }
                     result = result.OrderByDescending(item => item.value).ToList();
 
                     cacheKey = $":{total_key}:{accountName}:reason:{_report_date}";
-                    string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey, false);
+                    string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey, false);
 
                     foreach (var keyname in reason_keys)
                     {
                         if ("没有优惠券".Equals(keyname)) continue;
                         cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
-                        int value = TkLogCore.GetTotal(cacheKey, false);
+                        int value = await TkLogCore.GetTotalAsync(cacheKey, false);
                         if (value < 50) continue;
                         reason_result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
                     }
@@ -820,7 +820,7 @@ namespace molilian.api.Controllers
         }
 
         [HttpPost]
-        public ActionResult chartData2([FromBody] JsonElement form)
+        public async Task<ActionResult> chartData2([FromBody] JsonElement form)
         {
             var result = new List<dynamic>();
             var reason_result = new List<dynamic>();
@@ -839,13 +839,13 @@ namespace molilian.api.Controllers
             if (isHourtrend) _report_date = stime.ToString("yyyyMMddHH");
 
             string cacheKey = $":{total_key}:{accountName}:{_report_date}";
-            double total = TkLogCore.GetTotal(cacheKey);
+            double total = await TkLogCore.GetTotalAsync(cacheKey);
             if (total > 0)
             {
                 string[] keys = ["success"];
 
                 cacheKey = $":{total_key}:{accountName}:message:{_report_date}";
-                string[] message_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] message_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 var combinedKeys = keys.Union(message_keys).ToList();
                 combinedKeys.RemoveAll(item => item == "fail");
@@ -855,20 +855,20 @@ namespace molilian.api.Controllers
                 foreach (var keyname in combinedKeys)
                 {
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
                 }
                 result = result.OrderByDescending(item => item.value).ToList();
 
                 cacheKey = $":{total_key}:{accountName}:reason:{_report_date}";
-                string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 foreach (var keyname in reason_keys)
                 {
                     if ("没有优惠券".Equals(keyname)) continue;
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     reason_result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
                 }

+ 0 - 90
molilian.api/Controllers/public/NewController.cs

@@ -1,90 +0,0 @@
-using molilian.core;
-using dodohold.core;
-using Microsoft.AspNetCore.Mvc;
-using Org.BouncyCastle.Ocsp;
-using System.Text.Json;
-using System.Runtime.InteropServices;
-using System.Net;
-using System.Threading;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using TencentCloud.Soe.V20180724.Models;
-using static dodohold.core.ZTOExpress.CreateOrderArgs;
-using static Spire.Xls.Core.Spreadsheet.HTMLOptions;
-using System.Net.Http.Json;
-using System.Text.RegularExpressions;
-using System.Text;
-using TencentCloud.Oceanus.V20190422.Models;
-using System.Security.Cryptography;
-using YunhuiKit;
-using System.Diagnostics;
-
-namespace molilian.api.Controllers
-{
-    [ApiController]
-    [Route("[controller]/[action]")]
-    public class NewController : ControllerBase
-    {
-
-        protected IHttpContextAccessor _accessor;
-        public NewController(IHttpContextAccessor accessor)
-        {
-            _accessor = accessor;
-        }
-
-
-        [HttpGet]
-        public async Task<ActionResult> redis()
-        {
-
-            var result = AlimamaPlus.GetFormattedObject("中国1@#阿斯蒂芬", "127.0.0.1", "0000-00-0000");
-
-            string cacheKey = "tmp:test:case1";
-            RedisHelper.Set(cacheKey, result, 300);
-            var data1 = RedisHelper.Get<TkDataDTO>(cacheKey);
-            var data2 = await RedisKit.GetAsync<TkDataDTO>(cacheKey);
-
-            await RedisKit.SetAsync(cacheKey, result, 300);
-            data1 = RedisHelper.Get<TkDataDTO>(cacheKey);
-            data2 = await RedisKit.GetAsync<TkDataDTO>(cacheKey);
-
-
-            await RedisKit.SetAsync(cacheKey, "a", 300);
-            var data3 = RedisHelper.Get<int>(cacheKey);
-            var data4 = await RedisKit.GetAsync<int>(cacheKey);
-
-
-            return new APIResult(new { data = new List<TkDataDTO> { data1, data2 } });
-        }
-
-
-
-        [HttpGet]
-        public async Task<ActionResult> redis2(int count = 100)
-        {
-            var stopwatch = new Stopwatch();
-            stopwatch.Start();
-            // 执行100次
-            for (int i = 0; i < 100; i++)
-            {
-                int total_count = TkLogCore.GetTotal($":total:tb:2025-01-09");
-            }
-            stopwatch.Stop();
-
-            var stopwatch2 = new Stopwatch();
-            stopwatch2.Start();
-            // 执行100次
-            for (int i = 0; i < 100; i++)
-            {
-                int total_count = await TkLogCore.GetTotalAsync($":total:tb:2025-01-09");
-            }
-            stopwatch2.Stop();
-            return new APIResult(new
-            {
-                ts = stopwatch.ElapsedMilliseconds,
-                ts2 = stopwatch2.ElapsedMilliseconds,
-            });
-
-        }
-
-    }
-}

+ 26 - 26
molilian.api/Controllers/public/TaskController.cs

@@ -64,7 +64,7 @@ namespace molilian.api.Controllers
                         .Add("itemId", itemId)
                         .Where("id=@id", new { item.id })
                         .Update();
-                    TkOrderTrackingCore.MatchOrder(account, item, null);
+                    TkOrderTrackingCore.MatchOrder(account, item);
                 }
             }
             return new APIResult(new { success = true, message = "ok", limit, total });
@@ -341,23 +341,23 @@ namespace molilian.api.Controllers
             try
             {
                 //本节点统计
-                AlimamaPlus.NodeDailyLogs(intervalDay, "parse_", "tb");
-                AlimamaPlus.NodeDailyLogs(intervalDay, "coupon_", "tb");
-                AlimamaPlus.NodeDailyLogs(intervalDay); //第三方老的统计
+                await AlimamaPlus.NodeDailyLogsAsync(intervalDay, "parse_", "tb");
+                await AlimamaPlus.NodeDailyLogsAsync(intervalDay, "coupon_", "tb");
+                await AlimamaPlus.NodeDailyLogsAsync(intervalDay); //第三方老的统计
 
                 if (CenterHub.IsCenter)
                 {
-                    _ = JdUnionPlus.DailyLogsAsync(intervalDay);
-                    ToolParsePlus.DailyLogs(intervalDay);
+                    await JdUnionPlus.DailyLogsAsync(intervalDay);
+                    await ToolParsePlus.DailyLogsAsync(intervalDay);
 
                     //中心服务器统计
-                    AlimamaPlus.AllDailyLogs(intervalDay, "parse_", "tb");
-                    AlimamaPlus.AllDailyLogs(intervalDay, "coupon_", "tb");
+                    await AlimamaPlus.AllDailyLogsAsync(intervalDay, "parse_", "tb");
+                    await AlimamaPlus.AllDailyLogsAsync(intervalDay, "coupon_", "tb");
 
-                    KsUnionPlus.DailyLogs(intervalDay);
-                    PddUnionPlus.DailyLogs(intervalDay);
+                    await KsUnionPlus.DailyLogsAsync(intervalDay);
+                    await PddUnionPlus.DailyLogsAsync(intervalDay);
 
-                    AlimamaPlus.AllDailyLogs(intervalDay);
+                    await AlimamaPlus.AllDailyLogsAsync(intervalDay);
                 }
             }
             catch (Exception ex)
@@ -381,12 +381,12 @@ namespace molilian.api.Controllers
             try
             {
 #if DEBUG
-                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.pdd);
+                await AlimamaPlus.ApiCallStatisticsAsync(1, intervalDay, TkChannelEnum.pdd);
 #else
-                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
-                AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
-                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.jd);
-                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.pdd);
+                await AlimamaPlus.ApiCallStatisticsAsync(1, intervalDay, TkChannelEnum.tb);
+                await AlimamaPlus.ApiCallStatisticsAsync(2, intervalDay, TkChannelEnum.tb);
+                await AlimamaPlus.ApiCallStatisticsAsync(1, intervalDay, TkChannelEnum.jd);
+                await AlimamaPlus.ApiCallStatisticsAsync(1, intervalDay, TkChannelEnum.pdd);
 #endif
             }
             catch (Exception ex)
@@ -525,8 +525,8 @@ namespace molilian.api.Controllers
                 {
                     try
                     {
-                        account.current_daily_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.tb, account.id, DateTime.Now.ToString("yyyyMMdd"));
-                        account.current_hourly_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.tb, account.id, DateTime.Now.ToString("yyyyMMddHH"));
+                        account.current_daily_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.tb, account.id, DateTime.Now.ToString("yyyyMMdd"));
+                        account.current_hourly_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.tb, account.id, DateTime.Now.ToString("yyyyMMddHH"));
 
                         new DBContext.Table("tk_pool")
                             .Add("current_hourly_calls", account.current_hourly_calls)
@@ -576,8 +576,8 @@ namespace molilian.api.Controllers
                     bool changed = false;
                     try
                     {
-                        account.current_daily_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.jd, account.id, DateTime.Now.ToString("yyyyMMdd"));
-                        account.current_hourly_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.jd, account.id, DateTime.Now.ToString("yyyyMMddHH"));
+                        account.current_daily_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.jd, account.id, DateTime.Now.ToString("yyyyMMdd"));
+                        account.current_hourly_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.jd, account.id, DateTime.Now.ToString("yyyyMMddHH"));
                         changed = true;
                         any_jd_changed = true;
                     }
@@ -637,8 +637,8 @@ namespace molilian.api.Controllers
                     bool changed = false;
                     try
                     {
-                        account.current_daily_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.pdd, account.id, DateTime.Now.ToString("yyyyMMdd"));
-                        account.current_hourly_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.pdd, account.id, DateTime.Now.ToString("yyyyMMddHH"));
+                        account.current_daily_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.pdd, account.id, DateTime.Now.ToString("yyyyMMdd"));
+                        account.current_hourly_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.pdd, account.id, DateTime.Now.ToString("yyyyMMddHH"));
                         changed = true;
                         any_pdd_changed = true;
                     }
@@ -672,8 +672,8 @@ namespace molilian.api.Controllers
                     bool changed = false;
                     try
                     {
-                        link.current_daily_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.cps, link.id, DateTime.Now.ToString("yyyyMMdd"));
-                        link.current_hourly_calls = RiskControlCore.GetAllNodesCalls(TkChannelEnum.cps, link.id, DateTime.Now.ToString("yyyyMMddHH"));
+                        link.current_daily_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.cps, link.id, DateTime.Now.ToString("yyyyMMdd"));
+                        link.current_hourly_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.cps, link.id, DateTime.Now.ToString("yyyyMMddHH"));
                         changed = true;
                         any_cps_changed = true;
                     }
@@ -719,7 +719,7 @@ namespace molilian.api.Controllers
                         if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 16)
                         {
                             DateTime date = DateTime.Now.AddDays(-1);
-                            alimama.FixReport(date);
+                            await alimama.FixReport(date);
                         }
                     }
                     catch (Exception ex)
@@ -844,7 +844,7 @@ namespace molilian.api.Controllers
 
                     while (date.Date < DateTime.Now.Date)
                     {
-                        alimama.FixReport(date);
+                        await alimama.FixReport(date);
                         date = date.AddDays(1);
                     }
                 }

+ 1 - 1
molilian.api/Properties/PublishProfiles/tester.pubxml

@@ -7,7 +7,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
     <WebPublishMethod>Custom</WebPublishMethod>
     <DockerPublish>true</DockerPublish>
     <RegistryUrl>https://ccr.ccs.tencentyun.com/shaobin</RegistryUrl>
-    <PublishImageTag>tester</PublishImageTag>
+    <PublishImageTag>tester2</PublishImageTag>
     <PublishProvider>ContainerRegistry</PublishProvider>
     <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
     <LastUsedPlatform>Any CPU</LastUsedPlatform>

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
molilian.api/Properties/PublishProfiles/tester.pubxml.user


+ 1 - 1
molilian.api/molilian.api.csproj

@@ -15,7 +15,7 @@
     <PackageReference Include="dodohold.core" Version="1.0.1.17" />
     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.0-Preview.1" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
-    <PackageReference Include="YunhuiKit" Version="0.0.7" />
+    <PackageReference Include="YunhuiKit" Version="0.0.12" />
   </ItemGroup>
 
   <ItemGroup>

+ 14 - 2
molilian.core/Core/EndPointCore.cs

@@ -23,6 +23,20 @@ namespace molilian.core
         private static readonly object _lockObj = new();
         private static IEnumerable<EndPointDTO> _cached;
 
+        public static string GetRedisServer(EndPointDTO node)
+        {
+#if DEBUG
+            return node.name switch
+            {
+                "bj" => "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook",
+                "gz" => "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook",
+                "coupon1" => "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon",
+                _ => string.Empty
+            };
+#else
+    return node.redis_server;
+#endif
+        }
 
         public static string CurrentEndPoint { get; set; }
         static EndPointCore()
@@ -206,7 +220,5 @@ Server=rm-2ze74506m3gfsqe7mco.rwlb.rds.aliyuncs.com; Port=3306; Database=coupon;
             });
             return result;
         }
-
     }
-
 }

+ 28 - 28
molilian.core/Core/admin/ChartDataCore.cs

@@ -27,19 +27,19 @@ namespace molilian.core
             public int total { get; set; } = 0;
         }
 
-        public static ChartDataRes GetJdData(string total_key, string accountName, string report_date)
+        public static async Task<ChartDataRes> GetJdDataAsync(string total_key, string accountName, string report_date)
         {
             ChartDataRes result = new();
             total_key = "parse_total";
             if (string.IsNullOrEmpty(accountName) || "all".Equals(accountName)) accountName = "jd";
             string cacheKey = $":{total_key}:{accountName}:{report_date}";
-            result.total = TkLogCore.GetTotal(cacheKey);
+            result.total = await TkLogCore.GetTotalAsync(cacheKey);
             if (result.total > 0)
             {
                 string[] keys = [];
 
                 cacheKey = $":{total_key}:{accountName}:message:{report_date}";
-                string[] message_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] message_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 var combinedKeys = keys.Union(message_keys).ToList();
                 combinedKeys.RemoveAll(item => item == "fail");
@@ -48,7 +48,7 @@ namespace molilian.core
                 foreach (var keyname in combinedKeys)
                 {
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data.Add(new ChartDataItem
                     {
@@ -60,13 +60,13 @@ namespace molilian.core
                 result.data = result.data.OrderByDescending(item => item.value).ToList();
 
                 cacheKey = $":{total_key}:{accountName}:reason:{report_date}";
-                string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 foreach (var keyname in reason_keys)
                 {
                     if ("没有优惠券".Equals(keyname)) continue;
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     //if (value < 50) continue;
                     result.data2.Add(new ChartDataItem
                     {
@@ -81,7 +81,7 @@ namespace molilian.core
                 foreach (var keyname in deeplink_keys)
                 {
                     cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data3.Add(new ChartDataItem
                     {
@@ -95,18 +95,18 @@ namespace molilian.core
 
             return result;
         }
-        public static ChartDataRes GetTaobaoData(string total_key, string accountName, string report_date)
+        public static async Task<ChartDataRes> GetTaobaoDataAsync(string total_key, string accountName, string report_date)
         {
             ChartDataRes result = new();
             if (string.IsNullOrEmpty(accountName) || "all".Equals(accountName)) accountName = "tb";
             string cacheKey = $":{total_key}:{accountName}:{report_date}";
-            result.total = TkLogCore.GetTotal(cacheKey);
+            result.total = await TkLogCore.GetTotalAsync(cacheKey);
             if (result.total > 0)
             {
                 string[] keys = ["success"];
 
                 cacheKey = $":{total_key}:{accountName}:message:{report_date}";
-                string[] message_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] message_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 var combinedKeys = keys.Union(message_keys).ToList();
                 combinedKeys.RemoveAll(item => item == "fail");
@@ -115,7 +115,7 @@ namespace molilian.core
                 foreach (var keyname in combinedKeys)
                 {
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data.Add(new ChartDataItem
                     {
@@ -127,14 +127,14 @@ namespace molilian.core
                 result.data = result.data.OrderByDescending(item => item.value).ToList();
 
                 cacheKey = $":{total_key}:{accountName}:reason:{report_date}";
-                string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 foreach (var keyname in reason_keys)
                 {
                     if ("没有优惠券".Equals(keyname)) continue;
 
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     //if (value < 50) continue;
                     result.data2.Add(new ChartDataItem
                     {
@@ -149,7 +149,7 @@ namespace molilian.core
                 foreach (var keyname in deeplink_keys)
                 {
                     cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data3.Add(new ChartDataItem
                     {
@@ -164,18 +164,18 @@ namespace molilian.core
             return result;
         }
 
-        public static ChartDataRes GetTaobaoCouponData(string total_key, string accountName, string report_date)
+        public static async Task<ChartDataRes> GetTaobaoCouponDataAsync(string total_key, string accountName, string report_date)
         {
             ChartDataRes result = new();
             if (string.IsNullOrEmpty(accountName) || "all".Equals(accountName)) accountName = "tb";
             string cacheKey = $":{total_key}:{accountName}:{report_date}";
-            result.total = TkLogCore.GetTotal(cacheKey, false);
+            result.total = await TkLogCore.GetTotalAsync(cacheKey, false);
             if (result.total > 0)
             {
                 string[] keys = ["success"];
 
                 cacheKey = $":{total_key}:{accountName}:message:{report_date}";
-                string[] message_keys = TkLogCore.GetTotalKeys(cacheKey, false);
+                string[] message_keys = await TkLogCore.GetTotalKeysAsync(cacheKey, false);
 
                 var combinedKeys = keys.Union(message_keys).ToList();
                 combinedKeys.RemoveAll(item => item == "fail");
@@ -184,7 +184,7 @@ namespace molilian.core
                 foreach (var keyname in combinedKeys)
                 {
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey, false);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey, false);
                     if (value == 0) continue;
                     result.data.Add(new ChartDataItem
                     {
@@ -196,14 +196,14 @@ namespace molilian.core
                 result.data = result.data.OrderByDescending(item => item.value).ToList();
 
                 cacheKey = $":{total_key}:{accountName}:reason:{report_date}";
-                string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey, false);
+                string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey, false);
 
                 foreach (var keyname in reason_keys)
                 {
                     if ("没有优惠券".Equals(keyname)) continue;
 
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey, false);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey, false);
                     //if (value < 50) continue;
                     result.data2.Add(new ChartDataItem
                     {
@@ -217,7 +217,7 @@ namespace molilian.core
             return result;
         }
 
-        public static ChartDataRes GetToolData(string total_key, string accountName, string report_date)
+        public static async Task<ChartDataRes> GetToolDataAsync(string total_key, string accountName, string report_date)
         {
             ChartDataRes result = new();
 
@@ -225,7 +225,7 @@ namespace molilian.core
             total_key = "parse_total";
 
             string cacheKey = $":{total_key}:{accountName}:{report_date}";
-            result.total = TkLogCore.GetTotal(cacheKey);
+            result.total = await TkLogCore.GetTotalAsync(cacheKey);
             if (result.total > 0)
             {
                 string[] keys = ["bdpan", "wemeet"];
@@ -234,10 +234,10 @@ namespace molilian.core
                 {
 
                     cacheKey = $":{total_key}:{keyname}:{report_date}";
-                    var total = TkLogCore.GetTotal(cacheKey);
+                    var total = await TkLogCore.GetTotalAsync(cacheKey);
 
                     cacheKey = $":{total_key}:{keyname}:success:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data.Add(new ChartDataItem
                     {
@@ -247,7 +247,7 @@ namespace molilian.core
                     });
 
                     cacheKey = $":{total_key}:{keyname}:fail:{report_date}";
-                    value = TkLogCore.GetTotal(cacheKey);
+                    value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data.Add(new ChartDataItem
                     {
@@ -258,12 +258,12 @@ namespace molilian.core
                 }
 
                 cacheKey = $":{total_key}:{accountName}:reason:{report_date}";
-                string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey);
+                string[] reason_keys = await TkLogCore.GetTotalKeysAsync(cacheKey);
 
                 foreach (var keyname in reason_keys)
                 {
                     cacheKey = $":{total_key}:{accountName}:{keyname}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data2.Add(new ChartDataItem
                     {
@@ -279,7 +279,7 @@ namespace molilian.core
                 foreach (var keyname in deeplink_keys)
                 {
                     cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date}";
-                    int value = TkLogCore.GetTotal(cacheKey);
+                    int value = await TkLogCore.GetTotalAsync(cacheKey);
                     if (value == 0) continue;
                     result.data3.Add(new ChartDataItem
                     {

+ 4 - 5
molilian.core/Core/aliyun/AliyunCore.cs

@@ -33,15 +33,14 @@ namespace molilian.core
             plus = new AliyunPlus(accessKeyId, accessKeySecret);
         }
 
-        public SearchByPicResponse SearchByPic(string base64String, string pid)
+        public async Task<SearchByPicResponse> SearchByPicAsync(string base64String, string pid)
         {
-            //account.refpid = "mm_6695915495_3161300068_115818650332";
-            return plus.SearchByPic(base64String, pid);
+            return await plus.SearchByPicAsync(base64String, pid);
         }
 
-        public PromotionQueryDTO picSimilaritem(string pic, string pid, ref PromotionQueryDTO result)
+        public async Task<PromotionQueryDTO> picSimilaritemAsync(string pic, string pid, PromotionQueryDTO result)
         {
-            var response = plus.SearchByPic(pic, pid);
+            var response = await plus.SearchByPicAsync(pic, pid);
             if (response == null)
             {
                 result.message = "调用失败";

+ 103 - 373
molilian.core/Core/log/base.cs

@@ -1,26 +1,7 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Controllers;
-using Microsoft.AspNetCore.Mvc.Filters;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using dodohold.core;
-using static dodohold.core.ZTOExpress.CreateOrderArgs;
-using System.Net;
-using System.Security.Cryptography;
-using Spire.Pdf.Exporting.XPS.Schema;
-using System.Xml.Linq;
-using static QRCoder.PayloadGenerator;
-using TencentCloud.Ssl.V20191205.Models;
+using dodohold.core;
 using CSRedis;
 using System.Data;
-using TencentCloud.Omics.V20221128.Models;
-using TencentCloud.Csip.V20221121.Models;
-using COSXML.Network;
-using System.Security.Policy;
 using System.Diagnostics;
-using TencentCloud.Ecm.V20190719.Models;
 using YunhuiKit;
 
 
@@ -42,194 +23,42 @@ namespace molilian.core
 
         public static async Task<int> BatchInsertLogDBAsync(int limit)
         {
-            await semaphore.WaitAsync(); // 等待获取锁
+            await semaphore.WaitAsync().ConfigureAwait(false);
             try
             {
-                var result = await Task.Run(() =>
-                {
-                    return EndPointCore.ProcessEndPointNodes<int>(node =>
+                var tasks = EndPointCore.List()
+                    .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+                    .Where(node => CenterHub.IsCenter ? !node.is_coupon_api : node.is_coupon_api)
+                    .Select(async node =>
                     {
-                        if (!node.is_public_api) return 0;
-
-                        if (CenterHub.IsCenter)
+                        var redisServer = EndPointCore.GetRedisServer(node);
+                        if (string.IsNullOrEmpty(redisServer)) return 0;
+                        try
                         {
-                            if (node.is_coupon_api) return 0;
+                            await using var scope = RedisClientFactory.CreateScope(redisServer);
+                            return BatchInsertLogDB(limit, scope.Client);
                         }
-                        else
-                        {
-                            if (!node.is_coupon_api) return 0;
-                        }
-
-                        if (string.IsNullOrEmpty(node.redis_server)) return 0;
-
-
-#if DEBUG
-                        switch (node.name)
+                        catch (Exception ex)
                         {
-
-                            case "bj":
-                                node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                                break;
-                            case "gz":
-                                node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                                break;
-                            case "coupon1":
-                                node.redis_server = "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                                break;
-                            default: return 0;
+                            // TODO: 添加日志记录
+                            return 0;
                         }
-#endif
-
-                        var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                        return BatchInsertLogDB(limit, redis);
                     });
-                });
-                return result.Sum();
-            }
-            finally
-            {
-                semaphore.Release(); // 释放锁,允许下一个任务执行
-            }
-        }
 
-
-        public static int BatchInsertLogDB2(int limit, CSRedisClient redis)
-        {
-            int total = 0;
-            using var connection = DBContext.GetOpenConnection();
-            connection.Open();
-            using var transaction = connection.BeginTransaction();
-
-            try
-            {
-                Stopwatch stopwatch = new Stopwatch(); // 创建一个计时器
-                LoggerLibrary log = new LoggerLibrary("debug", "BatchInsertLogDB"); // 创建日志对象
-
-
-                //第三方接口写入日志
-                stopwatch.Start();
-                int taskTotal = task_insert_tk_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_tk_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_tb_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_tb_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_jd_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_jd_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_pdd_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_pdd_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_dy_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_dy_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_tool_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_tool_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_deeplink_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_deeplink_logs  耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_coupon_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_coupon_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_cps_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_cps_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_promotion_img_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_promotion_img_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_ks_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_ks_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-
-                stopwatch.Start();
-                taskTotal = task_insert_parse_dy_logs(limit, redis);
-                total += taskTotal;
-                stopwatch.Stop();
-                log.Info($"task_insert_parse_dy_logs 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
-                log.SaveAsync();
-                stopwatch.Reset();
-
-                transaction.Commit();
+                var results = await Task.WhenAll(tasks).ConfigureAwait(false);
+                return results.Sum();
             }
-            catch (Exception ex)
+            catch (Exception)
             {
-                transaction.Rollback();
-
-                _ = new LoggerLibrary("database_error", "parse_log")
-                    .Info(ex.Message, ex.StackTrace)
-                    .SaveAsync();
-
-                NotifyCore.Notify(new NifyMessage
-                {
-                    message = $"【写入日志异常】\n{ex.Message}\n{ex.StackTrace}",
-                    priority = NifyMessagePriority.high,
-                    tags = ["red_circle"]
-                });
+                return 0;
             }
             finally
             {
-                connection.Close();
+                semaphore.Release();
             }
-            return total;
         }
 
-        public static int BatchInsertLogDB(int limit, CSRedisClient redis)
+        public static int BatchInsertLogDB(int limit, YunhuiKit.RedisClient redis)
         {
             int total = 0;
             //using var connection = DBContext.GetOpenConnection();
@@ -243,20 +72,35 @@ namespace molilian.core
                 Stopwatch stopwatch = new Stopwatch(); // 创建一个计时器
 
                 var tasks = new List<Task<int>>
-        {
-            Task.Run(() => RunTaskWithLogging(() => task_insert_tk_logs(limit, redis), "task_insert_tk_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_tb_logs(limit, redis), "task_insert_parse_tb_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_jd_logs(limit, redis), "task_insert_parse_jd_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_pdd_logs(limit, redis), "task_insert_parse_pdd_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_dy_logs(limit, redis), "task_insert_parse_dy_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_tool_logs(limit, redis), "task_insert_parse_tool_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_deeplink_logs(limit, redis), "task_insert_parse_deeplink_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_coupon_logs(limit, redis), "task_insert_parse_coupon_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_cps_logs(limit, redis), "task_insert_parse_cps_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_promotion_img_logs(limit, redis), "task_insert_promotion_img_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_ks_logs(limit, redis), "task_insert_parse_ks_logs")),
-            Task.Run(() => RunTaskWithLogging(() => task_insert_parse_dy_logs(limit, redis), "task_insert_parse_dy_logs"))
-        };
+                {
+                    RunTaskWithLoggingAsync(() => InsertPromotionImgAsync(limit, redis), "task_insert_promotion_img_logs"),
+                    RunTaskWithLoggingAsync(() => InsertParseTkLogAsync(limit, redis), "task_insert_parse_tb_logs"),
+                    RunTaskWithLoggingAsync(() => InsertParseJDLogAsync(limit, redis), "task_insert_parse_jd_logs"),
+                    RunTaskWithLoggingAsync(() => InsertParsePddLogAsync(limit, redis), "task_insert_parse_pdd_logs"),
+                    RunTaskWithLoggingAsync(() => InsertParseDyLogAsync(limit, redis), "task_insert_parse_dy_logs"),
+                    RunTaskWithLoggingAsync(() => InsertParseKsLogAsync(limit, redis), "task_insert_parse_ks_logs"),
+
+
+                    RunTaskWithLoggingAsync(() => InsertToolLogAsync(limit, redis), "task_insert_parse_tool_logs"),
+                    RunTaskWithLoggingAsync(() => InsertDeeplinkLogAsync(limit, redis), "task_insert_parse_deeplink_logs"),
+
+                    RunTaskWithLoggingAsync(() => InsertCouponLogAsync(limit, redis), "task_insert_parse_coupon_logs"),
+                    RunTaskWithLoggingAsync(() => InsertCpsLogAsync(limit, redis), "task_insert_parse_cps_logs"),
+
+
+
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_tk_logs(limit, redis), "task_insert_tk_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_tb_logs(limit, redis), "task_insert_parse_tb_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_jd_logs(limit, redis), "task_insert_parse_jd_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_pdd_logs(limit, redis), "task_insert_parse_pdd_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_dy_logs(limit, redis), "task_insert_parse_dy_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_tool_logs(limit, redis), "task_insert_parse_tool_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_deeplink_logs(limit, redis), "task_insert_parse_deeplink_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_coupon_logs(limit, redis), "task_insert_parse_coupon_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_cps_logs(limit, redis), "task_insert_parse_cps_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_promotion_img_logs(limit, redis), "task_insert_promotion_img_logs")),
+                    //Task.Run(() => RunTaskWithLogging(() => task_insert_parse_ks_logs(limit, redis), "task_insert_parse_ks_logs"))
+                };
 
                 // 等待所有任务完成
                 Task.WhenAll(tasks).Wait();//252行
@@ -312,42 +156,28 @@ namespace molilian.core
         }
 
 
-        // 新增一个辅助方法来处理日志记录和任务执行
-        private static int RunTaskWithLogging(Func<int> taskFunc, string taskName)
+
+        private static async Task<int> RunTaskWithLoggingAsync(Func<Task<int>> taskFunc, string taskName)
         {
             LoggerLibrary log = new LoggerLibrary("debug", "BatchInsertLogDB"); // 创建日志对象
             Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
-            int taskTotal = taskFunc();
+            int taskTotal = await taskFunc();
             stopwatch.Stop();
             log.Info($"{taskName} 耗时: {stopwatch.ElapsedMilliseconds} ms,\t插入记录数: {taskTotal}");
             log.SaveAsync();
             return taskTotal;
         }
 
-
-        public static int BatchInsertLogDB(int limit)
-        {
-            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
-            {
-                if (!node.is_public_api) return 0;
-
-                if (CenterHub.IsCenter)
-                {
-                    if (node.is_coupon_api) return 0;
-                }
-                else
-                {
-                    if (!node.is_coupon_api) return 0;
-                }
-
-                if (string.IsNullOrEmpty(node.redis_server)) return 0;
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                return BatchInsertLogDB(limit, redis);
-            });
-            return result.Sum();
-        }
+        /// <summary>
+        /// 过时方法 随时删除
+        /// </summary>
+        /// <param name="channel"></param>
+        /// <param name="accountId"></param>
+        /// <param name="accountName"></param>
+        /// <param name="success"></param>
+        /// <param name="message"></param>
+        /// <param name="reason"></param>
         private static void saveCache(string channel, int accountId, string accountName, bool success, string message, string reason)
         {
             saveAccountCache("all", success, message, reason);
@@ -419,11 +249,11 @@ namespace molilian.core
                 return Task.CompletedTask;
             });
         }
-        private async static Task saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
+        private async static Task saveClientRequestTotalAsync(TkChannelEnum channel, string ip, string oaid)
         {
-            await saveClientRequestTotal(channel.ToString(), ip, oaid);
+            await saveClientRequestTotalAsync(channel.ToString(), ip, oaid);
         }
-        private static async Task saveClientRequestTotal(string channel, string ip, string oaid)
+        private static async Task saveClientRequestTotalAsync(string channel, string ip, string oaid)
         {
             await EndPointCore.ProcessEndPointNodesAsync(node =>
             {
@@ -637,8 +467,6 @@ namespace molilian.core
                 saveParseAccountCache($"{channel}_{accountId}", success, message, reason);
             }
         }
-
-
         private static void saveParseAccountCache(string accountName, bool success,
             string message, string reason)
         {
@@ -684,164 +512,66 @@ namespace molilian.core
             }
         }
 
-        public static int GetTotal(string keyname, bool all_node = true)
-        {
-            //:coupon_total:tb:20240706
-            //:coupon_total:tb:success:20240706
-            //:coupon_total:tb:放弃转链:20240706
-
-            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
-            {
-                if (!node.is_public_api) return 0;
-                if (string.IsNullOrEmpty(node.redis_server)) return 0;
-
-                if (!all_node)
-                {
-                    if (CenterHub.IsCenter)
-                    {
-                        if (node.is_coupon_api) { return 0; }
-                    }
-                    else
-                    {
-                        if (!node.is_coupon_api) { return 0; }
-                    }
-                }
-
-#if DEBUG
-                switch (node.name)
-                {
-
-                    case "bj":
-                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "gz":
-                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "coupon1":
-                        node.redis_server = "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-
-#endif
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                int count = redis.Get<int>(keyname);
-                return count;
-            });
-            return result.Sum();
-        }
-
         public static async Task<int> GetTotalAsync(string keyname, bool all_node = true)
         {
-            async Task<int> ProcessNode(EndPointDTO node)
+            try
             {
-                if (!IsValidNode(node, all_node)) return 0;
+                var tasks = EndPointCore.List()
+                    .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+                    .Where(node => all_node || (CenterHub.IsCenter ? !node.is_coupon_api : node.is_coupon_api))
+                    .Select(async node =>
+                    {
+                        var redisServer = EndPointCore.GetRedisServer(node);
+                        if (string.IsNullOrEmpty(redisServer))
+                            return 0;
 
-                var redisServer = GetRedisServer(node);
-                if (string.IsNullOrEmpty(redisServer)) return 0;
+                        try
+                        {
+                            await using var scope = RedisClientFactory.CreateScope(redisServer);
+                            return await scope.Client.GetAsync<int>(keyname);
+                        }
+                        catch (Exception)
+                        {
+                            return 0;
+                        }
+                    });
 
-                try
-                {
-                    //var redis = RedisClientManager.GetRedisClient(redisServer);
-                    await using var scope = RedisClientFactory.CreateScope(redisServer);
-                    var client = scope.Client;
-                    return await client.GetAsync<int>(keyname);
-                }
-                catch (Exception ex)
-                {
-                    // 可以添加日志记录
-                    return 0;
-                }
+                var results = await Task.WhenAll(tasks);
+                return results.Sum();
             }
-
-            var result = await EndPointCore.ProcessEndPointNodesTaskAsync<int>(ProcessNode);
-            return result.Sum();
-        }
-
-        private static bool IsValidNode(EndPointDTO node, bool all_node)
-        {
-            if (!node.is_public_api || string.IsNullOrEmpty(node.redis_server))
-                return false;
-
-            if (!all_node)
+            catch (Exception)
             {
-                if (CenterHub.IsCenter)
-                    return !node.is_coupon_api;
-                else
-                    return node.is_coupon_api;
+                return 0;
             }
-
-            return true;
         }
 
-        private static string GetRedisServer(EndPointDTO node)
+        public static async Task<string[]> GetTotalKeysAsync(string keyname, bool all_node = true)
         {
-#if DEBUG
-            return node.name switch
-            {
-                "bj" => "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook",
-                "gz" => "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook",
-                "coupon1" => "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon",
-                _ => string.Empty
-            };
-#else
-    return node.redis_server;
-#endif
-        }
-
 
-
-        public static string[] GetTotalKeys(string keyname, bool all_node = true)
-        {
-
-            var result = EndPointCore.ProcessEndPointNodes<string[]>(node =>
+            var tasks = EndPointCore.List()
+            .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+            .Where(node => all_node || (CenterHub.IsCenter ? !node.is_coupon_api : node.is_coupon_api))
+            .Select(async node =>
             {
-                if (!node.is_public_api) return [];
-                if (string.IsNullOrEmpty(node.redis_server)) return [];
-
-                if (!all_node)
+                try
                 {
-                    if (CenterHub.IsCenter)
-                    {
-                        if (node.is_coupon_api) { return []; }
-                    }
-                    else
-                    {
-                        if (!node.is_coupon_api) { return []; }
-                    }
+                    var redisServer = EndPointCore.GetRedisServer(node);
+                    if (string.IsNullOrEmpty(redisServer)) return [];
+
+                    using var scope = RedisClientFactory.CreateScope(redisServer);
+                    return await scope.Client.SMembersAsync<string>(keyname);
                 }
-#if DEBUG
-                switch (node.name)
+                catch (Exception ex)
                 {
-
-                    case "bj":
-                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "gz":
-                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "coupon1":
-                        node.redis_server = "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return [];
+                    return [];
                 }
-#endif
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-
-                string[] message_keys = redis.SMembers(keyname);
-                return message_keys;
             });
 
-            string[] message_keys = [];
-            foreach (var arr in result)
-            {
-                message_keys = message_keys.Union(arr).ToArray();
-            }
-            return message_keys;
+            var results = await Task.WhenAll(tasks);
+            return results.SelectMany(x => x).Distinct().ToArray();
+
         }
 
 
     }
-
 }

+ 55 - 10
molilian.core/Core/log/coupon.cs

@@ -7,6 +7,54 @@ namespace molilian.core
     public partial class TkLogCore
     {
         static string queue_coupon_key = "queue:coupon_logs";
+
+
+        public static async Task<int> InsertCouponLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<UnionCouponDTO>(queue_coupon_key);
+                    if (data == null) break;
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        var test_data = data.Convert2Json().Convert2Object<TestUnionCouponDTO>();
+                        connection.Insert(test_data);
+                    }
+                    else
+                    {
+                        connection.Insert(data);
+                        if (data.success)
+                        {
+                            var success_data = data.Convert2Json().Convert2Object<SuccessUnionCouponDTO>();
+                            connection.Insert(success_data);
+                        }
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_coupon_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
         public static int task_insert_parse_coupon_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -53,7 +101,6 @@ namespace molilian.core
             }
             return total;
         }
-
         public static async Task CouponLogAsync(UnionCouponDTO response, AlimamaPlus? alimamaPlus = null)
         {
             try
@@ -67,21 +114,19 @@ namespace molilian.core
                     saveCouponCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
                 }
 
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                if (response.success) await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
                 if (!response.success && "nologin".Equals(response.message))
                 {
                     switch (response.channel)
                     {
                         case TkChannelEnum.tb:
-                            await Task.Run(() =>
+                            if (alimamaPlus != null)
                             {
-                                if (alimamaPlus != null)
-                                {
-                                    (bool success, string message) = alimamaPlus.RenewCookie();
-                                    if (success) return;
-                                }
-                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
-                            }); break;
+                                (bool success, string message) = alimamaPlus.RenewCookie();
+                                if (success) return;
+                            }
+                            TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
+                            break;
                     }
                 }
             }

+ 47 - 2
molilian.core/Core/log/cps.cs

@@ -9,6 +9,51 @@ namespace molilian.core
     {
         static string queue_cps_key = "queue:cps_logs";
 
+
+        public static async Task<int> InsertCpsLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<UnionCpsDTO>(queue_cps_key);
+                    if (data == null) break;
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        var test_data = data.Convert2Json().Convert2Object<TestUnionCpsDTO>();
+                        connection.Insert(test_data);
+                    }
+                    else
+                    {
+                        //按日保存数据
+                        string daily_table = $"tk_cps_logs_{data.create_time:yyyyMMdd}";
+                        save_cps_parse_logs(data, daily_table, connection, transaction);
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_cps_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
         public static int task_insert_parse_cps_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -91,8 +136,8 @@ namespace molilian.core
 
                 if (response.success)
                 {
-                    RiskControlCore.CallsIncrBy(TkChannelEnum.cps, response.accountId);
-                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                    await RiskControlCore.CallsIncrByAsync(TkChannelEnum.cps, response.accountId);
+                    await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
                 }
 
                 if (!response.ip.StartsWith("127.0.0"))

+ 61 - 2
molilian.core/Core/log/deeplink.cs

@@ -2,6 +2,7 @@
 using CSRedis;
 using System.Data;
 using static dodohold.core.ZTOExpress.CreateOrderArgs;
+using YunhuiKit;
 
 namespace molilian.core
 {
@@ -9,6 +10,64 @@ namespace molilian.core
     {
 
         static string queue_deeplink_parse_key = "queue:parse_logs:deeplink";
+        
+        public static async Task<int> InsertDeeplinkLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<DeeplinkParseDataDTO>(queue_deeplink_parse_key);
+                    if (data == null) break;
+
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        save_dp_parse_logs(data, "deeplink_parse_logs_test", connection, transaction);
+                    }
+                    else
+                    {
+                        //save_dp_parse_logs(data, "deeplink_parse_logs", connection, transaction);
+
+                        //if (save_dailys_log)
+                        {
+                            string daily_table = $"deeplink_parse_logs_{data.create_time:yyyyMMdd}";
+                            save_dp_parse_logs(data, daily_table, connection, transaction);
+                        }
+
+                        if (data.success)
+                        {
+                            save_dp_parse_logs(data, "deeplink_parse_logs_success", connection, transaction);
+                        }
+                        else
+                        {
+                            save_dp_parse_logs(data, "deeplink_parse_logs_fail", connection, transaction);
+                        }
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_deeplink_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
 
 
         public static int task_insert_parse_deeplink_logs(int limit, CSRedisClient redis)
@@ -109,11 +168,11 @@ namespace molilian.core
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_deeplink_parse_key, response);
+                _ = RedisKit.RPushAsync(queue_deeplink_parse_key, response);
 
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel_name, 0, "tool",
+                    await SaveParseCacheAsync(response.channel_name, 0, "tool",
                         response.success, response.message, response.reason,
                         response.deeplink_url);
                 }

+ 64 - 3
molilian.core/Core/log/dy.cs

@@ -1,12 +1,73 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using YunhuiKit;
 
 namespace molilian.core
 {
     public partial class TkLogCore
     {
         static string queue_parse_dy_key = "queue:parse_logs:dy";
+        public static async Task<int> InsertParseDyLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+
+                for (int i = 0; i < limit; i++)
+                {
+
+                    var data = await redis.LPopAsync<DyDataDTO>(queue_parse_dy_key);
+                    if (data == null) break;
+                    string daily_table = $"dy_parse_logs_{data.create_time:yyyyMMdd}";
+                    new DBContext.Table(connection, daily_table)
+                        .Add("end_point", data.end_point)
+                        .Add("channel", (int)data.channel)
+                        .Add("accountId", data.accountId)
+                        .Add("accountName", data.accountName)
+                        .Add("proxy_node", data.proxy_node)
+                        .Add("rawContent", data.rawContent)
+                        .Add("success", data.success)
+                        .Add("message", data.message)
+                        .Add("reason", data.reason)
+                        .Add("content", data.content)
+                        .Add("itemId", data.itemId)
+                        .Add("itemName", data.itemName)
+                        .Add("pic", data.pic)
+                        .Add("couponAmount", data.couponAmount)
+                        .Add("promotionPrice", data.promotionPrice)
+                        .Add("taoToken", data.taoToken)
+                        .Add("shortLinkurl", data.shortLinkurl)
+                        .Add("deeplink_url", data.deeplink_url)
+                        .Add("elapsedTime", data.elapsedTime)
+                        .Add("elapsedTime2", data.elapsedTime2)
+                        .Add("elapsedTime3", data.elapsedTime3)
+                        .Add("subCode", data.subCode)
+                        .Add("ip", data.ip)
+                        .Add("oaid", data.oaid)
+                        .Add("create_time", data.create_time)
+                        .Create(DBContext.InsertType.NORMAL, transaction);
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_dy_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
 
         public static int task_insert_parse_dy_logs(int limit, CSRedisClient redis)
         {
@@ -75,13 +136,13 @@ namespace molilian.core
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_dy_key, response);
+                _ = RedisKit.RPushAsync(queue_parse_dy_key, response);
 
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                if (response.success) await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
 
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId,
+                    await SaveParseCacheAsync(response.channel.ToString(), response.accountId,
                         response.accountName, response.success, response.message, response.reason,
                         response.deeplink_url);
                 }

+ 60 - 3
molilian.core/Core/log/jd.cs

@@ -9,6 +9,63 @@ namespace molilian.core
     {
         static string queue_parse_jd_key = "queue:parse_logs:jd";
 
+
+        public static async Task<int> InsertParseJDLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<JdDataDTO>(queue_parse_jd_key);
+                    if (data == null) break;
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        save_jd_parse_logs(data, "jd_parse_logs_test", connection, transaction);
+                    }
+                    else
+                    {
+                        //save_jd_parse_logs(data, "jd_parse_logs", connection, transaction);
+
+                        //if (save_dailys_log)
+                        {
+                            string daily_table = $"jd_parse_logs_{data.create_time:yyyyMMdd}";
+                            save_jd_parse_logs(data, daily_table, connection, transaction);
+                        }
+
+                        if (data.elapsedTime > 1000)
+                        {
+                            save_jd_parse_logs(data, "jd_parse_logs_test", connection, transaction);
+                        }
+                        if (data.success)
+                        {
+                            save_jd_parse_logs(data, "jd_parse_logs_success", connection, transaction);
+                        }
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_jd_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
         public static int task_insert_parse_jd_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -75,15 +132,15 @@ namespace molilian.core
 
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId,
+                    await SaveParseCacheAsync(response.channel.ToString(), response.accountId,
                         response.accountName, response.success, response.message, response.reason,
                         response.deeplink_url);
                 }
 
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                if (response.success) await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
+                    await RiskControlCore.CallsIncrByAsync(response.channel, response.accountId);
                     //saveClientRequestTotal(response.channel, response.ip, response.oaid);
                 }
 

+ 61 - 8
molilian.core/Core/log/ks.cs

@@ -1,6 +1,7 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using YunhuiKit;
 
 namespace molilian.core
 {
@@ -8,6 +9,61 @@ namespace molilian.core
     {
         static string queue_parse_ks_key = "queue:parse_logs:ks";
 
+
+
+
+        public static async Task<int> InsertParseKsLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<KsDataDTO>(queue_parse_ks_key);
+                    if (data == null) break;
+
+
+                    if (_test_oaid.Equals(data.oaid) || data.ip.StartsWith("127.0.0"))
+                    {
+                        save_ks_parse_logs(data, "ks_parse_logs_test", connection, transaction);
+                    }
+                    else
+                    {
+                        //save_ks_parse_logs(data, "ks_parse_logs", connection, transaction);
+
+                        //if (save_dailys_log)
+                        {
+                            string daily_table = $"ks_parse_logs_{data.create_time:yyyyMMdd}";
+                            save_ks_parse_logs(data, daily_table, connection, transaction);
+                        }
+
+                        if (data.success)
+                        {
+                            save_ks_parse_logs(data, "ks_parse_logs_success", connection, transaction);
+                        }
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_ks_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
         public static int task_insert_parse_ks_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -66,11 +122,11 @@ namespace molilian.core
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_ks_key, response);
+                _ = RedisKit.RPushAsync(queue_parse_ks_key, response);
 
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId,
+                    await SaveParseCacheAsync(response.channel.ToString(), response.accountId,
                         response.accountName, response.success, response.message, response.reason,
                         response.deeplink_url);
                 }
@@ -78,17 +134,14 @@ namespace molilian.core
                 //if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
-                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                    await RiskControlCore.CallsIncrByAsync(response.channel, response.accountId);
+                    await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
                 }
                 if (!response.success && ("nologin".Equals(response.reason) ||
                     "方法不存在".Equals(response.reason) ||
                     "未登录".Equals(response.reason)))
                 {
-                    await Task.Run(() =>
-                    {
-                        KsPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
-                    });
+                    KsPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
                 }
                 if ("没有匹配账号".Equals(response.reason))
                 {

+ 60 - 11
molilian.core/Core/log/pdd.cs

@@ -1,6 +1,7 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using YunhuiKit;
 
 namespace molilian.core
 {
@@ -8,6 +9,58 @@ namespace molilian.core
     {
         static string queue_parse_pdd_key = "queue:parse_logs:pdd";
 
+
+        public static async Task<int> InsertParsePddLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<PddDataDTO>(queue_parse_pdd_key);
+                    if (data == null) break;
+
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        save_pdd_parse_logs(data, "pdd_parse_logs_test", connection, transaction);
+                    }
+                    else
+                    {
+                        //save_pdd_parse_logs(data, "pdd_parse_logs", connection, transaction);
+                        //if (save_dailys_log)
+                        {
+                            string daily_table = $"pdd_parse_logs_{data.create_time:yyyyMMdd}";
+                            save_pdd_parse_logs(data, daily_table, connection, transaction);
+                        }
+                        if (!data.success)
+                        {
+                            save_pdd_parse_logs(data, "pdd_parse_logs_fail", connection, transaction);
+                        }
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_pdd_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
         public static int task_insert_parse_pdd_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -59,27 +112,26 @@ namespace molilian.core
             return total;
         }
 
-
         public static async Task ParseLogAsync(PddDataDTO response)
         {
             try
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_pdd_key, response);
+                _ = RedisKit.RPushAsync(queue_parse_pdd_key, response);
 
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId,
-                        response.accountName, response.success, response.message, response.reason,
-                        response.deeplink_url);
+                    await SaveParseCacheAsync(response.channel.ToString(), response.accountId,
+                          response.accountName, response.success, response.message, response.reason,
+                          response.deeplink_url);
                 }
 
                 //if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
-                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                    await RiskControlCore.CallsIncrByAsync(response.channel, response.accountId);
+                    await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
                 }
 
                 if (response.reason.Equals("您的调用次数过高"))
@@ -91,10 +143,7 @@ namespace molilian.core
                     "方法不存在".Equals(response.reason) ||
                     "未登录".Equals(response.reason)))
                 {
-                    await Task.Run(() =>
-                    {
-                        PddPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
-                    });
+                    PddPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
                 }
                 if (response.reason.Contains("当前账号被禁止使用转链功能"))
                 {

+ 78 - 41
molilian.core/Core/log/promotion.cs

@@ -1,6 +1,7 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using YunhuiKit;
 
 namespace molilian.core
 {
@@ -8,6 +9,49 @@ namespace molilian.core
     {
         static string promotion_img_key = "queue:promotion:img";
 
+        public static async Task<int> InsertPromotionImgAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<PromotionQueryDTO>(promotion_img_key);
+                    if (data == null) break;
+
+                    if (data.success)
+                    {
+                        data.similarPromotion = string.Empty;
+                        data.promotionImg = string.Empty;
+                    }
+
+                    //按日保存数据
+                    string daily_table = $"tk_promotion_logs_{data.create_time:yyyyMMdd}";
+                    save_tk_promotion_img_logs(data, daily_table, connection, transaction);
+
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_pdd_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
         public static int task_insert_promotion_img_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -50,7 +94,6 @@ namespace molilian.core
             }
             return total;
         }
-
         private static int save_tk_promotion_img_logs(PromotionQueryDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
         {
             try
@@ -88,11 +131,9 @@ namespace molilian.core
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(promotion_img_key, response);
+                _ = RedisKit.RPushAsync(promotion_img_key, response);
 
-                //using var connection = DBContext.GetOpenConnection();
-                //connection.Insert(response);
-                savePromotionCache(response.accountId, response.accountName, response.scene, response.success, response.message, response.reason);
+                _ = savePromotionCacheAsync(response.accountId, response.accountName, response.scene, response.success, response.message, response.reason);
             }
             catch (Exception ex) { }
         }
@@ -101,60 +142,56 @@ namespace molilian.core
 
 
 
-        private static void savePromotionCache(int accountId, string accountName, string scene, bool success, string message, string reason)
+        private static async Task savePromotionCacheAsync(int accountId, string accountName, string scene, bool success, string message, string reason)
         {
-            savePromotionAccountCache("all", success, message, reason);
-            savePromotionAccountCache($"{accountId}", success, message, reason);
-            savePromotionAccountCache($"all_scene_{scene}", success, message, reason);
-            savePromotionAccountCache($"{accountId}_{scene}", success, message, reason);
+            await savePromotionAccountCacheAsync("all", success, message, reason);
+            await savePromotionAccountCacheAsync($"{accountId}", success, message, reason);
+            await savePromotionAccountCacheAsync($"all_scene_{scene}", success, message, reason);
+            await savePromotionAccountCacheAsync($"{accountId}_{scene}", success, message, reason);
         }
 
-        private static void savePromotionAccountCache(string accountName, bool success, string message, string reason)
+        private static async Task savePromotionAccountCacheAsync(string accountName, bool success, string message, string reason)
         {
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
+            await RedisKit.IncrByAsync($":promotion_total:{accountName}:{DateTime.Now:yyyyMM}");
+            await RedisKit.IncrByAsync($":promotion_total:{accountName}:{DateTime.Now:yyyyMMdd}");
+            await RedisKit.IncrByAsync($":promotion_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
 
 
             string result = success ? "success" : "fail";
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
+            await RedisKit.IncrByAsync($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
+            await RedisKit.IncrByAsync($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
+            await RedisKit.IncrByAsync($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
 
 
             if (!string.IsNullOrEmpty(message))
             {
-                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
-                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
-                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
-
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
+                await RedisKit.SAddAsync($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
+                await RedisKit.SAddAsync($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
+                await RedisKit.SAddAsync($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
+
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
             }
 
             if (!string.IsNullOrEmpty(reason))
             {
-                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
-                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
-                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
-
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
+                await RedisKit.SAddAsync($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
+                await RedisKit.SAddAsync($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
+                await RedisKit.SAddAsync($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
+
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
+                await RedisKit.IncrByAsync($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
             }
         }
 
-
-
-
-
     }
 
 }

+ 83 - 12
molilian.core/Core/log/taobao.cs

@@ -1,6 +1,7 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using YunhuiKit;
 
 namespace molilian.core
 {
@@ -9,6 +10,78 @@ namespace molilian.core
 
         static string queue_parse_tb_key = "queue:parse_logs:tb";
 
+        public static async Task<int> InsertParseTkLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<TkDataDTO>(queue_parse_tb_key);
+                    if (data == null) break;
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        save_tk_parse_logs(data, "tk_parse_logs_test", connection, transaction);
+                    }
+                    else
+                    {
+                        //data.id = save_tk_parse_logs(data, "tk_parse_logs", connection, transaction);
+
+                        ////每日分表
+                        //if (save_dailys_log)
+                        {
+                            string daily_table = $"tk_parse_logs_{data.create_time:yyyyMMdd}";
+                            save_tk_parse_logs(data, daily_table, connection, transaction);
+                        }
+
+                        if (data.elapsedTime > 1000)
+                        {
+                            save_tk_parse_logs(data, "tk_parse_logs_test", connection, transaction);
+                        }
+                        if (data.success)
+                        {
+                            save_tk_parse_logs(data, "tk_success_parse_logs", connection, transaction);
+                        }
+                        if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
+                    }
+
+                    if (data.reason.Contains("初步筛选2") && !data.rawContent.Contains("I:/kWqN5t623Hx"))
+                    {
+                        save_tk_parse_logs(data, "tk_parse_logs_test2", connection, transaction);
+                    }
+
+                    if (data.reason.Contains("初步筛选1.5"))
+                    {
+                        save_tk_parse_logs(data, "tk_parse_logs_multi_token", connection, transaction);
+                    }
+                    if (data.reason.Contains("霸下验证码"))
+                    {
+                        save_tk_parse_logs(data, "tk_parse_logs_captcha", connection, transaction);
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_tb_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
         public static int task_insert_parse_tb_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -90,12 +163,12 @@ namespace molilian.core
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_tb_key, response);
+                _ = RedisKit.RPushAsync(queue_parse_tb_key, response);
 
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
-                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
+                    await RiskControlCore.CallsIncrByAsync(response.channel, response.accountId);
+                    await saveClientRequestTotalAsync(response.channel, response.ip, response.oaid);
                 }
                 if (response.success)
                 {
@@ -103,7 +176,7 @@ namespace molilian.core
                 }
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId,
+                    await SaveParseCacheAsync(response.channel.ToString(), response.accountId,
                         response.accountName, response.success, response.message, response.reason,
                         response.deeplink_url);
                 }
@@ -114,15 +187,13 @@ namespace molilian.core
                     switch (response.channel)
                     {
                         case TkChannelEnum.tb:
-                            await Task.Run(() =>
+                            if (alimamaPlus != null)
                             {
-                                if (alimamaPlus != null)
-                                {
-                                    (bool success, string message) = alimamaPlus.RenewCookie();
-                                    if (success) return;
-                                }
-                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
-                            }); break;
+                                (bool success, string message) = alimamaPlus.RenewCookie();
+                                if (success) return;
+                            }
+                            TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
+                            break;
                     }
                 }
                 if (response.subCode == TkSubCodeEnum.Captcha || "霸下验证码".Equals(response.reason))

+ 78 - 2
molilian.core/Core/log/tool.cs

@@ -1,6 +1,7 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using YunhuiKit;
 
 namespace molilian.core
 {
@@ -8,6 +9,80 @@ namespace molilian.core
     {
         static string queue_parse_tool_key = "queue:parse_logs:tool";
 
+        public static async Task<int> InsertToolLogAsync(int limit, YunhuiKit.RedisClient redis)
+        {
+            int total = 0;
+
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+            try
+            {
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = await redis.LPopAsync<ToolParseDataDTO>(queue_parse_tool_key);
+                    if (data == null) break;
+
+
+                    if (_test_oaid.Equals(data.oaid) ||
+                         data.ip.StartsWith("127.0.0"))
+                    {
+                        new DBContext.Table(connection, "tool_parse_logs_test")
+                            .Add("end_point", data.end_point)
+                            .Add("channel", (int)data.channel)
+                            .Add("rawContent", data.rawContent)
+                            .Add("success", data.success)
+                            .Add("message", data.message)
+                            .Add("reason", data.reason)
+                            .Add("content", data.content)
+                            .Add("taoToken", data.taoToken)
+                            .Add("shortLinkurl", data.shortLinkurl)
+                            .Add("deeplink_url", data.deeplink_url)
+                            .Add("elapsedTime", data.elapsedTime)
+                            .Add("ip", data.ip)
+                            .Add("oaid", data.oaid)
+                            .Add("create_time", data.create_time)
+                            .Create(DBContext.InsertType.NORMAL, transaction);
+                    }
+                    else
+                    {
+                        new DBContext.Table(connection, "tool_parse_logs")
+                            .Add("end_point", data.end_point)
+                            .Add("channel", (int)data.channel)
+                            .Add("rawContent", data.rawContent)
+                            .Add("success", data.success)
+                            .Add("message", data.message)
+                            .Add("reason", data.reason)
+                            .Add("content", data.content)
+                            .Add("taoToken", data.taoToken)
+                            .Add("shortLinkurl", data.shortLinkurl)
+                            .Add("deeplink_url", data.deeplink_url)
+                            .Add("elapsedTime", data.elapsedTime)
+                            .Add("ip", data.ip)
+                            .Add("oaid", data.oaid)
+                            .Add("create_time", data.create_time)
+                            .Create(DBContext.InsertType.NORMAL, transaction);
+                    }
+                    total++;
+                }
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+                new LoggerLibrary("TkLogCore_error", "task_insert_parse_tool_logs")
+                      .Info(ex.Message, ex.StackTrace)
+                      .SaveAsync();
+                throw;
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+
+
         public static int task_insert_parse_tool_logs(int limit, CSRedisClient redis)
         {
             int total = 0;
@@ -88,11 +163,12 @@ namespace molilian.core
             {
                 var ts = DateTime.Now - response.create_time;
                 response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_tool_key, response);
+
+                _ = RedisKit.RPushAsync(queue_parse_tool_key, response);
 
                 if (!response.ip.StartsWith("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), 0, "tool",
+                    await SaveParseCacheAsync(response.channel.ToString(), 0, "tool",
                         response.success, response.message, response.reason,
                         response.deeplink_url);
                 }

+ 100 - 46
molilian.core/Core/taoke/OrderTrackingCore.cs

@@ -14,6 +14,7 @@ using TencentCloud.Tcm.V20210413.Models;
 using System.Security.Cryptography;
 using System.Data;
 using System.Threading.Channels;
+using YunhuiKit;
 
 
 namespace molilian.core
@@ -57,70 +58,121 @@ namespace molilian.core
             RedisHelper.Set(cacheKey, newData, ttl);
         }
 
-        public static TkDataDTO GetLinkSummary(int accountId, string itemId, string mktId, string itemTitle)
+
+        public static async Task<TkDataDTO> GetLinkSummaryAsync(int accountId, string itemId, string mktId, string itemTitle)
         {
-            if (!string.IsNullOrEmpty(mktId) && mktId.Contains('-'))
+            try
             {
-                mktId = mktId.Split('-')[^1];
+                mktId = !string.IsNullOrEmpty(mktId) && mktId.Contains('-')
+                    ? mktId.Split('-')[^1]
+                    : mktId;
+
+                var tasks = EndPointCore.List()
+                    .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+                    .Select(async node =>
+                    {
+                        var redisServer = EndPointCore.GetRedisServer(node);
+                        if (string.IsNullOrEmpty(redisServer)) return null;
+
+                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        var redis = scope.Client;
+
+                        // 按优先级依次查询不同的缓存key
+                        TkDataDTO result = null;
+
+                        if (!string.IsNullOrEmpty(mktId))
+                        {
+                            result = await redis.GetAsync<TkDataDTO>($":cache:order_summary:{accountId}:mktId:{mktId}");
+                            if (result != null) return result;
+                        }
+
+                        if (!string.IsNullOrEmpty(itemId))
+                        {
+                            result = await redis.GetAsync<TkDataDTO>($":cache:order_summary:{accountId}:{itemId}");
+                            if (result != null) return result;
+
+                            if (!string.IsNullOrEmpty(itemTitle))
+                            {
+                                result = await redis.GetAsync<TkDataDTO>($":cache:order_summary:{accountId}:{itemTitle}");
+                                if (result != null) return result;
+                            }
+                        }
+
+                        return null;
+                    });
+
+                var results = await Task.WhenAll(tasks);
+                return results.FirstOrDefault(r => r != null);
             }
-            var result = EndPointCore.ProcessEndPointNodes<TkDataDTO>(node =>
+            catch (Exception)
             {
-                if (!node.is_public_api) return null;
-                if (string.IsNullOrEmpty(node.redis_server)) return null;
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                if (!string.IsNullOrEmpty(mktId))
-                {
-                    string cacheKey = $":cache:order_summary:{accountId}:mktId:{mktId}";
-                    var result = redis.Get<TkDataDTO>(cacheKey);
-                    if (result != null) return result;
-                }
-
-                if (!string.IsNullOrEmpty(itemId))
-                {
-                    string cacheKey = $":cache:order_summary:{accountId}:{itemId}";
-                    var result = redis.Get<TkDataDTO>(cacheKey);
-                    if (result != null) return result;
-                }
-                if (!string.IsNullOrEmpty(itemId))
-                {
-                    string cacheKey = $":cache:order_summary:{accountId}:{itemTitle}";
-                    var result = redis.Get<TkDataDTO>(cacheKey);
-                    if (result != null) return result;
-                }
+                // TODO: 添加日志记录
                 return null;
-            });
-            return result.Count > 0 ? result[0] : null;
+            }
         }
 
-        public static async void RemoveLinkSummary(int accountId, string itemId, string mktId, string itemTitle)
+        public static async Task RemoveLinkSummaryAsync(int accountId, string itemId, string mktId, string itemTitle)
         {
-            await EndPointCore.ProcessEndPointNodesAsync(node =>
+            try
+            {
+                var tasks = EndPointCore.List()
+                    .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+                    .Select(async node =>
+                    {
+                        var redisServer = EndPointCore.GetRedisServer(node);
+                        if (string.IsNullOrEmpty(redisServer)) return;
+
+                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        var redis = scope.Client;
+
+                        var keys = new[]
+                        {
+                            $":cache:order_summary:{accountId}:{itemId}",
+                            $":cache:order_summary:{accountId}:mktId:{mktId}",
+                            $":cache:order_summary:{accountId}:{itemTitle}"
+                        }.Where(k => !string.IsNullOrEmpty(k));
+
+                        // 批量删除所有相关缓存
+                        await redis.DelAsync(keys.ToArray());
+                    });
+                await Task.WhenAll(tasks);
+            }
+            catch (Exception)
             {
-                if (!node.is_public_api) return Task.CompletedTask;
-                if (string.IsNullOrEmpty(node.redis_server)) return Task.CompletedTask;
+                // TODO: 添加日志记录
+            }
+        }
 
 
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
 
-                string cacheKey = $":cache:order_summary:{accountId}:{itemId}";
-                redis.Del(cacheKey);
+        //public static async void RemoveLinkSummary(int accountId, string itemId, string mktId, string itemTitle)
+        //{
+        //    await EndPointCore.ProcessEndPointNodesAsync(node =>
+        //    {
+        //        if (!node.is_public_api) return Task.CompletedTask;
+        //        if (string.IsNullOrEmpty(node.redis_server)) return Task.CompletedTask;
 
-                cacheKey = $":cache:order_summary:{accountId}:mktId:{mktId}";
-                redis.Del(cacheKey);
 
-                cacheKey = $":cache:order_summary:{accountId}:{itemTitle}";
-                redis.Del(cacheKey);
+        //        var redis = RedisClientManager.GetRedisClient(node.redis_server);
 
-                return Task.CompletedTask;
-            });
-        }
+        //        string cacheKey = $":cache:order_summary:{accountId}:{itemId}";
+        //        redis.Del(cacheKey);
+
+        //        cacheKey = $":cache:order_summary:{accountId}:mktId:{mktId}";
+        //        redis.Del(cacheKey);
+
+        //        cacheKey = $":cache:order_summary:{accountId}:{itemTitle}";
+        //        redis.Del(cacheKey);
+
+        //        return Task.CompletedTask;
+        //    });
+        //}
 
-        public static bool MatchOrder(TkPoolDTO account, TkOrderDetailDTO item, IDbConnection conn)
+        public static async Task<bool> MatchOrder(TkPoolDTO account, TkOrderDetailDTO item)
         {
             if (item.tbPaidTime < DateTime.Now.AddDays(-1)) return false;
 
-            var summary = GetLinkSummary(item.accountId, item.itemId, item.mktId, item.itemTitle);
+            var summary = await GetLinkSummaryAsync(item.accountId, item.itemId, item.mktId, item.itemTitle);
             if (summary == null) return false;
 
 
@@ -179,8 +231,10 @@ namespace molilian.core
                 click_num = click_num,
             };
 
+            using var conn = DBContext.GetOpenConnection();
             conn.Replace(data);
-            RemoveLinkSummary(item.accountId, item.itemId, item.mktId, item.itemTitle);
+            //RemoveLinkSummary(item.accountId, item.itemId, item.mktId, item.itemTitle);
+            await RemoveLinkSummaryAsync(item.accountId, item.itemId, item.mktId, item.itemTitle);
             return true;
         }
     }

+ 106 - 44
molilian.core/Core/taoke/RiskControlCore.cs

@@ -7,6 +7,7 @@ using System.Linq;
 using System.Text;
 using dodohold.core;
 using System.Threading.Channels;
+using YunhuiKit;
 
 
 namespace molilian.core
@@ -24,6 +25,28 @@ namespace molilian.core
         {
             _calls = [];
         }
+        internal static async Task CallsIncrByAsync(TkChannelEnum channel, int accountId)
+        {
+            await CallsIncrByAsync(channel, accountId, DateTime.Now.ToString("yyyyMMdd"));
+            await CallsIncrByAsync(channel, accountId, DateTime.Now.ToString("yyyyMMddHH"));
+        }
+
+        internal static async Task CallsIncrByAsync(TkChannelEnum channel, int accountId, string flag)
+        {
+            string key = $"{channel}:{accountId}:{flag}";
+            if (_calls.ContainsKey(key))
+            {
+                _calls[key] += 1;
+            }
+            else
+            {
+                _calls[key] = 1;
+            }
+            string cache_key = $"RiskControl:{key}:calls:{flag}";
+            await RedisKit.IncrByAsync(cache_key);
+            await RedisKit.ExpireAsync(cache_key, 3 * 86400);
+        }
+
 
         internal static void CallsIncrBy(TkChannelEnum channel, int accountId)
         {
@@ -63,38 +86,69 @@ namespace molilian.core
             RedisHelper.ExpireAsync(cache_key, 3 * 86400);
         }
 
-        public static int GetAllNodesCalls(TkChannelEnum channel, int accountId, string flag)
+        //        public static int GetAllNodesCalls(TkChannelEnum channel, int accountId, string flag)
+        //        {
+        //            string key = $"{channel}:{accountId}:{flag}";
+        //            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
+        //            {
+        //                if (!node.is_public_api) return 0;
+        //                if (string.IsNullOrEmpty(node.redis_server)) return 0;
+        //#if DEBUG
+        //                switch (node.name)
+        //                {
+
+        //                    case "bj":
+        //                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
+        //                        break;
+        //                    case "gz":
+        //                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
+        //                        break;
+        //                    case "coupon1":
+        //                        node.redis_server = "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
+        //                        break;
+        //                    default: return 0;
+        //                }
+        //#endif
+
+        //                string cache_key = $"RiskControl:{key}:calls:{flag}";
+        //                var redis = RedisClientManager.GetRedisClient(node.redis_server);
+        //                return redis.Get<int>(cache_key);
+        //            });
+        //            int num = result.Sum();
+        //            _calls.TryAdd(key, num);
+        //            return num;
+        //        }
+        public static async Task<int> GetAllNodesCallsAsync(TkChannelEnum channel, int accountId, string flag)
         {
-            string key = $"{channel}:{accountId}:{flag}";
-            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
+            var key = $"{channel}:{accountId}:{flag}";
+            try
             {
-                if (!node.is_public_api) return 0;
-                if (string.IsNullOrEmpty(node.redis_server)) return 0;
-#if DEBUG
-                switch (node.name)
-                {
-
-                    case "bj":
-                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "gz":
-                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "coupon1":
-                        node.redis_server = "123.56.185.166:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-#endif
-
-                string cache_key = $"RiskControl:{key}:calls:{flag}";
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                return redis.Get<int>(cache_key);
-            });
-            int num = result.Sum();
-            _calls.TryAdd(key, num);
-            return num;
+                var tasks = EndPointCore.List()
+                    .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+                    .Select(async node =>
+                    {
+                        var redisServer = EndPointCore.GetRedisServer(node);
+                        if (string.IsNullOrEmpty(redisServer)) return 0;
+
+                        var cacheKey = $"RiskControl:{key}:calls:{flag}";
+                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        return await scope.Client.GetAsync<int>(cacheKey);
+                    });
+
+                var results = await Task.WhenAll(tasks);
+                var totalCalls = results.Sum();
+                _calls.TryAdd(key, totalCalls);
+                return totalCalls;
+            }
+            catch (Exception)
+            {
+                // TODO: 添加日志
+                return 0;
+            }
         }
+
+
+
         public static int GetCalls(TkChannelEnum channel, int accountId, string flag)
         {
             try
@@ -110,29 +164,37 @@ namespace molilian.core
             catch (Exception ex) { return 0; }
         }
 
-
-        internal static void SaveIncomeAmt(TkChannelEnum channel, string accountName, decimal income_amt)
+        internal static async Task SaveIncomeAmtAsync(TkChannelEnum channel, string accountName, decimal income_amt)
         {
             string key = $"{channel}:{accountName}:{DateTime.Now:yyyyMMdd}";
-            if (_incomeAmt.ContainsKey(key))
+            lock (_incomeAmt)
             {
-                _incomeAmt[key] = income_amt;
+                if (!_incomeAmt.TryAdd(key, income_amt))
+                    _incomeAmt[key] = income_amt;
             }
-            else
+            string cache_key = $"RiskControl:{key}:income_amt";
+            try
             {
-                _incomeAmt.Add(key, income_amt);
+                var tasks = EndPointCore.List()
+                    .Where(node => node.is_public_api && !string.IsNullOrEmpty(node.redis_server))
+                    .Select(async node =>
+                    {
+                        var redisServer = EndPointCore.GetRedisServer(node);
+                        if (string.IsNullOrEmpty(redisServer)) return false;
+
+                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        return await scope.Client.SetAsync(cache_key, income_amt, 3 * 86400);
+                    });
+
+                await Task.WhenAll(tasks);
             }
-            string cache_key = $"RiskControl:{key}:income_amt";
-
-            var result = EndPointCore.ProcessEndPointNodes<bool>(node =>
+            catch (Exception)
             {
-                if (!node.is_public_api) return true;
-                if (string.IsNullOrEmpty(node.redis_server)) return true;
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                return redis.Set(cache_key, income_amt, 3 * 86400);
-            });
+            }
         }
+
+
+
         public static decimal GetIncomeAmt(TkChannelEnum channel, string accountName)
         {
             try

+ 15 - 1
molilian.core/Core/taoke/TaokeOpenCore.cs

@@ -163,7 +163,21 @@ namespace molilian.core
                             {
                                 api = new AliyunCore(account.api_id);
                             }
-                            api.picSimilaritem(img, account.open_pid, ref result);
+
+                            var aliDelayTask = Task.Delay(1500, cts.Token);
+                            var aliRequestTask = api.picSimilaritemAsync(img, account.open_pid, result);
+
+                            var aliCompletedTask = await Task.WhenAny(aliDelayTask, aliRequestTask);
+                            if (aliCompletedTask == aliRequestTask)
+                            {
+                                result = await aliRequestTask;
+                            }
+                            else
+                            {
+                                result.success = false;
+                                result.message = "调用失败";
+                                result.reason = "请求超时";
+                            }
 
                             var ts2 = DateTime.Now - stime;
                             result.elapsedTime2 = (int)ts2.TotalMilliseconds;

+ 0 - 2
molilian.core/Core/taoke/UnionParseCore.cs

@@ -503,10 +503,8 @@ namespace molilian.core
         public static async Task<APIResult> JdParseAsync(string content, int commerceType, string ip, string oaid,
             int accountid = 0, string clickId = "", CancellationToken cancellationToken = default)
         {
-
             var config = TkConfigCore.Get();
 
-
             var result = JdUnionPlus.GetFormattedObject(content, ip, oaid, clickId);
             content = content.UrlDecode();
             result.rawContent = content;

+ 15 - 0
molilian.core/Core/tool/DeeplinkParseCore.cs

@@ -261,6 +261,21 @@ namespace molilian.core
                             ReplaceProcessing(val, i, ref deeplink, ref prompt_text);
                         }
 
+                        if (rule.replace != null && rule.replace.Count > 0)
+                        {
+                            foreach (var r in rule.replace)
+                            {
+                                string key = r[0];
+                                if (string.IsNullOrEmpty(key)) continue;
+
+                                string val = string.Empty;
+                                if (r.Length > 1)
+                                {
+                                    val = r[1];
+                                }
+                                deeplink = Regex.Replace(deeplink, key, val);
+                            }
+                        }
 
                         deeplink = Regex.Replace(deeplink, @"\{\d+\}", string.Empty);
                         prompt_text = Regex.Replace(prompt_text, @"\{\d+\}", string.Empty);

+ 1 - 0
molilian.core/DTO/deeplink/DeeplinkParseRuleDTO.cs

@@ -17,6 +17,7 @@ namespace molilian.core
         public string url_pattern { get; set; } = string.Empty;
         public string pattern { get; set; } = string.Empty;
         public string plugin { get; set; } = string.Empty;
+        public List<string[]> replace { get; set; } = new();
         public string deeplink_template { get; set; } = string.Empty;
         public string prompt_text { get; set; } = string.Empty;
         public bool enable { get; set; } = true;

+ 44 - 45
molilian.core/Plus/Alimama/crawler.cs

@@ -15,7 +15,7 @@ namespace molilian.core
         /// 更新API调用日志(1天一次)
         /// </summary>
         /// <param name="intervalDay"></param>
-        public static async void DailyLogs_bak(int intervalDay, string prefix = "", string channel = "all")
+        public static async Task DailyLogs_bak(int intervalDay, string prefix = "", string channel = "all")
         {
             int channelId = (int)TkChannelEnum.tb;
             var db_prefix = channel switch
@@ -35,14 +35,14 @@ namespace molilian.core
                 int accountId = account.id;
                 string accountName = $"{TkChannelEnum.tb}_{account.id}";
 
-                int total_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:{log_date:yyyyMMdd}");
+                int total_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:{log_date:yyyyMMdd}");
                 if (total_count == 0) accountName = account.name;
 
-                total_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:{log_date:yyyyMMdd}");
+                total_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:{log_date:yyyyMMdd}");
                 if (total_count == 0) continue;
 
-                var success_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:success:{log_date:yyyyMMdd}");
-                var abandon_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:放弃转链:{log_date:yyyyMMdd}");
+                var success_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:success:{log_date:yyyyMMdd}");
+                var abandon_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:放弃转链:{log_date:yyyyMMdd}");
                 string success_percentage = string.Empty;
                 string abandon_percentage = string.Empty;
 
@@ -81,9 +81,9 @@ namespace molilian.core
                 }
             }
 
-            int all_total_count = TkLogCore.GetTotal($":{prefix}total:{channel}:{log_date:yyyyMMdd}");
-            var all_success_count = TkLogCore.GetTotal($":{prefix}total:{channel}:success:{log_date:yyyyMMdd}");
-            var all_abandon_count = TkLogCore.GetTotal($":{prefix}total:{channel}:放弃转链:{log_date:yyyyMMdd}");
+            int all_total_count = await TkLogCore.GetTotalAsync($":{prefix}total:{channel}:{log_date:yyyyMMdd}");
+            var all_success_count = await TkLogCore.GetTotalAsync($":{prefix}total:{channel}:success:{log_date:yyyyMMdd}");
+            var all_abandon_count = await TkLogCore.GetTotalAsync($":{prefix}total:{channel}:放弃转链:{log_date:yyyyMMdd}");
 
             string all_success_percentage = string.Empty;
             string all_abandon_percentage = string.Empty;
@@ -122,18 +122,18 @@ namespace molilian.core
         }
 
 
-        public static void AllDailyLogs(int intervalDay, string prefix = "", string channel = "all")
+        public static async Task AllDailyLogsAsync(int intervalDay, string prefix = "", string channel = "all")
         {
-            DailyLogs(true, intervalDay, prefix, channel);
+            await DailyLogsAsync(true, intervalDay, prefix, channel);
         }
 
 
-        public static void NodeDailyLogs(int intervalDay, string prefix = "", string channel = "all")
+        public static async Task NodeDailyLogsAsync(int intervalDay, string prefix = "", string channel = "all")
         {
-            DailyLogs(false, intervalDay, prefix, channel);
+            await DailyLogsAsync(false, intervalDay, prefix, channel);
         }
 
-        public static async void DailyLogs(bool all_node, int intervalDay, string prefix = "", string channel = "all")
+        public static async Task DailyLogsAsync(bool all_node, int intervalDay, string prefix = "", string channel = "all")
         {
             int channelId = (int)TkChannelEnum.tb;
             var db_prefix = channel switch
@@ -158,14 +158,14 @@ namespace molilian.core
                 int accountId = account.id;
                 string accountName = $"{TkChannelEnum.tb}_{account.id}";
 
-                int total_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:{log_date:yyyyMMdd}", all_node);
+                int total_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:{log_date:yyyyMMdd}", all_node);
                 if (total_count == 0) accountName = account.name;
 
-                total_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:{log_date:yyyyMMdd}", all_node);
+                total_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:{log_date:yyyyMMdd}", all_node);
                 if (total_count == 0) continue;
 
-                var success_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:success:{log_date:yyyyMMdd}", all_node);
-                var abandon_count = TkLogCore.GetTotal($":{prefix}total:{accountName}:放弃转链:{log_date:yyyyMMdd}", all_node);
+                var success_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:success:{log_date:yyyyMMdd}", all_node);
+                var abandon_count = await TkLogCore.GetTotalAsync($":{prefix}total:{accountName}:放弃转链:{log_date:yyyyMMdd}", all_node);
                 string success_percentage = string.Empty;
                 string abandon_percentage = string.Empty;
 
@@ -204,9 +204,9 @@ namespace molilian.core
                 }
             }
 
-            int all_total_count = TkLogCore.GetTotal($":{prefix}total:{channel}:{log_date:yyyyMMdd}", all_node);
-            var all_success_count = TkLogCore.GetTotal($":{prefix}total:{channel}:success:{log_date:yyyyMMdd}", all_node);
-            var all_abandon_count = TkLogCore.GetTotal($":{prefix}total:{channel}:放弃转链:{log_date:yyyyMMdd}", all_node);
+            int all_total_count = await TkLogCore.GetTotalAsync($":{prefix}total:{channel}:{log_date:yyyyMMdd}", all_node);
+            var all_success_count = await TkLogCore.GetTotalAsync($":{prefix}total:{channel}:success:{log_date:yyyyMMdd}", all_node);
+            var all_abandon_count = await TkLogCore.GetTotalAsync($":{prefix}total:{channel}:放弃转链:{log_date:yyyyMMdd}", all_node);
 
             string all_success_percentage = string.Empty;
             string all_abandon_percentage = string.Empty;
@@ -248,11 +248,11 @@ namespace molilian.core
             //coupon_total
             //parse_total
 
-            var chatData = ChartDataCore.GetTaobaoData($"{prefix}total", "", $"{log_date:yyyyMMdd}");
+            var chatData = await GetTaobaoDataAsync($"{prefix}total", "", $"{log_date:yyyyMMdd}");
             //tableName2
         }
 
-        public static DBContext.Table FillLinkTypeData(DBContext.Table update, int data_type, DateTime report_date, TkChannelEnum channel)
+        public static async Task<DBContext.Table> FillLinkTypeDataAsync(DBContext.Table update, int data_type, DateTime report_date, TkChannelEnum channel)
         {
             long req_other_aff_num = 0;//1
             long req_goods_num = 0;//2
@@ -307,7 +307,7 @@ namespace molilian.core
                         foreach (var keyname in deeplink_keys)
                         {
                             string cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date:yyyyMMdd}";
-                            int value = TkLogCore.GetTotal(cacheKey);
+                            int value = await TkLogCore.GetTotalAsync(cacheKey);
                             if (value == 0) continue;
                             resp_deeplink_num += value;
                         }
@@ -336,7 +336,7 @@ namespace molilian.core
         /// <param name="data_type">1转链 2优惠券</param>
         /// <param name="intervalDay"></param>
         /// <param name="channel"></param>
-        public static void ApiCallStatistics(int data_type, int intervalDay, TkChannelEnum channel)
+        public static async Task ApiCallStatisticsAsync(int data_type, int intervalDay, TkChannelEnum channel)
         {
             DateTime log_date = DateTime.Now.AddDays(-intervalDay).Date;
 
@@ -475,7 +475,7 @@ namespace molilian.core
             if (data_type == 1)
             {
                 //todo 只有转链需要处理,优惠券和京东(未上线)暂不处理
-                update = FillLinkTypeData(update, data_type, log_date, channel);
+                update = await FillLinkTypeDataAsync(update, data_type, log_date, channel);
             }
             if (record == null)
             {
@@ -589,7 +589,7 @@ namespace molilian.core
         /// 事实动态接口(5分钟一次)
         /// </summary>
         /// <param name="date"></param>
-        public void SaveReportOverview()
+        public async void SaveReportOverview()
         {
             DateTime date = DateTime.Now;
             TkReportDTO result = new TkReportDTO();
@@ -654,15 +654,14 @@ namespace molilian.core
                 DateTime report_date = date.Date;
                 if (report_date == DateTime.Now.Date)
                 {
-                    RiskControlCore.SaveIncomeAmt(TkChannelEnum.tb, $"{_accountId}", result.eff_tk_disp_tfee);
-                    //TkPoolCore.SaveIncomeAmt(_accountName, result.eff_tk_disp_tfee);
-                    EachSaveReportOverview(report_date.AddHours(DateTime.Now.Hour), "tk_report_hourtrend", result);
-                    EachSaveReportOverview(report_date, "tk_report", result);
+                    await RiskControlCore.SaveIncomeAmtAsync(TkChannelEnum.tb, $"{_accountId}", result.eff_tk_disp_tfee);
+                    await EachSaveReportOverviewAsync(report_date.AddHours(DateTime.Now.Hour), "tk_report_hourtrend", result);
+                    await EachSaveReportOverviewAsync(report_date, "tk_report", result);
                 }
             }
             catch (Exception ex) { throw; }
         }
-        private void EachSaveReportOverview(DateTime report_date, string tableName, TkReportDTO data)
+        private async Task EachSaveReportOverviewAsync(DateTime report_date, string tableName, TkReportDTO data)
         {
             var exist = new DBContext.Table(tableName)
                  .Fields("id,report_date")
@@ -694,13 +693,13 @@ namespace molilian.core
             }
 
             string accountName = $"{TkChannelEnum.tb}_{_accountId}";
-            int total_count = TkLogCore.GetTotal($":total:{accountName}:{data_suffix}");
+            int total_count = await TkLogCore.GetTotalAsync($":total:{accountName}:{data_suffix}");
             int success_count = 0, abandon_count = 0;
             string success_percentage = string.Empty, abandon_percentage = string.Empty;
             if (total_count > 0)
             {
-                success_count = TkLogCore.GetTotal($":total:{accountName}:success:{data_suffix}");
-                abandon_count = TkLogCore.GetTotal($":total:{accountName}:放弃转链:{data_suffix}");
+                success_count = await TkLogCore.GetTotalAsync($":total:{accountName}:success:{data_suffix}");
+                abandon_count = await TkLogCore.GetTotalAsync($":total:{accountName}:放弃转链:{data_suffix}");
                 if (total_count > 0)
                 {
                     success_percentage = $"{success_count / (double)total_count * 100:f2}%";
@@ -713,13 +712,13 @@ namespace molilian.core
             createArgs.Add("success_percentage", success_percentage);
             createArgs.Add("abandon_percentage", abandon_percentage);
 
-            int parse_total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{data_suffix}");
+            int parse_total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{data_suffix}");
             int parse_success_count = 0, parse_abandon_count = 0;
             string parse_success_percentage = string.Empty, parse_abandon_percentage = string.Empty;
             if (parse_total_count > 0)
             {
-                parse_success_count = TkLogCore.GetTotal($":parse_total:{accountName}:success:{data_suffix}");
-                parse_abandon_count = TkLogCore.GetTotal($":parse_total:{accountName}:放弃转链:{data_suffix}");
+                parse_success_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:success:{data_suffix}");
+                parse_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:放弃转链:{data_suffix}");
                 if (parse_total_count > 0)
                 {
                     parse_success_percentage = $"{parse_success_count / (double)parse_total_count * 100:f2}%";
@@ -733,13 +732,13 @@ namespace molilian.core
             createArgs.Add("parse_abandon_percentage", parse_abandon_percentage);
 
 
-            int coupon_total_count = TkLogCore.GetTotal($":coupon_total:{accountName}:{data_suffix}", false);
+            int coupon_total_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:{data_suffix}", false);
             int coupon_success_count = 0, coupon_abandon_count = 0;
             string coupon_success_percentage = string.Empty, coupon_abandon_percentage = string.Empty;
             if (coupon_total_count > 0)
             {
-                coupon_success_count = TkLogCore.GetTotal($":coupon_total:{accountName}:success:{data_suffix}", false);
-                coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:{accountName}:放弃转链:{data_suffix}", false);
+                coupon_success_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:success:{data_suffix}", false);
+                coupon_abandon_count = await TkLogCore.GetTotalAsync($":coupon_total:{accountName}:放弃转链:{data_suffix}", false);
                 if (coupon_total_count > 0)
                 {
                     coupon_success_percentage = $"{coupon_success_count / (double)coupon_total_count * 100:f2}%";
@@ -753,13 +752,13 @@ namespace molilian.core
             createArgs.Add("coupon_abandon_percentage", coupon_abandon_percentage);
 
 
-            int tool_total_count = TkLogCore.GetTotal($":tool_total:{accountName}:{data_suffix}");
+            int tool_total_count = await TkLogCore.GetTotalAsync($":tool_total:{accountName}:{data_suffix}");
             int tool_success_count = 0, tool_abandon_count = 0;
             string tool_success_percentage = string.Empty, tool_abandon_percentage = string.Empty;
             if (tool_total_count > 0)
             {
-                tool_success_count = TkLogCore.GetTotal($":tool_total:{accountName}:success:{data_suffix}");
-                tool_abandon_count = TkLogCore.GetTotal($":tool_total:{accountName}:放弃转链:{data_suffix}");
+                tool_success_count = await TkLogCore.GetTotalAsync($":tool_total:{accountName}:success:{data_suffix}");
+                tool_abandon_count = await TkLogCore.GetTotalAsync($":tool_total:{accountName}:放弃转链:{data_suffix}");
                 if (tool_total_count > 0)
                 {
                     tool_success_percentage = $"{tool_success_count / (double)tool_total_count * 100:f2}%";
@@ -792,7 +791,7 @@ namespace molilian.core
         /// <summary>
         /// 修正点击数
         /// </summary>
-        public void FixReport(DateTime date)
+        public async Task FixReport(DateTime date)
         {
             TkReportDTO result = new TkReportDTO();
             try
@@ -852,7 +851,7 @@ namespace molilian.core
                 result.sett_tk_disp_tfee_56 = data.Read<decimal>("sett_tk_disp_tfee_56", 0);
 
                 DateTime report_date = date.Date;
-                EachSaveReportOverview(report_date, "tk_report", result);
+                await EachSaveReportOverviewAsync(report_date, "tk_report", result);
 
 
                 //var exist = new DBContext.Table("tk_report")

+ 2 - 8
molilian.core/Plus/Alimama/orders.cs

@@ -528,9 +528,6 @@ SET  order_ord_num = order_ord_num_3 + order_ord_num_12 + order_ord_num_13 + ord
                     if (sleep > 0) Thread.Sleep(sleep);
                     throw new APIException(body);
                 }
-                using var conn = DBContext.GetOpenConnection();
-                conn.Open();
-
                 try
                 {
 
@@ -552,11 +549,12 @@ SET  order_ord_num = order_ord_num_3 + order_ord_num_12 + order_ord_num_13 + ord
                         //进行订单和转链匹配
                         //(int state, item.itemId) = GetRawItemId(item.mktId);
                         if (item.tkStatus == 3 && item.tbPaidTime != DateTime.MinValue) orderTimes.Add(item.tbPaidTime.Date);
+                        using var conn = DBContext.GetOpenConnection();
                         int? id = conn.Replace(item);
                         if (id != null)
                         {
                             item.id = (int)id;
-                            TkOrderTrackingCore.MatchOrder(_account, item, conn);
+                            TkOrderTrackingCore.MatchOrder(_account, item);
                         }
                         total++;
                     }
@@ -566,10 +564,6 @@ SET  order_ord_num = order_ord_num_3 + order_ord_num_12 + order_ord_num_13 + ord
                     if (sleep > 0) Thread.Sleep(sleep);
                     throw;
                 }
-                finally
-                {
-                    conn.Dispose();
-                }
                 pageNo++;
                 hasNext = data.Read<bool>("hasNext");
                 positionIndex = data.Read<string>("positionIndex");

+ 10 - 3
molilian.core/Plus/Aliyun/ImageSearch.cs

@@ -12,17 +12,23 @@ namespace molilian.core
     public partial class AliyunPlus
     {
         private static string _end_point;
+        private static int _timeout = 1500;
         static AliyunPlus()
         {
             _end_point = Environment.GetEnvironmentVariable("IMG_EndPoint");
             if (string.IsNullOrEmpty(_end_point))
             {
+#if DEBUG
+                _end_point = "imagesearch.cn-shanghai.aliyuncs.com";
+#else
                 _end_point = "imagesearch-vpc.cn-shanghai.aliyuncs.com";
+#endif
             }
+
         }
 
 
-        public SearchByPicResponse SearchByPic(string base64String, string pid)
+        public async Task<SearchByPicResponse> SearchByPicAsync(string base64String, string pid)
         {
             if (string.IsNullOrEmpty(base64String)) return null;
             if (string.IsNullOrEmpty(pid)) return null;
@@ -32,12 +38,13 @@ namespace molilian.core
                 byte[] bytes = Convert.FromBase64String(base64String);
 
                 AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
+
                 Config config = new()
                 {
                     AccessKeyId = _app_key,
                     AccessKeySecret = _app_secret,
-                    //Endpoint = "imagesearch.cn-shanghai.aliyuncs.com",
                     Endpoint = _end_point,
+                    ConnectTimeout = _timeout,
                     RegionId = "cn-shanghai"
                 };
                 Client client = new(config);
@@ -66,7 +73,7 @@ namespace molilian.core
                 //request.relationId = 1145;
 
 
-                var response = client.SearchByPicAdvance(request, runtime);
+                var response = await client.SearchByPicAdvanceAsync(request, runtime);
                 return response;
             }
             catch (TeaException error)

+ 45 - 5
molilian.core/Plus/JDUnion/JdUnionPlus.cs

@@ -17,12 +17,16 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
 using System.Security.Cryptography;
 using Google.Protobuf.WellKnownTypes;
 using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using System.Web;
 
 
 namespace molilian.core
 {
     public partial class JdUnionPlus
     {
+        private const string VIDEO_URL_PREFIX = "https://h5.m.jd.com/active/faxian/video/index.html";
+
+
         public static string GetLink(string content)
         {
             if (string.IsNullOrEmpty(content)) return content;
@@ -72,9 +76,23 @@ namespace molilian.core
             if (string.IsNullOrEmpty(clickId)) clickId = config.dp_style_default_str;
 
             var ts = DateTime.Now.Convert2UnixTimestamp(true);
+            string virtual_params;
 
-            string virtual_params = $"{{\"category\":\"jump\",\"des\":\"HomePage\",\"m_param\":{{\"jdv\":\"0|oppo_seedling|-|widget|{clickId}|{ts}\"}}";
-            if (!string.IsNullOrEmpty(url))
+            if (!string.IsNullOrEmpty(url) && url.StartsWith(VIDEO_URL_PREFIX))
+            {
+                // 处理视频URL的情况
+                var queryString = url.Substring(VIDEO_URL_PREFIX.Length + 1); // +1 for the '?' character
+                var queryParams = HttpUtility.ParseQueryString(queryString);
+                var paramsDict = queryParams.AllKeys.ToDictionary(k => k, k => queryParams[k]);
+                paramsDict["category"] = "jump";
+                paramsDict["m_param"] = $"{{\"jdv\":\"0|oppo_seedling|-|widget|{clickId}|{ts}\"}}";
+                virtual_params = JsonSerializer.Serialize(paramsDict);
+            }
+            else if (string.IsNullOrEmpty(url))
+            {
+                virtual_params = $"{{\"category\":\"jump\",\"des\":\"HomePage\",\"m_param\":{{\"jdv\":\"0|oppo_seedling|-|widget|{clickId}|{ts}\"}}";
+            }
+            else
             {
                 virtual_params = $"{{\"category\":\"jump\",\"des\":\"m\",\"url\":\"{url}\",\"m_param\":{{\"jdv\":\"0|oppo_seedling|-|widget|{clickId}|{ts}\"}}}}";
             }
@@ -82,16 +100,38 @@ namespace molilian.core
             string result = $"openapp.jdmobile://virtual?params={virtual_params.UrlEncode()}";
             return result;
         }
-
-
         public static string GetDefaultStyleDeeplink(string url)
         {
             if (string.IsNullOrEmpty(url)) return "openapp.jdmobile://";
-            string virtual_params = $"{{\"category\":\"jump\",\"des\":\"m\",\"sourceValue\":\"babel-act\",\"sourceType\":\"babel\",\"url\":\"{url}\",\"M_sourceFrom\":\"h5auto\",\"msf_type\":\"auto\"}}";
+
+            string virtual_params;
+
+            if (url.StartsWith(VIDEO_URL_PREFIX))
+            {
+                // 处理视频URL的情况
+                var queryString = url.Substring(VIDEO_URL_PREFIX.Length + 1);
+                var queryParams = HttpUtility.ParseQueryString(queryString);
+                var paramsDict = queryParams.AllKeys.ToDictionary(k => k, k => queryParams[k]);
+                paramsDict["category"] = "jump";
+                virtual_params = JsonSerializer.Serialize(paramsDict);
+            }
+            else
+            {
+                virtual_params = $"{{\"category\":\"jump\",\"des\":\"m\",\"sourceValue\":\"babel-act\",\"sourceType\":\"babel\",\"url\":\"{url}\",\"M_sourceFrom\":\"h5auto\",\"msf_type\":\"auto\"}}";
+            }
             string result = $"openapp.jdmobile://virtual?params={virtual_params.UrlEncode()}";
             return result;
         }
 
+
+        //public static string GetDefaultStyleDeeplink(string url)
+        //{
+        //    if (string.IsNullOrEmpty(url)) return "openapp.jdmobile://";
+        //    string virtual_params = $"{{\"category\":\"jump\",\"des\":\"m\",\"sourceValue\":\"babel-act\",\"sourceType\":\"babel\",\"url\":\"{url}\",\"M_sourceFrom\":\"h5auto\",\"msf_type\":\"auto\"}}";
+        //    string result = $"openapp.jdmobile://virtual?params={virtual_params.UrlEncode()}";
+        //    return result;
+        //}
+
         public static JdDataDTO GetFormattedObject(string content, string ip = "", string oaid = "", string clickId = "")
         {
             string shortLinkurl = GetLink(content);

+ 4 - 4
molilian.core/Plus/Tool/ToolDailyLogs.cs

@@ -23,7 +23,7 @@ namespace molilian.core
 {
     public partial class ToolParsePlus
     {
-        public static void DailyLogs(int intervalDay)
+        public static async Task DailyLogsAsync(int intervalDay)
         {
             TkChannelEnum toolChannelEnum = TkChannelEnum.tool;
             string channel = toolChannelEnum.ToString();
@@ -36,9 +36,9 @@ namespace molilian.core
             List<TkChannelEnum> arr = [TkChannelEnum.wemeet, TkChannelEnum.bdpan];
             foreach (var channelEnum in arr)
             {
-                all_total_count += TkLogCore.GetTotal($":parse_total:{channelEnum}:{log_date:yyyyMMdd}");
-                all_success_count += TkLogCore.GetTotal($":parse_total:{channelEnum}:success:{log_date:yyyyMMdd}");
-                all_abandon_count += TkLogCore.GetTotal($":parse_total:{channelEnum}:放弃转链:{log_date:yyyyMMdd}");
+                all_total_count += await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:{log_date:yyyyMMdd}");
+                all_success_count += await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:success:{log_date:yyyyMMdd}");
+                all_abandon_count += await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:放弃转链:{log_date:yyyyMMdd}");
             }
 
             string all_success_percentage = string.Empty;

+ 8 - 8
molilian.core/Plus/ks/KsDailyLogs.cs

@@ -24,7 +24,7 @@ namespace molilian.core
 {
     public partial class KsUnionPlus
     {
-        public static void DailyLogs(int intervalDay)
+        public static async Task DailyLogsAsync(int intervalDay)
         {
             TkChannelEnum channelEnum = TkChannelEnum.ks;
 
@@ -42,14 +42,14 @@ namespace molilian.core
                 string accountName = $"{channelEnum}_{account.id}";
                 //if (account.is_hide) continue;
 
-                int total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{log_date:yyyyMMdd}");
+                int total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{log_date:yyyyMMdd}");
                 if (total_count == 0) accountName = account.name;
 
-                total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{log_date:yyyyMMdd}");
+                total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{log_date:yyyyMMdd}");
                 if (total_count == 0) continue;
 
-                var success_count = TkLogCore.GetTotal($":parse_total:{accountName}:success:{log_date:yyyyMMdd}");
-                var abandon_count = TkLogCore.GetTotal($":parse_total:{accountName}:放弃转链:{log_date:yyyyMMdd}");
+                var success_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:success:{log_date:yyyyMMdd}");
+                var abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:放弃转链:{log_date:yyyyMMdd}");
                 string success_percentage = string.Empty;
                 string abandon_percentage = string.Empty;
 
@@ -91,9 +91,9 @@ namespace molilian.core
                 }
             }
 
-            all_total_count = TkLogCore.GetTotal($":parse_total:{channelEnum}:{log_date:yyyyMMdd}");
-            all_success_count = TkLogCore.GetTotal($":parse_total:{channelEnum}:success:{log_date:yyyyMMdd}");
-            all_abandon_count = TkLogCore.GetTotal($":parse_total:{channelEnum}:放弃转链:{log_date:yyyyMMdd}");
+            all_total_count = await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:{log_date:yyyyMMdd}");
+            all_success_count = await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:success:{log_date:yyyyMMdd}");
+            all_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:放弃转链:{log_date:yyyyMMdd}");
 
 
             string all_success_percentage = string.Empty;

+ 8 - 8
molilian.core/Plus/pdd/PddDailyLogs.cs

@@ -24,7 +24,7 @@ namespace molilian.core
 {
     public partial class PddUnionPlus
     {
-        public static void DailyLogs(int intervalDay)
+        public static async Task DailyLogsAsync(int intervalDay)
         {
             TkChannelEnum channelEnum = TkChannelEnum.pdd;
 
@@ -45,14 +45,14 @@ namespace molilian.core
                 string accountName = $"{channelEnum}_{account.id}";
                 //if (account.is_hide) continue;
 
-                int total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{log_date:yyyyMMdd}");
+                int total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{log_date:yyyyMMdd}");
                 if (total_count == 0) accountName = account.name;
 
-                total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{log_date:yyyyMMdd}");
+                total_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:{log_date:yyyyMMdd}");
                 if (total_count == 0) continue;
 
-                var success_count = TkLogCore.GetTotal($":parse_total:{accountName}:success:{log_date:yyyyMMdd}");
-                var abandon_count = TkLogCore.GetTotal($":parse_total:{accountName}:放弃转链:{log_date:yyyyMMdd}");
+                var success_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:success:{log_date:yyyyMMdd}");
+                var abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{accountName}:放弃转链:{log_date:yyyyMMdd}");
                 string success_percentage = string.Empty;
                 string abandon_percentage = string.Empty;
 
@@ -94,9 +94,9 @@ namespace molilian.core
                 }
             }
 
-            all_total_count = TkLogCore.GetTotal($":parse_total:{channelEnum}:{log_date:yyyyMMdd}");
-            all_success_count = TkLogCore.GetTotal($":parse_total:{channelEnum}:success:{log_date:yyyyMMdd}");
-            all_abandon_count = TkLogCore.GetTotal($":parse_total:{channelEnum}:放弃转链:{log_date:yyyyMMdd}");
+            all_total_count = await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:{log_date:yyyyMMdd}");
+            all_success_count = await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:success:{log_date:yyyyMMdd}");
+            all_abandon_count = await TkLogCore.GetTotalAsync($":parse_total:{channelEnum}:放弃转链:{log_date:yyyyMMdd}");
 
 
             string all_success_percentage = string.Empty;

+ 1 - 1
molilian.core/molilian.core.csproj

@@ -25,7 +25,7 @@
     <PackageReference Include="IP2Region.Net" Version="2.0.2" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
     <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
-    <PackageReference Include="YunhuiKit" Version="0.0.7" />
+    <PackageReference Include="YunhuiKit" Version="0.0.12" />
   </ItemGroup>
 
   <ItemGroup>

Некоторые файлы не были показаны из-за большого количества измененных файлов