Pārlūkot izejas kodu

增加 enable_call_stats;
淘宝联盟增加 is_hide;

dodo hold 1 gadu atpakaļ
vecāks
revīzija
f353743919

+ 13 - 4
molilian.api/Controllers/admin/ReportController.cs

@@ -3,6 +3,7 @@ using dodohold.core;
 using Microsoft.AspNetCore.Mvc;
 using System.Text.Json;
 using static molilian.core.ChartDataCore;
+using Org.BouncyCastle.Asn1;
 namespace molilian.api.Controllers
 {
     [ApiController]
@@ -28,7 +29,6 @@ namespace molilian.api.Controllers
 
             string sort = form.Read<string>("sort");
             string order = form.Read<string>("order");
-
             string filter = string.Empty;
 
             var log_date = form.PathReadArray<string>("query_date[]");
@@ -76,11 +76,20 @@ namespace molilian.api.Controllers
                 .Page(size, page)
                 .Order(orderBy)
                 .PageList<DailyLogsDTO>(getTotal);
+             
+            var jd_accounts = await JdPoolCore.AllListAsync();
+            var jd_hide_ids = jd_accounts.Where(e => e.is_hide).Select(e => e.id).ToList();
+            result.List = result.List.Where(e => e.channel != 1 || !jd_hide_ids.Contains(e.accountId));
+
+
+            var tb_accounts = await TkPoolCore.AllListAsync();
+            var tb_hide_ids = tb_accounts.Where(e => e.is_hide).Select(e => e.id).ToList();
+            result.List = result.List.Where(e => e.channel != 0 || !tb_hide_ids.Contains(e.accountId));
 
+            var pdd_accounts = await PddPoolCore.AllListAsync();
+            var pdd_hide_ids = tb_accounts.Where(e => e.is_hide).Select(e => e.id).ToList();
+            result.List = result.List.Where(e => e.channel != 3 || !pdd_hide_ids.Contains(e.accountId));
 
-            var accounts = await JdPoolCore.ListAsync();
-            var hide_ids = accounts.Where(e => e.is_hide).Select(e => e.id).ToList();
-            result.List = result.List.Where(e => e.channel != 1 || !hide_ids.Contains(e.accountId));
             return new APIResult(new { data = result });
         }
 

+ 6 - 1
molilian.api/Controllers/admin/TaobaoController.cs

@@ -152,7 +152,7 @@ namespace molilian.api.Controllers
             string sort = form.Read<string>("sort");
             string order = form.Read<string>("order");
 
-            string filter = string.Empty;
+            string filter = "is_hide=0";
             if (!string.IsNullOrEmpty(keyword))
             {
                 filter += $" AND (`name` LIKE @keyword OR `description` LIKE @keyword)";
@@ -497,6 +497,11 @@ namespace molilian.api.Controllers
 
 
 
+            var tb_accounts = await TkPoolCore.AllListAsync();
+            var tb_hide_ids = tb_accounts.Where(e => e.is_hide).Select(e => e.id).ToList();
+            result.List = result.List.Where(e => !tb_hide_ids.Contains(e.accountId));
+
+
             foreach (var item in result.List)
             {
 #if DEBUG

+ 4 - 0
molilian.api/Controllers/admin/TaobaoOrderController.cs

@@ -37,6 +37,10 @@ namespace molilian.api.Controllers
             {
                 filter += $" AND accountId IN (SELECT ID FROM tk_pool WHERE company=@name)";
             }
+            else
+            {
+                filter += $" AND accountId NOT IN (SELECT ID FROM tk_pool WHERE is_hide=1)";
+            }
             if (tkStatus.Any())
             {
                 filter += $" AND tkStatus IN @tkStatus";

+ 9 - 0
molilian.api/Controllers/public/TaskController.cs

@@ -102,6 +102,7 @@ namespace molilian.api.Controllers
 #if DEBUG
                 if (13 != account.id) continue;
 #endif
+                if (account.is_hide) continue;
                 try
                 {
                     var alimama = new AlimamaPlus(account);
@@ -136,6 +137,7 @@ namespace molilian.api.Controllers
             {
 
                 if (id != account.id) continue;
+                if (account.is_hide) continue;
 
                 try
                 {
@@ -175,6 +177,7 @@ namespace molilian.api.Controllers
                 if (account.id != 17) continue;
 #endif
                 if (!account.enable_sync_order) continue;
+                if (account.is_hide) continue;
 
                 try
                 {
@@ -210,6 +213,7 @@ namespace molilian.api.Controllers
 #if DEBUG
                 if (account.id != id) continue;
 #endif
+                if (account.is_hide) continue;
                 try
                 {
                     var alimama = new AlimamaPlus(account);
@@ -244,6 +248,7 @@ namespace molilian.api.Controllers
             {
 
                 if (id != account.id) continue;
+                if (account.is_hide) continue;
 
                 try
                 {
@@ -283,6 +288,7 @@ namespace molilian.api.Controllers
                 if (account.id != 17) continue;
 #endif
                 if (!account.enable_sync_order) continue;
+                if (account.is_hide) continue;
 
                 try
                 {
@@ -523,6 +529,7 @@ namespace molilian.api.Controllers
             {
                 foreach (var account in list)
                 {
+                    if (account.is_hide) continue;
                     try
                     {
                         account.current_daily_calls = await RiskControlCore.GetAllNodesCallsAsync(TkChannelEnum.tb, account.id, DateTime.Now.ToString("yyyyMMdd"));
@@ -710,6 +717,7 @@ namespace molilian.api.Controllers
 #if DEBUG
                     if (account.id != 5) continue;
 #endif
+                    if (account.is_hide) continue;
                     try
                     {
                         var alimama = new AlimamaPlus(account);
@@ -838,6 +846,7 @@ namespace molilian.api.Controllers
             foreach (var account in list)
             {
                 if (id != account.id) continue;
+                if (account.is_hide) continue;
                 try
                 {
                     var alimama = new AlimamaPlus(account);

+ 0 - 1
molilian.api/Controllers/public/TkController.cs

@@ -625,7 +625,6 @@ namespace molilian.api.Controllers
 
             try
             {
-
                 //0:全分销类型;-1:各分销类型,1:goods 2: live 3:video 4: profile 5: unknown
                 int distributiontype = form.Read("distributiontype", 0);
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
molilian.api/Properties/PublishProfiles/latest.pubxml.user


+ 1 - 1
molilian.api/molilian.api.csproj.user

@@ -2,7 +2,7 @@
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <ActiveDebugProfile>http</ActiveDebugProfile>
-    <NameOfLastUsedPublishProfile>E:\project\2024\molilian\server\molilian.api\Properties\PublishProfiles\tester.pubxml</NameOfLastUsedPublishProfile>
+    <NameOfLastUsedPublishProfile>E:\project\2024\molilian\server\molilian.api\Properties\PublishProfiles\latest.pubxml</NameOfLastUsedPublishProfile>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>

+ 40 - 0
molilian.core/Core/pdd/PddPoolCore.cs

@@ -13,6 +13,7 @@ using System.Text.Json;
 using TencentCloud.Tcm.V20210413.Models;
 using System.Security.Cryptography;
 using System.Collections.Concurrent;
+using YunhuiKit;
 
 
 namespace molilian.core
@@ -21,10 +22,14 @@ namespace molilian.core
     {
         private static readonly object _lockObj = new();
         private static IEnumerable<PddPoolDTO> _cached;
+        private static IEnumerable<PddPoolDTO> _all_cached;
 
         private static string _end_point;
         private static Dictionary<string, decimal> _incomeAmt = new();
         private static ConcurrentDictionary<int, DateTime> _suspend = new();
+
+        private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
+
         static PddPoolCore()
         {
             _end_point = Environment.GetEnvironmentVariable("EndPoint");
@@ -77,6 +82,41 @@ namespace molilian.core
             return true;
         }
 
+
+
+        public static async Task<IEnumerable<PddPoolDTO>> AllListAsync(bool force = false)
+        {
+            if (!force && _all_cached != default) return _all_cached;
+
+            try
+            {
+                await _semaphore.WaitAsync();
+
+                string cache_key = $"cache:all_pdd_pool";
+                var list = await RedisKit.GetAsync<IEnumerable<PddPoolDTO>>(cache_key);
+
+                if (force || list == default)
+                {
+                    list = new DBContext.Table("pdd_pool").Select<PddPoolDTO>();
+                    if (list == null) return default;
+
+                    // 等待 Redis 写入完成
+                    await RedisKit.SetAsync(cache_key, list, 30 * 86400);
+                }
+
+                _all_cached = list;
+                return list;
+            }
+            catch (Exception)
+            {
+                // 发生异常时返回上一次的缓存,如果没有则返回默认值
+                return _all_cached ?? default;
+            }
+            finally
+            {
+                _semaphore.Release();
+            }
+        }
         public static IEnumerable<PddPoolDTO> List(bool force = false)
         {
             if (!force && _cached != null) return _cached;

+ 38 - 0
molilian.core/Core/taoke/TkPoolCore.cs

@@ -10,6 +10,7 @@ using Spire.Pdf.Exporting.XPS.Schema;
 using System.Xml.Linq;
 using System.Net;
 using TencentCloud.Mrs.V20200910.Models;
+using YunhuiKit;
 
 
 namespace molilian.core
@@ -33,6 +34,7 @@ namespace molilian.core
         private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
 
         private static IEnumerable<TkPoolDTO> _cached;
+        private static IEnumerable<TkPoolDTO> _all_cached;
         public static async Task<TkPoolDTO> GetOneAsync(TkAction action)
         {
             var list = await ListAsync();
@@ -87,6 +89,42 @@ namespace molilian.core
             return income_amt < item.daily_income_limit;
         }
 
+
+
+        public static async Task<IEnumerable<TkPoolDTO>> AllListAsync(bool force = false)
+        {
+            if (!force && _all_cached != default) return _all_cached;
+
+            try
+            {
+                await _semaphore.WaitAsync();
+
+                string cache_key = $"cache:all_tk_pool";
+                var list = await RedisKit.GetAsync<IEnumerable<TkPoolDTO>>(cache_key);
+
+                if (force || list == default)
+                {
+                    list = new DBContext.Table("tk_pool").Select<TkPoolDTO>();
+                    if (list == null) return default;
+
+                    // 等待 Redis 写入完成
+                    await RedisKit.SetAsync(cache_key, list, 30 * 86400);
+                }
+
+                _all_cached = list;
+                return list;
+            }
+            catch (Exception)
+            {
+                // 发生异常时返回上一次的缓存,如果没有则返回默认值
+                return _all_cached ?? default;
+            }
+            finally
+            {
+                _semaphore.Release();
+            }
+        }
+
         public static async Task<IEnumerable<TkPoolDTO>> ListAsync(bool force = false)
         {
             // 内存缓存检查

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

@@ -56,5 +56,7 @@
         public string appSecret { get; set; } = string.Empty;
         public string open_pid { get; set; } = string.Empty;
         public bool is_banned { get; set; } = false;
+        public bool is_hide { get; set; } = true;
+        public bool enable_call_stats { get; set; } = true;
     }
 }

+ 1 - 0
molilian.core/DTO/jd/JdPoolDTO.cs

@@ -49,6 +49,7 @@
         public int today_finishOrderNum { get; set; } = 0;
         public int today_orderNum { get; set; } = 0;
         public bool is_hide { get; set; } = false;
+        public bool enable_call_stats { get; set; } = true;
 
     }
 }

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

@@ -46,6 +46,6 @@ namespace molilian.core
         public bool enable_coupon { get; set; } = false;
         public bool enable_sync_order { get; set; } = false;
         public bool is_hide { get; set; } = true;
-
+        public bool enable_call_stats { get; set; } = true;
     }
 }

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

@@ -155,6 +155,8 @@ namespace molilian.core
 
             foreach (var account in accounts)
             {
+                if (!account.enable_call_stats) continue;
+
                 int accountId = account.id;
                 string accountName = $"{TkChannelEnum.tb}_{account.id}";
 
@@ -444,9 +446,6 @@ namespace molilian.core
                             decimal feeAmount = Math.Round(0.01m * (decimal)exist_report_dailys.feeAmount, 2);
                             decimal orderAmount = Math.Round(0.01m * (decimal)exist_report_dailys.orderAmount, 2);
 
-
-
-
                             update.Add("uclk_uv", 0)
                                 .Add("pay_ord_uv", 0)//付款人数
                                 .Add("uclk_pv", 0) //点击量 点击次数
@@ -664,7 +663,7 @@ namespace molilian.core
         private async Task EachSaveReportOverviewAsync(DateTime report_date, string tableName, TkReportDTO data)
         {
             var exist = new DBContext.Table(tableName)
-                 .Fields("id,report_date")
+                 .Fields("id, report_date")
                  .Get<dynamic>("report_date=@report_date AND accountId=@accountId",
                                  new { report_date, accountId = _accountId });
 

+ 2 - 2
molilian.core/Plus/JDUnion/H5stHack.cs

@@ -13,7 +13,7 @@ namespace molilian.core
             string useragent = _account.user_agent;
             if (string.IsNullOrEmpty(useragent)) useragent = ProviderFakeUserAgent.RandomComputer;
 #if DEBUG
-            _config.jd_h5st_sign_version = "5.0.6";
+            //_config.jd_h5st_sign_version = "5.0.6";
 #endif
             var args = new
             {
@@ -51,10 +51,10 @@ namespace molilian.core
                 string qs = root.PathRead<string>("body.qs");
                 if (code == 200)
                 {
+                    _ = new LoggerLibrary("JdUnion", "h5st").Info("ok").SaveAsync();
                     return qs;
                 }
                 _ = new LoggerLibrary("JdUnion", "h5st").Info(body).SaveAsync();
-
             }
             catch (Exception ex)
             {

+ 2 - 0
molilian.core/Plus/JDUnion/JdDailyLogs.cs

@@ -36,6 +36,8 @@ namespace molilian.core
             int all_total_count = 0, all_success_count = 0, all_abandon_count = 0;
             foreach (var account in accounts)
             {
+                if (!account.enable_call_stats) continue;
+
                 int accountId = account.id;
                 string accountName = $"{channelEnum}_{account.id}";
                 //if (account.is_hide) continue;

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

@@ -88,6 +88,7 @@ namespace molilian.core
                             var update = new DBContext.Table("jd_spread_report")
                                 .Add("accountId", _account.id)
                                 .Add("accountName", _account.name)
+                                .Add("is_hide", _account.is_hide)
                                 .Add("clickNum", report.clickNum)
                                 .Add("cosFee", report.cosFee)
                                 .Add("cosPrice", report.cosPrice)

+ 1 - 1
molilian.core/Plus/JDUnion/goods.cs

@@ -204,7 +204,7 @@ namespace molilian.core
                 result.message = "转链失败";
                 result.reason = "签名失败";
                 result.shortLinkurl = wareUrl;
-                result.deeplink_url = GetDefaultStyleDeeplink(result.shortLinkurl);
+                result.deeplink_url =  (result.shortLinkurl);
                 return result;
             }
 

+ 2 - 3
molilian.core/Plus/pdd/PddDailyLogs.cs

@@ -34,12 +34,11 @@ namespace molilian.core
             using var conn = CenterHub.GetOpenConnection();
 
 
-
             int all_total_count = 0, all_success_count = 0, all_abandon_count = 0;
             foreach (var account in accounts)
             {
-                //跳过隐藏的
-                if (account.is_hide) continue;
+                if (!account.enable_call_stats) continue;
+                //if (account.is_hide) continue;
 
                 int accountId = account.id;
                 string accountName = $"{channelEnum}_{account.id}";

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels