# dim_member_card_account_ex 会员卡账户扩展表

> 生成时间：2026-01-28

## 表信息

| 属性 | 值 |
|------|-----|
| Schema | dwd |
| 表名 | dim_member_card_account_ex |
| 主键 | member_card_id, scd2_start_time |
| 主表 | dim_member_card_account |
| 记录数 | 945 |
| 说明 | 会员卡账户扩展表，包含折扣配置、抵扣规则、使用限制等详细配置 |

## 字段说明

| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | member_card_id | BIGINT | NO | PK | 会员卡 ID → dim_member_card_account |
| 2 | site_name | TEXT | YES | | 门店名称。**当前值**: "朗朗桌球" |
| 3 | tenant_name | VARCHAR(64) | YES | | 租户名称（当前数据全为空） |
| 4 | tenantavatar | TEXT | YES | | 租户头像（当前数据全为空） |
| 5 | effect_site_id | BIGINT | YES | | 生效门店 ID（0=不限门店） |
| 6 | able_cross_site | INTEGER | YES | | 允许跨门店。**枚举值**: 1(945)=允许 |
| 7 | card_physics_type | INTEGER | YES | | 物理卡类型。**枚举值**: 1(945)=**[待确认]** |
| 8 | card_no | TEXT | YES | | 物理卡号（当前数据全为空） |
| 9 | bind_password | TEXT | YES | | 绑定密码（当前数据全为空） |
| 10 | use_scene | TEXT | YES | | 使用场景（当前数据全为空） |
| 11 | denomination | NUMERIC(18,2) | YES | | 面额/初始额度 |
| 12 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 13 | disable_start_time | TIMESTAMPTZ | YES | | 禁用开始时间 |
| 14 | disable_end_time | TIMESTAMPTZ | YES | | 禁用结束时间 |
| 15 | is_allow_give | INTEGER | YES | | 允许转赠。**枚举值**: 0(945)=不允许 |
| 16 | is_allow_order_deduct | INTEGER | YES | | 允许订单抵扣。**枚举值**: 0(945)=不允许 |
| 17 | sort | INTEGER | YES | | 排序序号 |
| 18 | table_discount | NUMERIC(10,2) | YES | | 台费折扣率（10.0=不打折） |
| 19 | goods_discount | NUMERIC(10,2) | YES | | 商品折扣率 |
| 20 | assistant_discount | NUMERIC(10,2) | YES | | 助教折扣率 |
| 21 | assistant_reward_discount | NUMERIC(10,2) | YES | | 助教奖励折扣率 |
| 22 | table_service_discount | NUMERIC(10,2) | YES | | 台费服务折扣率 |
| 23 | goods_service_discount | NUMERIC(10,2) | YES | | 商品服务折扣率 |
| 24 | assistant_service_discount | NUMERIC(10,2) | YES | | 助教服务折扣率 |
| 25 | coupon_discount | NUMERIC(10,2) | YES | | 券折扣率 |
| 26 | table_discount_sub_switch | INTEGER | YES | | 台费折扣叠加开关。**枚举值**: 2(945)=关闭 **[1=开启 待确认]** |
| 27 | goods_discount_sub_switch | INTEGER | YES | | 商品折扣叠加开关 |
| 28 | assistant_discount_sub_switch | INTEGER | YES | | 助教折扣叠加开关 |
| 29 | assistant_reward_discount_sub_switch | INTEGER | YES | | 助教奖励折扣叠加开关 |
| 30 | goods_discount_range_type | INTEGER | YES | | 商品折扣范围类型。**枚举值**: 1(945)=**[待确认]** |
| 31 | table_deduct_radio | NUMERIC(10,2) | YES | | 台费抵扣比例（100.0=全额抵扣） |
| 32 | goods_deduct_radio | NUMERIC(10,2) | YES | | 商品抵扣比例 |
| 33 | assistant_deduct_radio | NUMERIC(10,2) | YES | | 助教抵扣比例 |
| 34 | table_service_deduct_radio | NUMERIC(10,2) | YES | | 台费服务抵扣比例 |
| 35 | goods_service_deduct_radio | NUMERIC(10,2) | YES | | 商品服务抵扣比例 |
| 36 | assistant_service_deduct_radio | NUMERIC(10,2) | YES | | 助教服务抵扣比例 |
| 37 | assistant_reward_deduct_radio | NUMERIC(10,2) | YES | | 助教奖励抵扣比例 |
| 38 | coupon_deduct_radio | NUMERIC(10,2) | YES | | 券抵扣比例 |
| 39 | cardsettlededuct | NUMERIC(18,2) | YES | | 结算扣卡金额配置 |
| 40 | tablecarddeduct | NUMERIC(18,2) | YES | | 台费扣卡金额 |
| 41 | tableservicecarddeduct | NUMERIC(18,2) | YES | | 台费服务扣卡金额 |
| 42 | goodscardeduct | NUMERIC(18,2) | YES | | 商品扣卡金额 |
| 43 | goodsservicecarddeduct | NUMERIC(18,2) | YES | | 商品服务扣卡金额 |
| 44 | assistantcarddeduct | NUMERIC(18,2) | YES | | 助教扣卡金额 |
| 45 | assistantservicecarddeduct | NUMERIC(18,2) | YES | | 助教服务扣卡金额 |
| 46 | assistantrewardcarddeduct | NUMERIC(18,2) | YES | | 助教奖励扣卡金额 |
| 47 | couponcarddeduct | NUMERIC(18,2) | YES | | 券扣卡金额 |
| 48 | deliveryfeededuct | NUMERIC(18,2) | YES | | 配送费扣卡金额 |
| 49 | tableareaid | TEXT | YES | | 可用台区 ID 列表（当前数据全为空） |
| 50 | goodscategoryid | TEXT | YES | | 可用商品分类 ID 列表（当前数据全为空） |
| 51 | pdassisnatlevel | TEXT | YES | | 陪打助教等级限制。**当前值**: "{}" |
| 52 | cxassisnatlevel | TEXT | YES | | 促销助教等级限制。**当前值**: "{}" |
| 53 | able_share_member_discount | BOOLEAN | YES | | 是否可共享会员折扣 |
| 54 | electricity_deduct_radio | NUMERIC(18,4) | YES | | 电费扣减比例 |
| 55 | electricity_discount | NUMERIC(18,4) | YES | | 电费折扣 |
| 56 | electricity_card_deduct | BOOLEAN | YES | | 电费卡扣 |
| 57 | recharge_freeze_balance | NUMERIC(18,2) | YES | | 充值冻结余额 |
| 58 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 59 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 60 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 61 | scd2_version | INTEGER | YES | | 版本号 |

## 使用说明

**版本与最新值**
本表为 SCD2 维度表，版本字段：scd2_start_time / scd2_end_time / scd2_is_current / scd2_version。

- 最新版本：scd2_is_current = 1
- 按业务主键取最新：按 scd2_start_time 倒序

```sql
-- 取某业务主键的最新版本
SELECT *
FROM dwd.dim_member_card_account_ex
WHERE member_card_id = <value>
ORDER BY scd2_start_time DESC
LIMIT 1;
```
**使用示例**
```sql
-- 关联查询卡片及折扣配置
SELECT 
  m.member_card_type_name, m.balance,
  e.table_discount, e.goods_discount, e.assistant_discount
FROM dwd.dim_member_card_account m
JOIN dwd.dim_member_card_account_ex e
  ON m.member_card_id = e.member_card_id
  AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```
