Jelajahi Sumber

deeplink 增加地区频闭;
pdd支持数字id转链;

dodo hold 1 tahun lalu
induk
melakukan
94c0b08743

File diff ditekan karena terlalu besar
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 5 - 1
molilian.core/Core/log/deeplink.cs

@@ -1,6 +1,7 @@
 using dodohold.core;
 using CSRedis;
 using System.Data;
+using static dodohold.core.ZTOExpress.CreateOrderArgs;
 
 namespace molilian.core
 {
@@ -139,13 +140,16 @@ namespace molilian.core
             //public DateTime create_time { get; set; } = DateTime.Now;
             //public string end_point { get; set; } = string.Empty;
 
+            string content = data.content;
+            if (content.Length > 20000) content = $"{content[..20000]}...";
+
             return new DBContext.Table(connection, tablename)
                 .Add("end_point", data.end_point)
                 .Add("channel_name", data.channel_name)
                 .Add("success", data.success)
                 .Add("message", data.message)
                 .Add("reason", data.reason)
-                .Add("content", data.content)
+                .Add("content", content)
                 .Add("ip", data.ip)
                 .Add("oaid", data.oaid)
                 .Add("deeplink_url", data.deeplink_url)

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

@@ -57,6 +57,22 @@ namespace molilian.core
                     result.reason,
                 });
             }
+
+            if (ShouldIgnoreRequest(rule.IgnorePercentageCity, ip, oaid, out string reason))
+            {
+                result.success = false;
+                result.message = "放弃转链";
+                result.reason = reason;
+
+                _ = TkLogCore.ParseLogAsync(result);
+                return new APIResult(new
+                {
+                    result.success,
+                    result.message,
+                    result.reason,
+                });
+            }
+
             result.channel_id = rule.channel_id;
             result.channel_name = rule.channel_name;
 
@@ -71,9 +87,31 @@ namespace molilian.core
                 result.deeplink_url,
                 result.itemName,
             });
+        }
 
+        public static bool ShouldIgnoreRequest(string ignorePercentageCity, string ip, string oaid, out string reason)
+        {
+            reason = string.Empty;
+            try
+            {
+                // IP和流量控制
+                string? ipInfo = IP2RegionPlus.Search(ip);
+                if (AlimamaPlus.IgnoreRegionIncluded(ignorePercentageCity, ipInfo, out string regionInfo))
+                {
+                    reason = $"地区控制:{regionInfo}";
+                    return true;
+                }
+            }
+            catch (Exception ex)
+            {
+                reason = "配置异常";
+            }
+            return false;
         }
 
+
+
+
         public static async Task<DeeplinkParseDataDTO> GenerateDeeplink(string text, DeeplinkParseRuleDTO config, DeeplinkParseDataDTO result)
         {
             try

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

@@ -31,6 +31,7 @@ namespace molilian.core
         public string name { get; set; } = string.Empty;
         public string logo { get; set; } = string.Empty;
         public string rules { get; set; } = string.Empty;
+        public string IgnorePercentageCity { get; set; } = string.Empty;
         public bool status { get; set; } = false;
         public DateTime create_time { get; set; } = DateTime.Now;
         [IgnoreUpdate]

+ 13 - 12
molilian.core/Plus/pdd/PddUnionPlus.cs

@@ -178,18 +178,19 @@ 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;
-            }
+            //2024-09-26 放开数字id转链
+            //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();

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini