ソースを参照

增加deeplink统计

dodo hold 2 年 前
コミット
7d97fbbf66

ファイルの差分が大きいため隠しています
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 72 - 0
molilian.core/Core/admin/ChartDataCore.cs

@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using dodohold.core;
+using System.Threading.Channels;
 
 
 namespace molilian.core
@@ -22,6 +23,7 @@ namespace molilian.core
         {
             public List<ChartDataItem> data { get; set; } = [];
             public List<ChartDataItem> data2 { get; set; } = [];
+            public List<ChartDataItem> data3 { get; set; } = [];
             public int total { get; set; } = 0;
         }
 
@@ -74,7 +76,23 @@ namespace molilian.core
                     });
                 }
                 result.data2 = result.data2.OrderByDescending(item => item.value).ToList();
+
+                string[] deeplink_keys = ["none", "home", "success", "fail"];
+                foreach (var keyname in deeplink_keys)
+                {
+                    cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date}";
+                    int value = TkLogCore.GetTotal(cacheKey);
+                    if (value == 0) continue;
+                    result.data3.Add(new ChartDataItem
+                    {
+                        name = keyname,
+                        value = value,
+                        increases = Math.Round((decimal)value / result.total * 100, 2)
+                    });
+                }
+                result.data3 = result.data3.OrderByDescending(item => item.value).ToList();
             }
+
             return result;
         }
         public static ChartDataRes GetTaobaoData(string total_key, string accountName, string report_date)
@@ -126,7 +144,23 @@ namespace molilian.core
                     });
                 }
                 result.data2 = result.data2.OrderByDescending(item => item.value).ToList();
+
+                string[] deeplink_keys = ["none", "home", "success", "fail"];
+                foreach (var keyname in deeplink_keys)
+                {
+                    cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date}";
+                    int value = TkLogCore.GetTotal(cacheKey);
+                    if (value == 0) continue;
+                    result.data3.Add(new ChartDataItem
+                    {
+                        name = keyname,
+                        value = value,
+                        increases = Math.Round((decimal)value / result.total * 100, 2)
+                    });
+                }
+                result.data3 = result.data3.OrderByDescending(item => item.value).ToList();
             }
+
             return result;
         }
 
@@ -239,7 +273,45 @@ namespace molilian.core
                     });
                 }
                 result.data2 = result.data2.OrderByDescending(item => item.value).ToList();
+
+
+                string[] deeplink_keys = ["none", "home", "success", "fail"];
+                foreach (var keyname in deeplink_keys)
+                {
+                    cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date}";
+                    int value = TkLogCore.GetTotal(cacheKey);
+                    if (value == 0) continue;
+                    result.data3.Add(new ChartDataItem
+                    {
+                        name = keyname,
+                        value = value,
+                        increases = Math.Round((decimal)value / result.total * 100, 2)
+                    });
+                }
+                result.data3 = result.data3.OrderByDescending(item => item.value).ToList();
             }
+
+
+            //string dp_flag = deeplink switch
+            //{
+            //    "" => "none",
+            //    "tbopen://m.taobao.com/tbopen/index.html" or
+            //    "pinduoduo://com.xunmeng.pinduoduo/" or
+            //    "snssdk1128://feed?refer=web" or
+            //    "bdnetdisk://n/action.EXTERNAL_ACTIVITY" or
+            //    "openapp.jdmobile://virtual?params=" => "home",
+            //    _ => success ? "success" : "fail",
+            //};
+
+            ////关于dp的缓存
+            //saveParseAccountCache($"dp_{dp_flag}:all", success, message, reason);
+            //saveParseAccountCache($"dp_{dp_flag}:{channel}", success, message, reason);
+            //if (accountId != 0)
+            //{
+            //    saveParseAccountCache($"dp_{dp_flag}:{channel}_{accountId}", success, message, reason);
+            //}
+
+
             return result;
         }
 

+ 45 - 8
molilian.core/Core/taoke/TkLogCore.cs

@@ -18,6 +18,7 @@ using System.Data;
 using TencentCloud.Omics.V20221128.Models;
 using TencentCloud.Csip.V20221121.Models;
 using COSXML.Network;
+using System.Security.Policy;
 
 
 namespace molilian.core
@@ -610,9 +611,12 @@ namespace molilian.core
                 }
                 if (!response.ip.Contains("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                    saveParseCache(response.channel.ToString(), response.accountId,
+                        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))
@@ -696,7 +700,8 @@ namespace molilian.core
 
                 if (!response.ip.Contains("127.0.0"))
                 {
-                    saveCpsCache(response.channel.ToString(), response.accountId, response.success, response.message, response.reason);
+                    saveCpsCache(response.channel.ToString(), response.accountId,
+                        response.success, response.message, response.reason);
                 }
             }
             catch (Exception ex)
@@ -718,7 +723,9 @@ namespace molilian.core
 
                 if (!response.ip.Contains("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                    saveParseCache(response.channel.ToString(), response.accountId,
+                        response.accountName, response.success, response.message, response.reason,
+                        response.deeplink_url);
                 }
 
                 if (response.success || response.message.Equals("转链失败"))
@@ -798,7 +805,9 @@ namespace molilian.core
 
                 if (!response.ip.Contains("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                    saveParseCache(response.channel.ToString(), response.accountId,
+                        response.accountName, response.success, response.message, response.reason,
+                        response.deeplink_url);
                 }
 
                 if (response.success || response.message.Equals("转链失败"))
@@ -840,7 +849,9 @@ namespace molilian.core
 
                 if (!response.ip.Contains("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                    saveParseCache(response.channel.ToString(), response.accountId,
+                        response.accountName, response.success, response.message, response.reason,
+                        response.deeplink_url);
                 }
 
             }
@@ -856,7 +867,9 @@ namespace molilian.core
 
                 if (!response.ip.Contains("127.0.0"))
                 {
-                    saveParseCache(response.channel.ToString(), 0, "tool", response.success, response.message, response.reason);
+                    saveParseCache(response.channel.ToString(), 0, "tool",
+                        response.success, response.message, response.reason,
+                        response.deeplink_url);
                 }
             }
             catch (Exception ex) { }
@@ -990,8 +1003,29 @@ namespace molilian.core
 
 
 
-        private static void saveParseCache(string channel, int accountId, string accountName, bool success, string message, string reason)
+        private static void saveParseCache(string channel, int accountId, string accountName,
+            bool success, string message, string reason, string deeplink)
         {
+            string dp_flag = deeplink switch
+            {
+                "" => "none",
+                "tbopen://m.taobao.com/tbopen/index.html" or
+                "pinduoduo://com.xunmeng.pinduoduo/" or
+                "snssdk1128://feed?refer=web" or
+                "bdnetdisk://n/action.EXTERNAL_ACTIVITY" or
+                "openapp.jdmobile://virtual?params=" => "home",
+                _ => success ? "success" : "fail",
+            };
+
+            //关于dp的缓存
+            saveParseAccountCache($"dp_{dp_flag}:all", success, message, reason);
+            saveParseAccountCache($"dp_{dp_flag}:{channel}", success, message, reason);
+            saveParseAccountCache($"dp_{dp_flag}:{accountName}", success, message, reason);
+            if (accountId != 0)
+            {
+                saveParseAccountCache($"dp_{dp_flag}:{channel}_{accountId}", success, message, reason);
+            }
+
             saveParseAccountCache("all", success, message, reason);
             saveParseAccountCache($"{channel}", success, message, reason);
             saveParseAccountCache($"{accountName}", success, message, reason);
@@ -1002,8 +1036,11 @@ namespace molilian.core
             }
         }
 
-        private static void saveParseAccountCache(string accountName, bool success, string message, string reason)
+
+        private static void saveParseAccountCache(string accountName, bool success,
+            string message, string reason)
         {
+
             RedisHelper.IncrBy($":parse_total:{accountName}:{DateTime.Now:yyyyMM}");
             RedisHelper.IncrBy($":parse_total:{accountName}:{DateTime.Now:yyyyMMdd}");
             RedisHelper.IncrBy($":parse_total:{accountName}:{DateTime.Now:yyyyMMddHH}");

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

@@ -258,7 +258,7 @@ namespace molilian.core
             DateTime log_date = DateTime.Now.AddDays(-intervalDay).Date;
 
             var endpoint = data_type == 1 ? EndPointCore.GetParseAdmin() : EndPointCore.GetCouponAdmin();
-            if (string.IsNullOrEmpty(endpoint.db_server)) return;
+            if (endpoint == null || string.IsNullOrEmpty(endpoint.db_server)) return;
 
             using var conn = EndPointCore.GetDbConnection(endpoint.db_server);
             using var center_conn = CenterHub.GetOpenConnection();

+ 6 - 1
molilian.core/Plus/Alimama/parse_2.cs

@@ -654,7 +654,12 @@ namespace molilian.core
 
                     if (body.Contains("https://g.alicdn.com/sd/punish/waf_block.html"))
                     {
-                        throw new Exception("waf_block");
+
+                        result.channel = TkChannelEnum.tb;
+                        result.link_type = LinkTypeEnum.unknown;
+                        result.success = false;
+                        result.message = "waf_block";
+                        return result;
                     }
                     throw new Exception(body);
                 }

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません