Commit 9d832189 by 周立明

Merge branch 'v1.1' of http://192.168.3.233:8090/data_report/data-report into v1.1

2 parents c5399886 19d7c06c
......@@ -25,7 +25,7 @@ from report_utils import (
parse_inshop_delivery_touch, parse_commerce_policy_inshop,
parse_labor_cost, is_luxury_brand,
parse_budget_achieve_excel, extract_budget_ratio, prorate_by_period,
fetch_park_daily_report, fetch_light_reform_goods_stats, fuzzy_match_store,
fetch_park_daily_report, fetch_light_reform_goods_stats, fetch_light_reform_finance_stats, fuzzy_match_store,
get_with_fallback, safe_div, safe_div_pct, safe_div_pct_decimal,
)
from models import ReportLightReformInshop, db
......@@ -158,14 +158,15 @@ class LightReformInshopProcessor:
daily_report_map = fetch_park_daily_report(period_start, period_end, scene_type=1)
# 2c. 品类成交数 + 产值(店中店+园区店共用 SQL,按 dj_order_type + AITO/HIMA 关键字聚合)
goods_stats_map = fetch_light_reform_goods_stats(period_start, period_end)
# 2d. 财务成本分项(店中店+园区店共用 SQL,按 dj_order_type + 品类 + 原厂/副厂切分)
finance_map = fetch_light_reform_finance_stats(period_start, period_end, scene_type=1)
# 2b. 模糊匹配到门店 → 组装 sql_data dict(get_with_fallback 双优先用)
# 店中店:delivery_cnt→交车;equity→交付触客;after_sale→售后触客;
# 售后首保/事故回厂数 → 无 SQL,默认 0
biz_sql_data = {}
for rec in base_records:
sn = rec.get('store_name', '')
dr = fuzzy_match_store(sn, daily_report_map) or {}
gs = fuzzy_match_store(sn, goods_stats_map) or {}
fs = fuzzy_match_store(sn, finance_map) or {}
biz_sql_data[sn] = {
# —— 日报类(来自 fetch_park_daily_report)——
'delivery_cnt': dr.get('delivery_cnt', 0),
......@@ -175,7 +176,7 @@ class LightReformInshopProcessor:
'aftersales_shigu_cnt': 0, # 无 SQL
'sales_order_cnt': 0, # 无 SQL(销售大定数)
'sales_touch_cnt': 0, # 无 SQL(销售触客数)
# —— 品类成交数 + 产值(来自 fetch_inshop_goods_stats)——
# —— 品类成交数 + 产值(来自 fetch_light_reform_goods_stats)——
'total_deal_cnt': gs.get('total_deal_cnt', 0),
'window_film_oe_cnt': gs.get('window_film_oe_cnt', 0),
'window_film_nonoe_cnt': gs.get('window_film_nonoe_cnt', 0),
......@@ -188,6 +189,17 @@ class LightReformInshopProcessor:
'internal_settle_value': gs.get('internal_settle_value', Decimal('0')),
'oe_output_value': gs.get('oe_output_value', Decimal('0')),
'nonoe_output_value': gs.get('nonoe_output_value', Decimal('0')),
# —— 财务成本分项(来自 fetch_light_reform_finance_stats)——
'product_cost_finance': fs.get('product_cost_finance', Decimal('0')),
'internal_settle_cost': fs.get('internal_settle_cost', Decimal('0')),
'oe_product_cost': fs.get('oe_product_cost', Decimal('0')),
'nonoe_product_cost': fs.get('nonoe_product_cost', Decimal('0')),
'window_film_cost': fs.get('window_film_cost', Decimal('0')),
'car_wrap_cost': fs.get('car_wrap_cost', Decimal('0')),
'premium_cost': fs.get('premium_cost', Decimal('0')),
'store_share': fs.get('store_share', Decimal('0')),
'construction_income': fs.get('construction_income', Decimal('0')),
'market_fee': fs.get('market_fee', Decimal('0')),
}
# ========== Step3: 上月预算明细(已在 Step1 从 Excel 解析) ==========
......
......@@ -32,7 +32,7 @@ from report_utils import (
parse_labor_cost, is_luxury_brand,
parse_budget_achieve_excel, extract_budget_ratio, prorate_by_period,
fetch_indicator_data, fetch_park_daily_report, fetch_light_reform_goods_stats,
fetch_est_delivery_count, fuzzy_match_store,
fetch_light_reform_finance_stats, fetch_est_delivery_count, fuzzy_match_store,
get_with_fallback, safe_div, safe_div_pct, safe_div_pct_decimal,
)
from models import ReportLightReformPark, db
......@@ -166,13 +166,15 @@ class LightReformParkProcessor:
goods_stats_map = fetch_light_reform_goods_stats(period_start, period_end)
# 3c. 预估交车数(静态配置表,无日期参数,traffic_party_name 即门店名)
est_delivery_map = fetch_est_delivery_count(base_scene_code='100101')
# 3d. 模糊匹配到门店 → 组装 sql_data dict
# 园区店:delivery_cnt → 交车;equity + after_sale → 到店数;无效到店无 SQL → 0
# 3d. 财务成本分项(店中店+园区店共用 SQL,park 侧仅消费 4 项)
finance_map = fetch_light_reform_finance_stats(period_start, period_end, scene_type=1)
# 3e. 模糊匹配到门店 → 组装 sql_data dict
biz_sql_data = {}
for rec in base_records:
sn = rec.get('store_name', '')
dr = fuzzy_match_store(sn, daily_report_map) or {}
gs = fuzzy_match_store(sn, goods_stats_map) or {}
fs = fuzzy_match_store(sn, finance_map) or {}
eq = dr.get('equity_to_shop_count', 0)
af = dr.get('after_sale_equity_to_shop_count', 0)
biz_sql_data[sn] = {
......@@ -188,10 +190,15 @@ class LightReformParkProcessor:
# —— 产值(来自 fetch_light_reform_goods_stats)——
'store_sales_output': gs.get('store_output_value', Decimal('0')),
'internal_settle_value': gs.get('internal_settle_value', Decimal('0')),
# —— 预估交车数(来自 fetch_est_delivery_count,traffic_party_name 即门店名)——
# —— 预估交车数(来自 fetch_est_delivery_count)——
'est_delivery_cnt': fuzzy_match_store(sn, est_delivery_map) or 0,
# —— 财务分项(park 仅消费产品成本/内部结算成本/流量费/市场费)——
'product_cost_finance': fs.get('product_cost_finance', Decimal('0')),
'internal_settle_cost': fs.get('internal_settle_cost', Decimal('0')),
'traffic_fee_finance': fs.get('store_share', Decimal('0')), # 流量费 = gopa.shop_traffic_money (dj_order_type!=6)
'market_fee_weighted': fs.get('market_fee', Decimal('0')), # 市场费加权测算 = fee 四项费用累计
}
# 3e. 其他聚合 SQL(成本/市场费/流量费等)后续接入,当前保持默认 0
# 3f. 其他字段(service_fee / construction_cost 等) park 从 Excel 或公式取,保持 0
# ========== Step4: 上月预算明细(已在 Step1 从 Excel 解析) ==========
prev_budget_map = budget_achieve_map
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!