# dwd_recharge_order 充值订单主表

> 生成时间：2026-01-28 | 更新时间：2026-02-13

## 表信息

| 属性 | 值 |
|------|-----|
| Schema | dwd |
| 表名 | dwd_recharge_order |
| 主键 | recharge_order_id |
| 扩展表 | dwd_recharge_order_ex |
| 记录数 | 455 |
| 说明 | 会员充值订单事实表，记录会员卡充值的金额、方式等信息 |

## 字段说明

| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | recharge_order_id | BIGINT | NO | PK | 充值订单 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID |
| 4 | member_id | BIGINT | YES | | 会员 ID → dim_member |
| 5 | member_name_snapshot | TEXT | YES | | 会员名称快照 |
| 6 | member_phone_snapshot | TEXT | YES | | 会员电话快照 |
| 7 | tenant_member_card_id | BIGINT | YES | | 会员卡账户 ID → dim_member_card_account |
| 8 | member_card_type_name | TEXT | YES | | 卡类型名称。**枚举值**: "储值卡", "月卡" |
| 9 | settle_relate_id | BIGINT | YES | | 结算关联 ID |
| 10 | settle_type | INTEGER | YES | | 结算类型。**枚举值**: 5=充值订单, 7=充值退款 |
| 11 | settle_name | TEXT | YES | | 结算名称。**枚举值**: "充值订单", "充值退款" |
| 12 | is_first | INTEGER | YES | | 是否首充。**枚举值**: 1=是, 2=否 |
| 13 | pay_amount | NUMERIC(18,2) | YES | | 充值金额（元，撤销为负数） |
| 14 | refund_amount | NUMERIC(18,2) | YES | | 退款金额 |
| 15 | point_amount | NUMERIC(18,2) | YES | | 积分金额 |
| 16 | cash_amount | NUMERIC(18,2) | YES | | 现金金额 |
| 17 | payment_method | INTEGER | YES | | 支付方式，暂未启用。 |
| 18 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 19 | pay_time | TIMESTAMPTZ | YES | | 支付时间 |
| 20 | pl_coupon_sale_amount | NUMERIC | YES | | 平台券销售金额 |
| 21 | mervou_sales_amount | NUMERIC | YES | | 美团/大众点评等平台销售金额 |
| 22 | electricity_money | NUMERIC | YES | | 电费金额 |
| 23 | real_electricity_money | NUMERIC | YES | | 实际电费金额 |
| 24 | electricity_adjust_money | NUMERIC | YES | | 电费调整金额 |

## 使用说明

**版本与最新值**
本表为事实表，无 SCD2 版本字段。

- 可用时间字段：create_time, pay_time

```sql
-- 取最新一条（按时间字段倒序）
SELECT *
FROM dwd.dwd_recharge_order
ORDER BY pay_time DESC NULLS LAST
LIMIT 1;
```
**使用示例**
```sql
-- 充值总额统计（不含撤销）
SELECT 
  member_card_type_name,
  COUNT(*) AS order_count,
  SUM(pay_amount) AS total_recharge
FROM dwd.dwd_recharge_order
WHERE settle_type = 5
GROUP BY member_card_type_name;
```
