Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
data_report
/
data-report
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 38d60eb4
authored
Nov 04, 2026
by
周立明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
北汽专项-售后订单数口径修订
1 parent
73e4af4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
.workbuddy/memory/2026-11-04.md
data-process/baic_special_processor.py
.workbuddy/memory/2026-11-04.md
View file @
38d60eb
...
...
@@ -31,3 +31,15 @@
2) dj_order_type != 6 改为 OR IS NULL 兜底(NULL 行 != 比较会被漏)。
-
退款金额不按 success_date 截断(跟随用户原稿:周期内订单的全部退款均扣减);若退款表含需按状态过滤的记录须另行告知。
-
已 py_compile + mock 验证参数绑定/换算;生效需重启后端 PID 13536。
## 北汽专项-结果表导出文件名改中文(2026-11-04)
-
OSS object_key 前缀 baic_special_ → 北汽专项_(baic_special_processor.py 2074 行,与招聘管理/阿维塔专项同模式);本地预览副本 outputs/baic_special_{month}_task{task_id}.xlsx 保持英文前缀不变。
-
已 py_compile + grep 回读;生效需重启后端 PID 13536。
## 北汽专项-售后订单数口径修订(2026-11-04)
-
新口径:status IN (4,6,12)、排除内部结算 dj_order_type=6、退款过滤(无退款记录 或 存在 refund_type NULL/2 的退款记录才计数)。
-
BAIC_AFTER_SALE_ORDER_SQL 已改。用户原稿两处问题修正:
1) 退款表与客户单同用别名 c(Not unique table/alias 报错)→ 改 EXISTS 子查询(别名 r);
2) 退款明细直接 LEFT JOIN 会把 COUNT(0) 按退款笔数扇出放大 → EXISTS 无扇出。
-
注意:与产值 SQL 不同,此处退款是「过滤计数」而非「扣减金额」;客户单 c(sales_type=1) JOIN 及其余谓词不变。
-
已 py_compile + mock 验证;生效需重启后端 PID 13536。
data-process/baic_special_processor.py
View file @
38d60eb
...
...
@@ -767,8 +767,15 @@ def _month_last_day(d):
return
date
(
d
.
year
,
d
.
month
+
1
,
1
)
-
timedelta
(
days
=
1
)
# 售后订单数(用户 2026-10-16 指定口径):主订单 a + 支付单 b(pay_status=2) + 客户单 c(sales_type=1),
# 按商户 GROUP BY COUNT(0),得到「延保+权益」合并总数(不分拆)。商户号/时间为入参,其余参数固定。
# 售后订单数(用户 2026-10-16 指定口径;2026-11-04 修订):主订单 a + 支付单 b(pay_status=2)
# + 客户单 c(sales_type=1),按商户 GROUP BY COUNT(0),得到「延保+权益」合并总数(不分拆)。
# 2026-11-04 修订:status IN (4,6,12)(已支付/已完成/已退款)、排除内部结算(dj_order_type=6)、
# 退款过滤——订单无退款记录,或存在 refund_type 为 NULL/2 的退款记录时才计数
# (等价于用户原稿「(r.refund_type is null or r.refund_type=2)」的逐行过滤语义)。
# 实现与用户原稿的差异(修正,口径不变):
# 1) 退款表原稿与客户单同用别名 c(MySQL 报 Not unique table/alias),改用 EXISTS 子查询;
# 2) 退款明细直接 LEFT JOIN 时一单多笔退款会把 COUNT(0) 按退款笔数扇出放大,
# EXISTS 存在性判断无扇出,计数恒为 1 行/客户单。
BAIC_AFTER_SALE_ORDER_SQL
=
"""
SELECT a.merchant_id, COUNT(0) AS order_cnt
FROM dj_car_life_goods_order a
...
...
@@ -778,7 +785,16 @@ LEFT JOIN dj_car_life_goods_order_customer c
ON c.order_code = a.order_code AND c.deleted_flag='N'
WHERE a.deleted_flag='N'
AND a.merchant_id IN :merchant_ids
AND a.scene_type=0 AND a.business_type=2 AND a.status=4
AND a.scene_type=0 AND a.business_type=2
AND a.status IN (4, 6, 12)
AND (a.dj_order_type != 6 OR a.dj_order_type IS NULL)
AND (
NOT EXISTS (SELECT 1 FROM dj_car_life_goods_order_refund_details r
WHERE r.order_code = a.order_code AND r.deleted_flag = 'N')
OR EXISTS (SELECT 1 FROM dj_car_life_goods_order_refund_details r
WHERE r.order_code = a.order_code AND r.deleted_flag = 'N'
AND (r.refund_type IS NULL OR r.refund_type = 2))
)
AND b.success_date >= :date_from
AND b.success_date < :date_to
AND c.sales_type=1
...
...
@@ -2071,7 +2087,7 @@ class BaicSpecialProcessor:
# 导致覆盖后下游/CDN 仍返回首次上传的文件。
_now
=
datetime
.
now
()
_ts
=
_now
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S
%
f'
)
object_key
=
f
"data-process/{_now.strftime('
%
Y
%
m
%
d')}/
baic_special
_{month}_{task_id}_{_ts}.xlsx"
object_key
=
f
"data-process/{_now.strftime('
%
Y
%
m
%
d')}/
北汽专项
_{month}_{task_id}_{_ts}.xlsx"
url
=
upload_file
(
tmp
,
object_key
)
logger
.
info
(
f
"[北汽] 结果表已上传 OSS:task {task_id} -> {url}"
)
except
Exception
as
ue
:
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment