📊 对账与财务报表设计
本章详述即时配送小程序的日对账方案、财务报表设计、数据表结构。包括与微信支付的对账单核对、平台收入日报、骑手结算月报、代理分润报表等。
日对账
T+1结算
自动报表
对账原则:每日凌晨自动执行前一日对账,将平台订单数据与微信支付对账单进行核对,差异交易需人工排查处理,确保平台账目与支付渠道账目一致。
一、日对账方案
1.1 对账流程时序图
sequenceDiagram
participant SYS as 对账系统
participant PAY as 微信支付
participant DB as 平台数据库
participant DIFF as 差异处理
Note over SYS: 每日凌晨2:00执行
SYS->>PAY: 下载前一日微信支付对账单
SYS->>DB: 查询前一日平台订单数据
SYS->>SYS: 数据清洗与格式化
SYS->>SYS: 比对订单维度
SYS->>SYS: 比对支付维度
alt 账目一致
SYS->>DB: 写入对账成功标记
else 存在差异
SYS->>DIFF: 记录差异明细
DIFF->>DIFF: 差异分类(长款/短款/状态不一致)
DIFF->>FIN: 推送财务处理
end
SYS->>DB: 生成对账报表
1.2 对账差异类型
| 差异类型 | 说明 | 处理方式 |
| 长款 | 微信有,平台无(已付但平台未记账) | 补录平台订单,人工核实 |
| 短款 | 平台有,微信无(已记账但未支付) | 冲销平台订单,检查支付状态 |
| 金额不一致 | 订单金额与支付金额不符 | 以微信为准,排查是否被篡改 |
| 状态不一致 | 平台已取消,微信已支付 | 发起退款或人工处理 |
二、财务报表设计
2.1 平台收入日报
| 指标 | 说明 | 数据来源 |
| 统计日期 | 日报对应的日期 | - |
| 订单总数 | 当日完成支付的订单数 | ot_order |
| GMV | 当日订单总金额 | ot_order.pay_amount |
| 平台佣金 | 当日平台抽成总额 | ot_order.platform_fee求和 |
| 退款金额 | 当日退款总额 | ot_refund |
| 净收入 | 平台佣金 - 退款 | 计算得出 |
| 充值金额 | 当日用户钱包充值总额 | ot_wallet_log |
| 提现金额 | 当日用户+骑手提现总额 | ot_wallet_log + ot_courier_wallet_log |
2.2 骑手结算月报
| 指标 | 说明 | 数据来源 |
| 骑手姓名 | 骑手基本信息 | ot_courier |
| 配送单量 | 当月完成配送的订单数 | ot_order |
| 配送总收入 | 骑手配送费总和 | ot_order.courier_fee |
| 平台服务费 | 平台抽成(20%) | ot_order.platform_fee |
| 奖惩金额 | 奖励-罚款 | ot_courier_income_log |
| 应发金额 | 配送收入+奖惩-服务费 | 计算得出 |
| 已发金额 | 已提现金额 | ot_courier_settlement |
| 待发金额 | 应发-已发 | 计算得出 |
2.3 用户钱包报表
| 指标 | 说明 | 数据来源 |
| 充值金额 | 用户钱包充值总额 | ot_wallet_log WHERE type=1 |
| 消费金额 | 用户钱包支付总额 | ot_wallet_log WHERE type=2 |
| 退款金额 | 退款至钱包总额 | ot_wallet_log WHERE type=3 |
| 提现金额 | 用户提现总额 | ot_wallet_log WHERE type=4 |
| 当前余额 | 用户钱包实时余额 | ot_wallet.balance |
三、对账相关数据表
3.1 日对账记录表 ot_daily_reconciliation
| 字段 | 类型 | 说明 |
| id | bigint | 主键 |
| recon_date | date | 对账日期 |
| station_id | bigint | 站点ID(可空表示全平台) |
| order_count | int | 订单数 |
| platform_gmv | decimal(12,2) | 平台GMV |
| wechat_gmv | decimal(12,2) | 微信GMV |
| diff_amount | decimal(12,2) | 差异金额 |
| diff_count | int | 差异笔数 |
| status | tinyint | 状态(0进行中/1成功/2有差异) |
| recon_time | datetime | 对账完成时间 |
| created_at | datetime | 创建时间 |
3.2 差异记录表 ot_recon_diff
| 字段 | 类型 | 说明 |
| id | bigint | 主键 |
| recon_id | bigint | 对账记录ID |
| diff_type | tinyint | 差异类型(1长款/2短款/3金额差异/4状态差异) |
| order_no | varchar(32) | 订单号 |
| platform_amount | decimal(10,2) | 平台金额 |
| wechat_amount | decimal(10,2) | 微信金额 |
| diff_amount | decimal(10,2) | 差异金额 |
| platform_status | varchar(20) | 平台订单状态 |
| wechat_status | varchar(20) | 微信支付状态 |
| handle_status | tinyint | 处理状态(0待处理/1处理中/2已处理) |
| handle_remark | varchar(200) | 处理备注 |
| handle_user_id | bigint | 处理人ID |
| handle_time | datetime | 处理时间 |
| created_at | datetime | 创建时间 |
3.3 财务日报表 ot_financial_daily
| 字段 | 类型 | 说明 |
| id | bigint | 主键 |
| stat_date | date | 统计日期 |
| station_id | bigint | 站点ID(可空表示全平台) |
| order_count | int | 订单数 |
| gmv | decimal(12,2) | 订单总金额 |
| platform_commission | decimal(12,2) | 平台佣金 |
| refund_amount | decimal(12,2) | 退款金额 |
| net_income | decimal(12,2) | 净收入 |
| recharge_amount | decimal(12,2) | 充值金额 |
| withdraw_amount | decimal(12,2) | 提现金额 |
| created_at | datetime | 创建时间 |
3.4 骑手结算表 ot_courier_settlement
| 字段 | 类型 | 说明 |
| id | bigint | 主键 |
| settlement_no | varchar(32) | 结算单号 |
| courier_id | bigint | 骑手ID |
| settlement_period | varchar(20) | 结算周期(2026-04) |
| order_count | int | 配送单量 |
| gross_income | decimal(12,2) | 配送总收入 |
| commission | decimal(12,2) | 平台服务费 |
| reward_amount | decimal(10,2) | 奖励金额 |
| penalty_amount | decimal(10,2) | 罚款金额 |
| net_pay | decimal(12,2) | 应发金额 |
| paid_amount | decimal(12,2) | 已发金额 |
| status | tinyint | 状态(0待结算/1部分结算/2已结算) |
| settlement_time | datetime | 结算时间 |
| created_at | datetime | 创建时间 |
| updated_at | datetime | 更新时间 |
四、对账核心API
| 接口 | 说明 | 关键参数 |
POST /admin/ot/recon/daily | 执行日对账 | date(YYYY-MM-DD) |
GET /admin/ot/recon/report | 对账报表 | date, station_id |
GET /admin/ot/recon/diff-list | 差异列表 | recon_id, type, status |
POST /admin/ot/recon/diff-handle | 处理差异 | diff_id, remark |
GET /admin/ot/finance/daily-report | 财务日报 | start_date, end_date, station_id |
GET /admin/ot/finance/courier-monthly | 骑手月报 | period, courier_id |
POST /admin/ot/finance/export-daily | 导出日报 | start_date, end_date, format |
POST /admin/ot/finance/export-settlement | 导出结算单 | period |
文档同步:requirements_v2.md 对账模块 | 维护:项目团队