dodo hold 3 kuukautta sitten
vanhempi
sitoutus
ea05458e79

+ 9 - 2
molilian.api/Controllers/admin/TracksAdminController.cs

@@ -70,6 +70,9 @@ namespace molilian.api.Controllers
             int size = form.Read("pageSize", 10);
             bool getTotal = form.Read("getTotal", true);
             int linkId = form.Read("track_link_id", 0);
+            int accountId = form.Read("account_id", -1);
+            bool includeAccountBreakdown = form.Read("include_account_breakdown", false);
+            bool accountBreakdownOnly = form.Read("account_breakdown_only", false);
             string eventType = form.Read("event_type", string.Empty);
             string platform = form.Read("platform", string.Empty);
             string typename = form.Read("typename", string.Empty);
@@ -80,6 +83,9 @@ namespace molilian.api.Controllers
 
             string filter = string.Empty;
             if (linkId > 0) filter += " AND track_link_id=@linkId";
+            if (accountBreakdownOnly) filter += " AND account_id>0";
+            else if (accountId >= 0) filter += " AND account_id=@accountId";
+            else if (!includeAccountBreakdown) filter += " AND account_id=0";
             if (!string.IsNullOrWhiteSpace(eventType)) filter += " AND event_type=@eventType";
             if (!string.IsNullOrWhiteSpace(platform)) filter += " AND platform=@platform";
             if (!string.IsNullOrWhiteSpace(typename)) filter += " AND typename=@typename";
@@ -92,7 +98,7 @@ namespace molilian.api.Controllers
             string orderBy = "report_date DESC";
 
             var result = new DBContext.Table("track_daily_report")
-                .Where(filter, new { linkId, eventType, platform, typename, scene, uniqueId, start, end })
+                .Where(filter, new { linkId, accountId, eventType, platform, typename, scene, uniqueId, start, end })
                 .Page(size, page)
                 .Order(orderBy)
                 .PageList<TrackDailyReportDTO>(getTotal);
@@ -105,11 +111,12 @@ namespace molilian.api.Controllers
         {
             var token = provider.Get(_accessor.HttpContext);
             int linkId = form.Read("track_link_id", 0);
+            int accountId = form.Read("account_id", 0);
             string dateText = form.Read("date", string.Empty);
             string scene = form.Read("scene", string.Empty);
             DateTime date = DateTime.TryParse(dateText, out var parsed) ? parsed.Date : DateTime.Now.Date;
 
-            var list = await TracksCore.GetHourlyReportAsync(linkId, date, scene);
+            var list = await TracksCore.GetHourlyReportAsync(linkId, date, scene, accountId);
             return new APIResult(new
             {
                 data = new

+ 3 - 2
molilian.api/Controllers/public/TracksController.cs

@@ -19,7 +19,7 @@ namespace molilian.api.Controllers
         }
 
         [HttpGet]
-        public async Task<ActionResult> Track([FromQuery] int track_id, [FromQuery] string unique_id, [FromQuery] string scene = "")
+        public async Task<ActionResult> Track([FromQuery] int track_id, [FromQuery] string unique_id, [FromQuery] string scene = "", [FromQuery] int account_id = 0)
         {
             if (track_id <= 0)
             {
@@ -36,6 +36,7 @@ namespace molilian.api.Controllers
             var dto = new TrackRequestLogDTO
             {
                 track_id = track_id,
+                account_id = Math.Max(account_id, 0),
                 event_type = link.event_type,
                 platform = link.platform,
                 typename = link.typename,
@@ -46,7 +47,7 @@ namespace molilian.api.Controllers
                 referer = Request.Headers.Referer.ToString()
             };
             _ = TracksCore.LogTrackRequestAsync(dto);
-            _ = TracksCore.TrackAsync(link, trackScene);
+            _ = TracksCore.TrackAsync(link, trackScene, account_id);
             return new APIResult(new { success = true, message = "ok" });
         }
 

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


+ 1 - 1
molilian.api/Properties/launchSettings.json

@@ -16,7 +16,7 @@
         "CenterDB": "",
         "CenterRedis": ""
       },
-      "environmentVariables33": {
+      "environmentVariables22": {
         "ASPNETCORE_ENVIRONMENT": "Development",
         "EndPoint": "sh1",
         "NtfyServer": "https://ntfy.yunhui800.com/similar",

+ 4 - 1
molilian.core/Core/PushDataReport/PushDataReportCore.cs

@@ -100,6 +100,8 @@ namespace molilian.core
                                         .Get<PushDataReportDTO>(filter, new { report_date = reportDatetime.Date, platform = p.push_channel_id, distribution, data_type, sub_type });
                             if (exist != null && exist.status == 1) continue;
 
+
+
                             var item = new PushDataReportDTO();
                             item.report_date = reportDatetime.Date;
                             item.platform = p.push_channel_id;
@@ -116,7 +118,6 @@ namespace molilian.core
                                 item.dp_transition_succ_count = 0;
                                 item.transition_succ_count = 0;
                             }
-
                             item.click_count = data.uclk_pv;
                             item.click_user_count = data.uclk_uv;
                             item.order_count = data.eff_ord_num;
@@ -289,6 +290,8 @@ namespace molilian.core
         public async Task<int> PushReportData(DateTime report_date, bool repush = false, CancellationToken cancellationToken = default)
         {
             string filter = "report_date=@report_date";
+            //2026-06-05 淘宝 只生成不推送
+            filter += " AND sub_type=100000 AND platform=1";
 #if DEBUG
             filter += " AND sub_type=100000 AND platform IN (1,9,13)";
 #endif

+ 53 - 19
molilian.core/Core/TracksCore.cs

@@ -144,12 +144,13 @@ namespace molilian.core
         /// <summary>
         /// 曝光/点击触发:计入 Redis,失败不影响返回
         /// </summary>
-        public static Task<bool> TrackAsync(TrackLinkDTO link, string scene = "")
+        public static Task<bool> TrackAsync(TrackLinkDTO link, string scene = "", int accountId = 0)
         {
 
             string dateStr = DateTime.Now.ToString("yyyyMMdd");
             string hourStr = DateTime.Now.ToString("yyyyMMddHH");
             string metricScene = ResolveMetricScene(link, scene);
+            accountId = Math.Max(accountId, 0);
             string indexValue = BuildMetricIndexValue(link.event_type, link.id, metricScene);
 
             var metrics = new List<(string key, string indexKey, string indexValue, int expire)>
@@ -157,6 +158,12 @@ namespace molilian.core
                 (BuildDailyCountKey(link.event_type, link.id, dateStr, metricScene), $"{RedisPrefix}:daily:index:{dateStr}:track", indexValue, DailyExpireSeconds),
                 (BuildHourlyCountKey(link.event_type, link.id, hourStr, metricScene), $"{RedisPrefix}:hour:index:{hourStr}:track", indexValue, HourlyExpireSeconds),
             };
+            if (accountId > 0)
+            {
+                string accountIndexValue = BuildMetricIndexValue(link.event_type, link.id, metricScene, accountId);
+                metrics.Add((BuildDailyCountKey(link.event_type, link.id, dateStr, metricScene, accountId), $"{RedisPrefix}:daily:index:{dateStr}:track", accountIndexValue, DailyExpireSeconds));
+                metrics.Add((BuildHourlyCountKey(link.event_type, link.id, hourStr, metricScene, accountId), $"{RedisPrefix}:hour:index:{hourStr}:track", accountIndexValue, HourlyExpireSeconds));
+            }
 
             try
             {
@@ -196,15 +203,17 @@ namespace molilian.core
             foreach (var member in indexMembers)
             {
                 var parts = member.Split('|');
-                if (parts.Length != 2 && parts.Length != 3) continue;
+                if (parts.Length < 2 || parts.Length > 4) continue;
 
                 string eventType = NormalizeEventType(parts[0]);
                 if (!SupportEventTypes.Contains(eventType)) continue;
                 if (!int.TryParse(parts[1], out var trackId) || trackId <= 0) continue;
-                bool hasScenePart = parts.Length == 3;
+                bool hasScenePart = parts.Length >= 3;
                 string memberScene = hasScenePart ? DecodeIndexPart(parts[2]) : string.Empty;
+                int accountId = 0;
+                if (parts.Length == 4 && (!int.TryParse(parts[3], out accountId) || accountId <= 0)) continue;
 
-                string countKey = BuildDailyCountKey(eventType, trackId, dateStr, hasScenePart ? memberScene : string.Empty);
+                string countKey = BuildDailyCountKey(eventType, trackId, dateStr, hasScenePart ? memberScene : string.Empty, accountId);
                 int total = await RedisHelper.GetAsync<int>(countKey);
                 if (total <= 0) continue;
 
@@ -216,7 +225,7 @@ namespace molilian.core
                 }
 
                 string reportScene = ResolveMetricScene(link, memberScene);
-                string bucketKey = BuildMetricIndexValue(eventType, trackId, reportScene);
+                string bucketKey = BuildMetricIndexValue(eventType, trackId, reportScene, accountId);
                 if (!buckets.TryGetValue(bucketKey, out var bucket))
                 {
                     bucket = new DailyReportBucket
@@ -224,6 +233,7 @@ namespace molilian.core
                         EventType = eventType,
                         TrackId = trackId,
                         Scene = reportScene,
+                        AccountId = accountId,
                         Link = link
                     };
                     buckets[bucketKey] = bucket;
@@ -234,21 +244,22 @@ namespace molilian.core
             int rows = 0;
             foreach (var bucket in buckets.Values)
             {
-                await UpsertDailyReportAsync(conn, targetDate.Date, bucket.EventType, bucket.TrackId, bucket.Scene, bucket.Link, bucket.Total);
+                await UpsertDailyReportAsync(conn, targetDate.Date, bucket.EventType, bucket.TrackId, bucket.Scene, bucket.AccountId, bucket.Link, bucket.Total);
                 rows++;
             }
             return rows;
         }
 
-        private static Task<int> UpsertDailyReportAsync(IDbConnection conn, DateTime reportDate, string eventType, int trackId, string scene, TrackLinkDTO? link, int total)
+        private static Task<int> UpsertDailyReportAsync(IDbConnection conn, DateTime reportDate, string eventType, int trackId, string scene, int accountId, TrackLinkDTO? link, int total)
         {
             const string sql = @"
 INSERT INTO track_daily_report
-    (report_date, event_type, track_link_id, platform, typename, scene, unique_id, event_count, create_time, update_time)
+    (report_date, event_type, track_link_id, account_id, platform, typename, scene, unique_id, event_count, create_time, update_time)
 VALUES
-    (@reportDate, @eventType, @trackId, @platform, @typename, @scene, @uniqueId, @eventCount, @now, @now)
+    (@reportDate, @eventType, @trackId, @accountId, @platform, @typename, @scene, @uniqueId, @eventCount, @now, @now)
 ON DUPLICATE KEY UPDATE
     event_count = VALUES(event_count),
+    account_id = VALUES(account_id),
     platform = VALUES(platform),
     typename = VALUES(typename),
     scene = VALUES(scene),
@@ -260,6 +271,7 @@ ON DUPLICATE KEY UPDATE
                 reportDate,
                 eventType,
                 trackId,
+                accountId,
                 platform = link?.platform ?? string.Empty,
                 typename = link?.typename ?? string.Empty,
                 scene,
@@ -269,7 +281,7 @@ ON DUPLICATE KEY UPDATE
             });
         }
 
-        public static async Task<List<TrackHourlyReportDTO>> GetHourlyReportAsync(int trackId, DateTime targetDate, string scene = "")
+        public static async Task<List<TrackHourlyReportDTO>> GetHourlyReportAsync(int trackId, DateTime targetDate, string scene = "", int accountId = 0)
         {
             var result = new List<TrackHourlyReportDTO>();
             if (trackId <= 0) return result;
@@ -283,11 +295,12 @@ ON DUPLICATE KEY UPDATE
             string metricScene = ResolveMetricScene(link, scene);
             string linkScene = ResolveMetricScene(link, string.Empty);
             string dateStr = targetDate.ToString("yyyyMMdd");
+            accountId = Math.Max(accountId, 0);
             for (int hour = 0; hour < 24; hour++)
             {
                 string hourStr = $"{dateStr}{hour:00}";
-                int total = await RedisHelper.GetAsync<int>(BuildHourlyCountKey(eventType, trackId, hourStr, metricScene));
-                if (!string.IsNullOrEmpty(metricScene) && metricScene == linkScene)
+                int total = await RedisHelper.GetAsync<int>(BuildHourlyCountKey(eventType, trackId, hourStr, metricScene, accountId));
+                if (accountId == 0 && !string.IsNullOrEmpty(metricScene) && metricScene == linkScene)
                 {
                     total += await RedisHelper.GetAsync<int>(BuildHourlyCountKey(eventType, trackId, hourStr, string.Empty));
                 }
@@ -300,6 +313,7 @@ ON DUPLICATE KEY UPDATE
                     typename = link.typename ?? string.Empty,
                     scene = metricScene,
                     unique_id = link.unique_id ?? string.Empty,
+                    account_id = accountId,
                     report_date = targetDate.Date,
                     hour = hour,
                     event_count = total
@@ -314,28 +328,44 @@ ON DUPLICATE KEY UPDATE
             int trackId = type == TrackType.Click ? 1 : 2;
             if (result == null) return string.Empty;
             string unique_id = $"1|{result.itemId}_{result.mktId}";
-            return BuildPath(trackId, unique_id, GetTrackScene(result.parse_type, result.riskStrategy));
+            return BuildPath(trackId, unique_id, GetTrackScene(result.parse_type, result.riskStrategy), result.accountId);
         }
         public static string BuildPath(TrackType type, JdDataDTO result)
         {
             int trackId = type == TrackType.Click ? 19 : 20;
             if (result == null) return string.Empty;
             string unique_id = $"13|{result.shortLinkurl.UrlEncode()}";
-            return BuildPath(trackId, unique_id, GetTrackScene(result.parse_type, result.riskStrategy));
+            return BuildPath(trackId, unique_id, GetTrackScene(result.parse_type, result.riskStrategy), result.accountId);
         }
         public static string BuildPath(TrackType type, PddDataDTO result)
         {
             int trackId = type == TrackType.Click ? 21 : 22;
             if (result == null) return string.Empty;
             string unique_id = $"9|{result.shortLinkurl.UrlEncode()}";
-            return BuildPath(trackId, unique_id, GetTrackScene(result.parse_type, result.riskStrategy));
+            return BuildPath(trackId, unique_id, GetTrackScene(result.parse_type, result.riskStrategy), result.accountId);
         }
 
-        public static string BuildPath(int trackId, string unique_id = "", string scene = "")
+        public static string BuildBrwSimilarPath(TrackType type, TkDataDTO result, PromotionQueryItemDTO similar_goods = null, int index = 0)
+        {
+            int trackId = type == TrackType.Click ? 23 : 24;
+            if (result == null) return string.Empty;
+            string unique_id = $"1|{result.itemId}_{result.mktId}";
+            string scene = string.Empty;
+
+            if (similar_goods != null)
+            {
+                unique_id = $"1|{result.itemId}_{result.mktId}_{index}";
+                scene = "similar";
+            }
+
+            return BuildPath(trackId, unique_id, scene, result.accountId);
+        }
+        public static string BuildPath(int trackId, string unique_id = "", string scene = "", int accountId = 0)
         {
             scene = NormalizeReportScene(scene);
             string url = $"https://api.molilian.com/tracks/track?track_id={trackId}&unique_id={unique_id}";
             if (!string.IsNullOrEmpty(scene)) url += $"&scene={scene.UrlEncode()}";
+            if (accountId > 0) url += $"&account_id={accountId}";
             return url;
         }
 
@@ -477,28 +507,31 @@ ON DUPLICATE KEY UPDATE
             return DefaultDimensionValue;
         }
 
-        private static string BuildDailyCountKey(string eventType, int trackId, string dateStr, string scene)
+        private static string BuildDailyCountKey(string eventType, int trackId, string dateStr, string scene, int accountId = 0)
         {
             eventType = NormalizeEventType(eventType);
             scene = NormalizeReportScene(scene);
             string key = $"{RedisPrefix}:daily:{eventType}:{trackId}:{dateStr}";
             if (!string.IsNullOrEmpty(scene)) key += $":{EncodeIndexPart(scene)}";
+            if (accountId > 0) key += $":account:{accountId}";
             return key;
         }
 
-        private static string BuildHourlyCountKey(string eventType, int trackId, string hourStr, string scene)
+        private static string BuildHourlyCountKey(string eventType, int trackId, string hourStr, string scene, int accountId = 0)
         {
             eventType = NormalizeEventType(eventType);
             scene = NormalizeReportScene(scene);
             string key = $"{RedisPrefix}:hour:{eventType}:{trackId}:{hourStr}";
             if (!string.IsNullOrEmpty(scene)) key += $":{EncodeIndexPart(scene)}";
+            if (accountId > 0) key += $":account:{accountId}";
             return key;
         }
 
-        private static string BuildMetricIndexValue(string eventType, int trackId, string scene)
+        private static string BuildMetricIndexValue(string eventType, int trackId, string scene, int accountId = 0)
         {
             eventType = NormalizeEventType(eventType);
             scene = NormalizeReportScene(scene);
+            if (accountId > 0) return $"{eventType}|{trackId}|{EncodeIndexPart(scene)}|{accountId}";
             if (string.IsNullOrEmpty(scene)) return $"{eventType}|{trackId}";
             return $"{eventType}|{trackId}|{EncodeIndexPart(scene)}";
         }
@@ -525,6 +558,7 @@ ON DUPLICATE KEY UPDATE
             public string EventType { get; set; } = string.Empty;
             public int TrackId { get; set; }
             public string Scene { get; set; } = string.Empty;
+            public int AccountId { get; set; }
             public TrackLinkDTO? Link { get; set; }
             public int Total { get; set; }
         }

+ 2 - 0
molilian.core/Core/aliyun/AliyunCore.cs

@@ -81,6 +81,7 @@ namespace molilian.core
                     itemName = item.Title,
                     pic = item.PicUrl,
                     price = item.ReservePrice,
+                    zkFinalPrice = item.ZkFinalPrice,
                     promotionPrice = item.PriceAfterCoupon,
                     couponAmount = $"{item.CouponAmount}",
                     couponEffectiveStartTime = item.CouponStartTime,
@@ -136,6 +137,7 @@ namespace molilian.core
                     itemName = item.Title,
                     pic = item.PicUrl,
                     price = item.ReservePrice,
+                    zkFinalPrice = item.ZkFinalPrice,
                     promotionPrice = item.PriceAfterCoupon,
                     couponAmount = $"{item.CouponAmount}",
                     couponEffectiveStartTime = item.CouponStartTime,

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

@@ -187,6 +187,8 @@ namespace molilian.core
                 .Add("subCode", data.subCode)
                 .Add("ip", data.ip)
                 .Add("oaid", data.oaid)
+                .Add("riskStrategy", data.riskStrategy)
+                .Add("launchScene", data.launchScene)
                 .Add("create_time", data.create_time)
                 .Add("parse_type", data.parse_type)
                 .Create(DBContext.InsertType.NORMAL, transaction);

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

@@ -179,6 +179,8 @@ namespace molilian.core
                 .Add("pic", data.pic)
                 .Add("couponAmount", data.couponAmount)
                 .Add("promotionPrice", data.promotionPrice)
+                .Add("reservePrice", data.reservePrice)
+                .Add("zkFinalPrice", data.zkFinalPrice)
                 .Add("taoToken", data.taoToken)
                 .Add("shortLinkurl", data.shortLinkurl)
                 .Add("deeplink_url", data.deeplink_url)

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

@@ -171,6 +171,8 @@ namespace molilian.core
                   .Add("itemName", data.itemName)
                   .Add("pic", data.pic)
                   .Add("promotionPrice", data.promotionPrice)
+                  .Add("zkFinalPrice", data.zkFinalPrice)
+                  .Add("reservePrice", data.reservePrice)
                   .Add("taoToken", data.taoToken)
                   .Add("shortLinkurl", data.shortLinkurl)
                   .Add("deeplink_url", data.deeplink_url)

+ 1 - 1
molilian.core/Core/taoke/TkActivityCore.cs

@@ -139,7 +139,7 @@ namespace molilian.core
                 input_page_id = page_id,
                 result.estimatedCommission,
                 result.maxCommission,
-                result.zkFinalPrice,
+                price = result.reservePrice,
                 result.reservePrice,
                 result.title,
                 result.picUrl,

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

@@ -343,6 +343,8 @@ namespace molilian.core
                 result.itemId,
                 result.itemName,
                 result.pic,
+                result.zkFinalPrice,
+                result.reservePrice,
                 result.promotionPrice,
                 result.couponAmount,
                 result.couponEffectiveStartTime,
@@ -741,8 +743,8 @@ namespace molilian.core
                 {
                     success = ValidateDeeplinkIfRequired(result.success, result.deeplink_url),
                     result.commercial,
-                    exposeTracks = TracksCore.BuildPath(TrackType.Expose, result),
-                    clickTracks = TracksCore.BuildPath(TrackType.Click, result),
+                    exposeTracks = TracksCore.BuildBrwSimilarPath(TrackType.Expose, result),
+                    clickTracks = TracksCore.BuildBrwSimilarPath(TrackType.Click, result),
                     result.with_middle_page,
                     result.message,
                     sub_message = result.reason,
@@ -750,9 +752,12 @@ namespace molilian.core
                     link_type = result.link_type.ToString(),
                     channel = result?.channel.ToString(),
                     result.channel_type,
+                    result.shopTitle,
                     result.itemId,
                     result.itemName,
                     result.pic,
+                    price = result.reservePrice,
+                    result.zkFinalPrice,
                     result.promotionPrice,
                     result.couponAmount,
                     result.couponEffectiveStartTime,
@@ -780,9 +785,12 @@ namespace molilian.core
                 link_type = result.link_type.ToString(),
                 channel = result?.channel.ToString(),
                 result.channel_type,
+                result.shopTitle,
                 result.itemId,
                 result.itemName,
                 result.pic,
+                result.zkFinalPrice,
+                price = result.reservePrice,
                 result.promotionPrice,
                 result.couponAmount,
                 result.couponEffectiveStartTime,
@@ -1629,6 +1637,15 @@ namespace molilian.core
         }
         private static APIResult PddParseOutput(PddDataDTO result, APIResultCodeEnum code = APIResultCodeEnum.OK)
         {
+            string itemName = result.itemName;
+            switch (result.riskStrategy)
+            {
+                case "tbpush":
+                case "icon":
+                    itemName = string.Empty;
+                    break;
+            }
+
             return new APIResult(new
             {
                 //result.success,
@@ -1642,7 +1659,7 @@ namespace molilian.core
                 link_type = result.link_type.ToString(),
                 channel = result?.channel.ToString(),
                 result.itemId,
-                result.itemName,
+                itemName,
                 result.shortLinkurl,
                 result.deeplink_url,
             }, code);

+ 2 - 0
molilian.core/Core/taoke/UnionParseCore/dp2dp.cs

@@ -506,6 +506,8 @@ namespace molilian.core
                 result.itemId,
                 result.itemName,
                 result.pic,
+                result.zkFinalPrice,
+                price = result.reservePrice,
                 result.promotionPrice,
                 result.couponAmount,
                 result.couponEffectiveStartTime,

+ 3 - 0
molilian.core/DTO/TracksDTO.cs

@@ -31,6 +31,7 @@ namespace molilian.core
         public string scene { get; set; } = string.Empty;
         public string unique_id { get; set; } = string.Empty;
         public int track_link_id { get; set; } = 0;
+        public int account_id { get; set; } = 0;
         public int event_count { get; set; } = 0;
         public DateTime create_time { get; set; } = DateTime.Now;
         public DateTime update_time { get; set; } = DateTime.Now;
@@ -44,6 +45,7 @@ namespace molilian.core
         public string typename { get; set; } = string.Empty;
         public string scene { get; set; } = string.Empty;
         public string unique_id { get; set; } = string.Empty;
+        public int account_id { get; set; } = 0;
         public DateTime report_date { get; set; } = DateTime.Now.Date;
         public int hour { get; set; } = 0;
         public string hour_label => $"{hour:00}:00";
@@ -56,6 +58,7 @@ namespace molilian.core
         [Key]
         public long id { get; set; }
         public int track_id { get; set; } = 0;
+        public int account_id { get; set; } = 0;
         public string event_type { get; set; } = string.Empty;
         public string platform { get; set; } = string.Empty;
         public string typename { get; set; } = string.Empty;

+ 1 - 0
molilian.core/DTO/alimama/PromotionQueryDTO.cs

@@ -48,6 +48,7 @@ namespace molilian.core
         public string itemName { get; set; } = string.Empty;
         public string pic { get; set; } = string.Empty;
         public string price { get; set; } = string.Empty;
+        public string zkFinalPrice { get; set; } = string.Empty;
         public string promotionPrice { get; set; } = string.Empty;
         public string couponAmount { get; set; } = string.Empty;
         public string couponEffectiveStartTime { get; set; } = string.Empty;

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

@@ -109,6 +109,8 @@ namespace molilian.core
         public string itemName { get; set; } = string.Empty;
         public decimal couponAmount { get; set; } = 0;
         public decimal promotionPrice { get; set; } = 0;
+        public decimal reservePrice { get; set; } = 0;
+        public decimal zkFinalPrice { get; set; } = 0;
         public string pic { get; set; } = string.Empty;
         public string sellerNickName { get; set; } = string.Empty;
         public string shopTitle { get; set; } = string.Empty;

+ 6 - 2
molilian.core/Plus/Alimama/parse.cs

@@ -240,9 +240,13 @@ namespace molilian.core
                 result.PromotionImg = await InternalCallPromotionQuery(result.pic, request.Oaid, request.Ip);
                 //	"pic": "https://img.alicdn.com/i4/6000000004750/O1CN01w4wgqa1kxYS1BadZp_!!6000000004750-0-sm.jpg",
                 //result.pic
-                //result.PromotionImg[*].pic
+                //result.PromotionImg[*].pic
+                int i = 0;
                 foreach (var item in result.PromotionImg)
-                {
+                {
+                    i++;
+                    item.clickTracks = TracksCore.BuildBrwSimilarPath(TrackType.Click, result, item, i);
+                    item.exposeTracks = TracksCore.BuildBrwSimilarPath(TrackType.Expose, result, item, i);
                     item.pic = NormalizeAlicdnImageUrl(item.pic);
                 }
             }

+ 8 - 0
molilian.core/Plus/Alimama/parse_endpoint/aliyun.cs

@@ -102,6 +102,14 @@ namespace molilian.core
             {
                 result.promotionPrice = promotionPrice;
             }
+            if (decimal.TryParse(data.ReservePrice, out decimal reservePrice))
+            {
+                result.reservePrice = reservePrice;
+            }
+            if (decimal.TryParse(data.ZkFinalPrice, out decimal zkFinalPrice))
+            {
+                result.zkFinalPrice = zkFinalPrice;
+            }
             result.sellerNickName = data.Nick;
             result.shopTitle = data.ShopTitle;
             string picUrl = data.PicUrl;

+ 2 - 2
molilian.core/Plus/Aliyun/ImageSearch.cs

@@ -60,7 +60,7 @@ namespace molilian.core
                     Pid = pid,
                     Crop = true,
                     Num = 20,
-                    Fields = "itemId,Url,CouponShareUrl,DeeplinkUrl,DeeplinkCouponShareUrl,UserType,ShopTitle,Title,PicUrl,ReservePrice,PriceAfterCoupon,CouponAmount,CouponStartTime,CouponEndTime,Volume,Provcity"
+                    Fields = "itemId,Url,CouponShareUrl,DeeplinkUrl,DeeplinkCouponShareUrl,UserType,ShopTitle,Title,PicUrl,ZkFinalPrice,ReservePrice,PriceAfterCoupon,CouponAmount,CouponStartTime,CouponEndTime,Volume,Provcity"
                 };
 
                 // 选填,需要返回的字段list。不同的字段用逗号分割。默认 PicUrl,ReservePrice,Title,Url,ZkFinalPrice
@@ -154,7 +154,7 @@ namespace molilian.core
                 {
                     ItemIds = itemIds,
                     Pid = pid,
-                    Fields = "itemId,Title,Nick,SellerId,ShortTitle,SubTitle,PicUrl,ReservePrice,ZkFinalPrice,PriceAfterCoupon,CouponTotalCount,CouponRemainCount,CouponStartTime,CouponEndTime,CouponStartFee,CouponAmount,CouponInfo,CommissionRate,CouponShareUrl,DeeplinkCouponShareUrl,Url,DeeplinkUrl"
+                    Fields = "itemId,Title,Nick,SellerId,ShortTitle,ShopTitle,SubTitle,PicUrl,ReservePrice,ZkFinalPrice,PriceAfterCoupon,CouponTotalCount,CouponRemainCount,CouponStartTime,CouponEndTime,CouponStartFee,CouponAmount,CouponInfo,CommissionRate,CouponShareUrl,DeeplinkCouponShareUrl,Url,DeeplinkUrl"
                 };
 
                 var response = await client.GetProductInfoByIdsWithOptionsAsync(request, runtime);

+ 1 - 0
molilian.core/Plus/OtherApiPlus.cs

@@ -117,6 +117,7 @@ namespace molilian.core
                 newItem.itemName = item.Read<string>("Title", string.Empty);
                 newItem.pic = item.Read<string>("PicUrl", string.Empty);
                 newItem.price = item.Read<string>("ReservePrice", string.Empty);
+                newItem.zkFinalPrice = item.Read<string>("ZkFinalPrice", string.Empty);
                 newItem.promotionPrice = item.Read<string>("PriceAfterCoupon", string.Empty);
                 newItem.couponAmount = item.Read<string>("CouponAmount", string.Empty);
                 newItem.couponEffectiveStartTime = item.Read<string>("CouponStartTime", string.Empty);

+ 1 - 0
molilian.core/Plus/pdd/PddUnionPlus.cs

@@ -220,6 +220,7 @@ namespace molilian.core
         {
             switch (request.RiskStrategy)
             {
+                case "icon":
                 case "tbpush":
                     if (AlimamaPlus.IsDigitsOnly(request.Content))
                     {

+ 55 - 4
track_report_schema_fix.sql

@@ -1,6 +1,6 @@
 -- Fix track report dimensions:
 -- 1. track_links stores platform and typename separately.
--- 2. track_daily_report uniqueness is based on the monitored link + metric scene.
+-- 2. track_daily_report uniqueness is based on the monitored link + metric scene + account.
 
 SET @sql = (
   SELECT IF(
@@ -32,6 +32,40 @@ PREPARE stmt FROM @sql;
 EXECUTE stmt;
 DEALLOCATE PREPARE stmt;
 
+SET @sql = (
+  SELECT IF(
+    COUNT(*) = 0,
+    'ALTER TABLE `track_daily_report` ADD COLUMN `account_id` int NOT NULL DEFAULT 0 AFTER `track_link_id`',
+    'SELECT 1'
+  )
+  FROM information_schema.COLUMNS
+  WHERE TABLE_SCHEMA = DATABASE()
+    AND TABLE_NAME = 'track_daily_report'
+    AND COLUMN_NAME = 'account_id'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+SET @sql = (
+  SELECT IF(
+    (SELECT COUNT(*)
+     FROM information_schema.TABLES
+     WHERE TABLE_SCHEMA = DATABASE()
+       AND TABLE_NAME = 'track_request_logs') > 0
+    AND COUNT(*) = 0,
+    'ALTER TABLE `track_request_logs` ADD COLUMN `account_id` int NOT NULL DEFAULT 0 AFTER `track_id`',
+    'SELECT 1'
+  )
+  FROM information_schema.COLUMNS
+  WHERE TABLE_SCHEMA = DATABASE()
+    AND TABLE_NAME = 'track_request_logs'
+    AND COLUMN_NAME = 'account_id'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
 UPDATE `track_links`
 SET `typename` = CASE
   WHEN `typename` <> '' THEN `typename`
@@ -71,7 +105,7 @@ DROP TEMPORARY TABLE IF EXISTS `tmp_track_daily_merge`;
 CREATE TEMPORARY TABLE `tmp_track_daily_keep` AS
 SELECT MIN(`id`) AS `id`
 FROM `track_daily_report`
-GROUP BY `report_date`, `event_type`, `track_link_id`, `scene`;
+GROUP BY `report_date`, `event_type`, `track_link_id`, `scene`, `account_id`;
 
 CREATE TEMPORARY TABLE `tmp_track_daily_merge` AS
   SELECT
@@ -79,9 +113,10 @@ CREATE TEMPORARY TABLE `tmp_track_daily_merge` AS
     `event_type`,
     `track_link_id`,
     `scene`,
+    `account_id`,
     MAX(`event_count`) AS `event_count`
   FROM `track_daily_report`
-  GROUP BY `report_date`, `event_type`, `track_link_id`, `scene`;
+  GROUP BY `report_date`, `event_type`, `track_link_id`, `scene`, `account_id`;
 
 UPDATE `track_daily_report` d
 JOIN `tmp_track_daily_merge` m
@@ -89,6 +124,7 @@ JOIN `tmp_track_daily_merge` m
    AND d.`event_type` = m.`event_type`
    AND d.`track_link_id` = m.`track_link_id`
    AND d.`scene` = m.`scene`
+   AND d.`account_id` = m.`account_id`
 SET d.`event_count` = m.`event_count`
 WHERE d.`id` IN (SELECT `id` FROM `tmp_track_daily_keep`);
 
@@ -101,4 +137,19 @@ DROP TEMPORARY TABLE `tmp_track_daily_keep`;
 DROP TEMPORARY TABLE `tmp_track_daily_merge`;
 
 ALTER TABLE `track_daily_report`
-  ADD UNIQUE KEY `uk_track_daily` (`report_date`, `event_type`, `track_link_id`, `scene`);
+  ADD UNIQUE KEY `uk_track_daily` (`report_date`, `event_type`, `track_link_id`, `scene`, `account_id`);
+
+SET @sql = (
+  SELECT IF(
+    COUNT(*) = 0,
+    'ALTER TABLE `track_daily_report` ADD KEY `idx_track_daily_account` (`report_date`, `account_id`, `track_link_id`)',
+    'SELECT 1'
+  )
+  FROM information_schema.STATISTICS
+  WHERE TABLE_SCHEMA = DATABASE()
+    AND TABLE_NAME = 'track_daily_report'
+    AND INDEX_NAME = 'idx_track_daily_account'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;

+ 1 - 0
track_request_logs.sql

@@ -1,6 +1,7 @@
 CREATE TABLE `track_request_logs` (
   `id` bigint NOT NULL AUTO_INCREMENT,
   `track_id` int NOT NULL DEFAULT 0,
+  `account_id` int NOT NULL DEFAULT 0,
   `event_type` varchar(32) NOT NULL DEFAULT '',
   `platform` varchar(64) NOT NULL DEFAULT '',
   `typename` varchar(64) NOT NULL DEFAULT '',

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