上传源代码版本

This commit is contained in:
Im-Jenisson
2026-06-01 16:30:29 +08:00
commit b2a9b7d3c2
462 changed files with 104365 additions and 0 deletions

46
unclaimed-count-debug.sql Normal file
View File

@@ -0,0 +1,46 @@
-- 总无人认领数统计(单独查询,用于排查)
-- 逻辑扫描历史记录中CustomerId为0的有扫描记录的订单数去重
WITH
-- 步骤1获取所有CustomerId为0的扫描记录
UnclaimedScans AS (
SELECT
s.NeutralWaybillNumber,
s.CustomerId,
DATE(CONVERT_TZ(s.CreatedAt, '+00:00', '-05:00')) AS ,
s.CreatedAt AS ,
s.Result,
s.Description
FROM label_scan_history s
WHERE s.CustomerId = 0
),
-- 步骤2每个中性面单号每天取最新一条记录
DailyUnclaimedDistinct AS (
SELECT
NeutralWaybillNumber,
,
,
Result,
Description,
ROW_NUMBER() OVER (PARTITION BY NeutralWaybillNumber, ORDER BY DESC) AS rn
FROM UnclaimedScans
),
-- 步骤3统计每日总无人认领数去重
DailyUnclaimedCount AS (
SELECT
,
COUNT(DISTINCT NeutralWaybillNumber) AS
FROM DailyUnclaimedDistinct
WHERE rn = 1
GROUP BY
)
-- 最终查询结果
SELECT
AS ,
,
(UTC_TIMESTAMP() - INTERVAL 5 HOUR) AS UTC_5
FROM DailyUnclaimedCount
ORDER BY DESC;