You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
7.2 KiB
7.2 KiB
school_order_table 表文档
表概述
表名: school_order_table
功能: 订单信息管理表,负责管理教务系统中的所有订单信息,包括新订单、续费订单、转校订单等各种类型的订单处理
字段说明
Field Type Collation Null Key Default Extra Privileges Comment
id int NULL NO PRI NULL auto_increment select,insert,update,references 订单编号
payment_id varchar(255) utf8mb4_general_ci YES NULL select,insert,update,references 支付编号
order_type varchar(255) utf8mb4_general_ci YES NULL select,insert,update,references 订单类型1新订单2续费订单3内部员工订单4 转校 5 客户内转课订单
order_status enum('pending','paid','signed','completed','transfer') utf8mb4_general_ci YES pending select,insert,update,references 订单状态: pending-待支付, paid-已支付,signed待签约,completed已完成,transfer转学
payment_type enum('cash','scan_code','subscription','wxpay_online') utf8mb4_general_ci NO NULL select,insert,update,references 付款类型: cash-现金支付, scan_code-扫码支付, subscription-订阅支付, wxpay_online-微信在线代付
order_amount decimal(10,2) NULL NO NULL select,insert,update,references 订单金额
course_id int NULL NO NULL select,insert,update,references 课程ID
class_id int NULL YES NULL select,insert,update,references 班级ID
staff_id int NULL NO NULL select,insert,update,references 人员ID|员工表school_personnel.id
resource_id int NULL NO NULL select,insert,update,references 资源ID|客户资源表school_customer_resources.id
after_sales_status varchar(50) utf8mb4_general_ci YES NULL select,insert,update,references 售后状态
after_sales_reason text utf8mb4_general_ci YES NULL select,insert,update,references 售后原因
after_sales_time timestamp NULL YES NULL select,insert,update,references 售后时间
created_at timestamp NULL YES CURRENT_TIMESTAMP DEFAULT_GENERATED select,insert,update,references 创建时间
updated_at timestamp NULL YES CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP select,insert,update,references 修改时间
payment_time timestamp NULL YES NULL select,insert,update,references 支付时间
subscription_payment_time timestamp NULL YES NULL select,insert,update,references 订阅支付生成时间
ipv3 varchar(255) utf8mb4_general_ci YES NULL select,insert,update,references
accounting_time timestamp NULL YES NULL select,insert,update,references 核算时间
campus_id int NULL NO NULL select,insert,update,references 校区ID
gift_id int NULL YES NULL select,insert,update,references 赠品 id
discount_amount decimal(10,2) NULL YES NULL select,insert,update,references 优惠金额
course_plan_id int NULL YES NULL select,insert,update,references 课程计划 id
student_id int NULL NO NULL select,insert,update,references 学员 id
remark varchar(512) utf8mb4_general_ci YES NULL select,insert,update,references 订单备注
contract_id int NULL YES NULL select,insert,update,references 合同 id
gift_type tinyint NULL YES NULL select,insert,update,references 赠品使用类型 1 减现2 赠课
功能用途
主要功能
- 订单生命周期管理: 管理从订单创建到完成的全流程状态跟踪
- 多类型订单支持: 支持新订单、续费订单、内部员工订单、转校订单、客户内转课订单
- 支付管理: 关联支付信息,支持多种支付方式(现金、扫码、订阅、微信在线代付)
- 课程订单关联: 建立订单与课程、班级的关联关系
- 售后服务管理: 处理订单售后状态、原因和时间记录
- 财务核算: 订单金额、优惠金额、核算时间等财务相关信息管理
- 赠品管理: 支持赠品关联和赠品类型管理(减现、赠课)
- 合同关联: 订单与合同的关联管理
业务场景
- 订单创建: 学员报名时创建新订单,记录课程、金额、支付方式等信息
- 续费管理: 处理学员续费订单,延续学习服务
- 转校业务: 处理学员转校相关的订单和费用结算
- 内部订单: 处理员工内部订单,可能享受特殊优惠政策
- 支付处理: 跟踪订单支付状态,从待支付到已支付的状态流转
- 售后服务: 处理退费、换课等售后需求
- 财务结算: 进行订单核算,生成财务报表
- 营销活动: 通过赠品和优惠金额支持各种营销活动
关联关系
主要关联表
school_course: 课程信息表 (course_id)school_class: 班级信息表 (class_id)school_personnel: 人员信息表 (staff_id)school_customer_resources: 客户资源表 (resource_id)school_campus: 校区信息表 (campus_id)school_member: 学员信息表 (student_id)school_contract: 合同信息表 (contract_id)school_pay: 支付信息表 (payment_id)school_course_plan: 课程计划表 (course_plan_id)school_gift: 赠品信息表 (gift_id)
关联说明
- 课程关联: 通过course_id关联具体课程,class_id关联具体班级
- 人员关联: staff_id关联处理订单的员工,student_id关联购买的学员
- 支付关联: payment_id关联支付记录,跟踪支付状态和支付方式
- 合同关联: contract_id关联生成的合同,建立订单与合同的对应关系
- 校区关联: campus_id确定订单所属校区,用于区域化管理
- 资源关联: resource_id关联客户资源,跟踪订单来源
- 赠品关联: gift_id关联赠品信息,支持营销活动
索引建议
- 主键索引: id (已存在)
- 外键索引:
- course_id (课程查询)
- class_id (班级查询)
- staff_id (员工订单查询)
- student_id (学员订单查询)
- campus_id (校区订单查询)
- contract_id (合同关联查询)
- 状态索引: order_status (订单状态查询)
- 时间索引:
- created_at (创建时间查询)
- payment_time (支付时间查询)
- accounting_time (核算时间查询)
- 复合索引:
- (student_id, order_status) (学员订单状态查询)
- (campus_id, created_at) (校区订单时间查询)
- (order_type, order_status) (订单类型状态查询)
- (payment_type, order_status) (支付方式状态查询)
注意事项
- 金额精度: order_amount和discount_amount使用decimal(10,2),确保财务计算精度
- 状态流转: 订单状态有严格的流转规则,不能随意跳跃状态
- 支付关联: payment_id可能为空,表示未关联支付记录的订单
- 订单类型: order_type决定了订单的处理流程和业务逻辑
- 售后处理: 售后状态、原因、时间需要同步更新,保持数据一致性
- 时间逻辑: 支付时间不能早于创建时间,核算时间不能早于支付时间
- 校区归属: 订单必须归属于特定校区,不能为空
- 学员关联: student_id不能为空,每个订单必须有明确的学员
- 合同生成: 订单状态为signed时,应该有对应的contract_id
- 赠品逻辑: gift_type和gift_id需要配套使用,确保赠品逻辑正确
- 优惠计算: 实际支付金额 = order_amount - discount_amount
- 数据完整性: 删除订单时需要考虑关联数据的处理
- 权限控制: 不同角色对订单的操作权限需要严格控制