dalongxia/sqlserver/README_SQL_TEMPLATES.md
2026-03-04 13:25:48 +08:00

72 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 销售分析常用 SQL 模板包
数据源:`JSDataMiddlePlatform`(SQLServer)
执行方式:`company-db run-file <sql文件路径>`
默认分析口径(已按最新要求):
- 主口径优先:`发货件数 / 售后件数 / 订单数`
- 金额口径:仅补充展示;除非明确要求,不作为主排序维度
## 模板列表
1. `shop_weekly_report.sql`
- 用途:店铺周报(平台/店铺销售、退款、毛利、高退款风险店铺)
- 默认时间:上一个自然周
2. `sku_structure_report.sql`
- 用途:SKU结构分析(类目结构、SKU Top、价格带结构)
- 默认时间:最近30天
3. `refund_reason_report.sql`
- 用途:退款原因分析(全局原因Top、平台内原因Top、店铺风险清单、类型矩阵)
- 默认时间:最近30天
4. `fee_ratio_alert.sql`
- 用途:费比异常预警(店铺级P1/P2/P3预警、全局日趋势)
- 默认时间:最近14天
5. `logistics_sla_report.sql`
- 用途:物流时效/SLA分析(支付到发货、发货到签收、延迟预警)
- 默认时间:最近30天
6. `freight_efficiency_report.sql`
- 用途:运费效率分析(单票成本、单位重量成本、省份/快递组合成本)
- 默认时间:最近30天
7. `install_service_quality_report.sql`
- 用途:安装服务质量(工单状态、服务商表现、待审核区域)
- 默认时间:最近90天
8. `customer_service_hotspot_report.sql`
- 用途:客服问题热点(问题Top、店铺问题热点、日趋势)
- 默认时间:最近30天
9. `link_target_coverage_report.sql`
- 用途:链接目标覆盖(在线链接、运营负载、类目/价格带分布)
- 默认时间:在线链接全量
10. `after_sale_360_report.sql`
- 用途:售后360分析(退款金额、一级/二级原因、类型矩阵、安装工单联动)
- 默认时间:上一个自然周
## 运行示例
```bash
company-db run-file /root/.openclaw/workspace/sqlserver/shop_weekly_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/sku_structure_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/refund_reason_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/fee_ratio_alert.sql
company-db run-file /root/.openclaw/workspace/sqlserver/logistics_sla_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/freight_efficiency_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/install_service_quality_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/customer_service_hotspot_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/link_target_coverage_report.sql
company-db run-file /root/.openclaw/workspace/sqlserver/after_sale_360_report.sql
```
## 注意事项
- 所有模板都默认过滤 `配件` 和 `特殊单` 标签。
- 金额字段多为字符串,模板已使用 `TRY_CONVERT` 做安全转换。
- 如需自定义时间,修改每个模板顶部变量即可。