dodo hold 1 rok pred
rodič
commit
c4d9512cf6
46 zmenil súbory, kde vykonal 1118 pridanie a 799 odobranie
  1. 110 16
      molilian.api/Controllers/admin/JdUnionController.cs
  2. 1 1
      molilian.api/Controllers/admin/PddUnionController.cs
  3. 0 1
      molilian.api/Controllers/admin/ReportController.cs
  4. 9 2
      molilian.api/Controllers/admin/TaobaoController.cs
  5. 38 7
      molilian.api/Controllers/public/TaskController.cs
  6. 2 202
      molilian.api/Controllers/public/TkController.cs
  7. 0 0
      molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user
  8. 2 5
      molilian.api/Properties/launchSettings.json
  9. 13 5
      molilian.core/Core/ProxyNodesCore.cs
  10. 6 83
      molilian.core/Core/cps/ElePoolCore.cs
  11. 4 84
      molilian.core/Core/cps/MeituanPoolCore.cs
  12. 134 0
      molilian.core/Core/cps/UnionCpsCore.cs
  13. 4 82
      molilian.core/Core/jd/JdPoolCore.cs
  14. 23 86
      molilian.core/Core/ks/KsPoolCore.cs
  15. 2 0
      molilian.core/Core/log/coupon.cs
  16. 4 0
      molilian.core/Core/log/deeplink.cs
  17. 2 0
      molilian.core/Core/log/dy.cs
  18. 3 5
      molilian.core/Core/log/jd.cs
  19. 8 5
      molilian.core/Core/log/ks.cs
  20. 14 30
      molilian.core/Core/log/pdd.cs
  21. 5 3
      molilian.core/Core/log/taobao.cs
  22. 7 77
      molilian.core/Core/pdd/PddPoolCore.cs
  23. 151 0
      molilian.core/Core/taoke/RiskControlCore.cs
  24. 24 43
      molilian.core/Core/taoke/TkPoolCore.cs
  25. 12 24
      molilian.core/Core/taoke/UnionCouponCore.cs
  26. 9 1
      molilian.core/Core/taoke/UnionParseCore.cs
  27. 13 0
      molilian.core/Core/tool/DeeplinkParseCore.cs
  28. 16 0
      molilian.core/DTO/DailyLogsDTO.cs
  29. 2 0
      molilian.core/DTO/Emun/TkChannelEnum.cs
  30. 10 0
      molilian.core/DTO/alimama/TkConfigDTO.cs
  31. 9 0
      molilian.core/DTO/alimama/TkPoolDTO.cs
  32. 7 0
      molilian.core/DTO/cps/UnionCpsDTO.cs
  33. 36 0
      molilian.core/DTO/jd/JdSpreadReportDTO.cs
  34. 2 2
      molilian.core/DTO/pdd/PddPoolDTO.cs
  35. 0 15
      molilian.core/Plus/Alimama/coupon.cs
  36. 4 4
      molilian.core/Plus/Alimama/crawler.cs
  37. 21 1
      molilian.core/Plus/Alimama/parse.cs
  38. 2 2
      molilian.core/Plus/Alimama/parse_2.cs
  39. 30 1
      molilian.core/Plus/JDUnion/SpreadEffect.cs
  40. 54 3
      molilian.core/Plus/Pangolin/DyUnion/base.cs
  41. 136 0
      molilian.core/Plus/ks/KsDailyLogs.cs
  42. 9 2
      molilian.core/Plus/ks/KsUnionPlus.cs
  43. 5 2
      molilian.core/Plus/ks/open.cs
  44. 139 0
      molilian.core/Plus/pdd/PddDailyLogs.cs
  45. 36 4
      molilian.core/Plus/pdd/PddUnionPlus.cs
  46. 0 1
      molilian.core/Plus/pdd/base.cs

+ 110 - 16
molilian.api/Controllers/admin/JdUnionController.cs

@@ -23,29 +23,99 @@ namespace molilian.api.Controllers
             _accessor = accessor;
         }
 
+
+
         [HttpPost]
-        public async Task<ActionResult> updateCookies([FromBody] JsonElement form)
+        public ActionResult settle_bills_total([FromBody] JsonElement form)
         {
-            var clientIp = _accessor.HttpContext.GetUserIp();
-            var token = provider.Get(_accessor.HttpContext);
-            string user_agent = _accessor.HttpContext.Request.UserAgent();
+            int page = form.Read("current", 1);
+            int size = form.Read("pageSize", 10);
+            bool getTotal = form.Read("getTotal", true);
+            string sort = form.Read<string>("sort");
+            string order = form.Read<string>("order");
 
+            var report_date = form.PathReadArray<string>("query_date[]");
 
-            string cookie = form.Read<string>("cookie", string.Empty);
-            cookie = cookie.Replace("\r", "").Replace("\n", "").Trim();
-            if (!cookie.EndsWith(";")) cookie += ";";
+            string filter = string.Empty;
+            DateTime stime = DateTime.MinValue, etime = DateTime.MinValue;
+            if (report_date.Count == 2)
+            {
+                if (DateTime.TryParse(report_date[0], out stime) && DateTime.TryParse(report_date[1], out etime))
+                {
+                    etime = etime.AddDays(1).AddSeconds(-1);
+                    filter += $" AND report_date BETWEEN @stime AND @etime";
+                }
+            }
 
-            var accountId = JdPoolCore.UpdateCookies(cookie, user_agent);
-            bool success = accountId > 0;
-            if (success)
+            filter = filter.StringTrimStart(" AND ");
+
+            //排序
+            string orderBy = "report_date DESC";
+            if (!string.IsNullOrEmpty(order))
             {
-                //string desc = ObjectComparer.PrintCompareToString(old, form).Trim();
-                OperationLogCore.LogOperation(token.AccessKey, clientIp, $"jd_pool:{accountId}:cookie", string.Empty, cookie);
+                order = "descending".Equals(order) ? "DESC" : "ASC";
+                orderBy = sort switch
+                {
+                    _ => $"{sort} {order}",
+                };
             }
-            return new APIResult(new
+            var result = new DBContext.Table("v_jd_spread_report")
+                .Where(filter, new { stime, etime })
+                .Page(size, page)
+                .Order(orderBy)
+                .PageList<JdSpreadReportDTO>(getTotal);
+
+            return new APIResult(new { data = result });
+        }
+
+
+        [HttpPost]
+        public ActionResult settle_bills([FromBody] JsonElement form)
+        {
+            int page = form.Read("current", 1);
+            int size = form.Read("pageSize", 10);
+            bool getTotal = form.Read("getTotal", true);
+            string sort = form.Read<string>("sort");
+            string order = form.Read<string>("order");
+            string name = form.Read<string>("keyword");
+
+            var report_date = form.PathReadArray<string>("query_date[]");
+
+            string filter = string.Empty;
+            if (!string.IsNullOrEmpty(name))
             {
-                data = new { success, msg = success ? "更新成功" : "更新失败,请检查输入的cookie" },
-            });
+                filter += $" AND accountId IN (SELECT ID FROM tk_pool WHERE company=@name)";
+            }
+            DateTime stime = DateTime.MinValue, etime = DateTime.MinValue;
+            if (report_date.Count == 2)
+            {
+                if (DateTime.TryParse(report_date[0], out stime) && DateTime.TryParse(report_date[1], out etime))
+                {
+                    etime = etime.AddDays(1).AddSeconds(-1);
+                    filter += $" AND report_date BETWEEN @stime AND @etime";
+                }
+            }
+
+            filter = filter.StringTrimStart(" AND ");
+
+            //排序
+            string orderBy = "report_date DESC";
+            if (!string.IsNullOrEmpty(order))
+            {
+                order = "descending".Equals(order) ? "DESC" : "ASC";
+                orderBy = sort switch
+                {
+                    _ => $"{sort} {order}",
+                };
+            }
+
+            var result = new DBContext.Table("jd_spread_report")
+                .Where(filter, new { name, stime, etime })
+                .Page(size, page)
+                .Order(orderBy)
+                .PageList<JdSpreadReportDTO>(getTotal);
+
+            return new APIResult(new { data = result });
         }
 
         /// <summary>
@@ -74,7 +144,7 @@ namespace molilian.api.Controllers
             string sort = form.Read<string>("sort");
             string order = form.Read<string>("order");
 
-            string filter = " is_hide=0";
+            string filter = "is_hide=0";
             if (!string.IsNullOrEmpty(keyword))
             {
                 filter += $" AND (`name` LIKE @keyword OR `description` LIKE @keyword)";
@@ -177,5 +247,29 @@ namespace molilian.api.Controllers
         }
 
 
+        [HttpPost]
+        public async Task<ActionResult> updateCookies([FromBody] JsonElement form)
+        {
+            var clientIp = _accessor.HttpContext.GetUserIp();
+            var token = provider.Get(_accessor.HttpContext);
+            string user_agent = _accessor.HttpContext.Request.UserAgent();
+
+
+            string cookie = form.Read<string>("cookie", string.Empty);
+            cookie = cookie.Replace("\r", "").Replace("\n", "").Trim();
+            if (!cookie.EndsWith(";")) cookie += ";";
+
+            var accountId = JdPoolCore.UpdateCookies(cookie, user_agent);
+            bool success = accountId > 0;
+            if (success)
+            {
+                //string desc = ObjectComparer.PrintCompareToString(old, form).Trim();
+                OperationLogCore.LogOperation(token.AccessKey, clientIp, $"jd_pool:{accountId}:cookie", string.Empty, cookie);
+            }
+            return new APIResult(new
+            {
+                data = new { success, msg = success ? "更新成功" : "更新失败,请检查输入的cookie" },
+            });
+        }
     }
 }

+ 1 - 1
molilian.api/Controllers/admin/PddUnionController.cs

@@ -114,7 +114,7 @@ namespace molilian.api.Controllers
                 .Page(size, page)
                 .Order(orderBy)
                 .PageList<PddPoolDTO>(getTotal);
-
+                
             foreach (var item in result.List)
             {
                 item.app_secret = string.Empty;

+ 0 - 1
molilian.api/Controllers/admin/ReportController.cs

@@ -84,7 +84,6 @@ namespace molilian.api.Controllers
             return new APIResult(new { data = result });
         }
 
-
         [HttpPost]
         public ActionResult chartData([FromBody] JsonElement form)
         {

+ 9 - 2
molilian.api/Controllers/admin/TaobaoController.cs

@@ -97,9 +97,16 @@ namespace molilian.api.Controllers
                            .Add("last_time", DateTime.Now)
                            .Where("id=@id", new { id })
                            .Update();
-
                     log.SaveAsync();
                     break;
+                case "time_range":
+                    int.TryParse(val, out int iVal);
+                    result = new DBContext.Table("tk_pool")
+                           .Add(name, iVal)
+                           .Add("last_time", DateTime.Now)
+                           .Where("id=@id", new { id })
+                           .Update();
+                    break;
                 default:
                     return new APIResult(new { data = new { success = false, msg = "更新失败,未授权操作" } });
             }
@@ -188,7 +195,7 @@ namespace molilian.api.Controllers
 
             foreach (var item in result.List)
             {
-                item.current_amt = Math.Round(TkPoolCore.GetIncomeAmt($"{item.id}"), 2);
+                item.current_amt = Math.Round(RiskControlCore.GetIncomeAmt(TkChannelEnum.tb, $"{item.id}"), 2);
                 item.cookies = string.Empty;
             }
             return new APIResult(new { data = result });

+ 38 - 7
molilian.api/Controllers/public/TaskController.cs

@@ -283,7 +283,6 @@ namespace molilian.api.Controllers
         }
 
         [HttpGet]
-
         public async Task<ActionResult> DailyLogs(int intervalDay = 1)
         {
             try
@@ -301,6 +300,10 @@ namespace molilian.api.Controllers
                     //中心服务器统计
                     AlimamaPlus.AllDailyLogs(intervalDay, "parse_", "tb");
                     AlimamaPlus.AllDailyLogs(intervalDay, "coupon_", "tb");
+
+                    KsUnionPlus.DailyLogs(intervalDay);
+                    PddUnionPlus.DailyLogs(intervalDay);
+
                     AlimamaPlus.AllDailyLogs(intervalDay);
                 }
             }
