Selaa lähdekoodia

增加多多推广效果数据和api接口返回多多数据

dodo hold 1 vuosi sitten
vanhempi
sitoutus
530469535b

+ 99 - 1
molilian.api/Controllers/admin/PddUnionController.cs

@@ -114,7 +114,7 @@ namespace molilian.api.Controllers
                 .Page(size, page)
                 .Order(orderBy)
                 .PageList<PddPoolDTO>(getTotal);
-                
+
             foreach (var item in result.List)
             {
                 item.app_secret = string.Empty;
@@ -143,6 +143,7 @@ namespace molilian.api.Controllers
             {
                 case "enable_parse":
                 case "enable_coupon":
+                case "cookie_status":
                 case "status":
                     bool bVal = val.Equals("True");
                     result = new DBContext.Table("pdd_pool")
@@ -175,6 +176,103 @@ namespace molilian.api.Controllers
             });
         }
 
+        [HttpPost]
+        public ActionResult estimate_revenue_total([FromBody] JsonElement form)
+        {
+            int page = form.Read("current", 1);
+            int size = form.Read("pageSize", 10);
+            bool getTotal = form.Read("getTotal", true);
+            string sort = form.Read<string>("sort");
+            string order = form.Read<string>("order");
+
+            var report_date = form.PathReadArray<string>("query_date[]");
+
+            string filter = string.Empty;
+            DateTime stime = DateTime.MinValue, etime = DateTime.MinValue;
+            if (report_date.Count == 2)
+            {
+                if (DateTime.TryParse(report_date[0], out stime) && DateTime.TryParse(report_date[1], out etime))
+                {
+                    etime = etime.AddDays(1).AddSeconds(-1);
+                    filter += $" AND report_date BETWEEN @stime AND @etime";
+                }
+            }
+
+            filter = filter.StringTrimStart(" AND ");
+
+            //排序
+            string orderBy = "report_date DESC";
+            if (!string.IsNullOrEmpty(order))
+            {
+                order = "descending".Equals(order) ? "DESC" : "ASC";
+                orderBy = sort switch
+                {
+                    _ => $"{sort} {order}",
+                };
+            }
+            var result = new DBContext.Table("v_pdd_estimate_revenue")
+                .Where(filter, new { stime, etime })
+                .Page(size, page)
+                .Order(orderBy)
+                .PageList<PddEstimateRevenueDTO>(getTotal);
+
+            return new APIResult(new { data = result });
+        }
+
+
+        [HttpPost]
+        public ActionResult estimate_revenue([FromBody] JsonElement form)
+        {
+            int page = form.Read("current", 1);
+            int size = form.Read("pageSize", 10);
+            bool getTotal = form.Read("getTotal", true);
+            string sort = form.Read<string>("sort");
+            string order = form.Read<string>("order");
+            string name = form.Read<string>("keyword");
+
+            var report_date = form.PathReadArray<string>("query_date[]");
+
+            string filter = string.Empty;
+            if (!string.IsNullOrEmpty(name))
+            {
+                filter += $" AND accountId IN (SELECT ID FROM pdd_pool WHERE company=@name AND is_hide=0)";
+            }
+            else
+            {
+                filter += $" AND accountId IN (SELECT ID FROM pdd_pool WHERE is_hide=0)";
+            }
+
+            DateTime stime = DateTime.MinValue, etime = DateTime.MinValue;
+            if (report_date.Count == 2)
+            {
+                if (DateTime.TryParse(report_date[0], out stime) && DateTime.TryParse(report_date[1], out etime))
+                {
+                    etime = etime.AddDays(1).AddSeconds(-1);
+                    filter += $" AND report_date BETWEEN @stime AND @etime";
+                }
+            }
+
+            filter = filter.StringTrimStart(" AND ");
+
+            //排序
+            string orderBy = "report_date DESC";
+            if (!string.IsNullOrEmpty(order))
+            {
+                order = "descending".Equals(order) ? "DESC" : "ASC";
+                orderBy = sort switch
+                {
+                    _ => $"{sort} {order}",
+                };
+            }
+
+            var result = new DBContext.Table("pdd_estimate_revenue")
+                .Where(filter, new { name, stime, etime })
+                .Page(size, page)
+                .Order(orderBy)
+                .PageList<PddEstimateRevenueDTO>(getTotal);
+
+            return new APIResult(new { data = result });
+        }
 
     }
 }

+ 48 - 2
molilian.api/Controllers/public/TaskController.cs

@@ -336,9 +336,13 @@ namespace molilian.api.Controllers
         {
             try
             {
-                //AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
-                //AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
+#if DEBUG
+                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.pdd);
+#else
+                AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.tb);
+                AlimamaPlus.ApiCallStatistics(2, intervalDay, TkChannelEnum.tb);
                 AlimamaPlus.ApiCallStatistics(1, intervalDay, TkChannelEnum.jd);
+#endif
             }
             catch (Exception ex)
             {
@@ -742,6 +746,48 @@ namespace molilian.api.Controllers
             }
             return new APIResult(new { success = true, message = "ok" });
         }
+        [HttpGet]
+        public async Task<ActionResult> PddSaveReport()
+        {
+            string message = string.Empty;
+
+            var pdd_list = new DBContext.Table("pdd_pool").Where("cookie_status=1", new { }).Select<PddPoolDTO>();
+            if (pdd_list != null)
+            {
+                DateTime startDate = DateTime.Now.AddDays(-91);
+                DateTime endDate = DateTime.Now.AddDays(-1);
+                foreach (var account in pdd_list)
+                {
+                    if (account.is_hide) continue;
+
+                    if (!string.IsNullOrEmpty(account.cookies))
+                    {
+                        try
+                        {
+                            var plus = new PddUnionPlus(account);
+                            await plus.queryEstimateRevenueList(startDate, endDate);
+                        }
+                        catch (Exception ex)
+                        {
+                            if (ex.Message.Contains("43001:会话已过期"))
+                            {
+                                PddPoolCore.CookieDisabled(account.id);
+                            }
+                            message = $"【PDD报表接口异常】{account.id}:{account.name}\tqueryEstimateRevenueList\n{ex.Message}\n{ex.StackTrace}";
+                            NotifyCore.Notify(new NifyMessage
+                            {
+                                message = message,
+                                priority = NifyMessagePriority.high,
+                                tags = ["red_circle"]
+                            });
+                            continue;
+                        }
+                    }
+                }
+            }
+            return new APIResult(new { success = true, message = "ok" });
+        }
+
 
         [HttpGet]
         public async Task<ActionResult> FixReport(int id, string dt)

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

@@ -92,6 +92,31 @@ namespace molilian.api.Controllers
             return await UnionParseCore.UnionParseAsync(content, channel, commerceType, ip, oaid, accountid);
         }
 
+
+        [HttpPost]
+        public async Task<ActionResult> unsafeBatchParse([FromBody] JsonElement form)
+        {
+            var content = form.PathReadArray("s[]", string.Empty);
+            var channel = form.Read("c", string.Empty);
+            var ip = form.Read("ip", string.Empty);
+            var oaid = form.Read("oaid", string.Empty);
+            int accountid = form.Read("aid", 0);
+            int count = form.Read("count", 0);
+            var commerceType = form.Read<int>("commerceType", 0);
+
+#if DEBUG
+            //ip = "127.0.0.1";
+            //oaid = "test-oaid";
+#endif
+            for (int i = 0; i < count; i++)
+            {
+                _ = UnionParseCore.UnionParseAsync(content[i], channel, commerceType, ip, oaid, accountid);
+            }
+            return new APIResult(new { msg = "ok" });
+        }
+
+
+
         [HttpPost]
         public async Task<ActionResult> unionCoupon([FromBody] JsonElement form, [FromQuery] string a = "", [FromQuery] int t = 0, [FromQuery] string sign = "")
         {
@@ -527,7 +552,7 @@ namespace molilian.api.Controllers
                 //0:全分销类型;-1:各分销类型,1:goods 2: live 3:video 4: profile 5: unknown
                 int distributiontype = form.Read("distributiontype", 0);
 
-                //0:全平台;-1:各平台;1:淘宝 2:京东
+                //0:全平台;-1:各平台;1:淘宝 2:京东 2:多多
                 int platform = form.Read("platform", 0);
 
                 var data = await ApiReportCore.ReportDailysAsync(form, clientIp, debug);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 2 - 0
molilian.api/Properties/launchSettings.json

@@ -2,6 +2,7 @@
   "profiles": {
     "http": {
       "commandName": "Project",
+      "launchBrowser": true,
       "launchUrl": "swagger",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development",
@@ -30,6 +31,7 @@
     },
     "https": {
       "commandName": "Project",
+      "launchBrowser": true,
       "launchUrl": "swagger",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"

+ 3 - 2
molilian.core/Core/API/ApiReportCore.cs

@@ -50,7 +50,7 @@ namespace molilian.core
             //0:全分销类型;-1:各分销类型,1:goods 2: live 3:video 4: profile 5: unknown
             int distributiontype = form.Read("distributiontype", 0);
 
-            //0:全平台;-1:各平台;1:淘宝 2:京东
+            //0:全平台;-1:各平台;1:淘宝 2:京东 3:多多
             int platform = form.Read("platform", 0);
 
             int data_type = form.Read("type", 0);
@@ -69,6 +69,7 @@ namespace molilian.core
             {
                 case 1:
                 case 2:
+                case 3:
                     {
                         var data = await DataTypeReportDailysAsync(platform, distributiontype, data_type, stime, etime, clientIp, debug);
                         list.AddRange(data);
@@ -77,7 +78,7 @@ namespace molilian.core
                     break;
                 default:
                     {
-                        int[] types = { 1, 2 };
+                        int[] types = { 1, 2, 3 };
                         foreach (var type in types)
                         {
                             var data = await DataTypeReportDailysAsync(platform, distributiontype, type, stime, etime, clientIp, debug);

+ 22 - 8
molilian.core/Core/pdd/PddPoolCore.cs

@@ -48,6 +48,7 @@ namespace molilian.core
         {
             if (accountid != 0 && accountid != item.id) return false;
             if (mode != PddUnionWorkMode.All && mode != item.work_mode) return false;
+            if (item.work_mode == PddUnionWorkMode.Crawler && !item.cookie_status) return false;
 
             if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
             {
@@ -218,14 +219,15 @@ namespace molilian.core
                 accountId = exist.id;
                 if (work_mode == JdUnionWorkMode.Crawler) status = true;
                 new DBContext.Table("pdd_pool")
-                   .Add("duoId", duoId)
-                   .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();
+                    .Add("duoId", duoId)
+                    .Add("cookies", cookies)
+                    .Add("user_agent", user_agent)
+                    .Add("status", status)
+                    .Add("cookie_status", 1)
+                    .Add("last_time", DateTime.Now)
+                    .Add("login_time", DateTime.Now)
+                    .Where("id=@id", new { exist.id })
+                    .Update();
                 if (status) _ = List(true);
             }
             else
@@ -238,6 +240,7 @@ namespace molilian.core
                     .Add("cookies", cookies)
                     .Add("user_agent", user_agent)
                     .Add("pid", lastPid)
+                    .Add("cookie_status", 1)
                     .Add("create_time", DateTime.Now)
                     .Add("last_time", DateTime.Now)
                     .Add("login_time", DateTime.Now)
@@ -256,6 +259,16 @@ namespace molilian.core
         }
 
 
+        public static int CookieDisabled(int id)
+        {
+            return new DBContext.Table("pdd_pool")
+                .Add("cookie_status", 0)
+                .Add("last_time", DateTime.Now)
+                .Where("id=@id", new { id })
+                .Update();
+        }
+
+
         public static int Update(PddPoolDTO account)
         {
             return new DBContext.Table("pdd_pool")
@@ -269,6 +282,7 @@ namespace molilian.core
                 //.Add("today_finishCosPrice", account.today_finishCosPrice)
                 //.Add("today_finishOrderNum", account.today_finishOrderNum)
                 //.Add("today_orderNum", account.today_orderNum)
+                .Add("last_time", DateTime.Now)
                 .Where("id=@id", new { account.id })
                 .Update();
         }

+ 35 - 20
molilian.core/Core/taoke/UnionParseCore.cs

@@ -246,16 +246,16 @@ namespace molilian.core
                     _ = TkLogCore.ParseLogAsync(result);
 
 
-
-
                     //20241204 特例
                     if ("bj".Equals(EndPointCore.CurrentEndPoint))
                     {
-                        string ruleKey = $"tmp_rules:tb:{DateTime.Now:yyyyMMdd}";
-                        var count = RedisHelper.IncrBy(ruleKey);
-                        if (DateTime.Now < DateTime.Parse("2024-12-05") && count < 500)
+                        string ruleKey = $"tmp_rules2:tb:{DateTime.Now:yyyyMMdd}";
+                        var count = RedisHelper.Get<int>(ruleKey);
+                        if (DateTime.Now < DateTime.Parse("2024-12-09") && count < 500)
                         {
-                            result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?action=ali.open.nav&module=h5&source=alimama&bc_fl_src=tunion_vipmedia_sy&h5Url=https%3A%2F%2Fs.click.taobao.com%2Ft%3Funion_lens%3DlensId%253APUB%25401733285378%25402105593d_0f2e_1938fdbfb08_56d2%254001%2540eyJmbG9vcklkIjozODg1Miiwiic3BtQiiI6Il9wb3J0YWxfdjJfcGFnZXNfYWN0aXZpdHlfb2ZmaWNpYWxfaW5kZXhfaHRtIn0ie%253BeventPageId%253A20150318020019405%26e%3Dm%253D2%2526s%253DHT55zNJ42uRw4vFB6t2Z2iperVdZeJviAMbqNcPEYg76sTlfBitgxDLxqsKAeUFqgEGu%252B0FGP7cWpIFXOotQwxwkghS%252B3Tth35QMLhvYd5WzAlsM3q9KBQgChlAI37hjOkwAUKujKr8%252BB0zf4OD7u5LL0QPsyT77slidLc%252FfR2bfW12dRBt0XJ7LmQijlljrM7kxpdONUAKgtf8I59Gmj7WOELdnGdZV3eHn14rW1PBcfk1oQPCr5xDqzYVRkKA1NNRdkxXQuw4cJIIUvt07Yd%252BUDC4b2HeVswJbDN6vSgUIAoZQCN%252B4Y859REbZnVo89hl0nxWy%252BeTjkOUQ%252FOHRwAPUBlppf%252Btjs7UNLsd2bI5z8saC7t5FlO9Zh8BraVZYIcqHs8UcdUpXL0nm%252FTxRaQ4VydfXBQxnSpQpV4IkRoOOqZbKHGSDxYLRK9woGjcZwM7sKH2NkQIJ%252Fov1pArqR5rCLGafPO1NzTpSwSQKdJD1UZJeBohmpzCclrzRGqIlouD5cf%252BfoU5VXRkZOvK%252FVyaa21c5k%252BY9DYGmadGiXn0jUIaYy7GzzyoG4bBR4UOYsQQxcVtq4KEjiVO%252FBgG2pWuj0Yecd3Dfdij0RQXJBsf3Oqj9M98VWj7lCjCC8ck8";
+                            //result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?action=ali.open.nav&module=h5&source=alimama&bc_fl_src=tunion_vipmedia_sy&h5Url=https%3A%2F%2Fs.click.taobao.com%2Ft%3Funion_lens%3DlensId%253APUB%25401733285378%25402105593d_0f2e_1938fdbfb08_56d2%254001%2540eyJmbG9vcklkIjozODg1Miiwiic3BtQiiI6Il9wb3J0YWxfdjJfcGFnZXNfYWN0aXZpdHlfb2ZmaWNpYWxfaW5kZXhfaHRtIn0ie%253BeventPageId%253A20150318020019405%26e%3Dm%253D2%2526s%253DHT55zNJ42uRw4vFB6t2Z2iperVdZeJviAMbqNcPEYg76sTlfBitgxDLxqsKAeUFqgEGu%252B0FGP7cWpIFXOotQwxwkghS%252B3Tth35QMLhvYd5WzAlsM3q9KBQgChlAI37hjOkwAUKujKr8%252BB0zf4OD7u5LL0QPsyT77slidLc%252FfR2bfW12dRBt0XJ7LmQijlljrM7kxpdONUAKgtf8I59Gmj7WOELdnGdZV3eHn14rW1PBcfk1oQPCr5xDqzYVRkKA1NNRdkxXQuw4cJIIUvt07Yd%252BUDC4b2HeVswJbDN6vSgUIAoZQCN%252B4Y859REbZnVo89hl0nxWy%252BeTjkOUQ%252FOHRwAPUBlppf%252Btjs7UNLsd2bI5z8saC7t5FlO9Zh8BraVZYIcqHs8UcdUpXL0nm%252FTxRaQ4VydfXBQxnSpQpV4IkRoOOqZbKHGSDxYLRK9woGjcZwM7sKH2NkQIJ%252Fov1pArqR5rCLGafPO1NzTpSwSQKdJD1UZJeBohmpzCclrzRGqIlouD5cf%252BfoU5VXRkZOvK%252FVyaa21c5k%252BY9DYGmadGiXn0jUIaYy7GzzyoG4bBR4UOYsQQxcVtq4KEjiVO%252FBgG2pWuj0Yecd3Dfdij0RQXJBsf3Oqj9M98VWj7lCjCC8ck8";
+                            result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?source=auto&action=ali.open.nav&module=h5&bootImage=0&afc_route=1&bc_fl_src=growth_dhh_2200803434968_100-1930985-1595034112&dpa_Inid=159503411212096&dpa_material_id=530637422585&dpa_material_type=1&dpa_source_code=12096&force_no_smb=true&h5Url=https%3A%2F%2Fs.m.taobao.com%2Fh5%3Ffrom%3Dcustoms%26g_channelSrp%3Ddhhdpa_1232552832%26dpa_material_type%3D1%26ut_sk%3Dsearch%26spm%3Da2141.mb819t211c7%26sLaunch%3D0%26sKeep%3D1%26sModuleName%3Dsearch%26spm_back_up%3Da2141.mb819t211c7%26bc_fl_src%3Dgrowth_dhh_2200803434968_100-1930985-1595034112%26dpa_Inid%3D159503411212096%26dpa_material_id%3D530637422585%26dpa_material_type%3D1%26dpa_source_code%3D12096%26force_no_smb%3Dtrue%26itemIds%3D530637422585%26slk_actid%3D100000000207%26spm%3D2014.ugdhh.2200803434968.100-1930985-1595034112%26wh_biz%3Dtm&itemIds=530637422585&slk_actid=100000000207&spm=2014.ugdhh.2200803434968.100-1930985-1595034112&wh_biz=tm";
+                            RedisHelper.IncrBy(ruleKey);
                             RedisHelper.Expire(ruleKey, 86400 * 1);
                         }
                     }
@@ -282,6 +282,19 @@ namespace molilian.core
                     result.itemName = "点击打开淘宝APP";
                     _ = TkLogCore.ParseLogAsync(result);
 
+                    //20241204 特例
+                    if ("bj".Equals(EndPointCore.CurrentEndPoint))
+                    {
+                        string ruleKey = $"tmp_rules2:tb:{DateTime.Now:yyyyMMdd}";
+                        var count = RedisHelper.Get<int>(ruleKey);
+                        if (DateTime.Now < DateTime.Parse("2024-12-09") && count < 500)
+                        {
+                            //result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?action=ali.open.nav&module=h5&source=alimama&bc_fl_src=tunion_vipmedia_sy&h5Url=https%3A%2F%2Fs.click.taobao.com%2Ft%3Funion_lens%3DlensId%253APUB%25401733285378%25402105593d_0f2e_1938fdbfb08_56d2%254001%2540eyJmbG9vcklkIjozODg1Miiwiic3BtQiiI6Il9wb3J0YWxfdjJfcGFnZXNfYWN0aXZpdHlfb2ZmaWNpYWxfaW5kZXhfaHRtIn0ie%253BeventPageId%253A20150318020019405%26e%3Dm%253D2%2526s%253DHT55zNJ42uRw4vFB6t2Z2iperVdZeJviAMbqNcPEYg76sTlfBitgxDLxqsKAeUFqgEGu%252B0FGP7cWpIFXOotQwxwkghS%252B3Tth35QMLhvYd5WzAlsM3q9KBQgChlAI37hjOkwAUKujKr8%252BB0zf4OD7u5LL0QPsyT77slidLc%252FfR2bfW12dRBt0XJ7LmQijlljrM7kxpdONUAKgtf8I59Gmj7WOELdnGdZV3eHn14rW1PBcfk1oQPCr5xDqzYVRkKA1NNRdkxXQuw4cJIIUvt07Yd%252BUDC4b2HeVswJbDN6vSgUIAoZQCN%252B4Y859REbZnVo89hl0nxWy%252BeTjkOUQ%252FOHRwAPUBlppf%252Btjs7UNLsd2bI5z8saC7t5FlO9Zh8BraVZYIcqHs8UcdUpXL0nm%252FTxRaQ4VydfXBQxnSpQpV4IkRoOOqZbKHGSDxYLRK9woGjcZwM7sKH2NkQIJ%252Fov1pArqR5rCLGafPO1NzTpSwSQKdJD1UZJeBohmpzCclrzRGqIlouD5cf%252BfoU5VXRkZOvK%252FVyaa21c5k%252BY9DYGmadGiXn0jUIaYy7GzzyoG4bBR4UOYsQQxcVtq4KEjiVO%252FBgG2pWuj0Yecd3Dfdij0RQXJBsf3Oqj9M98VWj7lCjCC8ck8";
+                            result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?source=auto&action=ali.open.nav&module=h5&bootImage=0&afc_route=1&bc_fl_src=growth_dhh_2200803434968_100-1930985-1595034112&dpa_Inid=159503411212096&dpa_material_id=530637422585&dpa_material_type=1&dpa_source_code=12096&force_no_smb=true&h5Url=https%3A%2F%2Fs.m.taobao.com%2Fh5%3Ffrom%3Dcustoms%26g_channelSrp%3Ddhhdpa_1232552832%26dpa_material_type%3D1%26ut_sk%3Dsearch%26spm%3Da2141.mb819t211c7%26sLaunch%3D0%26sKeep%3D1%26sModuleName%3Dsearch%26spm_back_up%3Da2141.mb819t211c7%26bc_fl_src%3Dgrowth_dhh_2200803434968_100-1930985-1595034112%26dpa_Inid%3D159503411212096%26dpa_material_id%3D530637422585%26dpa_material_type%3D1%26dpa_source_code%3D12096%26force_no_smb%3Dtrue%26itemIds%3D530637422585%26slk_actid%3D100000000207%26spm%3D2014.ugdhh.2200803434968.100-1930985-1595034112%26wh_biz%3Dtm&itemIds=530637422585&slk_actid=100000000207&spm=2014.ugdhh.2200803434968.100-1930985-1595034112&wh_biz=tm";
+                            RedisHelper.IncrBy(ruleKey);
+                            RedisHelper.Expire(ruleKey, 86400 * 1);
+                        }
+                    }
                     other_aff = true;
                     return TaobaoParseOutput(result, swData, new
                     {
@@ -534,20 +547,22 @@ namespace molilian.core
                         _ => JdUnionPlus.GetDeeplink(string.Empty),
                     };
 
-                    if (result.link_type == LinkTypeEnum.other_aff)
-                    {
-                        //20241204 特例
-                        if ("bj".Equals(EndPointCore.CurrentEndPoint))
-                        {
-                            string ruleKey = $"tmp_rules:jd:{DateTime.Now:yyyyMMdd}";
-                            var count = RedisHelper.IncrBy(ruleKey);
-                            if (DateTime.Now < DateTime.Parse("2024-12-06") && count < 500)
-                            {
-                                result.deeplink_url = "openapp.jdmobile://virtual?params=%7B%22des%22%3A%22union%22%2C%22category%22%3A%22jump%22%2C%22url%22%3A%22https%3A%2F%2Fu.jd.com%2FugInesd%3Fe%3DCPS-11417-__ZLDEVICE__-CPS-wkfG72%22%7D&backurl=__back_url__";
-                                RedisHelper.Expire(ruleKey, 86400 * 1);
-                            }
-                        }
-                    }
+                    //if (result.link_type == LinkTypeEnum.other_aff)
+                    //{
+                    //    //20241204 特例
+                    //    if ("bj".Equals(EndPointCore.CurrentEndPoint))
+                    //    {
+                    //        string ruleKey = $"tmp_rules1:jd:{DateTime.Now:yyyyMMdd}";
+                    //        var count = RedisHelper.Get<int>(ruleKey);
+                    //        if (DateTime.Now < DateTime.Parse("2024-12-07") && count < 500)
+                    //        {
+                    //            result.deeplink_url = "openapp.jdmobile://virtual?params=%7B%22des%22%3A%22union%22%2C%22category%22%3A%22jump%22%2C%22url%22%3A%22https%3A%2F%2Fu.jd.com%2FugInesd%3Fe%3DCPS-11417-__ZLDEVICE__-CPS-wkfG72%22%7D&backurl=__back_url__";
+                    //            RedisHelper.IncrBy(ruleKey);
+                    //            RedisHelper.Expire(ruleKey, 86400 * 1);
+                    //        }
+
+                    //    }
+                    //}
                     result.success = false;
                     result.message = "放弃转链";
                     result.reason = reason;

+ 57 - 0
molilian.core/DTO/pdd/PddEstimateRevenueDTO.cs

@@ -0,0 +1,57 @@
+using dodohold.core;
+using System.Text.Json.Serialization;
+
+namespace molilian.core
+{
+
+    [Table("pdd_estimate_revenue")]
+    public class PddEstimateRevenueDTO
+    {
+        [Key]
+        public int id { get; set; }
+        public int accountId { get; set; } = 0;
+
+        public string accountName { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 订单完成日期
+        /// </summary>
+        [JsonConverter(typeof(DateTimeConverterUsingDateTimeParse))]
+        public DateTime report_date { get; set; } = DateTime.MinValue;
+        public DateTime calcDate { get; set; } = DateTime.MinValue;
+
+        public string pid { get; set; } = string.Empty;
+        public string pidName { get; set; } = string.Empty;
+
+
+        //支付笔数
+        public int orderNum { get; set; } = 0;
+        /// <summary>
+        /// 支付金额(分)
+        /// </summary>
+        public int orderAmount { get; set; } = 0;
+
+        /// <summary>
+        /// 支付订单的预估佣金收入(分)
+        /// </summary>
+        public int feeAmount { get; set; } = 0;
+
+        /// <summary>
+        /// 笔单价(分)
+        /// </summary>
+        public decimal avgPrice { get; set; } = 0;
+
+        /// <summary>
+        /// 跨店佣金收入(分)
+        /// </summary>
+        public int mallRelFeeAmount { get; set; } = 0;
+
+        /// <summary>
+        /// 应该是锁定金额?
+        /// </summary>
+        public int lockFeeAmount { get; set; } = 0;
+
+    }
+
+
+}

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

@@ -29,7 +29,8 @@ namespace molilian.core
         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 bool status { get; set; } = false;
+        public bool cookie_status { get; set; } = false;
         public PddUnionWorkMode work_mode { get; set; } = PddUnionWorkMode.SiteApi;
         public string cookies { get; set; } = string.Empty;
 

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

@@ -428,6 +428,36 @@ namespace molilian.core
                         }
                         break;
                     }
+                case TkChannelEnum.pdd:
+                    {
+                        var exist_report_dailys = new DBContext.Table(conn, "v_pdd_estimate_revenue")
+                            .Get<dynamic>("report_date=@log_date", new { log_date });
+
+                        if (exist_report_dailys != null)
+                        {
+                            update.Add("uclk_uv", 0)
+                                .Add("pay_ord_uv", 0)//付款人数
+                                .Add("uclk_pv", 0) //点击量 点击次数
+                                .Add("pay_tk_disp_tfee", exist_report_dailys.feeAmount)//预估收入 付款预估收入
+                                .Add("pay_ord_amt", exist_report_dailys.orderAmount) //付款金额
+                                .Add("pay_ord_num", exist_report_dailys.orderNum)
+                                .Add("order_ord_num", 0)
+                                .Add("eff_ord_amt", exist_report_dailys.orderAmount) //有效订单金额 有效订单金额
+                                .Add("eff_ord_num", exist_report_dailys.orderNum) //有效付款笔数 
+                                .Add("eff_tk_disp_tfee", exist_report_dailys.feeAmount); //有效付款预估收入 预估收入
+                        }
+
+                        var exist = new DBContext.Table(center_conn, "center_daily_logs")
+                             .Get<dynamic>("log_date=@log_date AND accountId=@accountId",
+                             new { log_date, channel, accountId = 0 });
+                        if (exist != null)
+                        {
+                            update.Add("total_count", exist.pdd_parse_total_count)
+                                .Add("abandon_count", exist.pdd_parse_abandon_count)
+                                .Add("success_count", exist.pdd_parse_success_count);
+                        }
+                        break;
+                    }
             }
 
             if (data_type == 1)

+ 0 - 14
molilian.core/Plus/JDUnion/goods.cs

@@ -211,21 +211,7 @@ namespace molilian.core
             WebClientUtility client = new WebClientUtility();
             client.Proxy = _proxy;
 #if DEBUG
-
-            client.Proxy = new WebProxy
-            {
-                Address = new Uri("http://bjapi.molilian.com:20063"),
-                //Credentials = new NetworkCredential("t12881967077999", "6a1eh304")
-            };
-
-            client.Proxy = new WebProxy
-            {
-                Address = new Uri("http://f848.kdltps.com:15818"),
-                Credentials = new NetworkCredential("t12881967077999", "6a1eh304")
-            };
-
             client.Proxy = null;
-
 #endif
             client.SetContentType("application/x-www-form-urlencoded");
             client.AddHeaders("X-Referer-Page", "https://union.jd.com/proManager/index");

+ 122 - 0
molilian.core/Plus/pdd/EstimateRevenue.cs

@@ -0,0 +1,122 @@
+using dodohold.core;
+using Sayaka.Common;
+using System.Drawing.Printing;
+using System.Text.Json;
+
+
+namespace molilian.core
+{
+    public partial class PddUnionPlus
+    {
+
+        public async Task queryEstimateRevenueList(DateTime startTime, DateTime endTime, CancellationToken cancellationToken = default)
+        {
+            var ts = DateTime.Now.Convert2UnixTimestamp(true);
+            string cookies = _account.cookies;
+
+            bool hasNext = true;
+            int pageNo = 1;
+            int pageSize = 100;
+            while (hasNext)
+            {
+                var args = new
+                {
+                    startTime = startTime.ToString("yyyy-MM-dd"),
+                    endTime = endTime.ToString("yyyy-MM-dd"),
+                    orderPromotionType = 0,
+                    pageNumber = pageNo,
+                    pageSize
+                };
+
+                DateTime stime = DateTime.Now;
+                string url = "https://jinbao.pinduoduo.com/network/api/order/stat/overall/list";
+                var root = await this.RequestAsync(url, args.Convert2Json());
+                TimeSpan ts2 = DateTime.Now - stime;
+
+                string xx = ts2.TotalSeconds.ToString();
+
+                var success = root.Read<bool>("success");
+                if (!success) break;
+                var list = root.ElementRead("result").ElementRead("list");
+                string filter = "accountId=@accountId AND report_date=@report_date AND pid=@pid";
+                var len = list.GetArrayLength();
+                if (len == 0) break;
+                foreach (var item in list.EnumerateArray())
+                {
+                    var report = item.GetRawText().Convert2Object<PddEstimateRevenueDTO>();
+
+                    var exist = new DBContext.Table("pdd_estimate_revenue")
+                        .Fields("id")
+                        .Get<dynamic>(filter, new { report_date = report.calcDate, accountId = _account.id, report.pid });
+
+                    var update = new DBContext.Table("pdd_estimate_revenue")
+                        .Add("accountId", _account.id)
+                        .Add("accountName", _account.name)
+                        .Add("report_date", report.calcDate)
+
+                        .Add("pid", report.pid)
+                        .Add("pidName", report.pidName)
+                        .Add("orderNum", report.orderNum)
+                        .Add("orderAmount", report.orderAmount)
+                        .Add("feeAmount", report.feeAmount)
+                        .Add("avgPrice", report.avgPrice)
+                        .Add("mallRelFeeAmount", report.mallRelFeeAmount)
+                        .Add("lockFeeAmount", report.lockFeeAmount)
+                        .Add("last_time", DateTime.Now);
+
+                    if (exist == null)
+                    {
+                        update.Add("report_date", report.calcDate)
+                        .Add("create_time", DateTime.Now)
+                        .Create(DBContext.InsertType.REPLACE);
+                    }
+                    else
+                    {
+                        update.Where("id=@id", new { exist.id }).Update();
+                    }
+                }
+
+                pageNo++;
+            }
+        }
+
+        public async Task<JsonElement> RequestAsync(string url, string data, CancellationToken cancellationToken = default)
+        {
+            string cookies = _account.cookies.Trim();
+            string useragent = ProviderFakeUserAgent.RandomComputer;
+
+            WebClientUtility client = new WebClientUtility();
+            client.Proxy = _proxy;
+#if DEBUG
+            client.Proxy = null;
+#endif
+            client.SetContentType("application/json");
+            client.AddHeaders("Referer", "https://jinbao.pinduoduo.com/data/data-analysis");
+            client.AddHeaders("Origin", "https://jinbao.pinduoduo.com");
+            client.UserAgent = useragent;
+            client.AddHeaders("Cookie", cookies);
+            client.Post(data);
+            var response = await client.RequestAsync(url, "POST", cancellationToken);
+            string body = response.Body();
+            var root = body.Convert2JsonElement();
+
+            //string message = string.Empty;
+            // todo 这里我会做一些 日志 处理
+
+
+            var success = root.Read<bool>("success");
+            if (!success)
+            {
+                var errorCode = root.Read<int>("errorCode");
+                var errorMsg = root.Read<string>("errorMsg");
+
+                _ = new LoggerLibrary("PddUnion", "unsuccessful").Info(url, data).Info(body).SaveAsync();
+                throw new APIException($"{errorCode}:{errorMsg}");
+            }
+            return root;
+        }
+
+
+
+    }
+}

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä