Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
dealaccountdata
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 efcd8ebf
authored
May 10, 2026
by
林冲
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
_process_audit_finance修复多保存一条数据
1 parent
7c4a9591
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
0 deletions
scene_refactor_data/.claude/settings.local.json
scene_refactor_data/BUGFIX_AUDIT_FINANCE.md
scene_refactor_data/.claude/settings.local.json
0 → 100644
View file @
efcd8eb
{
"permissions"
:
{
"allow"
:
[
"Bash(python main_scene_split.py --steps=5)"
,
"Bash(python main_scene_split.py --start-step=5 --end-step=5 --test-mode)"
]
}
}
scene_refactor_data/BUGFIX_AUDIT_FINANCE.md
0 → 100644
View file @
efcd8eb
# _process_audit_finance 方法修复报告
## 问题描述
**问题:**
`_process_audit_finance`
方法在处理 scene_type=0 的审核记录时,逻辑不正确。
**错误行为:**
-
原记录已经通过
`_update_audit_base_scene_code`
更新为
`110101`
场景
-
但代码仍然为所有4个场景(包括
`110101`
)都执行 INSERT 操作
-
导致
`110101`
场景的记录重复:1条更新 + 1条插入 = 2条
**正确行为:**
-
原记录更新为
`110101`
场景(已完成)
-
只需要为后面3个场景(
`110102`
,
`110201`
,
`110202`
)执行 INSERT 操作
-
最终结果:1条原记录(更新) + 3条新记录(插入) = 4条
---
## 场景拆分逻辑
### SCENE_TYPE_0_SPLIT 定义
```
python
SCENE_TYPE_0_SPLIT
=
[
'110101'
,
# 售前会员权益升级(原记录更新为此值)
'110102'
,
# 售后会员权益升级(复制插入)
'110201'
,
# 售前延保(复制插入)
'110202'
,
# 售后延保(复制插入)
]
```
---
## 修复方案
### 修改前
```
python
# 按顺序组装新记录
for
i
in
range
(
len
(
settle_mappings
)):
new_settle_id
=
settle_mappings
[
i
][
0
]
base_scene_code
=
settle_mappings
[
i
][
1
]
# 为所有场景都执行 INSERT(包括 110101)❌
insert_sql
=
f
"""INSERT INTO {table_name} ..."""
copy_count
+=
1
```
### 修改后
```
python
# 按顺序组装新记录
# 注意:第一个场景(110101)是通过更新原记录实现的,所以只需要插入后面3个
first_scene_code
=
SCENE_TYPE_0_SPLIT
[
0
]
# 110101
for
i
in
range
(
len
(
settle_mappings
)):
new_settle_id
=
settle_mappings
[
i
][
0
]
base_scene_code
=
settle_mappings
[
i
][
1
]
# 跳过第一个场景(110101),因为它是通过更新原记录实现的 ✅
if
base_scene_code
==
first_scene_code
:
# 为原记录建立映射关系(old_id -> old_id)
self
.
id_mapper
.
add_mapping
(
table_name
,
old_id
,
old_id
,
base_scene_code
)
continue
# 只为后面3个场景执行 INSERT ✅
insert_sql
=
f
"""INSERT INTO {table_name} ..."""
copy_count
+=
1
```
---
## 数据量影响
### 修复前(错误)
假设有 N 条 scene_type=0 的审核记录:
-
UPDATE:N 条(更新为 110101)
-
INSERT:N × 4 条(为所有4个场景都插入)
-
**总计:N × 5 条**
❌(多了 N 条)
### 修复后(正确)
假设有 N 条 scene_type=0 的审核记录:
-
UPDATE:N 条(更新为 110101)
-
INSERT:N × 3 条(只为后面3个场景插入)
-
**总计:N × 4 条**
✅
---
## 验证方法
```
sql
-- 查询拆分后的记录数(应该是原始数量的4倍)
SELECT
base_scene_code
,
COUNT
(
*
)
as
count
FROM
dj_car_life_rule_audit
WHERE
scene_type
=
0
AND
rule_type
=
1
AND
deleted_flag
=
'N'
AND
base_scene_code
IN
(
'110101'
,
'110102'
,
'110201'
,
'110202'
)
GROUP
BY
base_scene_code
ORDER
BY
base_scene_code
;
-- 验证:每个场景的记录数应该相等
```
---
## 总结
### 问题根源
没有考虑到原记录已经通过 UPDATE 更新为
`110101`
场景,导致为所有4个场景都执行 INSERT,造成记录重复。
### 修复内容
添加判断逻辑,跳过第一个场景(
`110101`
)的 INSERT 操作,只为后面3个场景插入新记录。
---
**修复状态:**
✅ 已完成
**修复日期:**
2026-05-10
**修复版本:**
v1.2
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