# 数据表说明 ## 核心业务表 ### 用户账号表 **表名**: `bi_vala_app_account` **关键字段**: - `id`: 用户ID - `key_from`: 注册来源 - `created_at`: 注册时间 - `download_channel`: 下载渠道 - `status`: 账号状态(1表示有效) - `deleted_at`: 删除时间(NULL表示未删除) **常用筛选条件**: ```sql where status = 1 and id not in (51,2121) -- 排除测试用户 and deleted_at is NULL ``` --- ### 账号详情表 **表名**: `account_detail_info` **关键字段**: - `account_id`: 账号ID(关联 bi_vala_app_account.id) - `login_address`: 登录地址(格式如"省份-城市") - `phone_login_times`: 手机登录次数 **业务逻辑**: ```sql -- 提取城市 split_part(login_address,'-',2) as login_address -- 判断是否手机登录 case when phone_login_times = 0 then 0 else 1 end as phone_login ``` --- ### 订单表 **表名**: `bi_vala_order` **关键字段**: - `account_id`: 账号ID - `sale_channel`: 购课渠道(数字编码) - `key_from`: 购课来源 - `pay_success_date`: 支付成功时间 - `pay_amount`: 支付金额 - `pay_amount_int`: 支付金额(整数分) - `order_status`: 订单状态(3表示有效订单) **常用筛选条件**: ```sql where order_status = 3 and pay_amount_int > 49800 -- 金额大于498元 ``` --- ### 角色表 **表名**: `bi_vala_app_character` **关键字段**: - `id`: 角色ID - `account_id`: 账号ID - `gender`: 性别(0=girl, 1=boy) - `birthday`: 生日(格式如"YYYY-MM-DD") - `purchase_season_package`: 赛季包购买状态 - `deleted_at`: 删除时间 **业务逻辑**: ```sql -- 角色付费状态 case when purchase_season_package = '[1]' then 0 else 1 end as characer_pay_status -- 性别映射 case when gender = 0 then 'girl' when gender = 1 then 'boy' else 'unknow' end as gender -- 提取出生年份 case when split_part(birthday,'-',1) = '' then '0000' else split_part(birthday,'-',1) end as birthday ``` --- ## 课程播放记录表(分表) ### 用户章节播放记录 **表名**: `bi_user_chapter_play_record_0` ~ `bi_user_chapter_play_record_7` **说明**: 按分表存储,共8张表,需要使用 UNION ALL 合并 **关键字段**: - `user_id`: 用户ID - `chapter_id`: 章节ID - `chapter_unique_id`: 完课唯一标识 - `updated_at`: 更新时间 - `play_status`: 播放状态(1表示完成) **常用筛选条件**: ```sql where chapter_id in (55,56,57,58,59) -- 指定章节 and play_status = 1 -- 播放完成 ``` --- ### 用户组件播放记录 **表名**: `bi_user_component_play_record_0` ~ `bi_user_component_play_record_7` **说明**: 按分表存储,共8张表,需要使用 UNION ALL 合并 **关键字段**: - `chapter_unique_id`: 完课唯一标识 - `interval_time`: 播放时长(毫秒) **业务逻辑**: ```sql -- 计算完课耗时(mm:ss格式) format('%s:%s', floor(sum(interval_time)/1000/60), mod((sum(interval_time)/1000),60) ) as finish_time ``` --- ## 课程信息表 ### 课程单元表 **表名**: `bi_level_unit_lesson` **关键字段**: - `id`: ID(关联 chapter_id) - `course_level`: 课程级别 - `course_season`: 课程赛季 - `course_unit`: 课程单元 - `course_lesson`: 课程课时 **业务逻辑**: ```sql -- 生成课程ID format('%s-%s-%s-%s', course_level, course_season, course_unit, course_lesson ) as course_id ``` --- ## 其他表 ### 账号登录表 **表名**: `account_login` **关键字段**: - `account_id`: 账号ID - `login_date`: 登录日期