report_tables_ddl.sql
28.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
-- ============================================================
-- 红黄门店盈利测算 - 4 张输出表 DDL (MySQL 5.7+, utf8mb4)
-- 生成方式:由 SQLAlchemy ORM Model 反推,与 db.create_all() 等价
-- 使用:在目标库 data_process 中直接执行即可
-- ============================================================
-- ---------- 表 1:延保盈利测算表 ----------
DROP TABLE IF EXISTS `report_extended_warranty`;
CREATE TABLE `report_extended_warranty` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`task_id` INT NOT NULL COMMENT '所属任务单据ID',
`period_start` DATE DEFAULT NULL COMMENT '统计周期开始日期',
`period_end` DATE DEFAULT NULL COMMENT '统计周期结束日期',
-- 门店基础维度(9 列)
`region_area` VARCHAR(50) DEFAULT '' COMMENT '片区',
`province` VARCHAR(50) DEFAULT '' COMMENT '省份',
`city` VARCHAR(50) DEFAULT '' COMMENT '城市',
`region_manager` VARCHAR(50) DEFAULT '' COMMENT '区域运营',
`training_supervisor` VARCHAR(50) DEFAULT '' COMMENT '培训督导',
`biz_manager` VARCHAR(50) DEFAULT '' COMMENT '业务经理',
`resident_type` VARCHAR(50) DEFAULT '' COMMENT '驻店类型',
`store_name` VARCHAR(200) DEFAULT '' COMMENT '门店名',
`brand` VARCHAR(50) DEFAULT '' COMMENT '品牌',
-- 触客/成交(3 列)
`delivery_cnt` INT DEFAULT 0 COMMENT '交车',
`touch_cnt` INT DEFAULT 0 COMMENT '触客',
`deal_cnt` INT DEFAULT 0 COMMENT '成交数',
-- 延保特有指标(8 列)
`penetration_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '渗透率',
`vehicle_warranty_cnt` INT DEFAULT 0 COMMENT '整车延保成交数',
`vehicle_warranty_penetration` DECIMAL(10,6) DEFAULT 0 COMMENT '整车延保渗透率',
`vehicle_warranty_touch_convert` DECIMAL(10,6) DEFAULT 0 COMMENT '整车延保触客成交率',
`battery_warranty_cnt` INT DEFAULT 0 COMMENT '电池成交数',
`battery_warranty_penetration` DECIMAL(10,6) DEFAULT 0 COMMENT '电池渗透率',
`easy_bag_cnt` INT DEFAULT 0 COMMENT '安心包成交数',
`easy_bag_penetration` DECIMAL(10,6) DEFAULT 0 COMMENT '安心包渗透率',
-- 产值/成本/费用/毛利(18 列)
`store_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '门店产值',
`upgrade_unit_price` DECIMAL(15,2) DEFAULT 0 COMMENT '升级客单价',
`product_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '商品成本',
`store_share` DECIMAL(15,2) DEFAULT 0 COMMENT '门店分成',
`guarantee_amount` DECIMAL(15,2) DEFAULT 0 COMMENT '兜底金额',
`gl_share` DECIMAL(15,2) DEFAULT 0 COMMENT '广联分成',
`market_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '市场费',
`market_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '市场费占比',
`marketing_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '营销费用',
`marketing_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '营销费用占比',
`service_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '服务费用',
`service_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '服务费用占比',
`total_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '成本总计',
`cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '成本占比',
`gross_profit` DECIMAL(15,2) DEFAULT 0 COMMENT '毛利测算',
`gross_profit_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '预估毛利率',
`gross_profit_status` VARCHAR(20) DEFAULT '' COMMENT '预估毛利情况',
`gross_profit_rank` INT DEFAULT 0 COMMENT '门店毛利排名',
-- 公共字段
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近更新时间',
`is_deleted` INT NOT NULL DEFAULT 0 COMMENT '是否删除:0正常 / 1已删除',
`deleted_at` DATETIME DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_warranty_period_store_brand`
(`task_id`, `period_start`, `period_end`, `store_name`, `brand`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='红黄门店盈利测算-延保表';
-- ---------- 表 2:权益盈利测算表 ----------
DROP TABLE IF EXISTS `report_equity_service`;
CREATE TABLE `report_equity_service` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`task_id` INT NOT NULL COMMENT '所属任务单据ID',
`period_start` DATE DEFAULT NULL COMMENT '统计周期开始日期',
`period_end` DATE DEFAULT NULL COMMENT '统计周期结束日期',
-- 门店基础维度(9 列)
`region_area` VARCHAR(50) DEFAULT '' COMMENT '片区',
`province` VARCHAR(50) DEFAULT '' COMMENT '省份',
`city` VARCHAR(50) DEFAULT '' COMMENT '城市',
`region_manager` VARCHAR(50) DEFAULT '' COMMENT '区域运营',
`training_supervisor` VARCHAR(50) DEFAULT '' COMMENT '培训督导',
`biz_manager` VARCHAR(50) DEFAULT '' COMMENT '业务经理',
`resident_type` VARCHAR(50) DEFAULT '' COMMENT '驻店类型',
`store_name` VARCHAR(200) DEFAULT '' COMMENT '门店名',
`brand` VARCHAR(50) DEFAULT '' COMMENT '品牌',
-- 触客/成交(4 列)
`delivery_cnt` INT DEFAULT 0 COMMENT '交车',
`touch_cnt` INT DEFAULT 0 COMMENT '触客',
`deal_cnt` INT DEFAULT 0 COMMENT '成交数',
`penetration_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '渗透率',
-- 产值/成本/费用/毛利(18 列,与延保表一致)
`store_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '门店产值',
`upgrade_unit_price` DECIMAL(15,2) DEFAULT 0 COMMENT '升级客单价',
`product_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '商品成本',
`store_share` DECIMAL(15,2) DEFAULT 0 COMMENT '门店分成',
`guarantee_amount` DECIMAL(15,2) DEFAULT 0 COMMENT '兜底金额',
`gl_share` DECIMAL(15,2) DEFAULT 0 COMMENT '广联分成',
`market_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '市场费',
`market_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '市场费占比',
`marketing_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '营销费用',
`marketing_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '营销费用占比',
`service_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '服务费用',
`service_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '服务费用占比',
`total_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '成本总计',
`cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '成本占比',
`gross_profit` DECIMAL(15,2) DEFAULT 0 COMMENT '毛利测算',
`gross_profit_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '预估毛利率',
`gross_profit_status` VARCHAR(20) DEFAULT '' COMMENT '预估毛利情况',
`gross_profit_rank` INT DEFAULT 0 COMMENT '门店毛利排名',
-- 公共字段
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近更新时间',
`is_deleted` INT NOT NULL DEFAULT 0 COMMENT '是否删除:0正常 / 1已删除',
`deleted_at` DATETIME DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_equity_period_store_brand`
(`task_id`, `period_start`, `period_end`, `store_name`, `brand`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='红黄门店盈利测算-权益表';
-- ---------- 表 3:轻改-店中店汇总表 ----------
DROP TABLE IF EXISTS `report_light_reform_inshop`;
CREATE TABLE `report_light_reform_inshop` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`task_id` INT NOT NULL COMMENT '所属任务单据ID',
`period_start` DATE DEFAULT NULL COMMENT '统计周期开始日期',
`period_end` DATE DEFAULT NULL COMMENT '统计周期结束日期',
-- 门店基础信息(13 列)
`region_area` VARCHAR(50) DEFAULT '' COMMENT '大区名称',
`province` VARCHAR(50) DEFAULT '' COMMENT '区域省',
`city` VARCHAR(50) DEFAULT '' COMMENT '区域市',
`park_type` VARCHAR(50) DEFAULT '' COMMENT '园区类型',
`biz_line` VARCHAR(50) DEFAULT '' COMMENT '业务线',
`operate_type` VARCHAR(50) DEFAULT '' COMMENT '经营属性',
`region_manager` VARCHAR(50) DEFAULT '' COMMENT '区域经理',
`park_name` VARCHAR(200) DEFAULT '' COMMENT '园区名称',
`store_name` VARCHAR(200) DEFAULT '' COMMENT '门店名称',
`brand` VARCHAR(50) DEFAULT '' COMMENT '品牌(问界/鸿蒙)',
`brand_category` VARCHAR(50) DEFAULT '' COMMENT '品牌分类(豪华/非豪华)',
`purchase_indicator` VARCHAR(200) DEFAULT '' COMMENT '采买/兜底指标',
-- 销售端口(3 列)
`sales_order_cnt` INT DEFAULT 0 COMMENT '销售大定数',
`sales_touch_cnt` INT DEFAULT 0 COMMENT '销售触客数',
`sales_touch_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '销售触客率',
-- 交付端口(3 列)
`delivery_cnt` INT DEFAULT 0 COMMENT '交车数',
`delivery_touch_cnt` INT DEFAULT 0 COMMENT '交付触客数',
`delivery_touch_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '交付触客率',
-- 售后端口(6 列)
`aftersales_baohui_cnt` INT DEFAULT 0 COMMENT '售后首保回厂数',
`aftersales_shigu_cnt` INT DEFAULT 0 COMMENT '售后事故回厂数',
`aftersales_touch_cnt` INT DEFAULT 0 COMMENT '售后触客数',
`aftersales_touch_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '售后触客率',
`total_touch_cnt` INT DEFAULT 0 COMMENT '总触客数',
`total_deal_cnt` INT DEFAULT 0 COMMENT '总成交数',
-- 窗膜/车衣/精品 原厂+副厂(12 列 + 踏板 1 列)
`window_film_oe_cnt` INT DEFAULT 0 COMMENT '窗膜成交数-原厂',
`window_film_nonoe_cnt` INT DEFAULT 0 COMMENT '窗膜成交数-副厂',
`car_wrap_oe_cnt` INT DEFAULT 0 COMMENT '车衣成交数-原厂',
`car_wrap_nonoe_cnt` INT DEFAULT 0 COMMENT '车衣成交数-副厂',
`premium_oe_cnt` INT DEFAULT 0 COMMENT '精品成交数-原厂',
`premium_nonoe_cnt` INT DEFAULT 0 COMMENT '精品成交数-副厂',
`pedal_cnt` INT DEFAULT 0 COMMENT '踏板',
-- 产值(5 列)
`store_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '门店总产值',
`internal_settle_value` DECIMAL(15,2) DEFAULT 0 COMMENT '内部结算产值',
`total_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '合计总产值',
`oe_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '原厂总产值',
`nonoe_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '副厂总产值',
-- 客单/渗透(9 列)
`avg_unit_price_delivery` DECIMAL(15,2) DEFAULT 0 COMMENT '平均客单价(交车)',
`avg_price_target` DECIMAL(15,2) DEFAULT 0 COMMENT '平客目标值',
`avg_price_diff` DECIMAL(15,2) DEFAULT 0 COMMENT '平客差值',
`delivery_touch_unit_price` DECIMAL(15,2) DEFAULT 0 COMMENT '交付触客客单价',
`upgrade_unit_price` DECIMAL(15,2) DEFAULT 0 COMMENT '升级客单价',
`total_penetration_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '总订单渗透率',
`window_film_penetration` DECIMAL(10,6) DEFAULT 0 COMMENT '窗膜渗透率',
`car_wrap_penetration` DECIMAL(10,6) DEFAULT 0 COMMENT '车衣渗透率',
`premium_penetration` DECIMAL(10,6) DEFAULT 0 COMMENT '精品渗透率',
-- 成本-产品(8 列)
`product_cost_finance` DECIMAL(15,2) DEFAULT 0 COMMENT '产品成本(财务列表)',
`internal_settle_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '内部结算成本(财务列表)',
`oe_product_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '原厂产品成本(财务列表)',
`nonoe_product_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '副厂产品成本(财务列表)',
`window_film_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '窗膜成本',
`car_wrap_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '车衣成本',
`premium_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '精品成本',
`product_cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '产品总成本占比',
-- 施工/激励/进销差/分成(11 列)
`construction_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '施工成本',
`construction_cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '施工成本占比',
`frontline_incentive` DECIMAL(15,2) DEFAULT 0 COMMENT '一线激励',
`frontline_incentive_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '一线激励占比',
`gross_profit_pre_share` DECIMAL(15,2) DEFAULT 0 COMMENT '进销差(未分成)',
`gross_profit_pre_share_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '进销差占比',
`store_share` DECIMAL(15,2) DEFAULT 0 COMMENT '门店分成',
`store_share_per_car` DECIMAL(15,2) DEFAULT 0 COMMENT '门店单车利润',
`guarantee_amount` DECIMAL(15,2) DEFAULT 0 COMMENT '兜底金额',
`gl_share` DECIMAL(15,2) DEFAULT 0 COMMENT '广联分成',
`gl_share_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '广联分成占比',
-- 广联总分成/内部结算/施工收入(3 列)
`construction_income` DECIMAL(15,2) DEFAULT 0 COMMENT '施工收入',
`internal_settle_profit` DECIMAL(15,2) DEFAULT 0 COMMENT '内部结算',
`gl_total_share` DECIMAL(15,2) DEFAULT 0 COMMENT '广联总分成',
-- 营销/市场/装修/房租/耗材/服务商(9 列)
`marketing_personnel_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '营销人员成本',
`marketing_personnel_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '营销人员成本占比',
`market_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '市场费',
`market_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '市场费占比',
`renovation_amortization` DECIMAL(15,2) DEFAULT 0 COMMENT '装修分摊',
`rent_utilities` DECIMAL(15,2) DEFAULT 0 COMMENT '房租、水电费用',
`store_consumables` DECIMAL(15,2) DEFAULT 0 COMMENT '门店耗材',
`service_provider_share` DECIMAL(15,2) DEFAULT 0 COMMENT '服务商分成',
`service_provider_share_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '服务商分成占比',
-- 成本总计/毛利(6 列)
`total_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '成本总计',
`cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '总计占比',
`gross_profit` DECIMAL(15,2) DEFAULT 0 COMMENT '毛利测算',
`gross_profit_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '毛利率',
`gross_profit_status` VARCHAR(20) DEFAULT '' COMMENT '毛利情况',
`gross_profit_rank` INT DEFAULT 0 COMMENT '门店毛利排名',
-- 公共字段
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT='创建时间',
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT='最近更新时间',
`is_deleted` INT NOT NULL DEFAULT 0 COMMENT='是否删除:0正常 / 1已删除',
`deleted_at` DATETIME DEFAULT NULL COMMENT='删除时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_inshop_period_park_store`
(`task_id`, `period_start`, `period_end`, `park_name`, `store_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='红黄门店盈利测算-轻改店中店汇总表';
-- ---------- 表 4:轻改-园区店汇总表 ----------
DROP TABLE IF EXISTS `report_light_reform_park`;
CREATE TABLE `report_light_reform_park` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`task_id` INT NOT NULL COMMENT '所属任务单据ID',
`period_start` DATE DEFAULT NULL COMMENT '统计周期开始日期',
`period_end` DATE DEFAULT NULL COMMENT '统计周期结束日期',
-- 门店基础信息(12 列)
`region_area` VARCHAR(50) DEFAULT '' COMMENT '大区名称',
`province` VARCHAR(50) DEFAULT '' COMMENT '区域省',
`city` VARCHAR(50) DEFAULT '' COMMENT '区域市',
`park_type` VARCHAR(50) DEFAULT '' COMMENT '园区类型',
`operate_type` VARCHAR(50) DEFAULT '' COMMENT '经营属性',
`partner_store_cnt` INT DEFAULT 0 COMMENT '合作门店数量',
`region_manager` VARCHAR(50) DEFAULT '' COMMENT '区域经理',
`park_name` VARCHAR(200) DEFAULT '' COMMENT '园区名称',
`store_name` VARCHAR(200) DEFAULT '' COMMENT '门店名称',
`brand` VARCHAR(50) DEFAULT '' COMMENT '品牌',
`biz_type` VARCHAR(50) DEFAULT '' COMMENT '类型',
`purchase_indicator` VARCHAR(200) DEFAULT '' COMMENT '采买/兜底指标(流量费)',
-- 触客/交车/转化(7 列)
`delivery_cnt` INT DEFAULT 0 COMMENT '交车数',
`arrival_cnt` INT DEFAULT 0 COMMENT '到店数',
`arrival_invalid_cnt` INT DEFAULT 0 COMMENT '到店无效客户数',
`invalid_arrival_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '无效到店率',
`arrival_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '到店率',
`deal_cnt` INT DEFAULT 0 COMMENT '成交数',
`conversion_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '转化率',
-- 产值/客单(8 列)
`store_sales_output` DECIMAL(15,2) DEFAULT 0 COMMENT '门店销售产值',
`internal_settle_value` DECIMAL(15,2) DEFAULT 0 COMMENT '内部结算产值',
`total_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '合计总产值',
`output_progress` DECIMAL(10,6) DEFAULT 0 COMMENT '产值达成进度',
`avg_unit_price_arrival` DECIMAL(15,2) DEFAULT 0 COMMENT '平均客单价(到店)',
`avg_price_target` DECIMAL(15,2) DEFAULT 0 COMMENT '平客目标值',
`avg_price_diff` DECIMAL(15,2) DEFAULT 0 COMMENT '平客差值',
`upgrade_unit_price` DECIMAL(15,2) DEFAULT 0 COMMENT '升级客单价',
-- 窗膜/车衣/精品(6 列)
`window_film_cnt` INT DEFAULT 0 COMMENT '窗膜成交数',
`window_film_convert` DECIMAL(10,6) DEFAULT 0 COMMENT '窗膜转化率',
`car_wrap_cnt` INT DEFAULT 0 COMMENT '车衣成交数',
`car_wrap_convert` DECIMAL(10,6) DEFAULT 0 COMMENT '车衣转化率',
`premium_cnt` INT DEFAULT 0 COMMENT '精品成交数',
`premium_convert` DECIMAL(10,6) DEFAULT 0 COMMENT '精品转化率',
-- 预算(3 列)
`est_traffic` INT DEFAULT 0 COMMENT '商务上架预估流量',
`est_delivery_cnt` INT DEFAULT 0 COMMENT '预估交车数',
`est_output_value` DECIMAL(15,2) DEFAULT 0 COMMENT '预估总产值(预算目标)',
-- 成本/分成/毛利(38 列)
`product_cost_finance` DECIMAL(15,2) DEFAULT 0 COMMENT '产品成本(财务列表)',
`product_cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '产品成本占比',
`internal_settle_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '内部结算成本(财务列表)',
`traffic_fee_finance` DECIMAL(15,2) DEFAULT 0 COMMENT '流量费(财务列表)',
`traffic_fee_per_car` DECIMAL(15,2) DEFAULT 0 COMMENT '按单台计算流量/台',
`traffic_fee_order` DECIMAL(15,2) DEFAULT 0 COMMENT '按台次计算流量费',
`store_traffic_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '门店流量费',
`traffic_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '流量费率(列表测算)',
`gl_share` DECIMAL(15,2) DEFAULT 0 COMMENT '广联分成',
`gl_share_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '广联分成占比',
`internal_settle_profit` DECIMAL(15,2) DEFAULT 0 COMMENT '内部结算',
`gl_total_share` DECIMAL(15,2) DEFAULT 0 COMMENT '广联总分成',
`personnel_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '人员成本',
`personnel_cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '常规人员费率(加权参考)',
`construction_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '施工成本',
`construction_cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '施工成本占比',
`market_fee_weighted` DECIMAL(15,2) DEFAULT 0 COMMENT '市场费(加权测算)',
`market_fee_weighted_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '市场费费率(加权参考)',
`service_fee` DECIMAL(15,2) DEFAULT 0 COMMENT '服务费(商务报表)',
`service_fee_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '服务费费率(加权参考)',
`renovation_amortization` DECIMAL(15,2) DEFAULT 0 COMMENT '装修分摊(商务报表)',
`renovation_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '装修占比',
`rent_utilities` DECIMAL(15,2) DEFAULT 0 COMMENT '房租、水电费用',
`rent_utilities_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '房租、水电占比',
`store_consumables` DECIMAL(15,2) DEFAULT 0 COMMENT '门店耗材',
`store_consumables_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '门店耗材占比',
`total_cost` DECIMAL(15,2) DEFAULT 0 COMMENT '成本总计',
`cost_ratio` DECIMAL(10,6) DEFAULT 0 COMMENT '总计占比',
`gross_profit` DECIMAL(15,2) DEFAULT 0 COMMENT '毛利测算',
`gross_profit_rate` DECIMAL(10,6) DEFAULT 0 COMMENT '毛利率',
`gross_profit_status` VARCHAR(20) DEFAULT '' COMMENT '毛利情况',
`gross_profit_rank` INT DEFAULT 0 COMMENT '门店毛利排名',
-- 公共字段
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最近更新时间',
`is_deleted` INT NOT NULL DEFAULT 0 COMMENT '是否删除:0正常 / 1已删除',
`deleted_at` DATETIME DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_park_period_park_store`
(`task_id`, `period_start`, `period_end`, `park_name`, `store_name`)
) 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`;
-- ============================================================================
-- 增量 ALTER: 店中店新增后置施工成本 2 字段
-- DB 已有: construction_cost(总计), construction_cost_oe(前置原厂),
-- construction_cost_nonoe(前置副厂), construction_cost_ratio(总计占比)
-- 新增: construction_cost_post, construction_cost_post_ratio
-- construction_cost = oe + nonoe + post
-- ============================================================================
ALTER TABLE report_light_reform_inshop
ADD COLUMN `construction_cost_post` DECIMAL(15, 2) DEFAULT 0
COMMENT '后置施工成本(直营按商务政策, 服务商=0)'
AFTER `construction_cost_nonoe`,
ADD COLUMN `construction_cost_post_ratio` DECIMAL(10, 6) DEFAULT 0
COMMENT '后置施工成本占比(post/门店总产值)'
AFTER `construction_cost_post`;