# dwd_settlement_head 结账头表主表

> 生成时间：2026-01-28


## 表信息

| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_settlement_head |
| 主键 | order_settle_id |
| 扩展表 | dwd_settlement_head_ex |
| 记录数 | 23366 |
| 说明 | 结账单头表事实表，是核心交易表，记录每笔结账的消费金额、支付方式、折扣等汇总信息 |

## 字段说明

| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | order_settle_id | BIGINT | NO | PK | 结账单 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID → dim_site |
| 4 | site_name | VARCHAR | YES | | 门店名称。**当前值**: "朗朗桌球" |
| 5 | table_id | BIGINT | YES | | 台桌 ID → dim_table（0=非台桌订单，如商城订单） |
| 6 | settle_name | VARCHAR | YES | | 结账名称。**样本值**: "商城订单", "A区 A3", "A区 A4", "斯诺克区 S1" |
| 7 | order_trade_no | BIGINT | YES | | 订单号 |
| 8 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 9 | pay_time | TIMESTAMPTZ | YES | | 支付时间 |
| 10 | settle_type | INTEGER | YES | | 结账类型。**枚举值**: 1=台桌结账, 3=商城订单, 6=退货订单, 7=退款订单 |
| 11 | revoke_order_id | BIGINT | YES | | 撤销订单 ID（当前数据全为 0） |
| 12 | member_id | BIGINT | YES | | 会员 ID → dim_member（0=散客，占比约 82.8%） |
| 13 | member_name | VARCHAR | YES | | 会员名称 |
| 14 | member_phone | VARCHAR | YES | | 会员电话 |
| 15 | member_card_account_id | BIGINT | YES | | 会员卡账户 ID（当前数据全为 0） |
| 16 | member_card_type_name | VARCHAR | YES | | 卡类型名称（当前数据全为空） |
| 17 | is_bind_member | BOOLEAN | YES | | 是否绑定会员。**枚举值**: False=否 |
| 18 | member_discount_amount | NUMERIC(18,2) | YES | | 会员折扣金额 |
| 19 | consume_money | NUMERIC(18,2) | YES | | 消费总金额（元） |
| 20 | table_charge_money | NUMERIC(18,2) | YES | | 台费金额 |
| 21 | goods_money | NUMERIC(18,2) | YES | | 商品金额 |
| 22 | real_goods_money | NUMERIC(18,2) | YES | | 实收商品金额 |
| 23 | assistant_pd_money | NUMERIC(18,2) | YES | | 助教陪打费用 |
| 24 | assistant_cx_money | NUMERIC(18,2) | YES | | 助教促销费用 |
| 25 | adjust_amount | NUMERIC(18,2) | YES | | 调整金额 |
| 26 | pay_amount | NUMERIC(18,2) | YES | | 实付金额 |
| 27 | balance_amount | NUMERIC(18,2) | YES | | 余额支付金额 |
| 28 | recharge_card_amount | NUMERIC(18,2) | YES | | 储值卡支付金额 |
| 29 | gift_card_amount | NUMERIC(18,2) | YES | | 礼品卡支付金额 |
| 30 | coupon_amount | NUMERIC(18,2) | YES | | 券抵扣金额 |
| 31 | rounding_amount | NUMERIC(18,2) | YES | | 抹零金额 |
| 32 | point_amount | NUMERIC(18,2) | YES | | 积分抵扣等值金额 |


## 使用说明

```sql
-- 每日营收统计
SELECT 
  DATE(pay_time) AS pay_date,
  COUNT(*) AS order_count,
  SUM(consume_money) AS total_consume,
  SUM(pay_amount) AS total_pay
FROM billiards_dwd.dwd_settlement_head
GROUP BY DATE(pay_time)
ORDER BY pay_date DESC;

-- 台费 vs 商品 vs 助教收入
SELECT
  SUM(table_charge_money) AS table_revenue,
  SUM(goods_money) AS goods_revenue,
  SUM(assistant_pd_money + assistant_cx_money) AS assistant_revenue
FROM billiards_dwd.dwd_settlement_head;
```
