1.优化提现接口/api/finance/withdrawCreate

This commit is contained in:
2026-05-20 12:01:07 +08:00
parent 91229f4477
commit b9e4d806f7
12 changed files with 219 additions and 13 deletions

View File

@@ -428,6 +428,8 @@
- `status`int启用状态1=启用)
- `tier_ids`array兼容字段当前固定空数组表示自动兼容全部充值档位
- `withdraw`object
- `pay_channels`array提现可选支付渠道用于 `withdrawCreate``channel_code`;仅返回后台已启用且服务端已对接出金的渠道)
- 每项:`code`string渠道代码小写`name`(展示名)、`sort`(排序)
- `banks`array提现银行
- `min_ewallet`string电子钱包最低提现
- `min_bank`string银行卡最低提现
@@ -437,8 +439,11 @@
- `rate_mode`string`fixed` / `live`
- `fields`object**与 DDPay / `withdrawCreate` 一致**,不由后台「支付/收款配置」开关维护;用于客户端展示必填项)
- `receive_type_bank_only`bool当前固定 `true`,仅支持银行卡出金)
- `require_channel_code`bool固定 `true`,对应 `channel_code`
- `require_receiver_name`bool固定 `true`,对应 `receiver_name`
- `require_receive_account`bool固定 `true`,对应 `receive_account`
- `require_receiver_email`bool固定 `true`,对应 `receiver_email`
- `require_receiver_mobile`bool固定 `true`,对应 `receiver_mobile`
- `require_bank_code`bool固定 `true`,对应 `bank_code`
- `require_bank_branch`bool固定 `false``bank_branch` 选填,不传时服务端按 `N/A` 提交 DDPay
@@ -578,12 +583,19 @@
### 5.7 提现申请
- **POST** `/api/finance/withdrawCreate`
说明:
- **仅支持 DDPay 出金**`channel_code` 必须为 **`ddpay`**(兼容同义字段 `pay_channel`),且该渠道在收银台配置中为启用状态,否则返回 `code=2004`
- 可选渠道列表见 `depositWithdrawConfig``withdraw.pay_channels`
请求参数:
- `channel_code`string必填支付渠道代码当前仅支持 `ddpay`;兼容字段 `pay_channel`
- `withdraw_coin`string含义申请提现金额必须 > 0
- `receive_account`string含义收款账号对接 DDPay 出金时对应官方字段 **`receiver_account`**,为收款账户号/手机号,须与银行登记一致)
- `receive_type`string含义收款类型当前版本仅支持 `bank`
- `idempotency_key`string含义防重复提交提现
- `receiver_name`string含义收款账户持有人姓名`receive_type=bank` 必填,对应官方 **`receiver_name`**,须与银行登记一致)
- `receiver_email`string含义收款人邮箱必填须为合法邮箱格式最长 255
- `receiver_mobile`string含义收款人手机号必填532 位,仅允许数字与 `+` `-` 空格,至少含 5 位数字)
- `bank_code`string含义银行代码`receive_type=bank` 必填。取值来自收银台配置 `withdraw_banks[].code`;服务端会映射为 DDPay 所需的 **`bank[name]`** 银行全称发起出金)
- `bank_branch`string含义银行支行名称`receive_type=bank` 可选。官方 **`bank_branch`** 为必填项,若客户端不传则服务端按 **`N/A`** 提交,与 DDPay 文档「若缺失则默认值为 `N/A`」一致)
@@ -611,17 +623,18 @@
- `risk_review_required`bool含义是否命中人工审核
校验顺序(任一失败即返回对应错误码,不再创建订单):
1. 参数完整性与金额合法性(`code=1001`;金额必须为数值且 > 0
2. **待审核订单数限制**:同一用户 `status=0`(待审核)的 `withdraw_order` 不得超过 3 笔,否则 `code=2004 Too many pending withdraw orders``data` 中回传:
1. 参数完整性与金额合法性(`code=1001``channel_code``withdraw_coin` 等必填项;金额必须为数值且 > 0
2. **支付渠道**`channel_code` `ddpay` 返回 `code=2004 Withdraw only supports DDPay`;渠道未启用返回 `code=2004 Pay channel not available`
3. **待审核订单数限制**:同一用户 `status=0`(待审核)的 `withdraw_order` 不得超过 3 笔,否则 `code=2004 Too many pending withdraw orders``data` 中回传:
- `max_pending`:上限值(当前为 `3`
- `pending_count`:当前待审核订单数
3. `coin_balance >= withdraw_coin`,否则 `code=2001 Insufficient balance`
4. **单笔上限校验**`withdraw_coin <= max_withdrawable`,否则 `code=2002 Withdraw exceeds available bet flow``data` 中回传:
4. `coin_balance >= withdraw_coin`,否则 `code=2001 Insufficient balance`
5. **单笔上限校验**`withdraw_coin <= max_withdrawable`,否则 `code=2002 Withdraw exceeds available bet flow``data` 中回传:
- `max_withdrawable`**当前允许的单笔最大提现金额**= `min(coin_balance, max_withdraw_by_flow)`,前端据此提示"最大可提现金额为 XXX"
- `coin_balance``bet_flow_coin``total_withdraw_coin``ratio`
- `max_withdraw_by_flow`:仅按打码量折算的上限(= `max(0, bet_flow_coin / ratio - total_withdraw_coin)``ratio=0` 时为 `null`
5. 以上全通过后在同一事务内:
- `withdraw_order` 写入:`amount` / `fee`(默认 0.5% / `actual_amount = amount - fee` / `status=0`(待审核) / `channel_id` 取自用户归属渠道快照;同时写入收款字段(`receive_type/receive_account/receiver_name/bank_code/bank_branch`)。
6. 以上全通过后在同一事务内:
- `withdraw_order` 写入:`pay_channel`= `channel_code`/ `amount` / `fee`(默认 0.5% / `actual_amount = amount - fee` / `status=0`(待审核) / `channel_id` 取自用户归属渠道快照;同时写入收款字段(`receive_type/receive_account/receiver_email/receiver_mobile/receiver_name/bank_code/bank_branch`)。
- `user` 表原子更新:`coin -= withdraw_coin``total_withdraw_coin += withdraw_coin`WHERE `coin >= withdraw_coin` 防止并发超额扣减)。
- `user_wallet_record` 写入 `biz_type=withdraw``direction=2``amount=withdraw_coin``ref_type=withdraw_order``idempotency_key=wd_apply_{order_no}`,代表"冻结"动作。
@@ -645,6 +658,11 @@
- `withdraw_coin`string含义申请提现金额与后台 `withdraw_order.amount` 对齐)
- `fee_coin`string含义手续费与后台 `withdraw_order.fee` 对齐)
- `actual_arrival_coin`string含义实际到账金额 = 申请金额 - 手续费;后台审核调整后会同步刷新)
- `receive_type`string含义收款类型
- `receive_account`string含义收款账号
- `pay_channel`string含义支付渠道代码`channel_code` 一致)
- `receiver_email`string含义收款人邮箱
- `receiver_mobile`string含义收款人手机号
- `reject_reason`string/null含义拒绝原因`status=rejected` 时取自 `withdraw_order.remark`,否则为 `null`
- `create_time`int含义申请时间
- `review_time`int/null含义审核时间戳未审核为 `null`