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

API调用报表数据,增加转链类型的请求数;返回的dp数;

dodo hold 2 лет назад
Родитель
Сommit
d9303997e8

+ 1 - 1
molilian.api/Controllers/public/ApiController.cs

@@ -18,7 +18,6 @@ namespace molilian.api.Controllers
     [Route("api/[action]")]
     public class ApiController : ControllerBase
     {
-
         protected IHttpContextAccessor _accessor;
         TaokeOpenCore core;
         public ApiController(IHttpContextAccessor accessor)
@@ -28,6 +27,7 @@ namespace molilian.api.Controllers
         }
 
 
+
         [HttpPost]
         public async Task<ActionResult> PromotionQuery([FromBody] JsonElement form, [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
         {

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

@@ -280,48 +280,22 @@ namespace molilian.api.Controllers
                     tags = ["red_circle"]
                 });
             }
-
-
-            if (intervalDay > 0)
-            {
-                try
-                {
-                    AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
-                    AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
-                }
-                catch (Exception ex)
-                {
-                    string message = $"【API报表更新异常】ApiCallStatistics\n{ex.Message}\n{ex.StackTrace}";
-                    NotifyCore.Notify(new NifyMessage
-                    {
-                        message = message,
-                        priority = NifyMessagePriority.high,
-                        tags = ["red_circle"]
-                    });
-                }
-            }
             return new APIResult(new { success = true, message = "ok" });
         }
 
+
         [HttpGet]
-        public async Task<ActionResult> DailyTable(int days = 7)
+
+        public async Task<ActionResult> ApiCallStatistics(int intervalDay = 1)
         {
             try
             {
-                for (int i = 0; i < days; i++)
-                {
-                    string table_suffix = DateTime.Now.AddDays(i).ToString("yyyyMMdd");
-                    string sql = $"CREATE TABLE IF NOT EXISTS tk_parse_logs_{table_suffix} LIKE tk_parse_logs;";
-                    DBContext.Execute(sql, null);
-                    sql = $"CREATE TABLE IF NOT EXISTS jd_parse_logs_{table_suffix} LIKE jd_parse_logs;";
-                    DBContext.Execute(sql, null);
-                }
-                TkLogCore.save_dailys_log = true;
-                RedisHelper.Set("turn:save_dailys_log", 1, 86400);
+                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
+                AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
             }
             catch (Exception ex)
             {
-                string message = $"【创建数据标错误】\n{ex.Message}\n{ex.StackTrace}";
+                string message = $"【API报表更新异常】ApiCallStatistics\n{ex.Message}\n{ex.StackTrace}";
                 NotifyCore.Notify(new NifyMessage
                 {
                     message = message,
@@ -334,17 +308,33 @@ namespace molilian.api.Controllers
 
 
         [HttpGet]
-
-        public async Task<ActionResult> ApiCallStatistics(int intervalDay = 1)
+        public async Task<ActionResult> DailyTable(int days = 7)
         {
             try
             {
-                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
-                AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
+                for (int i = 0; i < days; i++)
+                {
+                    if (CenterHub.IsCenter)
+                    {
+
+                    }
+                    else
+                    {
+
+                    }
+
+                    string table_suffix = DateTime.Now.AddDays(i).ToString("yyyyMMdd");
+                    string sql = $"CREATE TABLE IF NOT EXISTS tk_parse_logs_{table_suffix} LIKE tk_parse_logs;";
+                    DBContext.Execute(sql, null);
+                    sql = $"CREATE TABLE IF NOT EXISTS jd_parse_logs_{table_suffix} LIKE jd_parse_logs;";
+                    DBContext.Execute(sql, null);
+                }
+                TkLogCore.save_dailys_log = true;
+                RedisHelper.Set("turn:save_dailys_log", 1, 86400);
             }
             catch (Exception ex)
             {
-                string message = $"【API报表更新异常】ApiCallStatistics\n{ex.Message}\n{ex.StackTrace}";
+                string message = $"【创建数据标错误】\n{ex.Message}\n{ex.StackTrace}";
                 NotifyCore.Notify(new NifyMessage
                 {
                     message = message,
@@ -443,7 +433,7 @@ namespace molilian.api.Controllers
                     }
                 }
             }
-            string filter = ""; 
+            string filter = "";
             var jd_list = new DBContext.Table("jd_pool").Where(filter, null).Select<JdPoolDTO>();
             if (jd_list != null)
             {
@@ -702,6 +692,7 @@ namespace molilian.api.Controllers
 
             ElePoolCore.Refresh();
             MeituanPoolCore.Refresh();
+            DeeplinkParseRuleCore.Refresh();
 
             return new APIResult(new
             {

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

@@ -27,6 +27,7 @@ namespace molilian.api.Controllers
             _accessor = accessor;
         }
 
+
         /// <summary>
         /// oppo调用
         /// </summary>
@@ -86,7 +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)
@@ -103,7 +104,6 @@ namespace molilian.api.Controllers
             return new APIResult(new { success = true, message = "ok" });
         }
 
-
         [HttpGet]
         public async Task<ActionResult> tespdd(int aid, int num = 10, int time = 10)
         {

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


+ 16 - 2
molilian.core/Core/ProxyNodesCore.cs

@@ -42,14 +42,28 @@ namespace molilian.core
                 Credentials = new NetworkCredential(ProxyNodesDTO.username, ProxyNodesDTO.password)
             };
         }
+        public static WebProxy? RandomOne()
+        {
+
+            var list = List();
+            if (!list.Any()) return null;
+            var ProxyNodesDTO = list.Where(e => SelectEndPointUseProxy(e, string.Empty)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
+            if (ProxyNodesDTO == null) return null;
+
+            return new WebProxy
+            {
+                Address = new Uri(ProxyNodesDTO.server),
+                Credentials = new NetworkCredential(ProxyNodesDTO.username, ProxyNodesDTO.password)
+            };
+        }
 
-        private static bool SelectEndPointUseProxy(ProxyNodesDTO item, string node)
+        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 item.name == node;
+            return string.IsNullOrEmpty(node) || item.name == node;
         }
         public static IEnumerable<ProxyNodesDTO> List(bool force = false)
         {

+ 46 - 0
molilian.core/Core/taoke/TkLogCore.cs

@@ -34,6 +34,7 @@ namespace molilian.core
 
         static string queue_parse_dy_key = "queue:parse_logs:dy";
         static string queue_parse_tool_key = "queue:parse_logs:tool";
+        static string queue_deeplink_parse_key = "queue:parse_logs:deeplink";
 
         static string queue_coupon_key = "queue:coupon_logs";
         static string promotion_img_key = "queue:promotion:img";
@@ -432,6 +433,34 @@ namespace molilian.core
                     total++;
                 }
 
+                for (int i = 0; i < limit; i++)
+                {
+                    var data = redis.LPop<DeeplinkParseDataDTO>(queue_deeplink_parse_key);
+                    if (data == null) break;
+
+                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                         data.ip.Contains("127.0.0"))
+                    {
+                        var test_data = data.Convert2Json().Convert2Object<TestDeeplinkParseDataDTO>();
+                        connection.Insert(test_data);
+                    }
+                    else
+                    {
+                        connection.Insert(data);
+                        if (!data.success)
+                        {
+                            var success_data = data.Convert2Json().Convert2Object<FilDeeplinkParseDataDTO>();
+                            connection.Insert(success_data);
+                        }
+                        else
+                        {
+                            var success_data = data.Convert2Json().Convert2Object<SuccessDeeplinkParseDataDTO>();
+                            connection.Insert(success_data);
+                        }
+                    }
+                    total++;
+                }
+
 
                 for (int i = 0; i < limit; i++)
                 {
@@ -874,6 +903,23 @@ namespace molilian.core
             }
             catch (Exception ex) { }
         }
+        public static async Task ParseLogAsync(DeeplinkParseDataDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_deeplink_parse_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveParseCache(response.channel_name, 0, "tool",
+                        response.success, response.message, response.reason,
+                        response.deeplink_url);
+                }
+            }
+            catch (Exception ex) { }
+        }
 
         private static void saveCache(string channel, int accountId, string accountName, bool success, string message, string reason)
         {

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

@@ -22,6 +22,9 @@ using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
 using System.Runtime.Intrinsics.Arm;
 using ZstdSharp.Unsafe;
 using System.Text.RegularExpressions;
+using static dodohold.core.ZTOExpress.CreateOrderArgs;
+using System.Security.Cryptography;
+using System.Threading.Channels;
 
 
 namespace molilian.core
@@ -38,10 +41,14 @@ namespace molilian.core
                 "jd" => await JdParseAsync(content, ip, oaid, accountid),
                 "dy" => await DyParseAsync(content, ip, oaid),
                 "pdd" => await PddParseAsync(content, ip, oaid, accountid),
-                _ => await TaobaoParseAsync(content, ip, oaid, accountid),
+                "tb" => await TaobaoParseAsync(content, ip, oaid, accountid),
+                _ => await DeeplinkParseCore.ParseAsync(content, channel, ip, oaid),
             };
         }
 
+        //return await DeeplinkParseCore.ParseAsync(content, channel, ip, oaid);
+
+
 
         public static async Task<APIResult> WemeetParseAsync(string content, string ip, string oaid)
         {

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

@@ -0,0 +1,242 @@
+
+using dodohold.core;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using Spire.Pdf.Annotations;
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+namespace molilian.core
+{
+    public partial class DeeplinkParseCore
+    {
+
+
+        private static string _end_point;
+        private static readonly string[] separators = ["\r\n", "\n"];
+
+        static DeeplinkParseCore()
+        {
+            _end_point = Environment.GetEnvironmentVariable("EndPoint");
+        }
+
+
+        public static DeeplinkParseDataDTO GetFormattedObject(string content, string channel, string ip = "", string oaid = "")
+        {
+            return new DeeplinkParseDataDTO()
+            {
+                message = string.Empty,
+                success = false,
+                content = content,
+                ip = ip,
+                oaid = oaid,
+                elapsedTime = 0,
+                create_time = DateTime.Now,
+                end_point = _end_point,
+            };
+        }
+
+        public static async Task<ActionResult> ParseAsync(string content, string channel, string ip, string oaid)
+        {
+            var result = GetFormattedObject(content, channel, ip, oaid);
+            content = content.Trim();
+
+            var rule = DeeplinkParseRuleCore.GetOne(channel);
+            if (rule == null)
+            {
+                result.success = false;
+                result.message = "转链失败";
+                result.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;
+
+            result = await GenerateDeeplink(content, rule, result);
+
+            _ = TkLogCore.ParseLogAsync(result);
+            return new APIResult(new
+            {
+                result.success,
+                result.message,
+                channel = result.channel_name,
+                result.deeplink_url,
+                result.itemName,
+            });
+
+        }
+
+        public static async Task<DeeplinkParseDataDTO> GenerateDeeplink(string text, DeeplinkParseRuleDTO config, DeeplinkParseDataDTO result)
+        {
+            try
+            {
+                var list = config.rules.Convert2Object<List<DeeplinkParseRule>>();
+
+                foreach (var rule in list)
+                {
+                    var e = await WorkEachRule(text, config, result, rule);
+                    if (e != null) return e;
+                }
+            }
+            catch (Exception ex)
+            {
+            }
+
+            result.success = false;
+            return result;
+        }
+
+        private static async Task<DeeplinkParseDataDTO?> WorkEachRule(string text, DeeplinkParseRuleDTO config, DeeplinkParseDataDTO result, DeeplinkParseRule rule)
+        {
+            if (!rule.enable) return null;
+
+            string content = text;
+
+            if (!string.IsNullOrEmpty(rule.url_pattern))
+            {
+                var regex = new Regex(rule.url_pattern);
+                var match = regex.Match(content);
+                if (!match.Success) return null;
+
+                content = match.Groups[1].Value;
+            }
+
+            string url = ToolParsePlus.GetLink(text);
+            try
+            {
+                switch (rule.url_action)
+                {
+                    case UrlAction.Redirect:
+                        {
+                            var response = await new WebClientUtility
+                            {
+                                Proxy = ProxyNodesCore.RandomOne(),
+                                AllowAutoRedirect = false
+                            }.RequestAsync(url);
+                            if (response.ResponseMessage != null)
+                            {
+                                content = response.ResponseMessage.Headers.Location.ToString();
+                                content = content.UrlDecode();
+                            }
+                        }
+                        break;
+                    case UrlAction.Body:
+                        {
+                            var response = await new WebClientUtility
+                            {
+                                Proxy = ProxyNodesCore.RandomOne(),
+                                AllowAutoRedirect = true
+                            }.RequestAsync(url);
+                            content = response.Body();
+                        }
+                        break;
+                    case UrlAction.None:
+                        //{
+                        //    content = url;
+                        //}
+                        break;
+                }
+            }
+            catch (Exception ex)
+            {
+                //Console.WriteLine($"{url}\t{rule.url_action}\t{ex.Message}");
+            }
+
+            if (rule.childs.Count > 0)
+            {
+                foreach (var sub_rule in rule.childs)
+                {
+                    var e = await WorkEachRule(content, config, result, sub_rule);
+                    if (e != null) return e;
+                }
+                return null;
+            }
+
+
+            var deeplink = rule.deeplink_template;
+            var prompt_text = rule.prompt_text;
+
+            try
+            {
+                var regex = new Regex(rule.pattern);
+                var match = regex.Match(content);
+                if (match.Success)
+                {
+                    if (match.Groups.Count > 1)
+                    {
+                        for (var i = 1; i < match.Groups.Count; i++)
+                        {
+                            string val = match.Groups[i].Value;
+                            if (deeplink.Contains("{url:"))
+                            {
+                                deeplink = deeplink.Replace($"{{url:{i - 1}}}", val.UrlEncode());
+                            }
+                            if (prompt_text.Contains("{url:"))
+                            {
+                                prompt_text = prompt_text.Replace($"{{url:{i - 1}}}", val.UrlEncode());
+                            }
+
+                            //atob
+                            if (deeplink.Contains("{atob:"))
+                            {
+                                deeplink = deeplink.Replace($"{{atob:{i - 1}}}", val.FromBase64());
+                            }
+                            if (prompt_text.Contains("{atob:"))
+                            {
+                                prompt_text = prompt_text.Replace($"{{atob:{i - 1}}}", val.FromBase64());
+                            }
+
+                            //btoa
+                            if (deeplink.Contains("{btoa:"))
+                            {
+                                deeplink = deeplink.Replace($"{{btoa:{i - 1}}}", val.ToBase64());
+                            }
+                            if (prompt_text.Contains("{btoa:"))
+                            {
+                                prompt_text = prompt_text.Replace($"{{btoa:{i - 1}}}", val.ToBase64());
+                            }
+
+
+                            deeplink = deeplink.Replace($"{{{i - 1}}}", val);
+                            prompt_text = prompt_text.Replace($"{{{i - 1}}}", val);
+                        }
+
+                        deeplink = Regex.Replace(deeplink, @"\{\d+\}", string.Empty);
+                        prompt_text = Regex.Replace(prompt_text, @"\{\d+\}", string.Empty);
+
+                        if (!string.IsNullOrEmpty(deeplink))
+                        {
+                            result.deeplink_url = deeplink;
+                            result.itemName = prompt_text;
+                            result.success = true;
+                            return result;
+                        }
+                    }
+                    else
+                    {
+                        result.deeplink_url = deeplink;
+                        result.itemName = prompt_text;
+                        result.success = true;
+                        return result;
+
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"Error processing pattern '{rule.pattern}': {ex.Message}");
+            }
+
+            return null;
+
+        }
+
+    }
+
+}

+ 69 - 0
molilian.core/Core/tool/DeeplinkParseRuleCore.cs

@@ -0,0 +1,69 @@
+
+using dodohold.core;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using Spire.Pdf.Annotations;
+using System.Text.RegularExpressions;
+using System.Threading.Channels;
+using System.Xml.Linq;
+namespace molilian.core
+{
+
+    public partial class DeeplinkParseRuleCore
+    {
+        private static string _end_point;
+        private static Dictionary<string, int> _calls = new();
+        static DeeplinkParseRuleCore()
+        {
+            _end_point = Environment.GetEnvironmentVariable("EndPoint");
+        }
+
+
+        private static readonly object _lockObj = new();
+        private static IEnumerable<DeeplinkParseRuleDTO> _cached;
+        public static DeeplinkParseRuleDTO? GetOne(string channel)
+        {
+#if DEBUG
+            var list = List(true);
+#else
+            var list = List();
+#endif
+            if (!list.Any()) return null;
+            return list.Where(e => channel.Equals(e.channel_name)).FirstOrDefault();
+        }
+
+        public static IEnumerable<DeeplinkParseRuleDTO> List(bool force = false)
+        {
+            if (!force && _cached != null) return _cached;
+
+            string cache_key = $"cache:deeplink_parse_rule";
+            var list = RedisHelper.Get<IEnumerable<DeeplinkParseRuleDTO>>(cache_key);
+            if (force || list == null)
+            {
+                lock (_lockObj)
+                {
+                    list = new DBContext.Table("deeplink_parse_rule")
+                        .Where("status=@status", new { status = 1 })
+                        .Select<DeeplinkParseRuleDTO>();
+                    if (list == null) return default;
+
+                    RedisHelper.Set(cache_key, list, 30 * 86400);
+                }
+            }
+            _cached = list;
+            return list;
+        }
+
+        public static void Refresh()
+        {
+            _ = List(true);
+        }
+
+        public static async Task<int> Update(DeeplinkParseRuleDTO rule)
+        {
+            var conn = DBContext.GetOpenConnection();
+            return await conn.UpdateAsync<DeeplinkParseRuleDTO>(rule);
+        }
+
+    }
+}

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

@@ -44,6 +44,7 @@
         alibaba = 127,
         dylite = 128,
         bdlite = 129, //百度极速版
+        unknown = -1,
     }
 
     public enum CpsChannelEnum

+ 38 - 0
molilian.core/DTO/deeplink/DeeplinkParseDataDTO.cs

@@ -0,0 +1,38 @@
+using dodohold.core;
+
+namespace molilian.core
+{
+    [Table("deeplink_parse_logs")]
+
+    public class DeeplinkParseDataDTO : BaseDeeplinkParseDataDTO;
+
+    [Table("deeplink_parse_logs_test")]
+    public class TestDeeplinkParseDataDTO : BaseDeeplinkParseDataDTO;
+
+
+    [Table("deeplink_parse_logs_success")]
+    public class SuccessDeeplinkParseDataDTO : BaseDeeplinkParseDataDTO;
+
+    [Table("deeplink_parse_logs_fil")]
+    public class FilDeeplinkParseDataDTO : BaseDeeplinkParseDataDTO;
+
+
+    public class BaseDeeplinkParseDataDTO
+    {
+        [Key]
+        public int channel_id { get; set; } = 0;
+        public string channel_name { get; set; } = "unknown";
+        public bool success { get; set; } = true;
+        public string message { get; set; } = string.Empty;
+        public string reason { get; set; } = string.Empty;
+        public string content { get; set; } = string.Empty;
+        public string ip { get; set; } = string.Empty;
+        public string oaid { get; set; } = string.Empty;
+        public string deeplink_url { get; set; } = string.Empty;
+        public string itemName { get; set; } = string.Empty;
+        public int elapsedTime { get; set; } = 0;
+        public DateTime create_time { get; set; } = DateTime.Now;
+        public string end_point { get; set; } = string.Empty;
+    }
+
+}

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

@@ -0,0 +1,39 @@
+using dodohold.core;
+
+namespace molilian.core
+{
+    public enum UrlAction
+    {
+        None = 0,
+        Redirect = 1,
+        Body = 2
+    }
+
+    public class DeeplinkParseRule
+    {
+        public UrlAction url_action { get; set; } = UrlAction.None;
+        public string url_pattern { get; set; } = string.Empty;
+        public string pattern { get; set; } = string.Empty;
+        public string deeplink_template { get; set; } = string.Empty;
+        public string prompt_text { get; set; } = string.Empty;
+        public bool enable { get; set; } = true;
+        public List<DeeplinkParseRule> childs { get; set; } = new();
+    }
+
+    [Table("deeplink_parse_rule")]
+    public class DeeplinkParseRuleDTO
+    {
+        [Key]
+        public int id { get; set; }
+        public int channel_id { get; set; } = 0;
+        public string channel_name { get; set; } = string.Empty;
+        public string name { get; set; } = string.Empty;
+        public string logo { get; set; } = string.Empty;
+        public string rules { get; set; } = string.Empty;
+        public bool status { get; set; } = false;
+        public DateTime create_time { get; set; } = DateTime.Now;
+        [IgnoreUpdate]
+        public DateTime last_time { get; set; } = DateTime.Now;
+    }
+
+}

+ 80 - 0
molilian.core/Plus/Alimama/crawler.cs

@@ -1,6 +1,8 @@
 using dodohold.core;
 using System.Text.Json;
 using TencentCloud.Cdn.V20180606.Models;
+using TencentCloud.Tse.V20201207.Models;
+using static molilian.core.ChartDataCore;
 
 
 namespace molilian.core
@@ -244,7 +246,80 @@ namespace molilian.core
 
             var chatData = ChartDataCore.GetTaobaoData($"{prefix}total", "", $"{log_date:yyyyMMdd}");
             //tableName2
+        }
+
+        public static DBContext.Table FillLinkTypeData(DBContext.Table update, int data_type, DateTime report_date)
+        {
+            long req_other_aff_num = 0;//1
+            long req_goods_num = 0;//2
+            long req_live_num = 0;//3
+            long req_video_num = 0;///4
+            long req_shop_num = 0;//5
+            long req_base_num = 0;//6
+            long req_note_num = 0;//7
+            int resp_deeplink_num = 0;
+
+            try
+            {
+
+                string tableName = $"tk_parse_logs_{report_date:yyyyMMdd}";
+
+                string exist_sql = @$"SELECT IF( EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_name = '{tableName}'), 1, 0) AS table_exists;";
+
+                int exist_table = DBContext.ExecuteScalar<int>(exist_sql);
+                if (exist_table == 1)
+                {
+                    var linkTypeTotal = new DBContext.Table(tableName)
+                                    .Fields("linkType, count(*) AS total")
+                                    .GroupBy("linkType")
+                                    .Select<dynamic>();
+
+                    foreach (var t in linkTypeTotal)
+                    {
+                        int linkType = t.linkType;
+                        long total = t.total;
+                        switch (linkType)
+                        {
+                            case 1: req_other_aff_num = total; break;
+                            case 2: req_goods_num = total; break;
+                            case 3: req_live_num = total; break;
+                            case 4: req_video_num = total; break;
+                            case 5: req_shop_num = total; break;
+                            case 6: req_base_num = total; break;
+                            case 7: req_note_num = total; break;
+                        }
+                    }
+                }
+
+                string total_key = data_type switch
+                {
+                    1 => "parse_total",
+                    2 or _ => "coupon_total",
+                };
 
+                string[] deeplink_keys = ["home", "success", "fail"];
+                string accountName = "all";
+                foreach (var keyname in deeplink_keys)
+                {
+                    string cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date:yyyyMMdd}";
+                    int value = TkLogCore.GetTotal(cacheKey);
+                    if (value == 0) continue;
+                    resp_deeplink_num += value;
+                }
+            }
+            catch (Exception e)
+            {
+            }
+            update.Add("req_other_aff_num", req_other_aff_num);
+            update.Add("req_goods_num", req_goods_num);
+            update.Add("req_live_num", req_live_num);
+            update.Add("req_video_num", req_video_num);
+            update.Add("req_shop_num", req_shop_num);
+            update.Add("req_base_num", req_base_num);
+            update.Add("req_note_num", req_note_num);
+            update.Add("resp_deeplink_num", resp_deeplink_num);
+
+            return update;
         }
 
         /// <summary>
@@ -310,6 +385,11 @@ namespace molilian.core
                 }
             }
 
+            if (data_type == 1)
+            {
+                //todo 只有转链需要处理,优惠券和京东(未上线)暂不处理
+                update = FillLinkTypeData(update, data_type, log_date);
+            }
             if (record == null)
             {
                 update.Add("read_num", 0).Add("create_time", DateTime.Now).Create();

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

@@ -186,8 +186,6 @@ namespace molilian.core
                 if (!url.Contains("m.tb.cn") && !url.Contains("s.tb.cn"))
                     return (false, "不是淘宝短网址");
 
-
-
                 if (!_account.enable_deep_url) return (true, url);
 
                 string desiredUrlPattern = "var url = '(.*?)'";

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