@@ -369,6 +372,8 @@ namespace molilian.api.Controllers
 
                     sql = $"CREATE TABLE IF NOT EXISTS deeplink_parse_logs_{table_suffix} LIKE deeplink_parse_logs;";
                     DBContext.Execute(sql, null);
+                    sql = $"CREATE TABLE IF NOT EXISTS pdd_parse_logs_{table_suffix} LIKE pdd_parse_logs;";
+                    DBContext.Execute(sql, null);
                 }
                 TkLogCore.save_dailys_log = true;
                 RedisHelper.Set("turn:save_dailys_log", 1, 86400);
@@ -455,6 +460,29 @@ namespace molilian.api.Controllers
             {
                 foreach (var account in list)
                 {
+                    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"));
+
+                        new DBContext.Table("tk_pool")
+                            .Add("current_hourly_calls", account.current_hourly_calls)
+                            .Add("current_daily_calls", account.current_daily_calls)
+                            .Where("id=@id", new { account.id })
+                            .Update();
+                    }
+                    catch (Exception ex)
+                    {
+                        message = $"【TB计数异常】SaveCalls\n{ex.Message}\n{ex.StackTrace}";
+                        NotifyCore.Notify(new NifyMessage
+                        {
+                            message = message,
+                            priority = NifyMessagePriority.high,
+                            tags = ["red_circle"]
+                        });
+                        continue;
+                    }
+
                     if (!account.enable_sync_order) continue;
                     try
                     {
@@ -474,6 +502,7 @@ namespace molilian.api.Controllers
                     }
                 }
             }
+
             string filter = "";
             var jd_list = new DBContext.Table("jd_pool").Where(filter, null).Select<JdPoolDTO>();
             if (jd_list != null)
@@ -484,8 +513,8 @@ namespace molilian.api.Controllers
                     bool changed = false;
                     try
                     {
-                        account.current_daily_calls = JdPoolCore.SaveCalls(account.id, DateTime.Now.ToString("yyyyMMdd"));
-                        account.current_hourly_calls = JdPoolCore.SaveCalls(account.id, DateTime.Now.ToString("yyyyMMddHH"));
+                        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"));
                         changed = true;
                         any_jd_changed = true;
                     }
@@ -550,8 +579,8 @@ namespace molilian.api.Controllers
                     bool changed = false;
                     try
                     {
-                        account.current_daily_calls = PddPoolCore.SaveCalls(account.id, DateTime.Now.ToString("yyyyMMdd"));
-                        account.current_hourly_calls = PddPoolCore.SaveCalls(account.id, DateTime.Now.ToString("yyyyMMddHH"));
+                        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"));
                         changed = true;
                         any_pdd_changed = true;
                     }
@@ -625,7 +654,7 @@ namespace molilian.api.Controllers
             var jd_list = new DBContext.Table("jd_pool").Where("", null).Select<JdPoolDTO>();
             if (jd_list != null)
             {
-                DateTime startDate = DateTime.Now.AddDays(-1);
+                DateTime startDate = DateTime.Now.AddDays(-89);
                 DateTime endDate = DateTime.Now.AddDays(-1);
                 foreach (var account in jd_list)
                 {
@@ -633,7 +662,7 @@ namespace molilian.api.Controllers
 #if DEBUG
                     if (account.id != 10) continue;
 #endif
-
+                    if (account.is_hide) continue;
 
                     if (!string.IsNullOrEmpty(account.cookies))
                     {
@@ -719,6 +748,7 @@ namespace molilian.api.Controllers
         [HttpGet]
         public ActionResult Reload()
         {
+            RiskControlCore.Refresh();
             TkConfigCore.Refresh();
             EndPointCore.Refresh();
             ProxyNodesCore.Refresh();
@@ -746,6 +776,7 @@ namespace molilian.api.Controllers
         [HttpGet]
         public ActionResult ReloadAccount()
         {
+            RiskControlCore.Refresh();
             EndPointCore.Refresh();
             ProxyNodesCore.Refresh();
             TkPoolCore.Refresh();

+ 2 - 202
molilian.api/Controllers/public/TkController.cs

@@ -87,96 +87,7 @@ namespace molilian.api.Controllers
             oaid = "test-oaid";
 #endif
             return await UnionParseCore.UnionParseAsync(content, channel, ip, oaid, accountid);
-        } 
-
-        [HttpGet]
-        public async Task<ActionResult> tesjd(int aid, int num = 100)
-        {
-            var channel = "jd";
-            string ip = "127.0.0.1";
-            string oaid = "test-oaid";
-
-            var list = new DBContext.Table("jd_parse_logs_success").Order("RAND()").Limit(num).Select<dynamic>();
-            foreach (var item in list)
-            {
-                await UnionParseCore.UnionParseAsync(item.rawContent, channel, ip, oaid, aid);
-            }
-            return new APIResult(new { success = true, message = "ok" });
-        }
-
-        [HttpGet]
-        public async Task<ActionResult> tespdd(int aid, int num = 10, int time = 10)
-        {
-            var channel = "pdd";
-            string ip = "127.0.0.1";
-            string oaid = "test-oaid";
-
-            long[] ids = [202388161458,
-637136869820,
-437298318944,
-450267426247,
-539858704020,
-454418994546,
-333101893158,
-548124555533,
-536810064160,
-394420905274,
-265854971073,
-470187982089,
-460166587606,
-606201132000,
-636576970817,
-503020436844,
-64075414938,
-564823147084,
-400331744081,
-549023673392,
-510533263139,
-426302139303,
-606182099388,
-592309700176,
-509945035718,
-536810064160,
-562434609588,
-210550635424,
-602689684700,
-394649770525,
-295709990348,
-241991260035,
-310685408148,
-636576970817,
-335033136305,
-629347481399,
-437298318944,
-524348092851,
-484213318266,
-397252362715,
-6326358156,
-450204411089,
-616697299054,
-602623733449,
-549023673392,
-367065511257,
-605812755181,
-562434609588,
-265854971073,
-476300076415];
-
-            for (int i = 0; i <= time; i++)
-            {
-                for (int j = 0; j <= num; j++)
-                {
-                    long currentId = ids[j % ids.Length];
-                    string content = $"https://mobile.yangkeduo.com/goods.html?goods_id={currentId}";
-                    _ = UnionParseCore.UnionParseAsync(content, channel, ip, oaid, aid);
-                }
-                Thread.Sleep(1000);
-            }
-            return new APIResult(new { success = true, message = "ok" });
-
-        }
-
-
+        }  
 
         [HttpPost]
         public async Task<ActionResult> unionCoupon([FromBody] JsonElement form, [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
@@ -352,118 +263,7 @@ namespace molilian.api.Controllers
                 result.deeplink_url,
             });
         }
-
-        [HttpGet]
-        public ActionResult parse2(string s, string s2 = "", string ip = "", string oaid = "")
-        {
-            AlimamaPlus alimama = null;
-            ip = AlimamaPlus.OppoDecode(ip);
-            oaid = AlimamaPlus.OppoDecode(oaid);
-            var result = AlimamaPlus.GetFormattedObject(s, ip, oaid);
-            string body = "";
-            string content = s.UrlDecode();
-            string content2 = s2.UrlDecode();
-            string account_name = string.Empty;
-            result.rawContent = content;
-            result.rawContent2 = content2;
-
-            try
-            {
-                if (AlimamaPlus.ShouldIgnoreRequest(ip, oaid, out string reason))
-                {
-                    result.success = false;
-                    result.message = "放弃转链";
-                    result.reason = reason;
-                    _ = TkLogCore.LogAsync(result);
-                    return new APIResult(new
-                    {
-                        result.success,
-                        result.message,
-                        result.content,
-                        result.couponAmount,
-                        result.taoToken,
-                        result.shortLinkurl,
-                        result.deeplink_url,
-                    });
-                }
-
-                var account = TkPoolCore.GetOne(TkPoolCore.TkAction.parse);
-                if (account == null)
-                {
-                    result.success = false;
-                    result.message = "放弃转链";
-                    result.reason = "没有匹配账号";
-                    _ = TkLogCore.LogAsync(result);
-                    return new APIResult(new
-                    {
-                        result.success,
-                        result.message,
-                        result.content,
-                        result.couponAmount,
-                        result.taoToken,
-                        result.shortLinkurl,
-                        result.deeplink_url,
-                    });
-                }
-
-                account_name = account.name;
-                alimama = new AlimamaPlus(account);
-
-                if (alimama.ShouldIgnoreOtherAff(s2))
-                {
-                    result.success = false;
-                    result.message = "放弃转链";
-                    result.reason = "其他推广链接";
-                    _ = TkLogCore.LogAsync(result);
-                    return new APIResult(new
-                    {
-                        result.success,
-                        result.message,
-                        result.content,
-                        result.couponAmount,
-                        result.taoToken,
-                        result.shortLinkurl,
-                        result.deeplink_url,
-                    });
-
-                }
-                alimama.UnionParse(content, ref result);
-                //result.ip = ip;
-                //result.oaid = oaid;
-
-            }
-            catch (Exception ex)
-            {
-                _ = new LoggerLibrary("api_error", "parse")
-                    .Info(s, s2)
-                    .Info($"【taobao】{account_name}", body)
-                    .Info(ex.Message, ex.StackTrace)
-                    .SaveAsync();
-                NotifyCore.Notify(new NifyMessage
-                {
-                    message = $"【转链接口异常】{account_name}\n{content}\n{content2}\n{body}\n\n{ex.Message}\n{ex.StackTrace}",
-                    priority = NifyMessagePriority.high,
-                    tags = ["red_circle"]
-                });
-                result.success = false;
-                result.message = "放弃转链";
-                result.reason = "转链接口异常";
-            }
-
-            _ = TkLogCore.LogAsync(result, alimama);
-            return new APIResult(new
-            {
-                result.success,
-                result.message,
-                result.content,
-                result.couponAmount,
-                result.taoToken,
-                result.shortLinkurl,
-                result.deeplink_url,
-            });
-        }
-
-
+         
         [HttpGet]
         public ActionResult jd_parse(string s, string s2 = "", string ip = "", string oaid = "")
         {

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 2 - 5
molilian.api/Properties/launchSettings.json

@@ -2,10 +2,9 @@
   "profiles": {
     "http": {
       "commandName": "Project",
-      "launchBrowser": true,
       "launchUrl": "swagger",
       "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT2": "Development",
+        "ASPNETCORE_ENVIRONMENT": "Development",
         "EndPoint": "admin",
         "NtfyServer": "https://ntfy.yunhui800.com/5Sq9BytXXM5WDY3G",
         "ANPush": "",
@@ -15,7 +14,7 @@
         "CenterDB": "",
         "CenterRedis": ""
       },
-      "environmentVariables": {
+      "environmentVariables2": {
         "ASPNETCORE_ENVIRONMENT": "Development",
         "EndPoint": "cadmin",
         "NtfyServer": "https://ntfy.yunhui800.com/5Sq9BytXXM5WDY3G",
@@ -25,14 +24,12 @@
         "RedisConfig": "8.140.49.136:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon",
         "CenterDB": "Server=rm-2zey1jqxnoqy9mcc0zo.rwlb.rds.aliyuncs.com; Port=3306; Database=taoke; Uid=taoke; Pwd=67ktWBmw5G4yMs4J;SslMode=None;CharSet=utf8mb4;ConnectionTimeout=60",
         "CenterRedis": "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook"
-
       },
       "dotnetRunMessages": true,
       "applicationUrl": "http://localhost:8186"
     },
     "https": {
       "commandName": "Project",
-      "launchBrowser": true,
       "launchUrl": "swagger",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"

+ 13 - 5
molilian.core/Core/ProxyNodesCore.cs

@@ -42,12 +42,20 @@ namespace molilian.core
                 Credentials = new NetworkCredential(ProxyNodesDTO.username, ProxyNodesDTO.password)
             };
         }
-        public static WebProxy? RandomOne()
+        private static bool SelectEndPointUseProxy(ProxyNodesDTO item, string node = "")
+        {
+            if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
+            {
+                if (item.end_point != _end_point) return false;
+            }
+            return string.IsNullOrEmpty(node) || item.name == node;
+        }
+        public static WebProxy? RandomOne(string excludeNode = "")
         {
 
             var list = List();
             if (!list.Any()) return null;
-            var ProxyNodesDTO = list.Where(e => SelectEndPointUseProxy(e, string.Empty)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
+            var ProxyNodesDTO = list.Where(e => SelectEndPointExcludeNodeUseProxy(e, string.Empty)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
             if (ProxyNodesDTO == null) return null;
 
             return new WebProxy
@@ -56,15 +64,15 @@ namespace molilian.core
                 Credentials = new NetworkCredential(ProxyNodesDTO.username, ProxyNodesDTO.password)
             };
         }
-
-        private static bool SelectEndPointUseProxy(ProxyNodesDTO item, string node="")
+        private static bool SelectEndPointExcludeNodeUseProxy(ProxyNodesDTO item, string excludeNode = "")
         {
             if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
             {
                 if (item.end_point != _end_point) return false;
             }
-            return string.IsNullOrEmpty(node) || item.name == node;
+            return string.IsNullOrEmpty(excludeNode) || item.name != excludeNode;
         }
+
         public static IEnumerable<ProxyNodesDTO> List(bool force = false)
         {
             if (!force && _cached != null) return _cached;

+ 6 - 83
molilian.core/Core/cps/ElePoolCore.cs

@@ -7,7 +7,6 @@ namespace molilian.core
     {
         private static string _end_point;
         private static Dictionary<string, decimal> _incomeAmt = new();
-        private static Dictionary<string, int> _calls = new();
         static ElePoolCore()
         {
             _end_point = Environment.GetEnvironmentVariable("EndPoint");
@@ -15,7 +14,7 @@ namespace molilian.core
 
         private static readonly object _lockObj = new();
         private static IEnumerable<ElePoolDTO> _cached;
-    
+
         public static ElePoolDTO? GetOne()
         {
             var list = List();
@@ -30,77 +29,6 @@ namespace molilian.core
             if (!list.Any()) return null;
             return list.Where(e => e.id == id && IsNotExceedDailyIncomeLimit(e)).FirstOrDefault();
         }
-        internal static void CallsIncrBy(int accountId)
-        {
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMdd"));
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMddHH"));
-        }
-
-        internal static void CallsIncrBy(int accountId, string flag)
-        {
-            string key = $"{accountId}:{flag}";
-            if (_calls.ContainsKey(key))
-            {
-                _calls[key] = _calls[key] + 1;
-            }
-            else
-            {
-                _calls[key] = 1;
-            }
-            string cache_key = $"cache:ele_pool:{key}:calls:{flag}";
-            RedisHelper.IncrBy(cache_key);
-            RedisHelper.Expire(cache_key, 3 * 86400);
-        }
-
-        public static int SaveCalls(int accountId, string flag)
-        {
-            string key = $"{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 = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-#endif
-
-                string cache_key = $"cache:ele_pool:{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 int GetCalls(int accountId, string flag)
-        {
-            try
-            {
-                string key = $"{accountId}:{flag}";
-                if (_calls.ContainsKey(key)) return _calls[key];
-
-                string cache_key = $"cache:ele_pool:{key}:calls:{flag}";
-                int num = RedisHelper.Get<int>(cache_key);
-                _calls.TryAdd(key, num);
-                return num;
-            }
-            catch (Exception ex) { return 0; }
-        }
 
         private static bool IsNotExceedDailyIncomeLimit(ElePoolDTO item)
         {
@@ -114,12 +42,12 @@ namespace molilian.core
 
             if (item.daily_calls_limit > 0)
             {
-                int daily_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMdd"));
+                int daily_num = RiskControlCore.GetCalls(TkChannelEnum.eleme, item.id, DateTime.Now.ToString("yyyyMMdd"));
                 if (daily_num >= item.daily_calls_limit) return false;
             }
             if (item.hourly_calls_limit > 0)
             {
-                int hourly_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMddHH"));
+                int hourly_num = RiskControlCore.GetCalls(TkChannelEnum.eleme, item.id, DateTime.Now.ToString("yyyyMMddHH"));
                 if (hourly_num >= item.hourly_calls_limit) return false;
             }
             return true;
@@ -140,15 +68,10 @@ namespace molilian.core
                         .Select<ElePoolDTO>();
                     if (list == null) return default;
 
-
-                    _calls = new Dictionary<string, int>();
                     foreach (var item in list)
                     {
-                        string key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_hourly_calls);
-
-                        key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_daily_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.eleme, item.id, DateTime.Now.ToString("yyyyMMddHH"), item.current_hourly_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.eleme, item.id, DateTime.Now.ToString("yyyyMMdd"), item.current_daily_calls);
                     }
                     RedisHelper.Set(cache_key, list, 30 * 86400);
                 }
@@ -160,7 +83,7 @@ namespace molilian.core
         {
             _ = List(true);
         }
-        
+
         internal static void AccountExhausted()
         {
             string cache_key = $"cache:tk_pool:account:exhausted";

+ 4 - 84
molilian.core/Core/cps/MeituanPoolCore.cs

@@ -6,8 +6,6 @@ namespace molilian.core
     public partial class MeituanPoolCore
     {
         private static string _end_point;
-        private static Dictionary<string, decimal> _incomeAmt = new();
-        private static Dictionary<string, int> _calls = new();
         static MeituanPoolCore()
         {
             _end_point = Environment.GetEnvironmentVariable("EndPoint");
@@ -29,78 +27,6 @@ namespace molilian.core
             if (!list.Any()) return null;
             return list.Where(e => e.id == id && IsNotExceedDailyIncomeLimit(e)).FirstOrDefault();
         }
-        internal static void CallsIncrBy(int accountId)
-        {
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMdd"));
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMddHH"));
-        }
-
-        internal static void CallsIncrBy(int accountId, string flag)
-        {
-            string key = $"{accountId}:{flag}";
-            if (_calls.ContainsKey(key))
-            {
-                _calls[key] = _calls[key] + 1;
-            }
-            else
-            {
-                _calls[key] = 1;
-            }
-            string cache_key = $"cache:meituan_pool:{key}:calls:{flag}";
-            RedisHelper.IncrBy(cache_key);
-            RedisHelper.Expire(cache_key, 3 * 86400);
-        }
-
-        public static int SaveCalls(int accountId, string flag)
-        {
-            string key = $"{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 = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-#endif
-
-                string cache_key = $"cache:meituan_pool:{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 int GetCalls(int accountId, string flag)
-        {
-            try
-            {
-                string key = $"{accountId}:{flag}";
-                if (_calls.ContainsKey(key)) return _calls[key];
-
-                string cache_key = $"cache:meituan_pool:{key}:calls:{flag}";
-                int num = RedisHelper.Get<int>(cache_key);
-                _calls.TryAdd(key, num);
-                return num;
-            }
-            catch (Exception ex) { return 0; }
-        }
-
         private static bool IsNotExceedDailyIncomeLimit(MeituanPoolDTO item)
         {
             if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
@@ -113,12 +39,12 @@ namespace molilian.core
 
             if (item.daily_calls_limit > 0)
             {
-                int daily_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMdd"));
+                int daily_num = RiskControlCore.GetCalls(TkChannelEnum.meituan, item.id, DateTime.Now.ToString("yyyyMMdd"));
                 if (daily_num >= item.daily_calls_limit) return false;
             }
             if (item.hourly_calls_limit > 0)
             {
-                int hourly_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMddHH"));
+                int hourly_num = RiskControlCore.GetCalls(TkChannelEnum.meituan, item.id, DateTime.Now.ToString("yyyyMMddHH"));
                 if (hourly_num >= item.hourly_calls_limit) return false;
             }
             return true;
@@ -138,16 +64,10 @@ namespace molilian.core
                         .Where("status=@status", new { status = 1 })
                         .Select<MeituanPoolDTO>();
                     if (list == null) return default;
-
-
-                    _calls = new Dictionary<string, int>();
                     foreach (var item in list)
                     {
-                        string key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_hourly_calls);
-
-                        key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_daily_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.meituan, item.id, DateTime.Now.ToString("yyyyMMddHH"), item.current_hourly_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.meituan, item.id, DateTime.Now.ToString("yyyyMMdd"), item.current_daily_calls);
                     }
                     RedisHelper.Set(cache_key, list, 30 * 86400);
                 }

+ 134 - 0
molilian.core/Core/cps/UnionCpsCore.cs

@@ -115,6 +115,140 @@ namespace molilian.core
         }
 
 
+        public static async Task<APIResult> TbtCouponAsync(string content, string channel, string ip, string oaid)
+        {
+            UnionCpsDTO result = GetFormattedObject(channel, ip, oaid);
+            if (string.IsNullOrEmpty(result.channel))
+            {
+                result.success = false;
+                result.message = "放弃转链";
+                result.reason = "无效渠道";
+                _ = TkLogCore.CpsLogAsync(result);
+                return new APIResult(new
+                {
+                    result.success,
+                    result.message,
+                    result.reason,
+                    channel,
+                });
+            }
+
+            AlimamaPlus alimama = null;
+            content = content.UrlDecode();
+
+            content = AlimamaPlus.FakeItemUrl(content, string.Empty);
+            result.rawContent = content;
+
+            if (string.IsNullOrEmpty(content))
+            {
+                result.success = false;
+                result.message = "放弃转链";
+                result.reason = "无效的参数";
+                result.rawContent = content;
+                _ = TkLogCore.CpsLogAsync(result);
+                return new APIResult(new
+                {
+                    result.success,
+                    result.reason,
+                    result.message,
+                    channel = result.channel.ToString(),
+                });
+            }
+
+            try
+            {
+                string reason;
+                if (AlimamaPlus.FilterRiskLink(ip, oaid, content, out reason) ||
+                    AlimamaPlus.ShouldIgnoreRequest(ip, oaid, out reason))
+                {
+                    result.success = false;
+                    result.message = "放弃转链";
+                    result.reason = reason;
+                    _ = TkLogCore.CpsLogAsync(result);
+                    return new APIResult(new
+                    {
+                        result.success,
+                        result.message,
+                        result.reason,
+                        channel = result.channel.ToString(),
+                    });
+                }
+
+                var account = TkPoolCore.GetOne(TkPoolCore.TkAction.parse);
+                if (account == null)
+                {
+                    result.success = false;
+                    result.message = "放弃转链";
+                    result.reason = "没有匹配账号";
+                    _ = TkLogCore.CpsLogAsync(result);
+                    return new APIResult(new
+                    {
+                        result.success,
+                        result.message,
+                        result.reason,
+                        channel = result.channel.ToString(),
+                    });
+                }
+                result.accountId = account.id;
+                result.accountName = account.name;
+                alimama = new AlimamaPlus(account);
+                //result = await alimama.UnionCoupon2Async(content, result);
+
+
+                TkDataDTO data = new();
+                data = await alimama.alimamaParseAsync(content, data);
+
+                result.success = data.success;
+                result.reason = data.reason;
+                result.message = data.success ? "OK" : data.message;
+
+                if (result.success)
+                {
+                    result.token = data.taoToken;
+                    //result.deeplink_url = data.deeplink_url;
+                    result.couponAmount = data.couponAmount;
+                    result.itemId = data.itemId;
+                }
+            }
+            catch (Exception ex)
+            {
+                if (ex.Message.Contains("was canceled"))
+                {
+                    result.success = false;
+                    result.message = "放弃转链";
+                    result.reason = "请求超时";
+                }
+                else
+                {
+                    _ = new LoggerLibrary("unionCoupon", "tb_error")
+                        .Info(ip, oaid)
+                        .Info(content)
+                        .Info(ex.Message, ex.StackTrace)
+                        .SaveAsync();
+
+                    NotifyCore.Notify(new NifyMessage
+                    {
+                        message = $"【转链异常TB】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
+                        priority = NifyMessagePriority.high,
+                        tags = ["red_circle"]
+                    });
+                    result.success = false;
+                    result.message = "放弃转链";
+                    result.reason = "转链接口异常";
+                }
+            }
+            _ = TkLogCore.CpsLogAsync(result);
+            return new APIResult(new
+            {
+                result.success,
+                result.message,
+                result.title,
+                result.deeplink_url,
+                result.token,
+                result.channel,
+            });
+        }
+
         //public static async Task<APIResult> EleAsync(string ip, string oaid)
         //{
         //    UnionCpsDTO result = GetFormattedObject(CpsChannelEnum.eleme, ip, oaid);

+ 4 - 82
molilian.core/Core/jd/JdPoolCore.cs

@@ -25,7 +25,6 @@ namespace molilian.core
         }
         private static string _end_point;
         private static Dictionary<string, decimal> _incomeAmt = new();
-        private static Dictionary<string, int> _calls = new();
         static JdPoolCore()
         {
             _end_point = Environment.GetEnvironmentVariable("EndPoint");
@@ -53,79 +52,7 @@ namespace molilian.core
             var list = List();
             if (!list.Any()) return null;
             return list.Where(e => e.id == id && IsNotExceedDailyIncomeLimit(e, action)).FirstOrDefault();
-        } 
-        internal static void CallsIncrBy(int accountId)
-        {
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMdd"));
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMddHH"));
         }
-
-        internal static void CallsIncrBy(int accountId, string flag)
-        {
-            string key = $"{accountId}:{flag}";
-            if (_calls.ContainsKey(key))
-            {
-                _calls[key] = _calls[key] + 1;
-            }
-            else
-            {
-                _calls[key] = 1;
-            }
-            string cache_key = $"cache:jd_pool:{key}:calls:{flag}";
-            RedisHelper.IncrBy(cache_key);
-            RedisHelper.Expire(cache_key, 3 * 86400);
-        }
-
-        public static int SaveCalls(int accountId, string flag)
-        {
-            string key = $"{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 = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-#endif
-
-                string cache_key = $"cache:jd_pool:{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 int GetCalls(int accountId, string flag)
-        {
-            try
-            {
-                string key = $"{accountId}:{flag}";
-                if (_calls.ContainsKey(key)) return _calls[key];
-
-                string cache_key = $"cache:jd_pool:{key}:calls:{flag}";
-                int num = RedisHelper.Get<int>(cache_key);
-                _calls.TryAdd(key, num);
-                return num;
-            }
-            catch (Exception ex) { return 0; }
-        }
-
         private static bool IsNotExceedDailyIncomeLimit(JdPoolDTO item, JdAction action)
         {
             if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
@@ -147,12 +74,12 @@ namespace molilian.core
 
             if (item.daily_calls_limit > 0)
             {
-                int daily_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMdd"));
+                int daily_num = RiskControlCore.GetCalls(TkChannelEnum.jd, item.id, DateTime.Now.ToString("yyyyMMdd"));
                 if (daily_num >= item.daily_calls_limit) return false;
             }
             if (item.hourly_calls_limit > 0)
             {
-                int hourly_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMddHH"));
+                int hourly_num = RiskControlCore.GetCalls(TkChannelEnum.jd, item.id, DateTime.Now.ToString("yyyyMMddHH"));
                 if (hourly_num >= item.hourly_calls_limit) return false;
             }
             return true;
@@ -173,15 +100,10 @@ namespace molilian.core
                         .Select<JdPoolDTO>();
                     if (list == null) return default;
 
-
-                    _calls = new Dictionary<string, int>();
                     foreach (var item in list)
                     {
-                        string key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_hourly_calls);
-
-                        key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_daily_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.jd, item.id, DateTime.Now.ToString("yyyyMMddHH"), item.current_hourly_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.jd, item.id, DateTime.Now.ToString("yyyyMMdd"), item.current_daily_calls);
                     }
                     RedisHelper.Set(cache_key, list, 30 * 86400);
                 }

+ 23 - 86
molilian.core/Core/ks/KsPoolCore.cs

@@ -25,7 +25,6 @@ namespace molilian.core
         }
         private static string _end_point;
         private static Dictionary<string, decimal> _incomeAmt = new();
-        private static Dictionary<string, int> _calls = new();
         static KsPoolCore()
         {
             _end_point = Environment.GetEnvironmentVariable("EndPoint");
@@ -54,78 +53,6 @@ namespace molilian.core
             if (!list.Any()) return null;
             return list.Where(e => e.id == id && IsNotExceedDailyIncomeLimit(e, action)).FirstOrDefault();
         }
-        internal static void CallsIncrBy(int accountId)
-        {
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMdd"));
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMddHH"));
-        }
-
-        internal static void CallsIncrBy(int accountId, string flag)
-        {
-            string key = $"{accountId}:{flag}";
-            if (_calls.ContainsKey(key))
-            {
-                _calls[key] = _calls[key] + 1;
-            }
-            else
-            {
-                _calls[key] = 1;
-            }
-            string cache_key = $"cache:ks_pool:{key}:calls:{flag}";
-            RedisHelper.IncrBy(cache_key);
-            RedisHelper.Expire(cache_key, 3 * 86400);
-        }
-
-        public static int SaveCalls(int accountId, string flag)
-        {
-            string key = $"{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 = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-#endif
-
-                string cache_key = $"cache:ks_pool:{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 int GetCalls(int accountId, string flag)
-        {
-            try
-            {
-                string key = $"{accountId}:{flag}";
-                if (_calls.ContainsKey(key)) return _calls[key];
-
-                string cache_key = $"cache:ks_pool:{key}:calls:{flag}";
-                int num = RedisHelper.Get<int>(cache_key);
-                _calls.TryAdd(key, num);
-                return num;
-            }
-            catch (Exception ex) { return 0; }
-        }
-
         private static bool IsNotExceedDailyIncomeLimit(KsPoolDTO item, KsAction action)
         {
 
@@ -148,12 +75,12 @@ namespace molilian.core
 
             if (item.daily_calls_limit > 0)
             {
-                int daily_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMdd"));
+                int daily_num = RiskControlCore.GetCalls(TkChannelEnum.ks, item.id, DateTime.Now.ToString("yyyyMMdd"));
                 if (daily_num >= item.daily_calls_limit) return false;
             }
             if (item.hourly_calls_limit > 0)
             {
-                int hourly_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMddHH"));
+                int hourly_num = RiskControlCore.GetCalls(TkChannelEnum.ks, item.id, DateTime.Now.ToString("yyyyMMddHH"));
                 if (hourly_num >= item.hourly_calls_limit) return false;
             }
             return true;
@@ -174,15 +101,10 @@ namespace molilian.core
                         .Select<KsPoolDTO>();
                     if (list == null) return default;
 
-
-                    _calls = new Dictionary<string, int>();
                     foreach (var item in list)
                     {
-                        string key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_hourly_calls);
-
-                        key = $"{item.id}:{DateTime.Now:yyyyMMddHH}";
-                        _calls.TryAdd(key, item.current_daily_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.ks, item.id, DateTime.Now.ToString("yyyyMMddHH"), item.current_hourly_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.ks, item.id, DateTime.Now.ToString("yyyyMMdd"), item.current_daily_calls);
                     }
                     RedisHelper.Set(cache_key, list, 30 * 86400);
                 }
@@ -209,7 +131,6 @@ namespace molilian.core
                 .Add("today_finishOrderNum", account.today_finishOrderNum)
                 .Add("today_orderNum", account.today_orderNum)
 
-
                 .Where("id=@id", new { account.id })
                 .Update();
         }
@@ -301,11 +222,9 @@ namespace molilian.core
         }
 
 
-
-
         internal static void AccountExhausted()
         {
-            string cache_key = $"cache:tk_pool:account:exhausted";
+            string cache_key = $"cache:ks_pool:account:exhausted";
             long count = RedisHelper.IncrBy(cache_key);
             if (count > 1) return;
             RedisHelper.Expire(cache_key, 3600);
@@ -318,6 +237,24 @@ namespace molilian.core
             NotifyCore.AnPushNotify("没账号", $"【快手联盟】没有匹配账号");
         }
 
+
+        internal static void NotifyInterfaceError(string reason)
+        {
+            string cache_key = $"cache:ks_pool:account:InterfaceError";
+            long count = RedisHelper.IncrBy(cache_key);
+            if (count > 1) return;
+            RedisHelper.Expire(cache_key, 3600);
+            NotifyCore.Notify(new NifyMessage
+            {
+                message = $"【快手联盟】{reason}",
+                priority = NifyMessagePriority.high,
+                tags = ["red_circle"]
+            });
+        }
+
+
+
+
     }
 
 

+ 2 - 0
molilian.core/Core/log/coupon.cs

@@ -66,6 +66,8 @@ 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 && "nologin".Equals(response.message))
                 {
                     switch (response.channel)

+ 4 - 0
molilian.core/Core/log/deeplink.cs

@@ -44,6 +44,10 @@ namespace molilian.core
                         {
                             save_dp_parse_logs(data, "deeplink_parse_logs_success", connection, transaction);
                         }
+                        else
+                        {
+                            save_dp_parse_logs(data, "deeplink_parse_logs_fail", connection, transaction);
+                        }
                     }
                     total++;
                 }

+ 2 - 0
molilian.core/Core/log/dy.cs

@@ -72,6 +72,8 @@ namespace molilian.core
                 response.elapsedTime = (int)ts.TotalMilliseconds;
                 _ = RedisHelper.RPushAsync(queue_parse_dy_key, response);
 
+                saveClientRequestTotal(response.channel, response.ip, response.oaid);
+
                 if (!response.ip.Contains("127.0.0"))
                 {
                     saveParseCache(response.channel.ToString(), response.accountId,

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

@@ -31,7 +31,7 @@ namespace molilian.core
                     {
                         //save_jd_parse_logs(data, "jd_parse_logs", connection, transaction);
 
-                        if (save_dailys_log)
+                        //if (save_dailys_log)
                         {
                             string daily_table = $"jd_parse_logs_{data.create_time:yyyyMMdd}";
                             save_jd_parse_logs(data, daily_table, connection, transaction);
@@ -82,11 +82,9 @@ namespace molilian.core
 
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    JdPoolCore.CallsIncrBy(response.accountId);
+                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
+                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
                 }
-                //CallsIncrBy
-
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
 
                 if (!response.success && ("nologin".Equals(response.reason) ||
                     "方法不存在".Equals(response.reason) ||

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

@@ -30,7 +30,7 @@ namespace molilian.core
                     {
                         //save_ks_parse_logs(data, "ks_parse_logs", connection, transaction);
 
-                        if (save_dailys_log)
+                        //if (save_dailys_log)
                         {
                             string daily_table = $"ks_parse_logs_{data.create_time:yyyyMMdd}";
                             save_ks_parse_logs(data, daily_table, connection, transaction);
@@ -77,12 +77,10 @@ namespace molilian.core
 
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    KsPoolCore.CallsIncrBy(response.accountId);
+                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
+                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
                 }
 
-
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
-
                 if (!response.success && ("nologin".Equals(response.reason) ||
                     "方法不存在".Equals(response.reason) ||
                     "未登录".Equals(response.reason)))
@@ -96,6 +94,11 @@ namespace molilian.core
                 {
                     KsPoolCore.AccountExhausted();
                 }
+
+                if ("TOKEN过期".Equals(response.reason))
+                {
+                    KsPoolCore.NotifyInterfaceError(response.reason);
+                }
             }
             catch (Exception ex) { }
         }

+ 14 - 30
molilian.core/Core/log/pdd.cs

@@ -29,10 +29,15 @@ namespace molilian.core
                     }
                     else
                     {
-                        save_pdd_parse_logs(data, "pdd_parse_logs", connection, transaction);
-                        if (data.success)
+                        //save_pdd_parse_logs(data, "pdd_parse_logs", connection, transaction);
+                        //if (save_dailys_log)
                         {
-                            save_pdd_parse_logs(data, "pdd_parse_logs_success", connection, transaction);
+                            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++;
@@ -63,30 +68,6 @@ namespace molilian.core
                 response.elapsedTime = (int)ts.TotalMilliseconds;
                 _ = RedisHelper.RPushAsync(queue_parse_pdd_key, response);
 
-
-#if DEBUG
-                for (int i = 0; i < 100; i++)
-                {
-                    var data = RedisHelper.LPop<PddDataDTO>(queue_parse_pdd_key);
-                    if (data == null) break;
-
-
-                    if (data.ip.Contains("127.0.0"))
-                    {
-                        save_pdd_parse_logs(data, "pdd_parse_logs_test", null, null);
-                    }
-                    else
-                    {
-                        save_pdd_parse_logs(data, "pdd_parse_logs", null, null);
-                        if (data.success)
-                        {
-                            save_pdd_parse_logs(data, "pdd_parse_logs_success", null, null);
-                        }
-                    }
-                }
-
-#endif
-
                 if (!response.ip.Contains("127.0.0"))
                 {
                     saveParseCache(response.channel.ToString(), response.accountId,
@@ -96,7 +77,8 @@ namespace molilian.core
 
                 if (response.success || response.message.Equals("转链失败"))
                 {
-                    PddPoolCore.CallsIncrBy(response.accountId);
+                    RiskControlCore.CallsIncrBy(response.channel, response.accountId);
+                    saveClientRequestTotal(response.channel, response.ip, response.oaid);
                 }
 
                 if (response.reason.Equals("您的调用次数过高"))
@@ -104,8 +86,6 @@ namespace molilian.core
                     PddPoolCore.TempSuspend(response.accountId);
                 }
 
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
-
                 if (!response.success && ("nologin".Equals(response.reason) ||
                     "方法不存在".Equals(response.reason) ||
                     "未登录".Equals(response.reason)))
@@ -115,6 +95,10 @@ namespace molilian.core
                         PddPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
                     });
                 }
+                if (response.reason.Contains("当前账号被禁止使用转链功能"))
+                {
+                    PddPoolCore.Disabled(response.accountId, response.accountName, response.reason);
+                }
                 if ("没有匹配账号".Equals(response.reason))
                 {
                     PddPoolCore.AccountExhausted();

+ 5 - 3
molilian.core/Core/log/taobao.cs

@@ -92,7 +92,11 @@ namespace molilian.core
                 response.elapsedTime = (int)ts.TotalMilliseconds;
                 _ = RedisHelper.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);
+                }
                 if (response.success)
                 {
                     _ = saveUnionCouponParseCacheAsync(response);
@@ -103,8 +107,6 @@ namespace molilian.core
                         response.accountName, response.success, response.message, response.reason,
                         response.deeplink_url);
                 }
-
-
                 if (!string.IsNullOrEmpty(response.itemId)) TkOrderTrackingCore.SaveLinkSummary(response);
 
                 if (!response.success && "nologin".Equals(response.message))

+ 7 - 77
molilian.core/Core/pdd/PddPoolCore.cs

@@ -24,7 +24,6 @@ namespace molilian.core
 
         private static string _end_point;
         private static Dictionary<string, decimal> _incomeAmt = new();
-        private static Dictionary<string, int> _calls = new();
         private static ConcurrentDictionary<int, DateTime> _suspend = new();
         static PddPoolCore()
         {
@@ -58,7 +57,6 @@ namespace molilian.core
             // 使用初始化参数创建工作时间表
             if (!new WorkSchedule(item.time_range).IsWorkHour()) return false;
 
-
             if (_suspend.TryGetValue(accountid, out DateTime suspendTime))
             {
                 var ts = DateTime.Now - suspendTime;
@@ -67,90 +65,17 @@ namespace molilian.core
 
             if (item.daily_calls_limit > 0)
             {
-                int daily_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMdd"));
+                int daily_num = RiskControlCore.GetCalls(TkChannelEnum.pdd, item.id, DateTime.Now.ToString("yyyyMMdd"));
                 if (daily_num >= item.daily_calls_limit) return false;
             }
             if (item.hourly_calls_limit > 0)
             {
-                int hourly_num = GetCalls(item.id, DateTime.Now.ToString("yyyyMMddHH"));
+                int hourly_num = RiskControlCore.GetCalls(TkChannelEnum.pdd, item.id, DateTime.Now.ToString("yyyyMMddHH"));
                 if (hourly_num >= item.hourly_calls_limit) return false;
             }
             return true;
         }
 
-        public static int GetCalls(int accountId, string flag)
-        {
-            try
-            {
-                string key = $"{accountId}:{flag}";
-                if (_calls.ContainsKey(key)) return _calls[key];
-
-                string cache_key = $"cache:jd_pool:{key}:calls:{flag}";
-                int num = RedisHelper.Get<int>(cache_key);
-                _calls.TryAdd(key, num);
-                return num;
-            }
-            catch (Exception ex) { return 0; }
-        }
-        internal static void CallsIncrBy(int accountId)
-        {
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMdd"));
-            CallsIncrBy(accountId, DateTime.Now.ToString("yyyyMMddHH"));
-        }
-
-        internal static void CallsIncrBy(int accountId, string flag)
-        {
-            string key = $"{accountId}:{flag}";
-            if (_calls.ContainsKey(key))
-            {
-                _calls[key] = _calls[key] + 1;
-            }
-            else
-            {
-                _calls[key] = 1;
-            }
-            string cache_key = $"cache:pdd_pool:{key}:calls:{flag}";
-            RedisHelper.IncrBy(cache_key);
-            RedisHelper.Expire(cache_key, 3 * 86400);
-        }
-
-        public static int SaveCalls(int accountId, string flag)
-        {
-            string key = $"{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 = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-#endif
-
-                string cache_key = $"cache:pdd_pool:{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 IEnumerable<PddPoolDTO> List(bool force = false)
         {
             if (!force && _cached != null) return _cached;
@@ -165,6 +90,11 @@ namespace molilian.core
                         .Where("status=@status", new { status = 1 })
                         .Select<PddPoolDTO>();
                     if (list == null) return default;
+                    foreach (var item in list)
+                    {
+                        RiskControlCore.SetCalls(TkChannelEnum.pdd, item.id, DateTime.Now.ToString("yyyyMMddHH"), item.current_hourly_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.pdd, item.id, DateTime.Now.ToString("yyyyMMdd"), item.current_daily_calls);
+                    }
                     RedisHelper.Set(cache_key, list, 30 * 86400);
                 }
             }

+ 151 - 0
molilian.core/Core/taoke/RiskControlCore.cs

@@ -0,0 +1,151 @@
+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 System.Threading.Channels;
+
+
+namespace molilian.core
+{
+    public partial class RiskControlCore
+    {
+        private static Dictionary<string, int> _calls = new();
+        private static Dictionary<string, decimal> _incomeAmt = new();
+
+        public static void Refresh()
+        {
+            _incomeAmt = [];
+        }
+        public static void ResetCalls()
+        {
+            _calls = [];
+        }
+
+        internal static void CallsIncrBy(TkChannelEnum channel, int accountId)
+        {
+            CallsIncrBy(channel, accountId, DateTime.Now.ToString("yyyyMMdd"));
+            CallsIncrBy(channel, accountId, DateTime.Now.ToString("yyyyMMddHH"));
+        }
+
+        internal static void CallsIncrBy(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}";
+            RedisHelper.IncrBy(cache_key);
+            RedisHelper.Expire(cache_key, 3 * 86400);
+        }
+
+        internal static void SetCalls(TkChannelEnum channel, int accountId, string flag, int val)
+        {
+            string key = $"{channel}:{accountId}:{flag}";
+            if (_calls.ContainsKey(key))
+            {
+                _calls[key] = val;
+            }
+            else
+            {
+                _calls[key] = val;
+            }
+            string cache_key = $"RiskControl:{key}:calls:{flag}";
+            RedisHelper.IncrBy(cache_key);
+            RedisHelper.Expire(cache_key, 3 * 86400);
+        }
+
+        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 = "c1api.molilian.com: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 int GetCalls(TkChannelEnum channel, int accountId, string flag)
+        {
+            try
+            {
+                string key = $"{channel}:{accountId}:{flag}";
+                if (_calls.ContainsKey(key)) return _calls[key];
+
+                string cache_key = $"RiskControl:{key}:calls:{flag}";
+                int num = RedisHelper.Get<int>(cache_key);
+                _calls.TryAdd(key, num);
+                return num;
+            }
+            catch (Exception ex) { return 0; }
+        }
+
+
+        internal static void SaveIncomeAmt(TkChannelEnum channel, string accountName, decimal income_amt)
+        {
+            string key = $"{channel}:{accountName}:{DateTime.Now:yyyyMMdd}";
+            if (_incomeAmt.ContainsKey(key))
+            {
+                _incomeAmt[key] = income_amt;
+            }
+            else
+            {
+                _incomeAmt.Add(key, income_amt);
+            }
+            string cache_key = $"RiskControl:{key}:income_amt";
+
+            var result = EndPointCore.ProcessEndPointNodes<bool>(node =>
+            {
+                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
+            {
+                string key = $"{channel}:{accountName}:{DateTime.Now:yyyyMMdd}";
+                if (_incomeAmt.ContainsKey(key)) return _incomeAmt[key];
+
+                string cache_key = $"RiskControl:{key}:income_amt";
+                return RedisHelper.Get<decimal>(cache_key);
+            }
+            catch (Exception ex) { return 0; }
+        }
+
+    }
+
+}

+ 24 - 43
molilian.core/Core/taoke/TkPoolCore.cs

@@ -32,7 +32,6 @@ namespace molilian.core
 
         private static readonly object _lockObj = new();
         private static IEnumerable<TkPoolDTO> _cached;
-        private static Dictionary<string, decimal> _incomeAmt = new();
         public static TkPoolDTO? GetOne(TkAction action)
         {
             var list = List();
@@ -46,48 +45,29 @@ namespace molilian.core
             return list.Where(e => e.id == id).FirstOrDefault();
         }
 
-        internal static void SaveIncomeAmt(string accountName, decimal income_amt)
+        private static bool FilterNodes(TkPoolDTO item, TkAction action)
         {
-            string key = $"{accountName}:{DateTime.Now:yyyyMMdd}";
-            if (_incomeAmt.ContainsKey(key))
-            {
-                _incomeAmt[key] = income_amt;
-            }
-            else
+            if (!string.IsNullOrEmpty(item.suspended_endpoint) && item.suspended_endpoint.Contains($"{_end_point}|")) return false;
+
+            if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
             {
-                _incomeAmt.Add(key, income_amt);
+                if (item.end_point != _end_point) return false;
             }
-            string cache_key = $"cache:tk_pool:{key}:income_amt";
 
-            var result = EndPointCore.ProcessEndPointNodes<bool>(node =>
-            {
-                if (!node.is_public_api) return true;
-                if (string.IsNullOrEmpty(node.redis_server)) return true;
+            // 使用初始化参数创建工作时间表
+            if (!new WorkSchedule(item.time_range).IsWorkHour()) return false;
 
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                return redis.Set(cache_key, income_amt, 3 * 86400);
-            });
-        }
-        public static decimal GetIncomeAmt(string accountName)
-        {
-            try
+            if (item.daily_calls_limit > 0)
             {
-                string key = $"{accountName}:{DateTime.Now:yyyyMMdd}";
-                if (_incomeAmt.ContainsKey(key)) return _incomeAmt[key];
-
-                string cache_key = $"cache:tk_pool:{key}:income_amt";
-                return RedisHelper.Get<decimal>(cache_key);
+                int daily_num = RiskControlCore.GetCalls(TkChannelEnum.tb, item.id, DateTime.Now.ToString("yyyyMMdd"));
+                if (daily_num >= item.daily_calls_limit) return false;
             }
-            catch (Exception ex) { return 0; }
-        }
-        private static bool FilterNodes(TkPoolDTO item, TkAction action)
-        {
-            if (!string.IsNullOrEmpty(item.suspended_endpoint) && item.suspended_endpoint.Contains($"{_end_point}|")) return false;
-
-            if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
+            if (item.hourly_calls_limit > 0)
             {
-                if (item.end_point != _end_point) return false;
+                int hourly_num = RiskControlCore.GetCalls(TkChannelEnum.tb, item.id, DateTime.Now.ToString("yyyyMMddHH"));
+                if (hourly_num >= item.hourly_calls_limit) return false;
             }
+
             switch (action)
             {
                 case TkAction.parse:
@@ -102,12 +82,14 @@ namespace molilian.core
             }
 
             if (item.daily_income_limit == 0) return true;
-            decimal income_amt = GetIncomeAmt($"{item.id}");
+            decimal income_amt = RiskControlCore.GetIncomeAmt(TkChannelEnum.tb, $"{item.id}");
             return income_amt < item.daily_income_limit;
-        }
+        } 
+
 
         public static IEnumerable<TkPoolDTO> List(bool force = false)
         {
+
             if (!force && _cached != null) return _cached;
 
             string cache_key = $"cache:tk_pool";
@@ -119,17 +101,17 @@ namespace molilian.core
                     list = new DBContext.Table("tk_pool")
                         .Where("status=@status", new { status = 1 })
                         .Select<TkPoolDTO>();
-#if DEBUG
-                    list = new DBContext.Table("tk_pool")
-                        .Where("id=@id", new { id=3 })
-                        .Select<TkPoolDTO>();
-#else
+
                     list = new DBContext.Table("tk_pool")
                         .Where("status=@status", new { status = 1 })
                         .Select<TkPoolDTO>();
                     if (list == null) return default;
+                    foreach (var item in list)
+                    {
+                        RiskControlCore.SetCalls(TkChannelEnum.tb, item.id, DateTime.Now.ToString("yyyyMMddHH"), item.current_hourly_calls);
+                        RiskControlCore.SetCalls(TkChannelEnum.tb, item.id, DateTime.Now.ToString("yyyyMMdd"), item.current_daily_calls);
+                    }
                     RedisHelper.Set(cache_key, list, 30 * 86400);
-#endif
                 }
             }
             _cached = list;
@@ -137,7 +119,6 @@ namespace molilian.core
         }
         public static void Refresh()
         {
-            _incomeAmt = [];
             _ = List(true);
         }
         public static void UpdateDrawBalance(string name, decimal amout)

+ 12 - 24
molilian.core/Core/taoke/UnionCouponCore.cs

@@ -1,23 +1,5 @@
-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 Spire.Pdf.Exporting.XPS.Schema;
-using System.Xml.Linq;
-using System.Net;
-using TencentCloud.Mrs.V20200910.Models;
+using dodohold.core;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Authentication;
-using Spire.Pdf.Graphics;
-using Google.Protobuf.WellKnownTypes;
-using System.Threading.Channels;
-using TencentCloud.Weilingwith.V20230427.Models;
-using System.Threading;
-
 
 namespace molilian.core
 {
@@ -32,12 +14,18 @@ namespace molilian.core
 
         public static async Task<ActionResult> UnionCouponAsync(string content, string dplink, string channel, string ip, string oaid)
         {
-            return channel switch
+            switch (channel)
             {
-                "jd" => await JdCouponAsync(content, dplink, ip, oaid),
-                "tb" => await TaobaoCouponAsync(content, dplink, ip, oaid),
-                _ => await UnionCpsCore.CpsCouponAsync(channel, ip, oaid),
-            };
+                case "tb":
+                    return await TaobaoCouponAsync(content, dplink, ip, oaid);
+                case "jd":
+                    return await JdCouponAsync(content, dplink, ip, oaid);
+                default:
+                    if (!string.IsNullOrEmpty(content.Trim()))
+                        return await UnionCpsCore.TbtCouponAsync(content, channel, ip, oaid);
+                    return await UnionCpsCore.CpsCouponAsync(channel, ip, oaid);
+            }
+
         }
 
         public static async Task<APIResult> TaobaoCouponAsync(string content, string dplink, string ip = "", string oaid = "")

+ 9 - 1
molilian.core/Core/taoke/UnionParseCore.cs

@@ -435,10 +435,18 @@ namespace molilian.core
                 //============================== 放弃转链-地区过滤 ==============================
                 if (accountid == 0 && JdUnionPlus.ShouldIgnoreRequest(config, ip, oaid, out string reason))
                 {
+                    result.link_type = JdUnionPlus.GetLinkType(result.shortLinkurl, out string out_url, out string itemId);
+                    if (result.link_type == LinkTypeEnum.other_aff)
+                    {
+                        result.deeplink_url = JdUnionPlus.GetDeeplink(result.shortLinkurl);
+                    }
+                    else
+                    {
+                        result.deeplink_url = JdUnionPlus.GetDeeplink(string.Empty);
+                    }
                     result.success = false;
                     result.message = "放弃转链";
                     result.reason = reason;
-                    result.deeplink_url = JdUnionPlus.GetDeeplink(string.Empty);
                     _ = TkLogCore.ParseLogAsync(result);
                     return JdParseOutput(result);
                 }

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

@@ -119,6 +119,7 @@ namespace molilian.core
                             var response = await new WebClientUtility
                             {
                                 Proxy = ProxyNodesCore.RandomOne(),
+                                UserAgent = ProviderFakeUserAgent.RandomMobile,
                                 AllowAutoRedirect = false
                             }.RequestAsync(url);
                             if (response.ResponseMessage != null)
@@ -197,6 +198,18 @@ namespace molilian.core
                                 //prompt_text = prompt_text.Replace($"{{url:{i - 1}}}", val.UrlEncode());
                             }
 
+                            if (deeplink.Contains("{decode:"))
+                            {
+                                string encodedUrl = HttpUtility.UrlDecode(val);
+                                deeplink = deeplink.Replace($"{{decode:{i - 1}}}", encodedUrl);
+                                //deeplink = deeplink.Replace($"{{url:{i - 1}}}", val.UrlEncode());
+                            }
+                            if (prompt_text.Contains("{decode:"))
+                            {
+                                string encodedUrl = HttpUtility.UrlDecode(val);
+                                prompt_text = prompt_text.Replace($"{{decode:{i - 1}}}", encodedUrl);
+                            }
+
 
                             if (deeplink.Contains("{url2:"))
                             {

+ 16 - 0
molilian.core/DTO/DailyLogsDTO.cs

@@ -51,6 +51,22 @@
 
 
 
+        public int pdd_parse_total_count { get; set; } = 0;
+        public int pdd_parse_abandon_count { get; set; } = 0;
+        public string pdd_parse_abandon_percentage { get; set; } = string.Empty;
+        public int pdd_parse_success_count { get; set; } = 0;
+        public string pdd_parse_success_percentage { get; set; } = string.Empty;
+
+
+
+        public int ks_parse_total_count { get; set; } = 0;
+        public int ks_parse_abandon_count { get; set; } = 0;
+        public string ks_parse_abandon_percentage { get; set; } = string.Empty;
+        public int ks_parse_success_count { get; set; } = 0;
+        public string ks_parse_success_percentage { get; set; } = string.Empty;
+
+
+
     }
 
 

+ 2 - 0
molilian.core/DTO/Emun/TkChannelEnum.cs

@@ -12,6 +12,7 @@
         ks = 7,
 
 
+
         tool = 100,
 
         wemeet = 101, //腾讯会议
@@ -45,6 +46,7 @@
         alibaba = 127,
         dylite = 128,
         bdlite = 129, //百度极速版
+        eleme = 137,
         unknown = -1,
     }
 

+ 10 - 0
molilian.core/DTO/alimama/TkConfigDTO.cs

@@ -46,5 +46,15 @@ namespace molilian.core
         public string ksIgnorePercentageCity { get; set; } = string.Empty;
         public int ks_limit_per_ip_24h { get; set; } = 0;
         public int ks_limit_per_oaid_24h { get; set; } = 0;
+        public string ksTestToken { get; set; } = string.Empty;
+
+
+        public int dyIgnorePercentage { get; set; } = 0;
+        public string dyIgnorePercentageCity { get; set; } = string.Empty;
+        public int dy_limit_per_ip_24h { get; set; } = 0;
+        public int dy_limit_per_oaid_24h { get; set; } = 0;
+
+
+
     }
 }

+ 9 - 0
molilian.core/DTO/alimama/TkPoolDTO.cs

@@ -27,6 +27,15 @@
         public string nodeName { get; set; } = string.Empty;
         public decimal current_amt { get; set; } = 0;
         public decimal daily_income_limit { get; set; } = 0;
+
+
+        public int daily_calls_limit { get; set; } = 0;
+        public int current_hourly_calls { get; set; } = 0;
+        public int hourly_calls_limit { get; set; } = 0;
+        public int current_daily_calls { get; set; } = 0;
+        public int time_range { get; set; } = 0;
+
+
         public decimal draw_balance { get; set; } = 0;
         public string api { get; set; } = string.Empty;
         public int api_id { get; set; } = 0;

+ 7 - 0
molilian.core/DTO/cps/UnionCpsDTO.cs

@@ -37,5 +37,12 @@ namespace molilian.core
         public string category { get; set; } = string.Empty;
         public string pid { get; set; } = string.Empty;
         public string title { get; set; } = string.Empty;
+
+
+        public string rawContent2 { get; set; } = string.Empty;
+        public decimal couponAmount { get; set; } = 0;
+        public string itemId { get; set; } = string.Empty;
+
+
     }
 }

+ 36 - 0
molilian.core/DTO/jd/JdSpreadReportDTO.cs

@@ -0,0 +1,36 @@
+using dodohold.core;
+using System.Text.Json.Serialization;
+
+namespace molilian.core
+{
+
+    [Table("jd_spread_report")]
+    public class JdSpreadReportDTO
+    {
+        [Key]
+        public int id { get; set; }
+        public int accountId { get; set; } = 0;
+
+        public string accountName { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 淘客付款时间 
+        /// </summary>
+        [JsonConverter(typeof(DateTimeConverterUsingDateTimeParse))]
+        public DateTime report_date { get; set; } = DateTime.MinValue;
+
+
+        public int clickNum { get; set; } = 0;
+        public decimal cosFee { get; set; } = 0.0m;
+        public decimal cosPrice { get; set; } = 0.0m;
+        public decimal finishCosFee { get; set; } = 0.0m;
+        public decimal finishCosPrice { get; set; } = 0.0m;
+        public int finishOrderNum { get; set; } = 0;
+        public int orderNum { get; set; } = 0;
+
+        [IgnoreUpdate]
+        public DateTime create_time { get; set; } = DateTime.Now;
+
+        public DateTime last_time { get; set; } = DateTime.Now;
+    }
+}

+ 2 - 2
molilian.core/DTO/pdd/PddPoolDTO.cs

@@ -33,17 +33,17 @@ namespace molilian.core
         public PddUnionWorkMode work_mode { get; set; } = PddUnionWorkMode.SiteApi;
         public string cookies { get; set; } = string.Empty;
 
-
         public decimal daily_income_limit { get; set; } = 0;
         public int daily_calls_limit { get; set; } = 0;
         public int current_hourly_calls { get; set; } = 0;
         public int hourly_calls_limit { get; set; } = 0;
         public int current_daily_calls { get; set; } = 0;
+        public int time_range { get; set; } = 0;
+
         public decimal draw_balance { get; set; } = 0;
         public bool enable_parse { get; set; } = false;
         public bool enable_coupon { get; set; } = false;
         public bool enable_sync_order { get; set; } = false;
-        public int time_range { get; set; } = 0;
         public bool is_hide { get; set; } = true;
 
     }

+ 0 - 15
molilian.core/Plus/Alimama/coupon.cs

@@ -49,21 +49,6 @@ namespace molilian.core
                     result.pic = data.pic;
                 }
             }
-
-
-
-
-            //public bool success { get; set; } = false;
-            //public string reason { get; set; } = string.Empty;
-            //public string message { get; set; } = string.Empty;
-            //public string deeplink_url { get; set; } = string.Empty;
-            //public int elapsedTime { get; set; } = 0;
-            //public string ip { get; set; } = string.Empty;
-            //public string oaid { get; set; } = string.Empty;
-            //public decimal couponAmount { get; set; } = 0.00M;
-            //public string itemId { get; set; } = string.Empty;
-            //public string pic { get; set; } = string.Empty;
-            //public DateTime create_time { get; set; } = DateTime.Now;
             return result;
         }
 

+ 4 - 4
molilian.core/Plus/Alimama/crawler.cs

@@ -139,6 +139,9 @@ namespace molilian.core
             {
                 "tool" => "tool_",
                 "jd" => "jd_parse_",
+                "ks" => "ks_parse_",
+                "pdd" => "pdd_parse_",
+                "dy" => "dy_parse_",
                 _ => prefix,
             };
 
@@ -559,10 +562,7 @@ namespace molilian.core
                 DateTime report_date = date.Date;
                 if (report_date == DateTime.Now.Date)
                 {
-#if DEBUG
-#else
-                    TkPoolCore.SaveIncomeAmt($"{_accountId}", result.eff_tk_disp_tfee);
-#endif
+                    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);

+ 21 - 1
molilian.core/Plus/Alimama/parse.cs

@@ -458,7 +458,6 @@ namespace molilian.core
             reason = string.Empty;
             try
             {
-
                 // IP和流量控制
                 var config = TkConfigCore.Get();
                 string ignorePercentageCity = config.ignorePercentageCity;
@@ -468,6 +467,27 @@ namespace molilian.core
                     reason = $"地区控制:{regionInfo}";
                     return true;
                 }
+
+                int limit_num = config.tk_limit_per_ip_24h;
+                if (limit_num > 0)
+                {
+                    int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.tb, ip);
+                    if (num > limit_num)
+                    {
+                        reason = "IP控制";
+                        return true;
+                    }
+                }
+                limit_num = config.tk_limit_per_oaid_24h;
+                if (limit_num > 0)
+                {
+                    int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.tb, oaid);
+                    if (num > limit_num)
+                    {
+                        reason = "OAID控制";
+                        return true;
+                    }
+                }
             }
             catch (Exception ex)
             {

+ 2 - 2
molilian.core/Plus/Alimama/parse_2.cs

@@ -193,7 +193,7 @@ namespace molilian.core
                 string desiredUrlPattern = "var url = '(.*?)'";
                 WebClientUtility client = new()
                 {
-                    Proxy = _proxy,
+                    Proxy = ProxyNodesCore.RandomOne(_account.nodeName),
                     UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
                 };
 #if DEBUG
@@ -257,7 +257,7 @@ namespace molilian.core
                 string desiredUrlPattern = "var url = '(.*?)'";
                 WebClientUtility client = new()
                 {
-                    Proxy = _proxy,
+                    Proxy = ProxyNodesCore.RandomOne(_account.nodeName),
                     UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
                 };
 #if DEBUG

+ 30 - 1
molilian.core/Plus/JDUnion/SpreadEffect.cs

@@ -78,9 +78,9 @@ namespace molilian.core
                         if (DateTime.TryParse(report.accountDate, out DateTime report_date))
                         {
                             changed_dates.Add(report_date.Date);
+                            bool data_changed = false;
 
                             var exist = new DBContext.Table("jd_spread_report")
-                                .Fields("id")
                                 .Get<dynamic>("report_date=@report_date AND accountId=@accountId",
                                     new { report_date = report_date.Date, accountId = _account.id });
 
@@ -101,11 +101,40 @@ namespace molilian.core
                                 update.Add("report_date", report_date.Date)
                                 .Add("create_time", DateTime.Now)
                                 .Create(DBContext.InsertType.REPLACE);
+                                data_changed = true;
                             }
                             else
                             {
                                 update.Where("id=@id", new { exist.id }).Update();
+
+                                if (report.clickNum != exist.clickNum) data_changed = true;
+                                if (report.cosFee != exist.cosFee) data_changed = true;
+                                if (report.cosPrice != exist.cosPrice) data_changed = true;
+                                if (report.finishCosFee != exist.finishCosFee) data_changed = true;
+                                if (report.finishCosPrice != exist.finishCosPrice) data_changed = true;
+                                if (report.finishOrderNum != exist.finishOrderNum) data_changed = true;
+                                if (report.orderNum != exist.orderNum) data_changed = true;
                             }
+
+                            if (data_changed)
+                            {
+                                //每次变动日志
+                                new DBContext.Table("jd_spread_report_log")
+                                    .Add("accountId", _account.id)
+                                    .Add("accountName", _account.name)
+                                    .Add("clickNum", report.clickNum)
+                                    .Add("cosFee", report.cosFee)
+                                    .Add("cosPrice", report.cosPrice)
+                                    .Add("finishCosFee", report.finishCosFee)
+                                    .Add("finishCosPrice", report.finishCosPrice)
+                                    .Add("finishOrderNum", report.finishOrderNum)
+                                    .Add("orderNum", report.orderNum)
+                                    .Add("last_time", DateTime.Now)
+                                    .Add("report_date", report_date.Date)
+                                    .Add("create_time", DateTime.Now)
+                                    .Create();
+                            }
+
                         }
                     }
                 }

+ 54 - 3
molilian.core/Plus/Pangolin/DyUnion/base.cs

@@ -140,16 +140,16 @@ namespace molilian.core
             reason = string.Empty;
             try
             {
+                // IP和流量控制
                 var config = TkConfigCore.Get();
-
-                int ignorePercentage = config.jdIgnorePercentage;
+                int ignorePercentage = config.dyIgnorePercentage;
                 if (ignorePercentage == 0) return false;
                 Random random = new Random();
                 var randomValue = (decimal)random.Next(0, 100);
                 bool result = randomValue <= ignorePercentage; // 如果生成的随机数小于忽略百分比,则返回 true,表示需要忽略请求
                 if (result) reason = "流量控制";
-                return result;
 
+                return result;
             }
             catch (Exception ex)
             {
@@ -157,6 +157,57 @@ namespace molilian.core
                 return true;
             }
         }
+        //public static bool ShouldIgnoreRequest(string ip, string oaid, out string reason)
+        //{
+        //    reason = string.Empty;
+        //    try
+        //    {
+        //        // IP和流量控制
+        //        var config = TkConfigCore.Get();
+        //        string ignorePercentageCity = config.dyIgnorePercentageCity;
+        //        string? ipInfo = IP2RegionPlus.Search(ip);
+        //        if (AlimamaPlus.IgnoreRegionIncluded(ignorePercentageCity, ipInfo, out string regionInfo))
+        //        {
+        //            reason = $"地区控制:{regionInfo}";
+        //            return true;
+        //        }
+
+        //        int ignorePercentage = config.dyIgnorePercentage;
+        //        if (ignorePercentage == 0) return false;
+        //        Random random = new Random();
+        //        var randomValue = (decimal)random.Next(0, 100);
+        //        bool result = randomValue <= ignorePercentage; // 如果生成的随机数小于忽略百分比,则返回 true,表示需要忽略请求
+        //        if (result) reason = "流量控制";
+
+
+        //        int limit_num = config.dy_limit_per_ip_24h;
+        //        if (limit_num > 0)
+        //        {
+        //            int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.dy, ip);
+        //            if (num > limit_num)
+        //            {
+        //                reason = "IP控制";
+        //                return true;
+        //            }
+        //        }
+        //        limit_num = config.dy_limit_per_oaid_24h;
+        //        if (limit_num > 0)
+        //        {
+        //            int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.dy, oaid);
+        //            if (num > limit_num)
+        //            {
+        //                reason = "OAID控制";
+        //                return true;
+        //            }
+        //        }
+        //        return result;
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        reason = $"配置异常";
+        //        return true;
+        //    }
+        //}
 
 
     }

+ 136 - 0
molilian.core/Plus/ks/KsDailyLogs.cs

@@ -0,0 +1,136 @@
+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 Dataoke;
+using System.Text.RegularExpressions;
+using Org.BouncyCastle.Ocsp;
+using System.Diagnostics;
+using TencentCloud.Fmu.V20191213.Models;
+using Microsoft.VisualBasic;
+using System.Text.Json;
+using static System.Runtime.InteropServices.JavaScript.JSType;
+using System.Security.Cryptography;
+using Google.Protobuf.WellKnownTypes;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using System.Threading.Channels;
+
+
+namespace molilian.core
+{
+    public partial class KsUnionPlus
+    {
+        public static void DailyLogs(int intervalDay)
+        {
+            TkChannelEnum channelEnum = TkChannelEnum.ks;
+
+            DateTime log_date = DateTime.Now.AddDays(-intervalDay).Date;
+
+            var accounts = KsPoolCore.List();
+            using var conn = CenterHub.GetOpenConnection();
+
+
+
+            int all_total_count = 0, all_success_count = 0, all_abandon_count = 0;
+            foreach (var account in accounts)
+            {
+                int accountId = account.id;
+                string accountName = $"{channelEnum}_{account.id}";
+                //if (account.is_hide) continue;
+
+                int total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{log_date:yyyyMMdd}");
+                if (total_count == 0) accountName = account.name;
+
+                total_count = TkLogCore.GetTotal($":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}");
+                string success_percentage = string.Empty;
+                string abandon_percentage = string.Empty;
+
+                if (total_count > 0)
+                {
+                    success_percentage = $"{success_count / (double)total_count * 100:f2}%";
+                    abandon_percentage = $"{abandon_count / (double)total_count * 100:f2}%";
+                }
+                //all_total_count += total_count;
+                //all_success_count += success_count;
+                //all_abandon_count += abandon_count;
+
+                var exist = new DBContext.Table(conn, "center_daily_logs")
+                .Fields("id,log_date")
+                     .Get<dynamic>("log_date=@log_date AND channel=@channel AND accountId=@accountId",
+                     new { log_date, channel = (int)channelEnum, accountId });
+
+
+                var createArgs = new DBContext.Table(conn, "center_daily_logs")
+                    .Add($"ks_parse_total_count", total_count)
+                    .Add($"ks_parse_abandon_count", abandon_count)
+                    .Add($"ks_parse_abandon_percentage", abandon_percentage)
+                    .Add($"ks_parse_success_count", success_count)
+                    .Add($"ks_parse_success_percentage", success_percentage)
+                    .Add("last_time", DateTime.Now);
+
+                if (exist == null)
+                {
+                    createArgs.Add("channel", (int)channelEnum)
+                        .Add("accountId", accountId)
+                        .Add("accountName", account.name)
+                        .Add("log_date", log_date)
+                        .Add("create_time", DateTime.Now)
+                        .Create();
+                }
+                else
+                {
+                    createArgs.Where("id=@id", new { exist.id }).Update();
+                }
+            }
+
+            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}");
+
+
+            string all_success_percentage = string.Empty;
+            string all_abandon_percentage = string.Empty;
+            if (all_total_count > 0)
+            {
+                all_success_percentage = $"{all_success_count / (double)all_total_count * 100:f2}%";
+                all_abandon_percentage = $"{all_abandon_count / (double)all_total_count * 100:f2}%";
+            }
+            var exist2 = new DBContext.Table(conn, "center_daily_logs")
+            .Fields("id,log_date")
+                 .Get<dynamic>("log_date=@log_date AND accountId=@accountId",
+                 new { log_date, accountId = 0 });
+
+            var createArgs2 = new DBContext.Table(conn, "center_daily_logs")
+                .Add($"ks_parse_total_count", all_total_count)
+                .Add($"ks_parse_abandon_count", all_abandon_count)
+                .Add($"ks_parse_abandon_percentage", all_abandon_percentage)
+                .Add($"ks_parse_success_count", all_success_count)
+                .Add($"ks_parse_success_percentage", all_success_percentage)
+                .Add("last_time", DateTime.Now);
+
+            if (exist2 == null)
+            {
+                createArgs2.Add("channel", (int)channelEnum)
+                    .Add("accountId", 0)
+                    .Add("accountName", "all")
+                    .Add("log_date", log_date)
+                    .Add("create_time", DateTime.Now)
+                    .Create();
+            }
+            else
+            {
+                createArgs2.Where("id=@id", new { exist2.id }).Update();
+            }
+
+        }
+
+    }
+}

+ 9 - 2
molilian.core/Plus/ks/KsUnionPlus.cs

@@ -219,6 +219,15 @@ namespace molilian.core
                     return result;
                 }
                 result.deeplink_url = GetDeeplink(url, result.link_type);
+
+                //临时规则
+                if (!content.Contains("商品"))
+                {
+                    result.success = false;
+                    result.message = "放弃转链";
+                    result.reason = "非商品链接";
+                    result.deeplink_url = GetDeeplink(content, LinkTypeEnum.goods);
+                }
                 return result;
             }
 
@@ -237,8 +246,6 @@ namespace molilian.core
             }
             //result.shortLinkurl = url;
 
-
-
             //临时规则
             if (!content.Contains("商品"))
             {

+ 5 - 2
molilian.core/Plus/ks/open.cs

@@ -69,6 +69,7 @@ namespace molilian.core
                 result.deeplink_url = GetDeeplink(content, LinkTypeEnum.goods);
                 return result;
             }
+            result.success = true;
             result.link_type = LinkTypeEnum.goods;
             result.shortLinkurl = data.data.linkUrl;
             result.deeplink_url = data.data.kwaiUrl;
@@ -79,8 +80,9 @@ namespace molilian.core
         {
             //todo 写死 
             var _ticket = new dodohold.core.kwaixiaodian.AccessTokenDTO();
-            _ticket.access_token = "ChFvYXV0aC5hY2Nlc3NUb2tlbhIwgR5U9K4VkaH5vh9ze_dvEaspL-4YVYgxLEbucXH_CJJodPtY6kPHuqDbtLK01JFUGhITB63P569DkqhlagGy21IJcH4iIDl5JrMkxS5areOgIXsfiWPjZa1sdiWFhNAXEpDLcfkhKAUwAQ";
 
+            _ticket.access_token = "ChFvYXV0aC5hY2Nlc3NUb2tlbhIwii6iYYKxyLm-BSThe3i6PzbpEPKAYtJWZLdIZ_jReeOfpJ4LjFdJhvkYE5uzHguQGhITB63P569DkqhlagGy21IJcH4iIECl5YRE_bk2h-1JjTf_u83zYhL-XeeG1QaT2PDMXZFYKAUwAQ";
+            if (!string.IsNullOrEmpty(_config.ksTestToken)) _ticket.access_token = _config.ksTestToken;
 
             string action = "open.distribution.cps.kwaimoney.link.parse";
             var data = new { cpsLink = content };
@@ -95,7 +97,8 @@ namespace molilian.core
         {
             //todo 写死 
             var _ticket = new dodohold.core.kwaixiaodian.AccessTokenDTO();
-            _ticket.access_token = "ChFvYXV0aC5hY2Nlc3NUb2tlbhIwgR5U9K4VkaH5vh9ze_dvEaspL-4YVYgxLEbucXH_CJJodPtY6kPHuqDbtLK01JFUGhITB63P569DkqhlagGy21IJcH4iIDl5JrMkxS5areOgIXsfiWPjZa1sdiWFhNAXEpDLcfkhKAUwAQ";
+            _ticket.access_token = "ChFvYXV0aC5hY2Nlc3NUb2tlbhIwii6iYYKxyLm-BSThe3i6PzbpEPKAYtJWZLdIZ_jReeOfpJ4LjFdJhvkYE5uzHguQGhITB63P569DkqhlagGy21IJcH4iIECl5YRE_bk2h-1JjTf_u83zYhL-XeeG1QaT2PDMXZFYKAUwAQ";
+            if (!string.IsNullOrEmpty(_config.ksTestToken)) _ticket.access_token = _config.ksTestToken;
 
 
             string action = "open.distribution.cps.kwaimoney.link.create";

+ 139 - 0
molilian.core/Plus/pdd/PddDailyLogs.cs

@@ -0,0 +1,139 @@
+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 Dataoke;
+using System.Text.RegularExpressions;
+using Org.BouncyCastle.Ocsp;
+using System.Diagnostics;
+using TencentCloud.Fmu.V20191213.Models;
+using Microsoft.VisualBasic;
+using System.Text.Json;
+using static System.Runtime.InteropServices.JavaScript.JSType;
+using System.Security.Cryptography;
+using Google.Protobuf.WellKnownTypes;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using System.Threading.Channels;
+
+
+namespace molilian.core
+{
+    public partial class PddUnionPlus
+    {
+        public static void DailyLogs(int intervalDay)
+        {
+            TkChannelEnum channelEnum = TkChannelEnum.pdd;
+
+            DateTime log_date = DateTime.Now.AddDays(-intervalDay).Date;
+
+            var accounts = PddPoolCore.List();
+            using var conn = CenterHub.GetOpenConnection();
+
+
+
+            int all_total_count = 0, all_success_count = 0, all_abandon_count = 0;
+            foreach (var account in accounts)
+            {
+                //跳过隐藏的
+                if (account.is_hide) continue;
+
+                int accountId = account.id;
+                string accountName = $"{channelEnum}_{account.id}";
+                //if (account.is_hide) continue;
+
+                int total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{log_date:yyyyMMdd}");
+                if (total_count == 0) accountName = account.name;
+
+                total_count = TkLogCore.GetTotal($":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}");
+                string success_percentage = string.Empty;
+                string abandon_percentage = string.Empty;
+
+                if (total_count > 0)
+                {
+                    success_percentage = $"{success_count / (double)total_count * 100:f2}%";
+                    abandon_percentage = $"{abandon_count / (double)total_count * 100:f2}%";
+                }
+                //all_total_count += total_count;
+                //all_success_count += success_count;
+                //all_abandon_count += abandon_count;
+
+                var exist = new DBContext.Table(conn, "center_daily_logs")
+                .Fields("id,log_date")
+                     .Get<dynamic>("log_date=@log_date AND channel=@channel AND accountId=@accountId",
+                     new { log_date, channel = (int)channelEnum, accountId });
+
+
+                var createArgs = new DBContext.Table(conn, "center_daily_logs")
+                    .Add($"pdd_parse_total_count", total_count)
+                    .Add($"pdd_parse_abandon_count", abandon_count)
+                    .Add($"pdd_parse_abandon_percentage", abandon_percentage)
+                    .Add($"pdd_parse_success_count", success_count)
+                    .Add($"pdd_parse_success_percentage", success_percentage)
+                    .Add("last_time", DateTime.Now);
+
+                if (exist == null)
+                {
+                    createArgs.Add("channel", (int)channelEnum)
+                        .Add("accountId", accountId)
+                        .Add("accountName", account.name)
+                        .Add("log_date", log_date)
+                        .Add("create_time", DateTime.Now)
+                        .Create();
+                }
+                else
+                {
+                    createArgs.Where("id=@id", new { exist.id }).Update();
+                }
+            }
+
+            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}");
+
+
+            string all_success_percentage = string.Empty;
+            string all_abandon_percentage = string.Empty;
+            if (all_total_count > 0)
+            {
+                all_success_percentage = $"{all_success_count / (double)all_total_count * 100:f2}%";
+                all_abandon_percentage = $"{all_abandon_count / (double)all_total_count * 100:f2}%";
+            }
+            var exist2 = new DBContext.Table(conn, "center_daily_logs")
+            .Fields("id,log_date")
+                 .Get<dynamic>("log_date=@log_date AND accountId=@accountId",
+                 new { log_date, accountId = 0 });
+
+            var createArgs2 = new DBContext.Table(conn, "center_daily_logs")
+                .Add($"pdd_parse_total_count", all_total_count)
+                .Add($"pdd_parse_abandon_count", all_abandon_count)
+                .Add($"pdd_parse_abandon_percentage", all_abandon_percentage)
+                .Add($"pdd_parse_success_count", all_success_count)
+                .Add($"pdd_parse_success_percentage", all_success_percentage)
+                .Add("last_time", DateTime.Now);
+
+            if (exist2 == null)
+            {
+                createArgs2.Add("channel", (int)channelEnum)
+                    .Add("accountId", 0)
+                    .Add("accountName", "all")
+                    .Add("log_date", log_date)
+                    .Add("create_time", DateTime.Now)
+                    .Create();
+            }
+            else
+            {
+                createArgs2.Where("id=@id", new { exist2.id }).Update();
+            }
+
+        }
+
+    }
+}

+ 36 - 4
molilian.core/Plus/pdd/PddUnionPlus.cs

@@ -40,7 +40,7 @@ namespace molilian.core
             var queryParams = HttpUtility.ParseQueryString(uri.Query);
             string goodsId = queryParams["goods_id"];
 
-            if (!string.IsNullOrEmpty(goodsId)&& uri.AbsolutePath.StartsWith("/goods"))
+            if (!string.IsNullOrEmpty(goodsId) && uri.AbsolutePath.StartsWith("/goods"))
             {
                 // 保持域名和路径不变,仅保留 goods_id 参数
                 var baseUrl = $"{uri.Scheme}://{uri.Host}{uri.AbsolutePath}";
@@ -49,11 +49,26 @@ namespace molilian.core
             return url; // 如果没有找到 goods_id 参数,则返回原始 URL
         }
 
-        public async Task<string> GetRedirectedUrlAsync(string sourceUrl, CancellationToken cancellationToken = default)
+
+
+        private bool IsTrackUrl(string sourceUrl)
         {
             string pattern = @"^https?://mobile\.yangkeduo\.com/goods(\d*)\.html\?ps=.*$";
             Regex regex = new Regex(pattern);
-            if (!regex.IsMatch(sourceUrl)) return ExtractGoodsIdUrl(sourceUrl);
+            return regex.IsMatch(sourceUrl);
+
+        }
+
+        /// <summary>
+        /// bool:是否ps链接,string 处理后的链接
+        /// </summary>
+        /// <param name="sourceUrl"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task<string> GetRedirectedUrlAsync(string sourceUrl, CancellationToken cancellationToken = default)
+        {
+            var isTrackUrl = IsTrackUrl(sourceUrl);
+            if (!isTrackUrl) return ExtractGoodsIdUrl(sourceUrl);
             string redirectedUrl = sourceUrl;
 
             try
@@ -161,12 +176,28 @@ namespace molilian.core
             }
 
 
-            //去追踪
+            var isTrackUrl = IsTrackUrl(url);
+            //不是跟踪链接 ps=*** 就返回
+            if (!isTrackUrl)
+            {
+                result.success = false;
+                result.link_type = LinkTypeEnum.unknown;
+                result.channel_type = ChannelTypeEnum.pdd;
+                result.message = "放弃转链";
+                result.reason = "数字id链接";
+                result.accountId = 0;
+                result.accountName = string.Empty;
+                result.content = content;
+                return result;
+            }
 
+            //去追踪
             Stopwatch stopwatch = Stopwatch.StartNew();
             stopwatch.Start();
             var redirectedUrl = await GetRedirectedUrlAsync(url, cancellationToken);
             stopwatch.Stop();
+
+
             if (redirectedUrl != url)
             {
                 result.rawContent2 = redirectedUrl;
@@ -175,6 +206,7 @@ namespace molilian.core
             }
 
 
+
             Stopwatch stopwatch2 = Stopwatch.StartNew();
             stopwatch2.Start();
 

+ 0 - 1
molilian.core/Plus/pdd/base.cs

@@ -73,7 +73,6 @@ namespace molilian.core
                         return true;
                     }
                 }
-
                 limit_num = config.pdd_limit_per_oaid_24h;
                 if (limit_num > 0)
                 {

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov