Commit 335323c3 by zhouhaibao

feat(report): 更新红黄报表数据结构和计算逻辑

- 调整了门店分成相关字段映射关系,修正字段含义
- 新增 store_share_ratio 字段用于门店分成占比计算
- 在模型定义中添加 store_share_ratio 数据库字段
- 更新 SQL 模板文件,添加相应的数据库表结构变更
- 修复字段注释和计算公式,确保数据准确性
- 统一了门店单车利润等关键指标的计算方式
1 parent 18f23017
...@@ -207,13 +207,13 @@ INSHOP_COL_MAP = { ...@@ -207,13 +207,13 @@ INSHOP_COL_MAP = {
59: 'frontline_incentive_ratio',# 一线激励占比 59: 'frontline_incentive_ratio',# 一线激励占比
60: 'gross_profit_pre_share',# 进销差/未分成 60: 'gross_profit_pre_share',# 进销差/未分成
61: 'gross_profit_pre_share_ratio',# 进销差/占比 61: 'gross_profit_pre_share_ratio',# 进销差/占比
62: 'store_share', # 门店分成/流量费/财务 62: 'store_share', # 门店分成/流量费(财务列表) → SQL 直接值
63: 'store_share_per_car', # 门店分成 63: 'store_share_ratio', # 门店分成(占比) → store_share/store_output_value*100%
64: 'guarantee_amount', # 门店单车利润 → guarantee_amount 64: 'store_share_per_car', # 门店单车利润 → store_share/delivery_cnt
65: 'gl_share', # 兜底金额情况 → gl_share 65: None, # 兜底金额情况 → 默认为空(ORM 无此字段)
66: 'gl_share_ratio', # 兜底金额 → gl_share_ratio 66: 'guarantee_amount', # 兜底金额 → 默认=0
67: 'gl_share', # 广联分成 → gl_share(⚠️与col65同ORM字段,业务侧复核) 67: 'gl_share', # 广联分成 → 进销差-门店分成-兜底金额
68: 'gl_share_ratio', # 广联分成/占比 → gl_share_ratio(⚠️与col66同ORM字段) 68: 'gl_share_ratio', # 广联分成(占比) → gl_share/store_output_value*100%
69: 'construction_income', # 施工收入 → construction_income 69: 'construction_income', # 施工收入 → construction_income
70: 'internal_settle_profit', # 内部结算 → internal_settle_profit 70: 'internal_settle_profit', # 内部结算 → internal_settle_profit
71: 'gl_total_share', # 广联总分成 → gl_total_share 71: 'gl_total_share', # 广联总分成 → gl_total_share
......
...@@ -356,3 +356,12 @@ CREATE TABLE `report_light_reform_park` ( ...@@ -356,3 +356,12 @@ CREATE TABLE `report_light_reform_park` (
UNIQUE KEY `uk_park_period_park_store` UNIQUE KEY `uk_park_period_park_store`
(`task_id`, `period_start`, `period_end`, `park_name`, `store_name`) (`task_id`, `period_start`, `period_end`, `park_name`, `store_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='红黄门店盈利测算-轻改园区店汇总表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='红黄门店盈利测算-轻改园区店汇总表';
-- ============================================================================
-- 增量 ALTER: 店中店新增 store_share_ratio (门店分成占比) 字段
-- 2026-09-10: col63 表头"门店分成(占比)"模板需要此列,但 ORM/DDL 均缺失
-- ============================================================================
ALTER TABLE report_light_reform_inshop
ADD COLUMN `store_share_ratio` DECIMAL(10, 6) DEFAULT 0
COMMENT '门店分成占比(门店分成/门店总产值)'
AFTER `store_share`;
...@@ -464,6 +464,7 @@ class LightReformInshopProcessor: ...@@ -464,6 +464,7 @@ class LightReformInshopProcessor:
gross_profit_pre_share=gross_profit_pre_share, gross_profit_pre_share=gross_profit_pre_share,
gross_profit_pre_share_ratio=gross_profit_pre_share_ratio, gross_profit_pre_share_ratio=gross_profit_pre_share_ratio,
store_share=store_share, store_share=store_share,
store_share_ratio=store_share_ratio,
store_share_per_car=store_share_per_car, store_share_per_car=store_share_per_car,
guarantee_amount=guarantee_amount, guarantee_amount=guarantee_amount,
gl_share=gl_share, gl_share=gl_share,
......
...@@ -490,6 +490,7 @@ class ReportLightReformInshop(db.Model): ...@@ -490,6 +490,7 @@ class ReportLightReformInshop(db.Model):
gross_profit_pre_share = db.Column(db.DECIMAL(15, 2), default=0, comment='进销差(未分成)') gross_profit_pre_share = db.Column(db.DECIMAL(15, 2), default=0, comment='进销差(未分成)')
gross_profit_pre_share_ratio = db.Column(db.DECIMAL(10, 6), default=0, comment='进销差占比') gross_profit_pre_share_ratio = db.Column(db.DECIMAL(10, 6), default=0, comment='进销差占比')
store_share = db.Column(db.DECIMAL(15, 2), default=0, comment='门店分成') store_share = db.Column(db.DECIMAL(15, 2), default=0, comment='门店分成')
store_share_ratio = db.Column(db.DECIMAL(10, 6), default=0, comment='门店分成占比(门店分成/门店总产值)')
store_share_per_car = db.Column(db.DECIMAL(15, 2), default=0, comment='门店单车利润') store_share_per_car = db.Column(db.DECIMAL(15, 2), default=0, comment='门店单车利润')
guarantee_amount = db.Column(db.DECIMAL(15, 2), default=0, comment='兜底金额') guarantee_amount = db.Column(db.DECIMAL(15, 2), default=0, comment='兜底金额')
gl_share = db.Column(db.DECIMAL(15, 2), default=0, comment='广联分成') gl_share = db.Column(db.DECIMAL(15, 2), default=0, comment='广联分成')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!