Commit 97ce80d6 by 林冲

scene_split_processor.py 增加merchant_id

1 parent 57b3f260
......@@ -32,12 +32,15 @@ class IDMappingManager:
old_id BIGINT NOT NULL COMMENT '原ID',
new_id BIGINT NOT NULL COMMENT '新ID',
base_scene_code VARCHAR(20) COMMENT '场景编码',
merchant_id BIGINT COMMENT '商户ID',
created_date DATETIME NOT NULL COMMENT '创建时间',
KEY uk_table_old_new (table_name, old_id, new_id),
KEY idx_table_old (table_name, old_id),
KEY idx_table_new (table_name, new_id),
KEY idx_table_newid_scene (table_name, new_id, base_scene_code),
KEY idx_table_oldid_scene (table_name, old_id, base_scene_code)
KEY idx_table_oldid_scene (table_name, old_id, base_scene_code),
KEY idx_table_merchant (table_name, merchant_id),
KEY idx_table_old_merchant (table_name, old_id, merchant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='规则ID映射关系临时表';
"""
try:
......@@ -56,7 +59,7 @@ class IDMappingManager:
except Exception as e:
self.logger.warning(f"删除临时映射表失败: {e}")
def add_mapping(self, table_name, old_id, new_id, base_scene_code):
def add_mapping(self, table_name, old_id, new_id, base_scene_code, merchant_id=None):
"""
添加ID映射关系
......@@ -65,16 +68,17 @@ class IDMappingManager:
old_id: 原ID
new_id: 新ID
base_scene_code: 场景编码
merchant_id: 商户ID(可选)
"""
merchant_id_str = str(merchant_id) if merchant_id is not None else 'NULL'
insert_sql = f"""
INSERT INTO {self.mapping_table}
(table_name, old_id, new_id, base_scene_code, created_date)
VALUES ('{table_name}', {old_id}, {new_id}, '{base_scene_code}', NOW())
ON DUPLICATE KEY UPDATE base_scene_code = '{base_scene_code}';
(table_name, old_id, new_id, base_scene_code, merchant_id, created_date)
VALUES ('{table_name}', {old_id}, {new_id}, '{base_scene_code}', {merchant_id_str}, NOW());
"""
try:
self.db.execute_update(insert_sql)
self.logger.debug(f"添加映射: {table_name} {old_id} -> {new_id} ({base_scene_code})")
self.logger.debug(f"添加映射: {table_name} {old_id} -> {new_id} ({base_scene_code}, merchant_id={merchant_id})")
except Exception as e:
self.logger.error(f"添加映射失败: {table_name} {old_id} -> {new_id}, 错误: {e}")
raise
......
......@@ -157,8 +157,11 @@ def main():
# 定义步骤映射
steps = {
# dj_car_life_merchant_settle_account_rule主表全部拆分,增加商户ID写入tmp_rule_id_mapping
1: ('处理财务账户规则主表(表1)', processor.step1_process_settle_account_rule),
# dj_car_life_merchant_division_rule主表全部拆分,增加商户ID写入tmp_rule_id_mapping
2: ('处理分账规则主表(表6)', processor.step2_process_division_rule),
# 按照商户merchant_id维度处理(3-9步)
3: ('处理结算规则分组表(表2)', processor.step3_process_settle_rule_group),
4: ('处理分账规则分组表(表7)', processor.step4_process_division_rule_group),
5: ('处理商品分组表(表4)', processor.step5_process_goods_type_group),
......@@ -166,9 +169,13 @@ def main():
7: ('处理商品分组关系表(表5)- 财务侧', processor.step7_process_goods_type_group_relation_finance),
8: ('处理分账明细规则表(表8)', processor.step8_process_distribution_rule),
9: ('处理自动分账配置表(表13)', processor.step9_process_division_rule_auto),
# dj_car_life_merchant_reconciliation_rule主表全部拆分,增加商户ID写入tmp_rule_id_mapping
10: ('处理对账规则主表(表9)', processor.step10_process_reconciliation_rule),
# 按照商户merchant_id维度处理
11: ('处理对账分组规则表(表10)及级联', processor.step11_process_reconciliation_rule_group),
# 审核记录不做处理,注释废弃
# 12: ('处理审核记录表(表12)', processor.step12_process_rule_audit),
# 无需根据商户维度处理,保持不变,增加商户ID写入tmp_rule_id_mapping
13: ('处理生效记录表(表11)', processor.step13_process_effect_record),
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!