Browse Source

调整写mysql日志的类结构,方便后续增加业务。

dodo hold 2 năm trước cách đây
mục cha
commit
c60f9aab90

+ 324 - 0
molilian.core/Core/ks/KsPoolCore.cs

@@ -0,0 +1,324 @@
+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 Google.Protobuf.WellKnownTypes;
+using System.Xml.Linq;
+
+
+namespace molilian.core
+{
+
+    public partial class KsPoolCore
+    {
+        public enum KsAction
+        {
+            all,
+            parse,
+            coupon,
+            promotionQuery
+        }
+        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");
+        }
+
+        private static readonly object _lockObj = new();
+        private static IEnumerable<KsPoolDTO> _cached;
+        public static KsPoolDTO? GetOne()
+        {
+            var list = List();
+            if (!list.Any()) return null;
+            return list.OrderBy(l => Guid.NewGuid()).FirstOrDefault();
+        }
+
+        public static KsPoolDTO? GetOne(KsAction action)
+        {
+            var list = List();
+            if (!list.Any()) return null;
+            return list.Where(e => IsNotExceedDailyIncomeLimit(e, action)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
+        }
+
+
+        public static KsPoolDTO? GetOne(int id, KsAction action)
+        {
+            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: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)
+        {
+
+            if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
+            {
+                if (item.end_point != _end_point) return false;
+            }
+            switch (action)
+            {
+                case KsAction.parse:
+                    if (!item.enable_parse) return false;
+                    break;
+                case KsAction.coupon:
+                    if (!item.enable_coupon) return false;
+                    break;
+            }
+
+            // 使用初始化参数创建工作时间表
+            if (!new WorkSchedule(item.time_range).IsWorkHour()) return false;
+
+            if (item.daily_calls_limit > 0)
+            {
+                int daily_num = GetCalls(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"));
+                if (hourly_num >= item.hourly_calls_limit) return false;
+            }
+            return true;
+        }
+
+        public static IEnumerable<KsPoolDTO> List(bool force = false)
+        {
+            if (!force && _cached != null) return _cached;
+
+            string cache_key = $"cache:ks_pool";
+            var list = RedisHelper.Get<IEnumerable<KsPoolDTO>>(cache_key);
+            if (force || list == null)
+            {
+                lock (_lockObj)
+                {
+                    list = new DBContext.Table("ks_pool")
+                        .Where("status=@status", new { status = 1 })
+                        .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);
+                    }
+                    RedisHelper.Set(cache_key, list, 30 * 86400);
+                }
+            }
+            _cached = list;
+            return list;
+        }
+        public static void Refresh()
+        {
+            _ = List(true);
+        }
+
+        public static int Update(KsPoolDTO account)
+        {
+            return new DBContext.Table("ks_pool")
+                .Add("current_hourly_calls", account.current_hourly_calls)
+                .Add("current_daily_calls", account.current_daily_calls)
+
+                .Add("today_clickNum", account.today_clickNum)
+                .Add("today_cosFee", account.today_cosFee)
+                .Add("today_cosPrice", account.today_cosPrice)
+                .Add("today_finishCosFee", account.today_finishCosFee)
+                .Add("today_finishCosPrice", account.today_finishCosPrice)
+                .Add("today_finishOrderNum", account.today_finishOrderNum)
+                .Add("today_orderNum", account.today_orderNum)
+
+
+                .Where("id=@id", new { account.id })
+                .Update();
+        }
+
+
+
+        public static int UpdateCookies(string cookies, string user_agent)
+        {
+            if (string.IsNullOrEmpty(cookies)) return 0;
+            string pin = cookies.GetContentPart("pin=", ";");
+            pin = pin.UrlDecode();
+
+            string company = pin;
+            int accountId = 0;
+            if (string.IsNullOrEmpty(pin)) return 0;
+            var exist = new DBContext.Table("ks_pool").Get<KsPoolDTO>("pin=@pin", new { pin });
+            if (exist != null)
+            {
+                var status = exist.status;
+                var work_mode = exist.work_mode;
+                accountId = exist.id;
+                if (work_mode == KsUnionWorkMode.Crawler) status = true;
+                new DBContext.Table("ks_pool")
+                   .Add("pin", pin)
+                   .Add("cookies", cookies)
+                   .Add("user_agent", user_agent)
+                   .Add("status", status)
+                   .Add("last_time", DateTime.Now)
+                   .Add("login_time", DateTime.Now)
+                   .Where("id=@id", new { exist.id })
+                   .Update();
+                if (status) _ = List(true);
+            }
+            else
+            {
+                accountId = new DBContext.Table("ks_pool")
+                    .Add("pin", pin)
+                    .Add("name", pin)
+                    .Add("company", pin)
+                    .Add("description", "由cookies上报创建此记录")
+                    .Add("cookies", cookies)
+                    .Add("user_agent", user_agent)
+                    .Add("create_time", DateTime.Now)
+                    .Add("last_time", DateTime.Now)
+                    .Add("login_time", DateTime.Now)
+                    .Add("status", 0)
+                    .Create();
+            }
+
+            NotifyCore.Notify(new NifyMessage
+            {
+                message = $"【快手{accountId}:{company}】cookie 上线",
+                tags = ["green_circle"]
+            });
+            EndPointCore.NotifyReload(true);
+            //NotifyCore.AnPushNotify("上线", $"【淘宝联盟:{dnk}】cookie 上报更新");
+            return accountId;
+        }
+
+
+        public static void Disabled(int accountId, string name, string content)
+        {
+            string cache_key = $"cache:ks_pool:{name}:disabled";
+            long count = RedisHelper.IncrBy(cache_key);
+            RedisHelper.Expire(cache_key, 10);
+            if (count > 1) return;
+
+            var update = new DBContext.Table("ks_pool").Add("status", 0);
+            if (accountId > 0)
+            {
+                update.Where("id=@accountId", new { accountId }).Update();
+            }
+            else
+            {
+                update.Where("name=@name", new { name }).Update();
+            }
+
+            _ = List(true);
+
+            NotifyCore.Notify(new NifyMessage
+            {
+                message = $"【快手联盟{accountId}:{name}】cookie 掉线\n\n{content}",
+                priority = NifyMessagePriority.high,
+                tags = ["red_circle"]
+            });
+
+            NotifyCore.AnPushNotify("掉线", $"【快手{accountId}:{name}】cookie 掉线");
+            EndPointCore.NotifyReload(true);
+        }
+
+
+
+
+        internal static void AccountExhausted()
+        {
+            string cache_key = $"cache:tk_pool:account:exhausted";
+            long count = RedisHelper.IncrBy(cache_key);
+            if (count > 1) return;
+            RedisHelper.Expire(cache_key, 3600);
+            NotifyCore.Notify(new NifyMessage
+            {
+                message = $"【快手联盟】没有匹配账号",
+                priority = NifyMessagePriority.high,
+                tags = ["red_circle"]
+            });
+            NotifyCore.AnPushNotify("没账号", $"【快手联盟】没有匹配账号");
+        }
+
+    }
+
+
+}

+ 425 - 0
molilian.core/Core/log/base.cs

@@ -0,0 +1,425 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Mvc.Filters;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using dodohold.core;
+using static dodohold.core.ZTOExpress.CreateOrderArgs;
+using System.Net;
+using System.Security.Cryptography;
+using Spire.Pdf.Exporting.XPS.Schema;
+using System.Xml.Linq;
+using static QRCoder.PayloadGenerator;
+using TencentCloud.Ssl.V20191205.Models;
+using CSRedis;
+using System.Data;
+using TencentCloud.Omics.V20221128.Models;
+using TencentCloud.Csip.V20221121.Models;
+using COSXML.Network;
+using System.Security.Policy;
+
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+
+        public static bool save_dailys_log = false;
+
+        static TkLogCore()
+        {
+            int flag = RedisHelper.Get<int>("turn:save_dailys_log");
+            if (flag == 1) save_dailys_log = true;
+        }
+        public static int BatchInsertLogDB(int limit)
+        {
+            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
+            {
+                if (!node.is_public_api) return 0;
+
+                if (CenterHub.IsCenter)
+                {
+                    if (node.is_coupon_api) return 0;
+                }
+                else
+                {
+                    if (!node.is_coupon_api) return 0;
+                }
+
+                if (string.IsNullOrEmpty(node.redis_server)) return 0;
+
+                var redis = RedisClientManager.GetRedisClient(node.redis_server);
+                return BatchInsertLogDB(limit, redis);
+            });
+            return result.Sum();
+        }
+
+        public static int BatchInsertLogDB(int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            using var connection = DBContext.GetOpenConnection();
+            connection.Open();
+            using var transaction = connection.BeginTransaction();
+
+
+            string cacheKey = ":lock_key:start_comparison_tk";
+            bool start_comparison_tk = RedisHelper.Get<int>(cacheKey) > 0;
+
+
+            try
+            {
+                //第三方接口写入日志
+                total += task_insert_tk_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_tb_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_jd_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_pdd_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_dy_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_tool_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_deeplink_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_coupon_logs(connection, transaction, limit, redis);
+
+                total += task_insert_parse_cps_logs(connection, transaction, limit, redis);
+
+                total += task_insert_promotion_img_logs(connection, transaction, limit, redis);
+
+                transaction.Commit();
+            }
+            catch (Exception ex)
+            {
+                transaction.Rollback();
+
+                _ = new LoggerLibrary("database_error", "parse_log")
+                    .Info(ex.Message, ex.StackTrace)
+                    .SaveAsync();
+
+                NotifyCore.Notify(new NifyMessage
+                {
+                    message = $"【写入日志异常】\n{ex.Message}\n{ex.StackTrace}",
+                    priority = NifyMessagePriority.high,
+                    tags = ["red_circle"]
+                });
+            }
+            finally
+            {
+                connection.Close();
+            }
+            return total;
+        }
+     
+        private static void saveCache(string channel, int accountId, string accountName, bool success, string message, string reason)
+        {
+            saveAccountCache("all", success, message, reason);
+            saveAccountCache($"{channel}", success, message, reason);
+            saveAccountCache($"{accountName}", success, message, reason);
+            if (accountId != 0)
+            {
+                //todo 放着跑两天,要将读取的地方改成读取accountid
+                saveAccountCache($"{channel}_{accountId}", success, message, reason);
+            }
+        }
+
+        private static void saveAccountCache(string accountName, bool success, string message, string reason)
+        {
+            RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMMddHH}");
+
+
+            string result = success ? "success" : "fail";
+            RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
+
+
+            if (!string.IsNullOrEmpty(message))
+            {
+                RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
+                RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
+                RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
+
+                RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
+
+                RedisHelper.IncrBy($":total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+            if (!string.IsNullOrEmpty(reason))
+            {
+                RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
+                RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
+                RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
+
+                RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
+
+
+                RedisHelper.IncrBy($":total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+        }
+
+        private static async Task saveUnionCouponParseCacheAsync(TkDataDTO data)
+        {
+            string cacheKey = $":cache:parse:{data.ip}_{data.oaid}_{data.itemId}";
+            await EndPointCore.ProcessEndPointNodesAsync(node =>
+            {
+                if (!node.is_coupon_api) return Task.CompletedTask;
+                if (string.IsNullOrEmpty(node.redis_server)) return Task.CompletedTask;
+
+                var redis = RedisClientManager.GetRedisClient(node.redis_server);
+                redis.Set(cacheKey, 1, 2 * 86400);
+                return Task.CompletedTask;
+            });
+        }
+        private static void saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
+        {
+            string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
+            RedisHelper.IncrBy(cacheKey);
+            RedisHelper.Expire(cacheKey, 86400);
+
+            if (!string.IsNullOrEmpty(oaid))
+            {
+                cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
+                RedisHelper.IncrBy(cacheKey);
+                RedisHelper.Expire(cacheKey, 86400);
+            }
+        }
+        public static int getClientRequestTotalByOAID(TkChannelEnum channel, string oaid)
+        {
+            if (string.IsNullOrEmpty(oaid)) return 0;
+            string cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
+            return RedisHelper.Get<int>(cacheKey);
+        }
+        public static int getClientRequestTotalByIp(TkChannelEnum channel, string ip)
+        {
+            if (string.IsNullOrEmpty(ip)) return 0;
+            string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
+            return RedisHelper.Get<int>(cacheKey);
+        }
+
+
+        private static void saveClientRequestTotal(CpsChannelEnum channel, string ip, string oaid)
+        {
+            string cacheKey = $":cache:cps_{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
+            RedisHelper.IncrBy(cacheKey);
+            RedisHelper.Expire(cacheKey, 86400);
+
+            if (!string.IsNullOrEmpty(oaid))
+            {
+                cacheKey = $":cache:cps_{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
+                RedisHelper.IncrBy(cacheKey);
+                RedisHelper.Expire(cacheKey, 86400);
+            }
+        }
+        public static int getClientRequestTotalByOAID(CpsChannelEnum channel, string oaid)
+        {
+            if (string.IsNullOrEmpty(oaid)) return 0;
+            string cacheKey = $":cache:cps_{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
+            return RedisHelper.Get<int>(cacheKey);
+        }
+        public static int getClientRequestTotalByIp(CpsChannelEnum channel, string ip)
+        {
+            if (string.IsNullOrEmpty(ip)) return 0;
+            string cacheKey = $":cache:cps_{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
+            return RedisHelper.Get<int>(cacheKey);
+        }
+
+
+
+
+
+        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);
+            if (accountId != 0)
+            {
+                //todo 放着跑两天,要将读取的地方改成读取accountid
+                saveParseAccountCache($"{channel}_{accountId}", success, message, 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}");
+
+
+            string result = success ? "success" : "fail";
+            RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
+
+
+            if (!string.IsNullOrEmpty(message))
+            {
+                RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
+                RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
+                RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
+
+                RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+            if (!string.IsNullOrEmpty(reason))
+            {
+                RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
+                RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
+                RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
+
+                RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
+
+                RedisHelper.IncrBy($":parse_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":parse_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
+            }
+        }
+
+        public static int GetTotal(string keyname, bool all_node = true)
+        {
+            //:coupon_total:tb:20240706
+            //:coupon_total:tb:success:20240706
+            //:coupon_total:tb:放弃转链:20240706
+
+            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
+            {
+                if (!node.is_public_api) return 0;
+                if (string.IsNullOrEmpty(node.redis_server)) return 0;
+
+                if (!all_node)
+                {
+                    if (CenterHub.IsCenter)
+                    {
+                        if (node.is_coupon_api) { return 0; }
+                    }
+                    else
+                    {
+                        if (!node.is_coupon_api) { return 0; }
+                    }
+                }
+
+#if DEBUG
+                switch (node.name)
+                {
+
+                    case "bj":
+                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
+                        break;
+                    case "gz":
+                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
+                        break;
+                    case "coupon1":
+                        node.redis_server = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
+                        break;
+                    default: return 0;
+                }
+
+#endif
+                var redis = RedisClientManager.GetRedisClient(node.redis_server);
+                int count = redis.Get<int>(keyname);
+                return count;
+            });
+            return result.Sum();
+        }
+
+        public static string[] GetTotalKeys(string keyname, bool all_node = true)
+        {
+
+            var result = EndPointCore.ProcessEndPointNodes<string[]>(node =>
+            {
+                if (!node.is_public_api) return [];
+                if (string.IsNullOrEmpty(node.redis_server)) return [];
+
+                if (!all_node)
+                {
+                    if (CenterHub.IsCenter)
+                    {
+                        if (node.is_coupon_api) { return []; }
+                    }
+                    else
+                    {
+                        if (!node.is_coupon_api) { return []; }
+                    }
+                }
+#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 [];
+                }
+#endif
+
+                var redis = RedisClientManager.GetRedisClient(node.redis_server);
+
+                string[] message_keys = redis.SMembers(keyname);
+                return message_keys;
+            });
+
+            string[] message_keys = [];
+            foreach (var arr in result)
+            {
+                message_keys = message_keys.Union(arr).ToArray();
+            }
+            return message_keys;
+        }
+
+
+    }
+
+}

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

@@ -0,0 +1,134 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_coupon_key = "queue:coupon_logs";
+        public static int task_insert_parse_coupon_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<UnionCouponDTO>(queue_coupon_key);
+                if (data == null) break;
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    var test_data = data.Convert2Json().Convert2Object<TestUnionCouponDTO>();
+                    connection.Insert(test_data);
+                }
+                else
+                {
+                    connection.Insert(data);
+                    if (data.success)
+                    {
+                        var success_data = data.Convert2Json().Convert2Object<SuccessUnionCouponDTO>();
+                        connection.Insert(success_data);
+                    }
+                }
+                total++;
+            }
+            return total;
+        }
+
+        public static async Task CouponLogAsync(UnionCouponDTO response, AlimamaPlus? alimamaPlus = null)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_coupon_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveCouponCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                }
+                if (!response.success && "nologin".Equals(response.message))
+                {
+                    switch (response.channel)
+                    {
+                        case TkChannelEnum.tb:
+                            await Task.Run(() =>
+                            {
+                                if (alimamaPlus != null)
+                                {
+                                    (bool success, string message) = alimamaPlus.RenewCookie();
+                                    if (success) return;
+                                }
+                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
+                            }); break;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                _ = new LoggerLibrary("unionCoupon", "database_error")
+                .Info(response.rawContent)
+                .Info(response.Convert2Json())
+                .Info(ex.Message, ex.StackTrace)
+                .SaveAsync();
+            }
+        }
+        private static void saveCouponCache(string channel, int accountId, string accountName, bool success, string message, string reason)
+        {
+            saveAccountCouponCache("all", success, message, reason);
+            saveAccountCouponCache($"{channel}", success, message, reason);
+            if (accountId != 0)
+            {
+                saveAccountCouponCache($"{channel}_{accountId}", success, message, reason);
+            }
+        }
+
+        private static void saveAccountCouponCache(string accountName, bool success, string message, string reason)
+        {
+            RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
+
+
+            string result = success ? "success" : "fail";
+            RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
+
+
+            if (!string.IsNullOrEmpty(message))
+            {
+                RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
+                RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
+                RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
+
+                RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+            if (!string.IsNullOrEmpty(reason))
+            {
+                RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
+                RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
+                RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
+
+                RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":coupon_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+        }
+
+
+
+
+    }
+
+}

+ 124 - 0
molilian.core/Core/log/cps.cs

@@ -0,0 +1,124 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_cps_key = "queue:cps_logs";
+
+        public static int task_insert_parse_cps_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<UnionCpsDTO>(queue_cps_key);
+                if (data == null) break;
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    var test_data = data.Convert2Json().Convert2Object<TestUnionCpsDTO>();
+                    connection.Insert(test_data);
+                }
+                else
+                {
+                    connection.Insert(data);
+                    if (data.success)
+                    {
+                        var success_data = data.Convert2Json().Convert2Object<SuccessUnionCpsDTO>();
+                        connection.Insert(success_data);
+                    }
+                }
+                total++;
+            }
+            return total;
+        }
+
+
+        public static async Task CpsLogAsync(UnionCpsDTO response, AlimamaPlus? alimamaPlus = null)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_cps_key, response);
+
+                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveCpsCache(response.channel.ToString(), response.accountId,
+                        response.success, response.message, response.reason);
+                }
+            }
+            catch (Exception ex)
+            {
+                _ = new LoggerLibrary("unionCps", "database_error")
+                .Info(response.rawContent)
+                .Info(response.Convert2Json())
+                .Info(ex.Message, ex.StackTrace)
+                .SaveAsync();
+            }
+        }
+
+        private static void saveCpsCache(string channel, int accountId, bool success, string message, string reason)
+        {
+            saveAccountCpsCache("all", success, message, reason);
+            saveAccountCpsCache($"{channel}", success, message, reason);
+            if (accountId != 0)
+            {
+                saveAccountCpsCache($"{channel}_{accountId}", success, message, reason);
+            }
+        }
+
+        private static void saveAccountCpsCache(string flagName, bool success, string message, string reason)
+        {
+            RedisHelper.IncrBy($":cps_total:{flagName}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":cps_total:{flagName}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":cps_total:{flagName}:{DateTime.Now:yyyyMMddHH}");
+
+
+            string result = success ? "success" : "fail";
+            RedisHelper.IncrBy($":cps_total:{flagName}:{result}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":cps_total:{flagName}:{result}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":cps_total:{flagName}:{result}:{DateTime.Now:yyyyMMddHH}");
+
+
+            if (!string.IsNullOrEmpty(message))
+            {
+                RedisHelper.SAdd($":cps_total:{flagName}:message:{DateTime.Now:yyyyMM}", message);
+                RedisHelper.SAdd($":cps_total:{flagName}:message:{DateTime.Now:yyyyMMdd}", message);
+                RedisHelper.SAdd($":cps_total:{flagName}:message:{DateTime.Now:yyyyMMddHH}", message);
+
+                RedisHelper.IncrBy($":cps_total:{flagName}:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:{message}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:message:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:message:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+            if (!string.IsNullOrEmpty(reason))
+            {
+                RedisHelper.SAdd($":cps_total:{flagName}:reason:{DateTime.Now:yyyyMM}", reason);
+                RedisHelper.SAdd($":cps_total:{flagName}:reason:{DateTime.Now:yyyyMMdd}", reason);
+                RedisHelper.SAdd($":cps_total:{flagName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
+
+                RedisHelper.IncrBy($":cps_total:{flagName}:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:{reason}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:reason:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":cps_total:{flagName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+        }
+
+
+
+
+    }
+
+}

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

@@ -0,0 +1,65 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+
+        static string queue_deeplink_parse_key = "queue:parse_logs:deeplink";
+
+        public static int task_insert_parse_deeplink_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+
+            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++;
+            }
+            return total;
+        }
+        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) { }
+        }
+
+    }
+
+}

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

@@ -0,0 +1,69 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_parse_dy_key = "queue:parse_logs:dy";
+
+        public static int task_insert_parse_dy_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+
+
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<DyDataDTO>(queue_parse_dy_key);
+                if (data == null) break;
+                new DBContext.Table(connection, "tk_parse_logs")
+                    .Add("end_point", data.end_point)
+                    .Add("channel", (int)data.channel)
+                    .Add("accountId", data.accountId)
+                    .Add("accountName", data.accountName)
+                    .Add("rawContent", data.rawContent)
+                    .Add("success", data.success)
+                    .Add("message", data.message)
+                    .Add("reason", data.reason)
+                    .Add("content", data.content)
+                    .Add("itemId", data.itemId)
+                    .Add("itemName", data.itemName)
+                    .Add("pic", data.pic)
+                    .Add("couponAmount", data.couponAmount)
+                    .Add("promotionPrice", data.promotionPrice)
+                    .Add("taoToken", data.taoToken)
+                    .Add("shortLinkurl", data.shortLinkurl)
+                    .Add("deeplink_url", data.deeplink_url)
+                    .Add("elapsedTime", data.elapsedTime)
+                    .Add("subCode", data.subCode)
+                    .Add("ip", data.ip)
+                    .Add("oaid", data.oaid)
+                    .Add("create_time", data.create_time)
+                    .Create(DBContext.InsertType.NORMAL, transaction);
+                total++;
+            }
+            return total;
+        }
+
+        public static async Task ParseLogAsync(DyDataDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_parse_dy_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveParseCache(response.channel.ToString(), response.accountId,
+                        response.accountName, response.success, response.message, response.reason,
+                        response.deeplink_url);
+                }
+
+            }
+            catch (Exception ex) { }
+        }
+    }
+
+}

+ 133 - 0
molilian.core/Core/log/jd.cs

@@ -0,0 +1,133 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_parse_jd_key = "queue:parse_logs:jd";
+
+        public static int task_insert_parse_jd_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<JdDataDTO>(queue_parse_jd_key);
+                if (data == null) break;
+
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    save_jd_parse_logs(data, "jd_parse_logs_test", connection, transaction);
+                }
+                else
+                {
+                    save_jd_parse_logs(data, "jd_parse_logs", connection, transaction);
+
+                    if (save_dailys_log)
+                    {
+                        string daily_table = $"jd_parse_logs_{DateTime.Now:yyyyMMdd}";
+                        save_jd_parse_logs(data, daily_table, connection, transaction);
+                    }
+
+                    if (data.elapsedTime > 1000)
+                    {
+                        save_jd_parse_logs(data, "jd_parse_logs_test", connection, transaction);
+                    }
+                    if (data.success)
+                    {
+                        save_jd_parse_logs(data, "jd_parse_logs_success", connection, transaction);
+                    }
+                }
+                total++;
+            }
+            return total;
+        }
+
+        public static async Task ParseLogAsync(JdDataDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_parse_jd_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveParseCache(response.channel.ToString(), response.accountId,
+                        response.accountName, response.success, response.message, response.reason,
+                        response.deeplink_url);
+                }
+
+                if (response.success || response.message.Equals("转链失败"))
+                {
+                    JdPoolCore.CallsIncrBy(response.accountId);
+                }
+                //CallsIncrBy
+
+                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
+
+                if (!response.success && ("nologin".Equals(response.reason) ||
+                    "方法不存在".Equals(response.reason) ||
+                    "未登录".Equals(response.reason)))
+                {
+                    await Task.Run(() =>
+                    {
+                        JdPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
+                    });
+                    //switch (response.channel)
+                    //{
+                    //    case TkChannelEnum.tb:
+
+                    //        //await Task.Run(() =>
+                    //        //{
+                    //        //    if (alimamaPlus != null)
+                    //        //    {
+                    //        //        (bool success, string message) = alimamaPlus.RenewCookie();
+                    //        //        if (success) return;
+                    //        //    }
+                    //        //    TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
+                    //        //});
+                    //        break;
+                    //}
+                }
+                if ("没有匹配账号".Equals(response.reason))
+                {
+                    JdPoolCore.AccountExhausted();
+                }
+            }
+            catch (Exception ex) { }
+        }
+        private static int save_jd_parse_logs(JdDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
+        {
+            return new DBContext.Table(connection, tablename)
+                .Add("end_point", data.end_point)
+                .Add("channel", (int)data.channel)
+                .Add("accountId", data.accountId)
+                .Add("accountName", data.accountName)
+                .Add("rawContent", data.rawContent)
+                .Add("success", data.success)
+                .Add("message", data.message)
+                .Add("reason", data.reason)
+                .Add("content", data.content)
+                .Add("itemId", data.itemId)
+                .Add("itemName", data.itemName)
+                .Add("pic", data.pic)
+                .Add("couponAmount", data.couponAmount)
+                .Add("promotionPrice", data.promotionPrice)
+                .Add("taoToken", data.taoToken)
+                .Add("shortLinkurl", data.shortLinkurl)
+                .Add("deeplink_url", data.deeplink_url)
+                .Add("elapsedTime", data.elapsedTime)
+                .Add("subCode", data.subCode)
+                .Add("ip", data.ip)
+                .Add("oaid", data.oaid)
+                .Add("create_time", data.create_time)
+                .Create(DBContext.InsertType.NORMAL, transaction);
+        }
+
+    }
+
+}

+ 146 - 0
molilian.core/Core/log/pdd.cs

@@ -0,0 +1,146 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_parse_pdd_key = "queue:parse_logs:pdd";
+
+        public static int task_insert_parse_pdd_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<PddDataDTO>(queue_parse_pdd_key);
+                if (data == null) break;
+
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    save_pdd_parse_logs(data, "pdd_parse_logs_test", connection, transaction);
+                }
+                else
+                {
+                    save_pdd_parse_logs(data, "pdd_parse_logs", connection, transaction);
+                    if (data.elapsedTime > 1000)
+                    {
+                        save_pdd_parse_logs(data, "pdd_parse_logs_test", connection, transaction);
+                    }
+                    if (data.success)
+                    {
+                        save_pdd_parse_logs(data, "pdd_parse_logs_success", connection, transaction);
+                    }
+                }
+                total++;
+            }
+            return total;
+        }
+
+
+        public static async Task ParseLogAsync(PddDataDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_parse_pdd_key, response);
+
+
+#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.elapsedTime > 1000)
+                        {
+                            save_pdd_parse_logs(data, "pdd_parse_logs_test", 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,
+                        response.accountName, response.success, response.message, response.reason,
+                        response.deeplink_url);
+                }
+
+                if (response.success || response.message.Equals("转链失败"))
+                {
+                    PddPoolCore.CallsIncrBy(response.accountId);
+                }
+
+                if (response.reason.Equals("您的调用次数过高"))
+                {
+                    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)))
+                {
+                    await Task.Run(() =>
+                    {
+                        PddPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
+                    });
+                }
+                if ("没有匹配账号".Equals(response.reason))
+                {
+                    PddPoolCore.AccountExhausted();
+                }
+            }
+            catch (Exception ex) { }
+        }
+        private static int save_pdd_parse_logs(PddDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
+        {
+            return new DBContext.Table(connection, tablename)
+                .Add("end_point", data.end_point)
+                .Add("channel", (int)data.channel)
+                .Add("accountId", data.accountId)
+                .Add("accountName", data.accountName)
+                .Add("rawContent", data.rawContent)
+                .Add("success", data.success)
+                .Add("message", data.message)
+                .Add("reason", data.reason)
+                .Add("content", data.content)
+                .Add("itemId", data.itemId)
+                .Add("itemName", data.itemName)
+                .Add("pic", data.pic)
+                .Add("couponAmount", data.couponAmount)
+                .Add("promotionPrice", data.promotionPrice)
+                .Add("taoToken", data.taoToken)
+                .Add("shortLinkurl", data.shortLinkurl)
+                .Add("deeplink_url", data.deeplink_url)
+                .Add("elapsedTime", data.elapsedTime)
+                .Add("subCode", data.subCode)
+                .Add("ip", data.ip)
+                .Add("oaid", data.oaid)
+                .Add("create_time", data.create_time)
+                .Create(DBContext.InsertType.NORMAL, transaction);
+        }
+
+
+
+    }
+
+}

+ 103 - 0
molilian.core/Core/log/promotion.cs

@@ -0,0 +1,103 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string promotion_img_key = "queue:promotion:img";
+
+        public static int task_insert_promotion_img_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<PromotionQueryDTO>(promotion_img_key);
+                if (data == null) break;
+
+                if (data.success)
+                {
+                    data.similarPromotion = string.Empty;
+                    data.promotionImg = string.Empty;
+                }
+                connection.Insert(data);
+                total++;
+            }
+            return total;
+        }
+        public static async Task PromotionImgLogAsync(PromotionQueryDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(promotion_img_key, response);
+
+                //using var connection = DBContext.GetOpenConnection();
+                //connection.Insert(response);
+                savePromotionCache(response.accountId, response.accountName, response.success, response.message, response.reason);
+            }
+            catch (Exception ex) { }
+        }
+
+
+
+
+
+        private static void savePromotionCache(int accountId, string accountName, bool success, string message, string reason)
+        {
+            savePromotionAccountCache("all", success, message, reason);
+            savePromotionAccountCache($"{accountId}", success, message, reason);
+        }
+
+        private static void savePromotionAccountCache(string accountName, bool success, string message, string reason)
+        {
+            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
+
+
+            string result = success ? "success" : "fail";
+            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
+            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
+            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
+
+
+            if (!string.IsNullOrEmpty(message))
+            {
+                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
+                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
+                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
+
+                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
+            }
+
+            if (!string.IsNullOrEmpty(reason))
+            {
+                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
+                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
+                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
+
+                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
+                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
+            }
+        }
+
+
+
+
+
+    }
+
+}

+ 157 - 0
molilian.core/Core/log/taobao.cs

@@ -0,0 +1,157 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+
+        static string queue_parse_tb_key = "queue:parse_logs:tb";
+
+        public static int task_insert_parse_tb_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<TkDataDTO>(queue_parse_tb_key);
+                if (data == null) break;
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    save_tk_parse_logs(data, "tk_parse_logs_test", connection, transaction);
+                }
+                else
+                {
+                    data.id = save_tk_parse_logs(data, "tk_parse_logs", connection, transaction);
+
+                    //每日分表
+                    if (save_dailys_log)
+                    {
+                        string daily_table = $"tk_parse_logs_{DateTime.Now:yyyyMMdd}";
+                        save_tk_parse_logs(data, daily_table, connection, transaction);
+                    }
+
+                    if (data.elapsedTime > 1000)
+                    {
+                        save_tk_parse_logs(data, "tk_parse_logs_test", connection, transaction);
+                    }
+                    if (data.success)
+                    {
+                        save_tk_parse_logs(data, "tk_success_parse_logs", connection, transaction);
+                    }
+                    if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
+                }
+
+                if (data.reason.Contains("初步筛选2") && !data.rawContent.Contains("I:/kWqN5t623Hx"))
+                {
+                    save_tk_parse_logs(data, "tk_parse_logs_test2", connection, transaction);
+                }
+
+                if (data.reason.Contains("初步筛选1.5"))
+                {
+                    save_tk_parse_logs(data, "tk_parse_logs_multi_token", connection, transaction);
+                }
+                if (data.reason.Contains("霸下验证码"))
+                {
+                    save_tk_parse_logs(data, "tk_parse_logs_captcha", connection, transaction);
+                }
+                total++;
+            }
+            return total;
+        }
+
+        public static async Task ParseLogAsync(TkDataDTO response, AlimamaPlus? alimamaPlus = null)
+        {
+#if DEBUG
+            //return;
+#endif
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_parse_tb_key, response);
+
+
+                if (response.success)
+                {
+                    _ = saveUnionCouponParseCacheAsync(response);
+                }
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    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))
+                {
+                    switch (response.channel)
+                    {
+                        case TkChannelEnum.tb:
+                            await Task.Run(() =>
+                            {
+                                if (alimamaPlus != null)
+                                {
+                                    (bool success, string message) = alimamaPlus.RenewCookie();
+                                    if (success) return;
+                                }
+                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
+                            }); break;
+                    }
+                }
+                if (response.subCode == TkSubCodeEnum.Captcha || "霸下验证码".Equals(response.reason))
+                {
+                    TkPoolCore.Suspend(response.end_point, response.accountId, response.accountName, "霸下验证码");
+                }
+            }
+            catch (Exception ex)
+            {
+                _ = new LoggerLibrary("unionParse", "database_error")
+                .Info(response.rawContent)
+                .Info(response.Convert2Json())
+                .Info(ex.Message, ex.StackTrace)
+                .SaveAsync();
+            }
+        }
+        private static int save_tk_parse_logs(TkDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
+        {
+            return new DBContext.Table(connection, tablename)
+                .Add("end_point", data.end_point)
+                .Add("channel", (int)data.channel)
+                .Add("linkType", (int)data.link_type)
+                .Add("accountId", data.accountId)
+                .Add("accountName", data.accountName)
+                .Add("rawContent", data.rawContent)
+                .Add("success", data.success)
+                .Add("message", data.message)
+                .Add("reason", data.reason)
+                .Add("content", data.content)
+                .Add("itemId", data.itemId)
+                .Add("itemName", data.itemName)
+                .Add("pic", data.pic)
+                .Add("couponAmount", data.couponAmount)
+                .Add("promotionPrice", data.promotionPrice)
+                .Add("taoToken", data.taoToken)
+                .Add("shortLinkurl", data.shortLinkurl)
+                .Add("deeplink_url", data.deeplink_url)
+                .Add("num_iid", data.num_iid)
+                .Add("elapsedTime", data.elapsedTime)
+                .Add("elapsedTime2", data.elapsedTime2)
+                .Add("elapsedTime3", data.elapsedTime3)
+                .Add("subCode", data.subCode)
+                .Add("ip", data.ip)
+                .Add("oaid", data.oaid)
+                .Add("create_time", data.create_time)
+
+                .Create(DBContext.InsertType.NORMAL, transaction);
+        }
+
+
+    }
+
+}

+ 85 - 0
molilian.core/Core/log/tool.cs

@@ -0,0 +1,85 @@
+using dodohold.core;
+using CSRedis;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_parse_tool_key = "queue:parse_logs:tool";
+
+        public static int task_insert_parse_tool_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<ToolParseDataDTO>(queue_parse_tool_key);
+                if (data == null) break;
+
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    new DBContext.Table(connection, "tool_parse_logs_test")
+                        .Add("end_point", data.end_point)
+                        .Add("channel", (int)data.channel)
+                        .Add("rawContent", data.rawContent)
+                        .Add("success", data.success)
+                        .Add("message", data.message)
+                        .Add("reason", data.reason)
+                        .Add("content", data.content)
+                        .Add("taoToken", data.taoToken)
+                        .Add("shortLinkurl", data.shortLinkurl)
+                        .Add("deeplink_url", data.deeplink_url)
+                        .Add("elapsedTime", data.elapsedTime)
+                        .Add("ip", data.ip)
+                        .Add("oaid", data.oaid)
+                        .Add("create_time", data.create_time)
+                        .Create(DBContext.InsertType.NORMAL, transaction);
+                }
+                else
+                {
+                    new DBContext.Table(connection, "tool_parse_logs")
+                        .Add("end_point", data.end_point)
+                        .Add("channel", (int)data.channel)
+                        .Add("rawContent", data.rawContent)
+                        .Add("success", data.success)
+                        .Add("message", data.message)
+                        .Add("reason", data.reason)
+                        .Add("content", data.content)
+                        .Add("taoToken", data.taoToken)
+                        .Add("shortLinkurl", data.shortLinkurl)
+                        .Add("deeplink_url", data.deeplink_url)
+                        .Add("elapsedTime", data.elapsedTime)
+                        .Add("ip", data.ip)
+                        .Add("oaid", data.oaid)
+                        .Add("create_time", data.create_time)
+                        .Create(DBContext.InsertType.NORMAL, transaction);
+                }
+                total++;
+            }
+            return total;
+        }
+
+
+        public static async Task ParseLogAsync(ToolParseDataDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_parse_tool_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveParseCache(response.channel.ToString(), 0, "tool",
+                        response.success, response.message, response.reason,
+                        response.deeplink_url);
+                }
+            }
+            catch (Exception ex) { }
+        }
+    }
+
+}

+ 160 - 0
molilian.core/Core/log/第三方旧接口.cs

@@ -0,0 +1,160 @@
+
+using CSRedis;
+using dodohold.core;
+using System.Data;
+
+namespace molilian.core
+{
+    public partial class TkLogCore
+    {
+        static string queue_tb_key = "queue:logs:tb";
+        static string queue_jd_key = "queue:logs:jd";
+
+        public static int task_insert_tk_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
+        {
+            int total = 0;
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<TkDataDTO>(queue_tb_key);
+                if (data == null) break;
+
+                if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
+                     data.ip.Contains("127.0.0"))
+                {
+                    save_tk_log(data, "tk_logs_test", connection, transaction);
+                }
+                else
+                {
+                    data.id = save_tk_log(data, "tk_logs", connection, transaction);
+                    if (data.elapsedTime > 1000)
+                    {
+                        save_tk_log(data, "tk_logs_test", connection, transaction);
+                    }
+                    if (data.success)
+                    {
+                        save_tk_log(data, "tk_success_logs", connection, transaction);
+                    }
+                    if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
+                }
+                total++;
+            }
+
+            for (int i = 0; i < limit; i++)
+            {
+                var data = redis.LPop<JdDataDTO>(queue_jd_key);
+                if (data == null) break;
+                new DBContext.Table(connection, "tk_logs")
+                    .Add("end_point", data.end_point)
+                    .Add("channel", (int)data.channel)
+                    .Add("accountId", data.accountId)
+                    .Add("accountName", data.accountName)
+                    .Add("rawContent", data.rawContent)
+                    .Add("rawContent2", data.rawContent2)
+                    .Add("success", data.success)
+                    .Add("message", data.message)
+                    .Add("reason", data.reason)
+                    .Add("shortLinkurl", data.shortLinkurl)
+                    .Add("deeplink_url", data.deeplink_url)
+                    .Add("elapsedTime", data.elapsedTime)
+                    .Add("ip", data.ip)
+                    .Add("oaid", data.oaid)
+                    .Add("create_time", data.create_time)
+                    .Create(DBContext.InsertType.NORMAL, transaction);
+                total++;
+            }
+            return total;
+        }
+        public static async Task LogAsync(JdDataDTO response)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_jd_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                }
+            }
+            catch (Exception ex) { }
+        }
+        public static async Task LogAsync(TkDataDTO response, AlimamaPlus? alimamaPlus = null)
+        {
+            try
+            {
+                var ts = DateTime.Now - response.create_time;
+                response.elapsedTime = (int)ts.TotalMilliseconds;
+                _ = RedisHelper.RPushAsync(queue_tb_key, response);
+
+                if (!response.ip.Contains("127.0.0"))
+                {
+                    saveCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
+                }
+
+                if (!response.success && "nologin".Equals(response.message))
+                {
+                    switch (response.channel)
+                    {
+                        case TkChannelEnum.tb:
+
+                            await Task.Run(() =>
+                            {
+                                if (alimamaPlus != null)
+                                {
+                                    (bool success, string message) = alimamaPlus.RenewCookie();
+                                    if (success) return;
+                                }
+                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
+                            });
+                            break;
+                    }
+                }
+                if ("没有匹配账号".Equals(response.reason))
+                {
+                    TkPoolCore.AccountExhausted();
+                }
+            }
+            catch (Exception ex)
+            {
+                _ = new LoggerLibrary("unionParse", "database_error")
+                .Info(response.rawContent, response.rawContent2)
+                .Info(response.Convert2Json())
+                .Info(ex.Message, ex.StackTrace)
+                .SaveAsync();
+            }
+        }
+
+        private static int save_tk_log(TkDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
+        {
+            return new DBContext.Table(connection, tablename)
+                  .Add("end_point", data.end_point)
+                  .Add("channel", (int)data.channel)
+                  .Add("accountId", data.accountId)
+                  .Add("accountName", data.accountName)
+                  .Add("rawContent", data.rawContent)
+                  .Add("rawContent2", data.rawContent2)
+                  .Add("success", data.success)
+                  .Add("message", data.message)
+                  .Add("reason", data.reason)
+                  .Add("content", data.content)
+                  .Add("couponAmount", data.couponAmount)
+                  .Add("itemId", data.itemId)
+                  .Add("itemName", data.itemName)
+                  .Add("pic", data.pic)
+                  .Add("promotionPrice", data.promotionPrice)
+                  .Add("taoToken", data.taoToken)
+                  .Add("shortLinkurl", data.shortLinkurl)
+                  .Add("deeplink_url", data.deeplink_url)
+                  .Add("num_iid", data.num_iid)
+                  .Add("elapsedTime", data.elapsedTime)
+                  .Add("subCode", data.subCode)
+                  .Add("ip", data.ip)
+                  .Add("oaid", data.oaid)
+                  .Add("create_time", data.create_time)
+                  .Create(DBContext.InsertType.NORMAL, transaction);
+        }
+
+    }
+
+}

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

@@ -1,1397 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Controllers;
-using Microsoft.AspNetCore.Mvc.Filters;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using dodohold.core;
-using static dodohold.core.ZTOExpress.CreateOrderArgs;
-using System.Net;
-using System.Security.Cryptography;
-using Spire.Pdf.Exporting.XPS.Schema;
-using System.Xml.Linq;
-using static QRCoder.PayloadGenerator;
-using TencentCloud.Ssl.V20191205.Models;
-using CSRedis;
-using System.Data;
-using TencentCloud.Omics.V20221128.Models;
-using TencentCloud.Csip.V20221121.Models;
-using COSXML.Network;
-using System.Security.Policy;
-
-
-namespace molilian.core
-{
-    public class TkLogCore
-    {
-        static string queue_tb_key = "queue:logs:tb";
-        static string queue_jd_key = "queue:logs:jd";
-
-        static string queue_parse_tb_key = "queue:parse_logs:tb";
-        static string queue_parse_jd_key = "queue:parse_logs:jd";
-        static string queue_parse_pdd_key = "queue:parse_logs:pdd";
-
-        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";
-
-        static string queue_cps_key = "queue:cps_logs";
-        public static bool save_dailys_log = false;
-
-        static TkLogCore()
-        {
-            int flag = RedisHelper.Get<int>("turn:save_dailys_log");
-            if (flag == 1) save_dailys_log = true;
-        }
-        public static int BatchInsertLogDB(int limit)
-        {
-            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
-            {
-                if (!node.is_public_api) return 0;
-
-                if (CenterHub.IsCenter)
-                {
-                    if (node.is_coupon_api) return 0;
-                }
-                else
-                {
-                    if (!node.is_coupon_api) return 0;
-                }
-
-                if (string.IsNullOrEmpty(node.redis_server)) return 0;
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                return BatchInsertLogDB(limit, redis);
-            });
-            return result.Sum();
-        }
-
-        private static int save_tk_log(TkDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
-        {
-            return new DBContext.Table(connection, tablename)
-                  .Add("end_point", data.end_point)
-                  .Add("channel", (int)data.channel)
-                  .Add("accountId", data.accountId)
-                  .Add("accountName", data.accountName)
-                  .Add("rawContent", data.rawContent)
-                  .Add("rawContent2", data.rawContent2)
-                  .Add("success", data.success)
-                  .Add("message", data.message)
-                  .Add("reason", data.reason)
-                  .Add("content", data.content)
-                  .Add("couponAmount", data.couponAmount)
-                  .Add("itemId", data.itemId)
-                  .Add("itemName", data.itemName)
-                  .Add("pic", data.pic)
-                  .Add("promotionPrice", data.promotionPrice)
-                  .Add("taoToken", data.taoToken)
-                  .Add("shortLinkurl", data.shortLinkurl)
-                  .Add("deeplink_url", data.deeplink_url)
-                  .Add("num_iid", data.num_iid)
-                  .Add("elapsedTime", data.elapsedTime)
-                  .Add("subCode", data.subCode)
-                  .Add("ip", data.ip)
-                  .Add("oaid", data.oaid)
-                  .Add("create_time", data.create_time)
-                  .Create(DBContext.InsertType.NORMAL, transaction);
-        }
-        private static int save_tk_parse_logs(TkDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
-        {
-            return new DBContext.Table(connection, tablename)
-                .Add("end_point", data.end_point)
-                .Add("channel", (int)data.channel)
-                .Add("linkType", (int)data.link_type)
-                .Add("accountId", data.accountId)
-                .Add("accountName", data.accountName)
-                .Add("rawContent", data.rawContent)
-                .Add("success", data.success)
-                .Add("message", data.message)
-                .Add("reason", data.reason)
-                .Add("content", data.content)
-                .Add("itemId", data.itemId)
-                .Add("itemName", data.itemName)
-                .Add("pic", data.pic)
-                .Add("couponAmount", data.couponAmount)
-                .Add("promotionPrice", data.promotionPrice)
-                .Add("taoToken", data.taoToken)
-                .Add("shortLinkurl", data.shortLinkurl)
-                .Add("deeplink_url", data.deeplink_url)
-                .Add("num_iid", data.num_iid)
-                .Add("elapsedTime", data.elapsedTime)
-                .Add("elapsedTime2", data.elapsedTime2)
-                .Add("elapsedTime3", data.elapsedTime3)
-                .Add("subCode", data.subCode)
-                .Add("ip", data.ip)
-                .Add("oaid", data.oaid)
-                .Add("create_time", data.create_time)
-
-                .Create(DBContext.InsertType.NORMAL, transaction);
-        }
-        private static int save_jd_parse_logs(JdDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
-        {
-            return new DBContext.Table(connection, tablename)
-                .Add("end_point", data.end_point)
-                .Add("channel", (int)data.channel)
-                .Add("accountId", data.accountId)
-                .Add("accountName", data.accountName)
-                .Add("rawContent", data.rawContent)
-                .Add("success", data.success)
-                .Add("message", data.message)
-                .Add("reason", data.reason)
-                .Add("content", data.content)
-                .Add("itemId", data.itemId)
-                .Add("itemName", data.itemName)
-                .Add("pic", data.pic)
-                .Add("couponAmount", data.couponAmount)
-                .Add("promotionPrice", data.promotionPrice)
-                .Add("taoToken", data.taoToken)
-                .Add("shortLinkurl", data.shortLinkurl)
-                .Add("deeplink_url", data.deeplink_url)
-                .Add("elapsedTime", data.elapsedTime)
-                .Add("subCode", data.subCode)
-                .Add("ip", data.ip)
-                .Add("oaid", data.oaid)
-                .Add("create_time", data.create_time)
-                .Create(DBContext.InsertType.NORMAL, transaction);
-        }
-        private static int save_pdd_parse_logs(PddDataDTO data, string tablename, IDbConnection connection, IDbTransaction transaction)
-        {
-            return new DBContext.Table(connection, tablename)
-                .Add("end_point", data.end_point)
-                .Add("channel", (int)data.channel)
-                .Add("accountId", data.accountId)
-                .Add("accountName", data.accountName)
-                .Add("rawContent", data.rawContent)
-                .Add("success", data.success)
-                .Add("message", data.message)
-                .Add("reason", data.reason)
-                .Add("content", data.content)
-                .Add("itemId", data.itemId)
-                .Add("itemName", data.itemName)
-                .Add("pic", data.pic)
-                .Add("couponAmount", data.couponAmount)
-                .Add("promotionPrice", data.promotionPrice)
-                .Add("taoToken", data.taoToken)
-                .Add("shortLinkurl", data.shortLinkurl)
-                .Add("deeplink_url", data.deeplink_url)
-                .Add("elapsedTime", data.elapsedTime)
-                .Add("subCode", data.subCode)
-                .Add("ip", data.ip)
-                .Add("oaid", data.oaid)
-                .Add("create_time", data.create_time)
-                .Create(DBContext.InsertType.NORMAL, transaction);
-        }
-        public static int BatchInsertLogDB(int limit, CSRedisClient redis)
-        {
-            int total = 0;
-            using var connection = DBContext.GetOpenConnection();
-            connection.Open();
-            using var transaction = connection.BeginTransaction();
-
-
-            string cacheKey = ":lock_key:start_comparison_tk";
-            bool start_comparison_tk = RedisHelper.Get<int>(cacheKey) > 0;
-
-
-            try
-            {
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<TkDataDTO>(queue_tb_key);
-                    if (data == null) break;
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        save_tk_log(data, "tk_logs_test", connection, transaction);
-                    }
-                    else
-                    {
-                        data.id = save_tk_log(data, "tk_logs", connection, transaction);
-                        if (data.elapsedTime > 1000)
-                        {
-                            save_tk_log(data, "tk_logs_test", connection, transaction);
-                        }
-                        if (data.success)
-                        {
-                            save_tk_log(data, "tk_success_logs", connection, transaction);
-                        }
-                        if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
-                    }
-                    total++;
-                }
-
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<JdDataDTO>(queue_jd_key);
-                    if (data == null) break;
-                    new DBContext.Table(connection, "tk_logs")
-                        .Add("end_point", data.end_point)
-                        .Add("channel", (int)data.channel)
-                        .Add("accountId", data.accountId)
-                        .Add("accountName", data.accountName)
-                        .Add("rawContent", data.rawContent)
-                        .Add("rawContent2", data.rawContent2)
-                        .Add("success", data.success)
-                        .Add("message", data.message)
-                        .Add("reason", data.reason)
-                        .Add("shortLinkurl", data.shortLinkurl)
-                        .Add("deeplink_url", data.deeplink_url)
-                        .Add("elapsedTime", data.elapsedTime)
-                        .Add("ip", data.ip)
-                        .Add("oaid", data.oaid)
-                        .Add("create_time", data.create_time)
-                        .Create(DBContext.InsertType.NORMAL, transaction);
-                    total++;
-                }
-
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<TkDataDTO>(queue_parse_tb_key);
-                    if (data == null) break;
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        save_tk_parse_logs(data, "tk_parse_logs_test", connection, transaction);
-                    }
-                    else
-                    {
-                        data.id = save_tk_parse_logs(data, "tk_parse_logs", connection, transaction);
-
-                        //每日分表
-                        if (save_dailys_log)
-                        {
-                            string daily_table = $"tk_parse_logs_{DateTime.Now:yyyyMMdd}";
-                            save_tk_parse_logs(data, daily_table, connection, transaction);
-                        }
-
-                        if (data.elapsedTime > 1000)
-                        {
-                            save_tk_parse_logs(data, "tk_parse_logs_test", connection, transaction);
-                        }
-                        if (data.success)
-                        {
-                            save_tk_parse_logs(data, "tk_success_parse_logs", connection, transaction);
-                        }
-                        if (!string.IsNullOrEmpty(data.itemId)) TkOrderTrackingCore.SaveLinkSummary(data);
-                    }
-
-                    if (data.reason.Contains("初步筛选2") && !data.rawContent.Contains("I:/kWqN5t623Hx"))
-                    {
-                        save_tk_parse_logs(data, "tk_parse_logs_test2", connection, transaction);
-                    }
-
-                    if (data.reason.Contains("初步筛选1.5"))
-                    {
-                        save_tk_parse_logs(data, "tk_parse_logs_multi_token", connection, transaction);
-                    }
-                    if (data.reason.Contains("霸下验证码"))
-                    {
-                        save_tk_parse_logs(data, "tk_parse_logs_captcha", connection, transaction);
-                    }
-                    total++;
-                }
-
-
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<JdDataDTO>(queue_parse_jd_key);
-                    if (data == null) break;
-
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        save_jd_parse_logs(data, "jd_parse_logs_test", connection, transaction);
-                    }
-                    else
-                    {
-                        save_jd_parse_logs(data, "jd_parse_logs", connection, transaction);
-
-                        if (save_dailys_log)
-                        {
-                            string daily_table = $"jd_parse_logs_{DateTime.Now:yyyyMMdd}";
-                            save_jd_parse_logs(data, daily_table, connection, transaction);
-                        }
-
-                        if (data.elapsedTime > 1000)
-                        {
-                            save_jd_parse_logs(data, "jd_parse_logs_test", connection, transaction);
-                        }
-                        if (data.success)
-                        {
-                            save_jd_parse_logs(data, "jd_parse_logs_success", connection, transaction);
-                        }
-                    }
-                    total++;
-                }
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<PddDataDTO>(queue_parse_pdd_key);
-                    if (data == null) break;
-
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        save_pdd_parse_logs(data, "pdd_parse_logs_test", connection, transaction);
-                    }
-                    else
-                    {
-                        save_pdd_parse_logs(data, "pdd_parse_logs", connection, transaction);
-                        if (data.elapsedTime > 1000)
-                        {
-                            save_pdd_parse_logs(data, "pdd_parse_logs_test", connection, transaction);
-                        }
-                        if (data.success)
-                        {
-                            save_pdd_parse_logs(data, "pdd_parse_logs_success", connection, transaction);
-                        }
-                    }
-                    total++;
-                }
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<DyDataDTO>(queue_parse_dy_key);
-                    if (data == null) break;
-                    new DBContext.Table(connection, "tk_parse_logs")
-                        .Add("end_point", data.end_point)
-                        .Add("channel", (int)data.channel)
-                        .Add("accountId", data.accountId)
-                        .Add("accountName", data.accountName)
-                        .Add("rawContent", data.rawContent)
-                        .Add("success", data.success)
-                        .Add("message", data.message)
-                        .Add("reason", data.reason)
-                        .Add("content", data.content)
-                        .Add("itemId", data.itemId)
-                        .Add("itemName", data.itemName)
-                        .Add("pic", data.pic)
-                        .Add("couponAmount", data.couponAmount)
-                        .Add("promotionPrice", data.promotionPrice)
-                        .Add("taoToken", data.taoToken)
-                        .Add("shortLinkurl", data.shortLinkurl)
-                        .Add("deeplink_url", data.deeplink_url)
-                        .Add("elapsedTime", data.elapsedTime)
-                        .Add("subCode", data.subCode)
-                        .Add("ip", data.ip)
-                        .Add("oaid", data.oaid)
-                        .Add("create_time", data.create_time)
-                        .Create(DBContext.InsertType.NORMAL, transaction);
-                    total++;
-                }
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<ToolParseDataDTO>(queue_parse_tool_key);
-                    if (data == null) break;
-
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        new DBContext.Table(connection, "tool_parse_logs_test")
-                            .Add("end_point", data.end_point)
-                            .Add("channel", (int)data.channel)
-                            .Add("rawContent", data.rawContent)
-                            .Add("success", data.success)
-                            .Add("message", data.message)
-                            .Add("reason", data.reason)
-                            .Add("content", data.content)
-                            .Add("taoToken", data.taoToken)
-                            .Add("shortLinkurl", data.shortLinkurl)
-                            .Add("deeplink_url", data.deeplink_url)
-                            .Add("elapsedTime", data.elapsedTime)
-                            .Add("ip", data.ip)
-                            .Add("oaid", data.oaid)
-                            .Add("create_time", data.create_time)
-                            .Create(DBContext.InsertType.NORMAL, transaction);
-                    }
-                    else
-                    {
-                        new DBContext.Table(connection, "tool_parse_logs")
-                            .Add("end_point", data.end_point)
-                            .Add("channel", (int)data.channel)
-                            .Add("rawContent", data.rawContent)
-                            .Add("success", data.success)
-                            .Add("message", data.message)
-                            .Add("reason", data.reason)
-                            .Add("content", data.content)
-                            .Add("taoToken", data.taoToken)
-                            .Add("shortLinkurl", data.shortLinkurl)
-                            .Add("deeplink_url", data.deeplink_url)
-                            .Add("elapsedTime", data.elapsedTime)
-                            .Add("ip", data.ip)
-                            .Add("oaid", data.oaid)
-                            .Add("create_time", data.create_time)
-                            .Create(DBContext.InsertType.NORMAL, transaction);
-                    }
-                    total++;
-                }
-
-                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++)
-                {
-                    var data = redis.LPop<UnionCouponDTO>(queue_coupon_key);
-                    if (data == null) break;
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        var test_data = data.Convert2Json().Convert2Object<TestUnionCouponDTO>();
-                        connection.Insert(test_data);
-                    }
-                    else
-                    {
-                        connection.Insert(data);
-                        if (data.success)
-                        {
-                            var success_data = data.Convert2Json().Convert2Object<SuccessUnionCouponDTO>();
-                            connection.Insert(success_data);
-                        }
-                    }
-                    total++;
-                }
-
-
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<UnionCpsDTO>(queue_cps_key);
-                    if (data == null) break;
-
-                    if ("3B191CFA4C6B48F9BA459E915B57743BEC7D424979CC9C51BCAD0C245B1C7BA2".Equals(data.oaid) ||
-                         data.ip.Contains("127.0.0"))
-                    {
-                        var test_data = data.Convert2Json().Convert2Object<TestUnionCpsDTO>();
-                        connection.Insert(test_data);
-                    }
-                    else
-                    {
-                        connection.Insert(data);
-                        if (data.success)
-                        {
-                            var success_data = data.Convert2Json().Convert2Object<SuccessUnionCpsDTO>();
-                            connection.Insert(success_data);
-                        }
-                    }
-                    total++;
-                }
-
-                for (int i = 0; i < limit; i++)
-                {
-                    var data = redis.LPop<PromotionQueryDTO>(promotion_img_key);
-                    if (data == null) break;
-
-                    if (data.success)
-                    {
-                        data.similarPromotion = string.Empty;
-                        data.promotionImg = string.Empty;
-                    }
-                    connection.Insert(data);
-                    total++;
-                }
-                transaction.Commit();
-            }
-            catch (Exception ex)
-            {
-                transaction.Rollback();
-
-                _ = new LoggerLibrary("database_error", "parse_log")
-                    .Info(ex.Message, ex.StackTrace)
-                    .SaveAsync();
-
-                NotifyCore.Notify(new NifyMessage
-                {
-                    message = $"【写入日志异常】\n{ex.Message}\n{ex.StackTrace}",
-                    priority = NifyMessagePriority.high,
-                    tags = ["red_circle"]
-                });
-            }
-            finally
-            {
-                connection.Close();
-            }
-            return total;
-        }
-
-        public static async Task PromotionImgLogAsync(PromotionQueryDTO response)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(promotion_img_key, response);
-
-                //using var connection = DBContext.GetOpenConnection();
-                //connection.Insert(response);
-                savePromotionCache(response.accountId, response.accountName, response.success, response.message, response.reason);
-            }
-            catch (Exception ex) { }
-        }
-
-        public static async Task LogAsync(JdDataDTO response)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_jd_key, response);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
-                }
-            }
-            catch (Exception ex) { }
-        }
-        public static async Task LogAsync(TkDataDTO response, AlimamaPlus? alimamaPlus = null)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_tb_key, response);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
-                }
-
-                if (!response.success && "nologin".Equals(response.message))
-                {
-                    switch (response.channel)
-                    {
-                        case TkChannelEnum.tb:
-
-                            await Task.Run(() =>
-                            {
-                                if (alimamaPlus != null)
-                                {
-                                    (bool success, string message) = alimamaPlus.RenewCookie();
-                                    if (success) return;
-                                }
-                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
-                            });
-                            break;
-                    }
-                }
-                if ("没有匹配账号".Equals(response.reason))
-                {
-                    TkPoolCore.AccountExhausted();
-                }
-            }
-            catch (Exception ex)
-            {
-                _ = new LoggerLibrary("unionParse", "database_error")
-                .Info(response.rawContent, response.rawContent2)
-                .Info(response.Convert2Json())
-                .Info(ex.Message, ex.StackTrace)
-                .SaveAsync();
-            }
-        }
-
-        public static async Task ParseLogAsync(TkDataDTO response, AlimamaPlus? alimamaPlus = null)
-        {
-#if DEBUG
-            //return;
-#endif
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_tb_key, response);
-
-
-                if (response.success)
-                {
-                    _ = saveUnionCouponParseCacheAsync(response);
-                }
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    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))
-                {
-                    switch (response.channel)
-                    {
-                        case TkChannelEnum.tb:
-                            await Task.Run(() =>
-                            {
-                                if (alimamaPlus != null)
-                                {
-                                    (bool success, string message) = alimamaPlus.RenewCookie();
-                                    if (success) return;
-                                }
-                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
-                            }); break;
-                    }
-                }
-                if (response.subCode == TkSubCodeEnum.Captcha || "霸下验证码".Equals(response.reason))
-                {
-                    TkPoolCore.Suspend(response.end_point, response.accountId, response.accountName, "霸下验证码");
-                }
-            }
-            catch (Exception ex)
-            {
-                _ = new LoggerLibrary("unionParse", "database_error")
-                .Info(response.rawContent)
-                .Info(response.Convert2Json())
-                .Info(ex.Message, ex.StackTrace)
-                .SaveAsync();
-            }
-        }
-
-        public static async Task CouponLogAsync(UnionCouponDTO response, AlimamaPlus? alimamaPlus = null)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_coupon_key, response);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveCouponCache(response.channel.ToString(), response.accountId, response.accountName, response.success, response.message, response.reason);
-                }
-                if (!response.success && "nologin".Equals(response.message))
-                {
-                    switch (response.channel)
-                    {
-                        case TkChannelEnum.tb:
-                            await Task.Run(() =>
-                            {
-                                if (alimamaPlus != null)
-                                {
-                                    (bool success, string message) = alimamaPlus.RenewCookie();
-                                    if (success) return;
-                                }
-                                TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}");
-                            }); break;
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                _ = new LoggerLibrary("unionCoupon", "database_error")
-                .Info(response.rawContent)
-                .Info(response.Convert2Json())
-                .Info(ex.Message, ex.StackTrace)
-                .SaveAsync();
-            }
-        }
-        public static async Task CpsLogAsync(UnionCpsDTO response, AlimamaPlus? alimamaPlus = null)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_cps_key, response);
-
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveCpsCache(response.channel.ToString(), response.accountId,
-                        response.success, response.message, response.reason);
-                }
-            }
-            catch (Exception ex)
-            {
-                _ = new LoggerLibrary("unionCps", "database_error")
-                .Info(response.rawContent)
-                .Info(response.Convert2Json())
-                .Info(ex.Message, ex.StackTrace)
-                .SaveAsync();
-            }
-        }
-        public static async Task ParseLogAsync(JdDataDTO response)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_jd_key, response);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveParseCache(response.channel.ToString(), response.accountId,
-                        response.accountName, response.success, response.message, response.reason,
-                        response.deeplink_url);
-                }
-
-                if (response.success || response.message.Equals("转链失败"))
-                {
-                    JdPoolCore.CallsIncrBy(response.accountId);
-                }
-                //CallsIncrBy
-
-                if (response.success) saveClientRequestTotal(response.channel, response.ip, response.oaid);
-
-                if (!response.success && ("nologin".Equals(response.reason) ||
-                    "方法不存在".Equals(response.reason) ||
-                    "未登录".Equals(response.reason)))
-                {
-                    await Task.Run(() =>
-                    {
-                        JdPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
-                    });
-                    //switch (response.channel)
-                    //{
-                    //    case TkChannelEnum.tb:
-
-                    //        //await Task.Run(() =>
-                    //        //{
-                    //        //    if (alimamaPlus != null)
-                    //        //    {
-                    //        //        (bool success, string message) = alimamaPlus.RenewCookie();
-                    //        //        if (success) return;
-                    //        //    }
-                    //        //    TkPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
-                    //        //});
-                    //        break;
-                    //}
-                }
-                if ("没有匹配账号".Equals(response.reason))
-                {
-                    JdPoolCore.AccountExhausted();
-                }
-            }
-            catch (Exception ex) { }
-        }
-        public static async Task ParseLogAsync(PddDataDTO response)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_pdd_key, response);
-
-
-#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.elapsedTime > 1000)
-                        {
-                            save_pdd_parse_logs(data, "pdd_parse_logs_test", 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,
-                        response.accountName, response.success, response.message, response.reason,
-                        response.deeplink_url);
-                }
-
-                if (response.success || response.message.Equals("转链失败"))
-                {
-                    PddPoolCore.CallsIncrBy(response.accountId);
-                }
-
-                if (response.reason.Equals("您的调用次数过高"))
-                {
-                    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)))
-                {
-                    await Task.Run(() =>
-                    {
-                        PddPoolCore.Disabled(response.accountId, response.accountName, $"{response.rawContent}\n{response.rawContent2}");
-                    });
-                }
-                if ("没有匹配账号".Equals(response.reason))
-                {
-                    PddPoolCore.AccountExhausted();
-                }
-            }
-            catch (Exception ex) { }
-        }
-
-        public static async Task ParseLogAsync(DyDataDTO response)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_dy_key, response);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveParseCache(response.channel.ToString(), response.accountId,
-                        response.accountName, response.success, response.message, response.reason,
-                        response.deeplink_url);
-                }
-
-            }
-            catch (Exception ex) { }
-        }
-        public static async Task ParseLogAsync(ToolParseDataDTO response)
-        {
-            try
-            {
-                var ts = DateTime.Now - response.create_time;
-                response.elapsedTime = (int)ts.TotalMilliseconds;
-                _ = RedisHelper.RPushAsync(queue_parse_tool_key, response);
-
-                if (!response.ip.Contains("127.0.0"))
-                {
-                    saveParseCache(response.channel.ToString(), 0, "tool",
-                        response.success, response.message, response.reason,
-                        response.deeplink_url);
-                }
-            }
-            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)
-        {
-            saveAccountCache("all", success, message, reason);
-            saveAccountCache($"{channel}", success, message, reason);
-            saveAccountCache($"{accountName}", success, message, reason);
-            if (accountId != 0)
-            {
-                //todo 放着跑两天,要将读取的地方改成读取accountid
-                saveAccountCache($"{channel}_{accountId}", success, message, reason);
-            }
-        }
-
-        private static void saveAccountCache(string accountName, bool success, string message, string reason)
-        {
-            RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":total:{accountName}:{DateTime.Now:yyyyMMddHH}");
-
-
-            string result = success ? "success" : "fail";
-            RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
-
-
-            if (!string.IsNullOrEmpty(message))
-            {
-                RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
-                RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
-                RedisHelper.SAdd($":total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
-
-                RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
-
-                RedisHelper.IncrBy($":total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-            if (!string.IsNullOrEmpty(reason))
-            {
-                RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
-                RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
-                RedisHelper.SAdd($":total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
-
-                RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
-
-
-                RedisHelper.IncrBy($":total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-        }
-
-        private static async Task saveUnionCouponParseCacheAsync(TkDataDTO data)
-        {
-            string cacheKey = $":cache:parse:{data.ip}_{data.oaid}_{data.itemId}";
-            await EndPointCore.ProcessEndPointNodesAsync(node =>
-            {
-                if (!node.is_coupon_api) return Task.CompletedTask;
-                if (string.IsNullOrEmpty(node.redis_server)) return Task.CompletedTask;
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                redis.Set(cacheKey, 1, 2 * 86400);
-                return Task.CompletedTask;
-            });
-        }
-        private static void saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
-        {
-            string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
-            RedisHelper.IncrBy(cacheKey);
-            RedisHelper.Expire(cacheKey, 86400);
-
-            if (!string.IsNullOrEmpty(oaid))
-            {
-                cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
-                RedisHelper.IncrBy(cacheKey);
-                RedisHelper.Expire(cacheKey, 86400);
-            }
-        }
-        public static int getClientRequestTotalByOAID(TkChannelEnum channel, string oaid)
-        {
-            if (string.IsNullOrEmpty(oaid)) return 0;
-            string cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
-            return RedisHelper.Get<int>(cacheKey);
-        }
-        public static int getClientRequestTotalByIp(TkChannelEnum channel, string ip)
-        {
-            if (string.IsNullOrEmpty(ip)) return 0;
-            string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
-            return RedisHelper.Get<int>(cacheKey);
-        }
-
-
-        private static void saveClientRequestTotal(CpsChannelEnum channel, string ip, string oaid)
-        {
-            string cacheKey = $":cache:cps_{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
-            RedisHelper.IncrBy(cacheKey);
-            RedisHelper.Expire(cacheKey, 86400);
-
-            if (!string.IsNullOrEmpty(oaid))
-            {
-                cacheKey = $":cache:cps_{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
-                RedisHelper.IncrBy(cacheKey);
-                RedisHelper.Expire(cacheKey, 86400);
-            }
-        }
-        public static int getClientRequestTotalByOAID(CpsChannelEnum channel, string oaid)
-        {
-            if (string.IsNullOrEmpty(oaid)) return 0;
-            string cacheKey = $":cache:cps_{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
-            return RedisHelper.Get<int>(cacheKey);
-        }
-        public static int getClientRequestTotalByIp(CpsChannelEnum channel, string ip)
-        {
-            if (string.IsNullOrEmpty(ip)) return 0;
-            string cacheKey = $":cache:cps_{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
-            return RedisHelper.Get<int>(cacheKey);
-        }
-
-
-
-
-
-        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);
-            if (accountId != 0)
-            {
-                //todo 放着跑两天,要将读取的地方改成读取accountid
-                saveParseAccountCache($"{channel}_{accountId}", success, message, 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}");
-
-
-            string result = success ? "success" : "fail";
-            RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":parse_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
-
-
-            if (!string.IsNullOrEmpty(message))
-            {
-                RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
-                RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
-                RedisHelper.SAdd($":parse_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
-
-                RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-            if (!string.IsNullOrEmpty(reason))
-            {
-                RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
-                RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
-                RedisHelper.SAdd($":parse_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
-
-                RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
-
-                RedisHelper.IncrBy($":parse_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":parse_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
-            }
-        }
-
-        private static void savePromotionCache(int accountId, string accountName, bool success, string message, string reason)
-        {
-            savePromotionAccountCache("all", success, message, reason);
-            savePromotionAccountCache($"{accountId}", success, message, reason);
-        }
-
-        private static void savePromotionAccountCache(string accountName, bool success, string message, string reason)
-        {
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
-
-
-            string result = success ? "success" : "fail";
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":promotion_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
-
-
-            if (!string.IsNullOrEmpty(message))
-            {
-                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
-                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
-                RedisHelper.SAdd($":promotion_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
-
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-            if (!string.IsNullOrEmpty(reason))
-            {
-                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
-                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
-                RedisHelper.SAdd($":promotion_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
-
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":promotion_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
-            }
-        }
-
-
-        private static void saveCouponCache(string channel, int accountId, string accountName, bool success, string message, string reason)
-        {
-            saveAccountCouponCache("all", success, message, reason);
-            saveAccountCouponCache($"{channel}", success, message, reason);
-            if (accountId != 0)
-            {
-                saveAccountCouponCache($"{channel}_{accountId}", success, message, reason);
-            }
-        }
-
-        private static void saveAccountCouponCache(string accountName, bool success, string message, string reason)
-        {
-            RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":coupon_total:{accountName}:{DateTime.Now:yyyyMMddHH}");
-
-
-            string result = success ? "success" : "fail";
-            RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":coupon_total:{accountName}:{result}:{DateTime.Now:yyyyMMddHH}");
-
-
-            if (!string.IsNullOrEmpty(message))
-            {
-                RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMM}", message);
-                RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMMdd}", message);
-                RedisHelper.SAdd($":coupon_total:{accountName}:message:{DateTime.Now:yyyyMMddHH}", message);
-
-                RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:{message}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:message:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-            if (!string.IsNullOrEmpty(reason))
-            {
-                RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMM}", reason);
-                RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMMdd}", reason);
-                RedisHelper.SAdd($":coupon_total:{accountName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
-
-                RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:{reason}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":coupon_total:{accountName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-        }
-
-
-
-        private static void saveCpsCache(string channel, int accountId, bool success, string message, string reason)
-        {
-            saveAccountCpsCache("all", success, message, reason);
-            saveAccountCpsCache($"{channel}", success, message, reason);
-            if (accountId != 0)
-            {
-                saveAccountCpsCache($"{channel}_{accountId}", success, message, reason);
-            }
-        }
-
-        private static void saveAccountCpsCache(string flagName, bool success, string message, string reason)
-        {
-            RedisHelper.IncrBy($":cps_total:{flagName}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":cps_total:{flagName}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":cps_total:{flagName}:{DateTime.Now:yyyyMMddHH}");
-
-
-            string result = success ? "success" : "fail";
-            RedisHelper.IncrBy($":cps_total:{flagName}:{result}:{DateTime.Now:yyyyMM}");
-            RedisHelper.IncrBy($":cps_total:{flagName}:{result}:{DateTime.Now:yyyyMMdd}");
-            RedisHelper.IncrBy($":cps_total:{flagName}:{result}:{DateTime.Now:yyyyMMddHH}");
-
-
-            if (!string.IsNullOrEmpty(message))
-            {
-                RedisHelper.SAdd($":cps_total:{flagName}:message:{DateTime.Now:yyyyMM}", message);
-                RedisHelper.SAdd($":cps_total:{flagName}:message:{DateTime.Now:yyyyMMdd}", message);
-                RedisHelper.SAdd($":cps_total:{flagName}:message:{DateTime.Now:yyyyMMddHH}", message);
-
-                RedisHelper.IncrBy($":cps_total:{flagName}:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:{message}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:message:{message}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:message:{message}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:message:{message}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-            if (!string.IsNullOrEmpty(reason))
-            {
-                RedisHelper.SAdd($":cps_total:{flagName}:reason:{DateTime.Now:yyyyMM}", reason);
-                RedisHelper.SAdd($":cps_total:{flagName}:reason:{DateTime.Now:yyyyMMdd}", reason);
-                RedisHelper.SAdd($":cps_total:{flagName}:reason:{DateTime.Now:yyyyMMddHH}", reason);
-
-                RedisHelper.IncrBy($":cps_total:{flagName}:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:{reason}:{DateTime.Now:yyyyMMddHH}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:reason:{reason}:{DateTime.Now:yyyyMM}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:reason:{reason}:{DateTime.Now:yyyyMMdd}");
-                RedisHelper.IncrBy($":cps_total:{flagName}:reason:{reason}:{DateTime.Now:yyyyMMddHH}");
-            }
-
-        }
-
-        public static int GetTotal(string keyname, bool all_node = true)
-        {
-            //:coupon_total:tb:20240706
-            //:coupon_total:tb:success:20240706
-            //:coupon_total:tb:放弃转链:20240706
-
-            var result = EndPointCore.ProcessEndPointNodes<int>(node =>
-            {
-                if (!node.is_public_api) return 0;
-                if (string.IsNullOrEmpty(node.redis_server)) return 0;
-
-                if (!all_node)
-                {
-                    if (CenterHub.IsCenter)
-                    {
-                        if (node.is_coupon_api) { return 0; }
-                    }
-                    else
-                    {
-                        if (!node.is_coupon_api) { return 0; }
-                    }
-                }
-
-#if DEBUG
-                switch (node.name)
-                {
-
-                    case "bj":
-                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "gz":
-                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
-                        break;
-                    case "coupon1":
-                        node.redis_server = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
-                        break;
-                    default: return 0;
-                }
-
-#endif
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-                int count = redis.Get<int>(keyname);
-                return count;
-            });
-            return result.Sum();
-        }
-
-        public static string[] GetTotalKeys(string keyname, bool all_node = true)
-        {
-
-            var result = EndPointCore.ProcessEndPointNodes<string[]>(node =>
-            {
-                if (!node.is_public_api) return [];
-                if (string.IsNullOrEmpty(node.redis_server)) return [];
-
-                if (!all_node)
-                {
-                    if (CenterHub.IsCenter)
-                    {
-                        if (node.is_coupon_api) { return []; }
-                    }
-                    else
-                    {
-                        if (!node.is_coupon_api) { return []; }
-                    }
-                }
-#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 [];
-                }
-#endif
-
-                var redis = RedisClientManager.GetRedisClient(node.redis_server);
-
-                string[] message_keys = redis.SMembers(keyname);
-                return message_keys;
-            });
-
-            string[] message_keys = [];
-            foreach (var arr in result)
-            {
-                message_keys = message_keys.Union(arr).ToArray();
-            }
-            return message_keys;
-        }
-
-
-        //if (item.total_count > 0) continue;
-        //item.total_count = RedisHelper.Get<int>($":total:all:{item.report_date:yyyyMMdd}");
-        //if (item.total_count == 0) continue;
-        //item.success_count = RedisHelper.Get<int>($":total:all:success:{item.report_date:yyyyMMdd}");
-        //item.abandon_count = RedisHelper.Get<int>($":total:all:放弃转链:{item.report_date:yyyyMMdd}");
-
-
-
-
-    }
-
-}

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

@@ -9,6 +9,7 @@
         vipshop = 4,
         tmall = 5,
         xhs = 6,
+        ks = 7,
 
 
         tool = 100,

+ 33 - 0
molilian.core/DTO/ks/KsDataDTO.cs

@@ -0,0 +1,33 @@
+namespace molilian.core
+{
+    public class KsDataDTO
+    {
+        public TkChannelEnum channel { get; set; }
+        public LinkTypeEnum link_type { get; set; }
+        public int accountId { get; set; } = 0;
+        public string accountName { get; set; } = string.Empty;
+        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 taoToken { get; set; } = string.Empty;
+        public string rawContent { get; set; } = string.Empty;
+        public string rawContent2 { get; set; } = string.Empty;
+        public string ip { get; set; } = string.Empty;
+        public string oaid { get; set; } = string.Empty;
+
+        public string itemId { get; set; } = string.Empty;
+        public string itemName { get; set; } = string.Empty;
+        public decimal couponAmount { get; set; } = 0;
+        public decimal promotionPrice { get; set; } = 0;
+        public string pic { get; set; } = string.Empty;
+
+        public string shortLinkurl { get; set; } = string.Empty;
+        public string deeplink_url { 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;
+        public int subCode { get; set; } = 0;
+    }
+
+}

+ 53 - 0
molilian.core/DTO/ks/KsPoolDTO.cs

@@ -0,0 +1,53 @@
+namespace molilian.core
+{
+    public enum KsUnionWorkMode
+    {
+        SiteApi = 1,
+        Crawler = 3,
+
+    }
+    public class KsPoolDTO
+    {
+        public int id { get; set; }
+        public string name { get; set; } = string.Empty;
+        public string company { get; set; } = string.Empty;
+        public string description { get; set; } = string.Empty;
+        public string pid { get; set; } = string.Empty;
+        public string app_key { get; set; } = string.Empty;
+        public string app_secret { get; set; } = string.Empty;
+        public string sign_secret { get; set; } = string.Empty;
+        public string event_secret { get; set; } = string.Empty;
+
+        public DateTime create_time { get; set; } = DateTime.Now;
+        public DateTime last_time { get; set; } = DateTime.Now;
+        public DateTime login_time { get; set; } = DateTime.Now;
+        public bool status { get; set; }
+        public KsUnionWorkMode work_mode { get; set; } = KsUnionWorkMode.SiteApi;
+        public string user_agent { get; set; } = string.Empty;
+        public string cookies { get; set; } = string.Empty;
+
+        public string nodeName { get; set; } = string.Empty;
+        public string end_point { get; set; } = string.Empty;
+        public decimal current_amt { get; set; } = 0;
+        public int current_daily_calls { get; set; } = 0;
+        public int current_hourly_calls { get; set; } = 0;
+        public decimal daily_income_limit { get; set; } = 0;
+        public int daily_calls_limit { get; set; } = 0;
+        public int hourly_calls_limit { 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 int today_clickNum { get; set; } = 0;
+        public decimal today_cosFee { get; set; } = 0;
+        public decimal today_cosPrice { get; set; } = 0;
+        public decimal today_finishCosFee { get; set; } = 0;
+        public decimal today_finishCosPrice { get; set; } = 0;
+        public int today_finishOrderNum { get; set; } = 0;
+        public int today_orderNum { get; set; } = 0;
+        public bool is_hide { get; set; } = false;
+
+    }
+}