Commit 901fe3c7 by zhouhaibao

refactor(budget): 精简预算达成数据处理逻辑

- 移除门店资产耗材、市场费总表、人力成本统计表、外施施工费用表的清洗与处理流程
- 精简 FEE_TYPES 枚举,仅保留房租水电和装修摊销两种费用类型
- 统一毛利公式为:嘀加分润 - 房租水电 - 装修摊销,不再区分嘀加自营
- 移除 processor reset 中对已删除费用字段的清零操作
- 精简 Excel 导出列,移除市场费/人员工资/外援施工/技师工资/营销团队工资/门店耗材/F公司毛利
- 未匹配费用追踪仅保留房租水电,跳过 process_consumables 调用
1 parent 31f35605
...@@ -971,9 +971,10 @@ def process_task(conn, task, dry_run=False): ...@@ -971,9 +971,10 @@ def process_task(conn, task, dry_run=False):
log(' dry-run:不写库,样例前 3 行:') log(' dry-run:不写库,样例前 3 行:')
for r in rows[:3]: for r in rows[:3]:
log(f' {r}') log(f' {r}')
# dry-run 也演示装修摊销 / 门店资产耗材预览(依赖库内已有的结果行) # dry-run 也演示装修摊销预览(依赖库内已有的结果行)
_preview_renovation(conn, task_id, stat_month, dry_run=True) _preview_renovation(conn, task_id, stat_month, dry_run=True)
_preview_consumables(conn, task_id, stat_month) # 2026-10 精简:门店资产耗材已移除,跳过预览
# _preview_consumables(conn, task_id, stat_month)
return len(rows) return len(rows)
deleted, inserted = save_budget_rows(conn, task_id, stat_month, rows) deleted, inserted = save_budget_rows(conn, task_id, stat_month, rows)
...@@ -985,13 +986,15 @@ def process_task(conn, task, dry_run=False): ...@@ -985,13 +986,15 @@ def process_task(conn, task, dry_run=False):
# 第二步:装修摊销(来自「装修费用表」附件,仅 1.1 业务) # 第二步:装修摊销(来自「装修费用表」附件,仅 1.1 业务)
ren_updated, ren_unmatched = process_renovation(conn, task_id, stat_month, dry_run=False) ren_updated, ren_unmatched = process_renovation(conn, task_id, stat_month, dry_run=False)
# 第三步:门店资产耗材(来自「门店资产耗材明细表」附件,按业务类型分别匹配) # 第三步:门店资产耗材 —— 2026-10 精简:门店资产耗材明细表已移除,跳过此步骤
cons_updated, cons_unmatched = process_consumables(conn, task_id, stat_month, dry_run=False) log(f' [门店资产耗材] 已移除(2026-10 精简),跳过 process_consumables')
cons_updated, cons_unmatched = 0, 0.0
# 第四步:未匹配金额写库(biz_unmatched_fee,先删后插幂等) # 第四步:未匹配金额写库(biz_unmatched_fee,先删后插幂等)
# 2026-10 精简:cons_unmatched 固定为 0(门店耗材不再处理)
unmatched_rows = write_unmatched_fee(conn, task_id, stat_month, ren_unmatched, cons_unmatched) unmatched_rows = write_unmatched_fee(conn, task_id, stat_month, ren_unmatched, cons_unmatched)
if unmatched_rows: if unmatched_rows:
log(f' 写入 {UNMATCHED_FEE_TABLE}:新增 {unmatched_rows} 行未匹配费用记录') log(f' 写入 {UNMATCHED_FEE_TABLE}:新增 {unmatched_rows} 行未匹配费用记录')
return inserted + ren_updated + cons_updated return inserted + ren_updated
except Exception: except Exception:
if not dry_run: if not dry_run:
update_clean_status(conn, file_row['id'], CLEAN_PENDING) # 失败回退为待清洗 update_clean_status(conn, file_row['id'], CLEAN_PENDING) # 失败回退为待清洗
......
...@@ -134,14 +134,11 @@ class Config: ...@@ -134,14 +134,11 @@ class Config:
'name': '预算达成数据', 'name': '预算达成数据',
'need_period': False, 'need_period': False,
'support_week': False, 'support_week': False,
# 2026-10 精简:移除市场费总表/人力成本统计表/外施施工费用表/门店资产耗材明细表
'forms': [ 'forms': [
'结算数据汇总表', '结算数据汇总表',
'市场费总表',
'人力成本统计表',
'外施施工费用表',
'房租水电费用表', '房租水电费用表',
'装修费用表', '装修费用表',
'门店资产耗材明细表',
], ],
}, },
'store_effect_earnings': { 'store_effect_earnings': {
......
...@@ -245,14 +245,10 @@ class BizUnmatchedFee(db.Model): ...@@ -245,14 +245,10 @@ class BizUnmatchedFee(db.Model):
updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间') updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
# fee_type 枚举常量 # fee_type 枚举常量
# 2026-10 精简:仅保留房租水电(processor 写入)和装修摊销(clean 写入)
FEE_TYPES = [ FEE_TYPES = [
'market_fee',
'external_construction',
'technician_salary',
'marketing_team_salary',
'rent_utilities', 'rent_utilities',
'renovation_amortization', 'renovation_amortization',
'store_consumables',
] ]
......
...@@ -55,7 +55,8 @@ BIZ_TYPE_2_1 = "2.1" # 2.1业务 ...@@ -55,7 +55,8 @@ BIZ_TYPE_2_1 = "2.1" # 2.1业务
BIZ_TYPE_2_3 = "2.3" # 2.3业务 BIZ_TYPE_2_3 = "2.3" # 2.3业务
# 必需的表单类型(仅下载这些文件) # 必需的表单类型(仅下载这些文件)
REQUIRED_FORM_TYPES = ['市场费总表', '人力成本统计表', '外施施工费用表', '房租水电费用表'] # 2026-10 精简:移除市场费总表/人力成本统计表/外施施工费用表(由 config.forms 控制)
REQUIRED_FORM_TYPES = ['房租水电费用表']
# 需要先行运行「预算达成数据清洗」(clean_budget_achievement) 的数据表类型; # 需要先行运行「预算达成数据清洗」(clean_budget_achievement) 的数据表类型;
# 该清洗负责建立 biz_budget_achieve 基础行与 GMV,供本脚本成本计算消费。 # 该清洗负责建立 biz_budget_achieve 基础行与 GMV,供本脚本成本计算消费。
...@@ -1520,24 +1521,26 @@ class DataProcessor: ...@@ -1520,24 +1521,26 @@ class DataProcessor:
password=_pwd, db=_db, charset='utf8mb4', autocommit=True) password=_pwd, db=_db, charset='utf8mb4', autocommit=True)
_cur = _conn.cursor() _cur = _conn.cursor()
# reset 前诊断 # reset 前诊断
_cur.execute("SELECT SUM(marketing_team_salary), SUM(technician_salary) FROM biz_budget_achieve WHERE task_id=%s AND stat_month=%s", (task.id, task.month)) # 2026-10 精简:仅诊断 processor 自己负责的字段(rent_utilities)
# renovation_amortization / store_consumables 由 clean_budget_achievement 写入,不得清零
_cur.execute("SELECT SUM(rent_utilities) FROM biz_budget_achieve WHERE task_id=%s AND stat_month=%s", (task.id, task.month))
_before = _cur.fetchone() _before = _cur.fetchone()
logger.info(f"[诊断] reset 参数: task.id={task.id!r}, task.month={task.month!r}") logger.info(f"[诊断] reset 参数: task.id={task.id!r}, task.month={task.month!r}")
logger.info(f"[诊断] reset 前: mkt={float(_before[0] or 0):.2f}, tech={float(_before[1] or 0):.2f}") logger.info(f"[诊断] reset 前: rent_utilities={float(_before[0] or 0):.2f}")
# 执行 reset # 2026-10 精简:仅清零 processor.py 自己负责重算的 rent_utilities
# renovation_amortization / store_consumables 由 clean_budget_achievement 管理,不应清零
# market_fee / external_construction / technician_salary / marketing_team_salary 已不再处理
_cur.execute(""" _cur.execute("""
UPDATE biz_budget_achieve UPDATE biz_budget_achieve
SET market_fee = 0, external_construction = 0, SET rent_utilities = 0,
technician_salary = 0, marketing_team_salary = 0,
rent_utilities = 0, renovation_amortization = 0, store_consumables = 0,
updated_at = CURRENT_TIMESTAMP updated_at = CURRENT_TIMESTAMP
WHERE task_id = %s AND stat_month = %s WHERE task_id = %s AND stat_month = %s
""", (task.id, task.month)) """, (task.id, task.month))
logger.info(f"[处理任务] 步骤 a-2 reset 影响行数: {_cur.rowcount}") logger.info(f"[处理任务] 步骤 a-2 reset 影响行数: {_cur.rowcount}")
# reset 后诊断 # reset 后诊断
_cur.execute("SELECT SUM(marketing_team_salary), SUM(technician_salary) FROM biz_budget_achieve WHERE task_id=%s AND stat_month=%s", (task.id, task.month)) _cur.execute("SELECT SUM(rent_utilities) FROM biz_budget_achieve WHERE task_id=%s AND stat_month=%s", (task.id, task.month))
_after = _cur.fetchone() _after = _cur.fetchone()
logger.info(f"[诊断] reset 后: mkt={float(_after[0] or 0):.2f}, tech={float(_after[1] or 0):.2f}") logger.info(f"[诊断] reset 后: rent_utilities={float(_after[0] or 0):.2f}")
_conn.close() _conn.close()
logger.info(f"[处理任务] 步骤 a-2 完成, 耗时 {time.time() - reset_start:.2f}s") logger.info(f"[处理任务] 步骤 a-2 完成, 耗时 {time.time() - reset_start:.2f}s")
except Exception as reset_err: except Exception as reset_err:
...@@ -1726,7 +1729,9 @@ class DataProcessor: ...@@ -1726,7 +1729,9 @@ class DataProcessor:
logger.info(f"[未匹配补录] 房租水电写库失败合并到 unmatched_collector: failed_amount={failed_amount}, rent_utilities now={unmatched_collector['rent_utilities']}") logger.info(f"[未匹配补录] 房租水电写库失败合并到 unmatched_collector: failed_amount={failed_amount}, rent_utilities now={unmatched_collector['rent_utilities']}")
# 人员工资汇总值和占比更新(按主键ID直接更新,在所有金额数据落库后执行) # 人员工资汇总值和占比更新(按主键ID直接更新,在所有金额数据落库后执行)
self._update_labor_ratios_by_id(task.id, task.month) # 2026-10 精简:人力成本统计表已移除,此步骤仅当 labor_results 非空时执行
if labor_results:
self._update_labor_ratios_by_id(task.id, task.month)
# 毛利更新(按主键ID直接更新,在所有前置数据落库后最后执行) # 毛利更新(按主键ID直接更新,在所有前置数据落库后最后执行)
self._update_gross_profit_by_id(task.id, task.month) self._update_gross_profit_by_id(task.id, task.month)
...@@ -1735,8 +1740,8 @@ class DataProcessor: ...@@ -1735,8 +1740,8 @@ class DataProcessor:
# ========== 步骤 e-2: 统一写库 biz_unmatched_fee(先删后插) ========== # ========== 步骤 e-2: 统一写库 biz_unmatched_fee(先删后插) ==========
# 所有 update 执行完毕后,把 unmatched_collector 一次性写入,避免顺序问题 # 所有 update 执行完毕后,把 unmatched_collector 一次性写入,避免顺序问题
PROCESSOR_FEE_TYPES = ['market_fee', 'external_construction', # 2026-10 精简:仅保留房租水电的未匹配追踪(其他费用类型不再处理)
'technician_salary', 'marketing_team_salary', 'rent_utilities'] PROCESSOR_FEE_TYPES = ['rent_utilities']
try: try:
logger.info(f"[未匹配写库] 最终 unmatched_collector={unmatched_collector}") logger.info(f"[未匹配写库] 最终 unmatched_collector={unmatched_collector}")
BizUnmatchedFee.query.filter( BizUnmatchedFee.query.filter(
...@@ -4410,26 +4415,15 @@ class DataProcessor: ...@@ -4410,26 +4415,15 @@ class DataProcessor:
elif prev_key_no_brand in prev_month_data: elif prev_key_no_brand in prev_month_data:
row["人员工资上月占比"] = prev_month_data[prev_key_no_brand]["personnel_salary_ratio"] row["人员工资上月占比"] = prev_month_data[prev_key_no_brand]["personnel_salary_ratio"]
# ---------- 计算毛利相关字段 ---------- # ---------- 计算毛利相关字段(2026-10 精简版) ----------
# F公司毛利 - 仅服务商=嘀加自营时计算 # F公司毛利 - 固定为 0(不再计算)
sp = (service_provider or "").strip() sp = (service_provider or "").strip()
is_dijia_self = "嘀加自营" in sp
if sp and sp not in _seen_sp:
_seen_sp.add(sp)
logger.info(f"[毛利计算] 服务商类型: '{sp}', 含嘀加自营={is_dijia_self}")
f_company_gross_profit = Decimal("0") f_company_gross_profit = Decimal("0")
if is_dijia_self:
f_company_gross_profit = service_fee - row["人员工资"]
f_company_gross_profit = round_2(f_company_gross_profit)
row["F公司毛利"] = f_company_gross_profit row["F公司毛利"] = f_company_gross_profit
# 毛利计算 # 2026-10 精简:统一公式,不再区分嘀加自营
# 服务商=嘀加自营时:毛利 = 嘀加分润 - 市场费 - 房租水电 - 装修摊销 - 门店耗材 + F公司毛利 # 毛利 = 嘀加分润 - 房租水电 - 装修摊销
# 服务商≠嘀加自营时:毛利 = 嘀加分润 - 市场费 - 房租水电 - 装修摊销 - 门店耗材 gross_profit = dijia_profit - row["房租及水电费"] - renovation
if is_dijia_self:
gross_profit = dijia_profit - row["市场费"] - row["房租及水电费"] - renovation - consumables + f_company_gross_profit
else:
gross_profit = dijia_profit - row["市场费"] - row["房租及水电费"] - renovation - consumables
row["毛利"] = round_2(gross_profit) row["毛利"] = round_2(gross_profit)
# 本月毛利率 = 毛利/GMV*100% # 本月毛利率 = 毛利/GMV*100%
...@@ -4444,8 +4438,8 @@ class DataProcessor: ...@@ -4444,8 +4438,8 @@ class DataProcessor:
row["毛利率上月"] = prev_month_data[prev_key_no_brand].get("gross_profit_ratio", Decimal("0")) row["毛利率上月"] = prev_month_data[prev_key_no_brand].get("gross_profit_ratio", Decimal("0"))
# 四舍五入所有金额 # 四舍五入所有金额
for key in ["市场费", "外援施工", "技师工资", "营销团队工资", "人员工资", # 2026-10 精简:移除市场费/外援施工/技师工资/营销团队工资/人员工资/门店耗材相关 key
"房租及水电费", "F公司毛利", "毛利"]: for key in ["房租及水电费", "F公司毛利", "毛利"]:
row[key] = round_2(row[key]) row[key] = round_2(row[key])
summary.append(row) summary.append(row)
...@@ -4533,7 +4527,7 @@ class DataProcessor: ...@@ -4533,7 +4527,7 @@ class DataProcessor:
park_amount = park_amount / park_count park_amount = park_amount / park_count
s["房租及水电费"] += round_2(park_amount) s["房租及水电费"] += round_2(park_amount)
# 重新计算占比和毛利(使用与主循环一致的公式) # 2026-10 精简:重新计算占比和毛利(已统一公式,不再区分嘀加自营)
for s in summary: for s in summary:
gmv = s["GMV"] gmv = s["GMV"]
revenue = s["产值"] revenue = s["产值"]
...@@ -4542,28 +4536,17 @@ class DataProcessor: ...@@ -4542,28 +4536,17 @@ class DataProcessor:
if ratio_denominator <= 0: if ratio_denominator <= 0:
ratio_denominator = Decimal("0") ratio_denominator = Decimal("0")
s["市场费本月占比"] = pct(s["市场费"], gmv) # 2026-10 精简:以下占比计算项不再有数据源,保留公式但值为 0
s["技师工资占比"] = pct(s["技师工资"], ratio_denominator) # s["市场费本月占比"] = pct(s["市场费"], gmv)
s["营销团队工资占比"] = pct(s["营销团队工资"], ratio_denominator) # s["技师工资占比"] = pct(s["技师工资"], ratio_denominator)
s["人员工资本月占比"] = pct(s["人员工资"], ratio_denominator) # s["营销团队工资占比"] = pct(s["营销团队工资"], ratio_denominator)
# s["人员工资本月占比"] = pct(s["人员工资"], ratio_denominator)
# 重新计算 F公司毛利 和 毛利(使用正确公式)
sp_recalc = (s.get("服务商", "") or "").strip()
is_dijia_self = "嘀加自营" in sp_recalc
f_company_gp = Decimal("0")
if is_dijia_self:
svc_fee = s.get("服务费", Decimal("0"))
f_company_gp = round_2(svc_fee - s["人员工资"])
s["F公司毛利"] = f_company_gp
# 2026-10 精简:F公司毛利固定为 0,毛利统一公式
s["F公司毛利"] = Decimal("0")
dijia_profit_sharing = s.get("嘀加分润", Decimal("0")) dijia_profit_sharing = s.get("嘀加分润", Decimal("0"))
renovation_amort = s.get("装修摊销", Decimal("0")) renovation_amort = s.get("装修摊销", Decimal("0"))
store_consum = s.get("门店耗材", Decimal("0")) gp = dijia_profit_sharing - s["房租及水电费"] - renovation_amort
if is_dijia_self:
gp = dijia_profit_sharing - s["市场费"] - s["房租及水电费"] - renovation_amort - store_consum + f_company_gp
else:
gp = dijia_profit_sharing - s["市场费"] - s["房租及水电费"] - renovation_amort - store_consum
s["毛利"] = round_2(gp) s["毛利"] = round_2(gp)
s["毛利率本月"] = pct(gp, gmv) s["毛利率本月"] = pct(gp, gmv)
...@@ -5587,16 +5570,22 @@ class DataProcessor: ...@@ -5587,16 +5570,22 @@ class DataProcessor:
return self._execute_batch_update(task_id, month, data_list, update_columns, log_prefix="外援施工费") return self._execute_batch_update(task_id, month, data_list, update_columns, log_prefix="外援施工费")
def _update_gross_profit_by_id(self, task_id, month): def _update_gross_profit_by_id(self, task_id, month):
"""按ID计算并更新毛利相关字段(F公司毛利、毛利、毛利率本月、毛利率上月)""" """按ID计算并更新毛利相关字段(2026-10 精简版本)
logger.info(f"[毛利更新] 开始按ID更新,task_id={task_id}, month={month}")
新公式(统一,不再区分嘀加自营):
毛利 = 嘀加分润 - 房租水电 - 装修摊销
毛利率本月 = 毛利 / GMV * 100
毛利率上月 = 上月毛利 / 上月GMV * 100
移除:市场费、门店耗材因子,f_company_gross_profit 固定为 0。
"""
logger.info(f"[毛利更新] 开始按ID更新(2026-10 精简版),task_id={task_id}, month={month}")
# 1. 查询当前月份所有记录 # 1. 查询当前月份所有记录(精简查询字段)
rows = db.session.execute( rows = db.session.execute(
text(""" text("""
SELECT id, service_provider, service_fee, dijia_profit_sharing, SELECT id, dijia_profit_sharing, rent_utilities, renovation_amortization,
market_fee, rent_utilities, renovation_amortization, gmv, traffic_name, business_type, brand, park_store
store_consumables, personnel_salary, gmv,
traffic_name, business_type, brand, park_store
FROM biz_budget_achieve FROM biz_budget_achieve
WHERE task_id=:tid AND stat_month=:sm WHERE task_id=:tid AND stat_month=:sm
"""), """),
...@@ -5655,40 +5644,23 @@ class DataProcessor: ...@@ -5655,40 +5644,23 @@ class DataProcessor:
count = 0 count = 0
for row in rows: for row in rows:
row_id = row.id row_id = row.id
service_provider = (row.service_provider or "").strip()
service_fee = float(row.service_fee or 0)
dijia_profit_sharing = float(row.dijia_profit_sharing or 0) dijia_profit_sharing = float(row.dijia_profit_sharing or 0)
market_fee = float(row.market_fee or 0)
rent_utilities = float(row.rent_utilities or 0) rent_utilities = float(row.rent_utilities or 0)
renovation_amortization = float(row.renovation_amortization or 0) renovation_amortization = float(row.renovation_amortization or 0)
store_consumables = float(row.store_consumables or 0)
personnel_salary = float(row.personnel_salary or 0)
gmv = float(row.gmv or 0) gmv = float(row.gmv or 0)
traffic_name = (row.traffic_name or "").strip() traffic_name = (row.traffic_name or "").strip()
business_type = (row.business_type or "").strip() business_type = (row.business_type or "").strip()
brand = (row.brand or "").strip() brand = (row.brand or "").strip()
park_store = (row.park_store or "").strip() park_store = (row.park_store or "").strip()
# F公司毛利判断 # 2026-10 精简:f_company_gross_profit 固定为 0,不再计算
is_dijia_self = "嘀加自营" in service_provider
# F公司毛利
f_company_gross_profit = 0.0 f_company_gross_profit = 0.0
if is_dijia_self:
f_company_gross_profit = round(service_fee - personnel_salary, 2) # 2026-10 精简:统一公式,不再区分嘀加自营
# 毛利 = 嘀加分润 - 房租水电 - 装修摊销
# 毛利 gross_profit = round(
if is_dijia_self: dijia_profit_sharing - rent_utilities - renovation_amortization, 2
gross_profit = round( )
dijia_profit_sharing - market_fee - rent_utilities
- renovation_amortization - store_consumables
+ f_company_gross_profit, 2
)
else:
gross_profit = round(
dijia_profit_sharing - market_fee - rent_utilities
- renovation_amortization - store_consumables, 2
)
# 毛利率本月 # 毛利率本月
if gmv != 0: if gmv != 0:
...@@ -6011,21 +5983,9 @@ class DataProcessor: ...@@ -6011,21 +5983,9 @@ class DataProcessor:
("成本\n(收入口径)", "cost_revenue"), ("成本\n(收入口径)", "cost_revenue"),
("流量费\n(收入口径)", "traffic_fee_revenue"), ("流量费\n(收入口径)", "traffic_fee_revenue"),
("嘀加分润", "dijia_profit_sharing"), ("嘀加分润", "dijia_profit_sharing"),
("市场费", "market_fee"), # 2026-10 精简:移除市场费/人力成本/外援施工/技师工资/营销团队工资/门店耗材/F公司毛利 系列列
("本月占比", "market_fee_ratio_current"),
("上月占比", "market_fee_ratio_previous"),
("人员工资", "personnel_salary"),
("外援施工", "external_construction"),
("技师工资", "technician_salary"),
("技师工资占比", "technician_salary_ratio"),
("营销团队工资", "marketing_team_salary"),
("营销团队工资占比", "marketing_team_salary_ratio"),
("本月占比", "personnel_salary_ratio_current"),
("上月占比", "personnel_salary_ratio_previous"),
("房租及\n水电费", "rent_utilities"), ("房租及\n水电费", "rent_utilities"),
("装修摊销", "renovation_amortization"), ("装修摊销", "renovation_amortization"),
("门店耗材", "store_consumables"),
("F公司毛利", "f_company_gross_profit"),
("毛利", "gross_profit"), ("毛利", "gross_profit"),
("本月毛利率", "gross_profit_ratio_current"), ("本月毛利率", "gross_profit_ratio_current"),
("上月毛利率", "gross_profit_ratio_previous"), ("上月毛利率", "gross_profit_ratio_previous"),
...@@ -6033,11 +5993,11 @@ class DataProcessor: ...@@ -6033,11 +5993,11 @@ class DataProcessor:
HEADERS = [h for h, _ in ORDERED] HEADERS = [h for h, _ in ORDERED]
# 列分类(用于数字格式) # 列分类(用于数字格式)
# 2026-10 精简:移除已删除列对应的分类项
AMOUNT_COLS = {'GMV', '收入', '成本(GMV口径)', '流量费(GMV口径)', '服务费', AMOUNT_COLS = {'GMV', '收入', '成本(GMV口径)', '流量费(GMV口径)', '服务费',
'成本(收入口径)', '流量费(收入口径)', '嘀加分润', '市场费', '人员工资', '成本(收入口径)', '流量费(收入口径)', '嘀加分润', '房租及水电费',
'外援施工', '技师工资', '营销团队工资', '房租及水电费', '装修摊销', '门店耗材', '装修摊销', '毛利'}
'F公司毛利', '毛利'} RATIO_COLS = {'本月占比', '上月占比', '本月毛利率', '上月毛利率'}
RATIO_COLS = {'本月占比', '上月占比', '技师工资占比', '营销团队工资占比', '本月毛利率', '上月毛利率'}
INT_COLS = {'订单数'} INT_COLS = {'订单数'}
# ---------- 4. 构建工作簿 ---------- # ---------- 4. 构建工作簿 ----------
...@@ -6063,15 +6023,14 @@ class DataProcessor: ...@@ -6063,15 +6023,14 @@ class DataProcessor:
cell.border = thin_border cell.border = thin_border
# 列宽 # 列宽
# 2026-10 精简:移除已删除列对应的列宽配置
column_widths = { column_widths = {
"是否为多品类": 10, "流量方名称": 18, "业务类型": 9, "主体": 14, "是否为多品类": 10, "流量方名称": 18, "业务类型": 9, "主体": 14,
"品牌": 8, "园区店": 18, "服务商": 14, "订单数": 8, "GMV": 14, "收入": 14, "品牌": 8, "园区店": 18, "服务商": 14, "订单数": 8, "GMV": 14, "收入": 14,
"成本(GMV口径)": 14, "本月占比": 11, "上月占比": 11, "成本(GMV口径)": 14, "本月占比": 11, "上月占比": 11,
"流量费(GMV口径)": 14, "服务费": 12, "成本(收入口径)": 14, "流量费(收入口径)": 14, "流量费(GMV口径)": 14, "服务费": 12, "成本(收入口径)": 14, "流量费(收入口径)": 14,
"嘀加分润": 12, "市场费": 12, "人员工资": 12, "外援施工": 11, "技师工资": 11, "嘀加分润": 12, "房租及水电费": 13, "装修摊销": 11,
"技师工资占比": 12, "营销团队工资": 13, "营销团队工资占比": 14, "毛利": 12, "本月毛利率": 11, "上月毛利率": 11,
"房租及水电费": 13, "装修摊销": 11, "门店耗材": 11,
"F公司毛利": 12, "毛利": 12, "本月毛利率": 11, "上月毛利率": 11,
} }
# 写入数据行(从第 2 行开始)—— 全部直接读取表中字段,不做任何重算 # 写入数据行(从第 2 行开始)—— 全部直接读取表中字段,不做任何重算
...@@ -6119,14 +6078,10 @@ class DataProcessor: ...@@ -6119,14 +6078,10 @@ class DataProcessor:
# ---------- 5. 追加未匹配金额汇总行 ---------- # ---------- 5. 追加未匹配金额汇总行 ----------
# 映射 fee_type → ORDERED 里的 db_attr(用于定位 Excel 列) # 映射 fee_type → ORDERED 里的 db_attr(用于定位 Excel 列)
# 2026-10 精简:仅保留房租水电和装修摊销的未匹配追踪
FEE_TYPE_TO_DB_ATTR = { FEE_TYPE_TO_DB_ATTR = {
'market_fee': 'market_fee',
'external_construction': 'external_construction',
'technician_salary': 'technician_salary',
'marketing_team_salary': 'marketing_team_salary',
'rent_utilities': 'rent_utilities', 'rent_utilities': 'rent_utilities',
'renovation_amortization': 'renovation_amortization', 'renovation_amortization': 'renovation_amortization',
'store_consumables': 'store_consumables',
} }
# 反向查 db_attr → Excel 列索引(1-based) # 反向查 db_attr → Excel 列索引(1-based)
db_attr_to_col = {attr: c for c, (h, attr) in enumerate(ORDERED, 1)} db_attr_to_col = {attr: c for c, (h, attr) in enumerate(ORDERED, 1)}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!