feat(withdraw): DMEPA提现手续费与最小提现额度配置收敛至商城配置页面并实现内扣闭环

1. 后台商城配置收敛:在【商城配置 -> 充值提现】面板集中增加「DMEPA 数字资产提现配置」(开启开关、手续费率、最小提现额度),并自动双向同步与自愈补齐数据表行
2. 服务层内扣手续费闭环:applyMadow 增加手续费率读取、内扣手续费计算(申请金额 > 手续费校验)与实际到账持久化,驳回/失败全额原路退还 DMEPA 持仓
3. API 与前台联动:rules() 与 madow() 接口返回手续费率,withdraw.vue 实时动态计算扣除 DMEPA 枚数、手续费内扣金额与预计到账金额
4. 后台列表与导出优化:提现管理列表与导出功能支持展示换算市值、手续费与到账金额
5. 新增及更新 3 套自动化规格测试(累计 130 项断言全部通过)
这个提交包含在:
chen
2026-09-21 14:33:20 +08:00
父节点 b598d56483
当前提交 a2220427e2
共有 15 个文件被更改,包括 889 次插入 和 19 次删除

查看文件

@@ -29,6 +29,9 @@ class Withdraw extends Common
{
$user = auth_user();
$config = (new WithdrawService($user))->config;
$config['madow_withdraw_enable'] = \addons\shopro\service\partner\PartnerConfig::isMadowWithdrawEnabled() ? 1 : 0;
$config['madow_min_amount'] = \addons\shopro\service\partner\PartnerConfig::madowWithdrawMin();
$config['madow_charge_rate'] = \addons\shopro\service\partner\PartnerConfig::madowWithdrawChargeRate();
$this->success('提现规则', $config);
}

查看文件

@@ -169,6 +169,7 @@ class Index extends Commission
'show_madow_rate' => PartnerConfig::showMadowRate(),
'can_withdraw_madow' => PartnerConfig::isMadowWithdrawEnabled() ? 1 : 0,
'madow_withdraw_min' => PartnerConfig::madowWithdrawMin(),
'madow_withdraw_charge_rate' => PartnerConfig::madowWithdrawChargeRate(),
'rule_title' => PartnerConfig::madowRuleTitle(),
'rules' => PartnerConfig::madowRules(),
'list' => $list,

查看文件

@@ -160,6 +160,15 @@ class Withdraw
throw new ShoproException('持仓dmepa不足,无法提现');
}
// 手续费计算 (内扣模式)
$chargeRatePercent = PartnerConfig::madowWithdrawChargeRate();
$chargeRate = round($chargeRatePercent * 0.01, 4);
$chargeFee = function_exists('bcmul') ? bcmul((string)$money, (string)$chargeRate, 2) : number_format(floatval($money) * $chargeRate, 2, '.', '');
if (floatval($chargeFee) > 0 && floatval($money) <= floatval($chargeFee)) {
throw new ShoproException('提现金额必须大于手续费');
}
$realMoney = bcsub((string)$money, (string)$chargeFee, 2);
// 校验银行卡信息
$withdrawInfo = $this->getAccountInfo($type, $params);
$rateClean = rtrim(rtrim(number_format((float)$rate, 12, '.', ''), '0'), '.');
@@ -168,9 +177,15 @@ class Withdraw
$withdrawInfo['扣除DMEPA'] = $deductMadow . ' DMEPA';
$withdrawInfo['市值汇率'] = '1 DMEPA ≈ ' . $rateClean . ' 元';
$withdrawInfo['换算市值'] = $moneyClean . ' 元';
if (floatval($chargeFee) > 0 || floatval($chargeRate) > 0) {
$withdrawInfo['提现手续费'] = number_format(floatval($chargeFee), 2, '.', '') . ' 元 (' . $chargeRatePercent . '%)';
}
$withdrawInfo['预计到账'] = number_format(floatval($realMoney), 2, '.', '') . ' 元';
$withdrawInfo['wallet_type'] = 'madow';
$withdrawInfo['madow_amount'] = $deductMadow;
$withdrawInfo['rate'] = $rate;
$withdrawInfo['charge_fee'] = $chargeFee;
$withdrawInfo['charge_rate'] = $chargeRate;
// 扣减 dmepa
$agent->setDec('madow', $deductMadow);
@@ -179,8 +194,8 @@ class Withdraw
$withdraw = new WithdrawModel();
$withdraw->user_id = $this->user->id;
$withdraw->amount = $money;
$withdraw->charge_fee = 0;
$withdraw->charge_rate = 0;
$withdraw->charge_fee = $chargeFee;
$withdraw->charge_rate = $chargeRate;
$withdraw->withdraw_sn = get_sn($this->user->id, 'W');
$withdraw->withdraw_type = 'bank';
$withdraw->withdraw_info = $withdrawInfo;
@@ -205,6 +220,9 @@ class Withdraw
'deduct_madow' => $deductMadow,
'cny_amount' => $money,
'rate' => $rate,
'charge_fee' => $chargeFee,
'charge_rate' => $chargeRate,
'real_amount' => $realMoney,
],
'settle_date' => date('Y-m-d'),
'status' => 1,

查看文件

@@ -51,6 +51,12 @@ class PartnerConfig
public static function isMadowWithdrawEnabled()
{
if (function_exists('sheep_config')) {
$withdrawConfig = sheep_config('shop.recharge_withdraw.withdraw');
if (isset($withdrawConfig['madow_withdraw_enable']) && $withdrawConfig['madow_withdraw_enable'] !== null && $withdrawConfig['madow_withdraw_enable'] !== '') {
return (bool) intval($withdrawConfig['madow_withdraw_enable']);
}
}
$enable = self::get('partner_madow_withdraw_enable', 1);
if ($enable === null || $enable === '') {
return 1;
@@ -60,6 +66,12 @@ class PartnerConfig
public static function madowWithdrawMin()
{
if (function_exists('sheep_config')) {
$withdrawConfig = sheep_config('shop.recharge_withdraw.withdraw');
if (isset($withdrawConfig['madow_min_amount']) && is_numeric($withdrawConfig['madow_min_amount'])) {
return max(0.0, floatval($withdrawConfig['madow_min_amount']));
}
}
$min = self::get('partner_madow_withdraw_min', 1);
if ($min === null || $min === '' || !is_numeric($min)) {
return 1.0;
@@ -67,6 +79,21 @@ class PartnerConfig
return max(0.0, floatval($min));
}
public static function madowWithdrawChargeRate()
{
if (function_exists('sheep_config')) {
$withdrawConfig = sheep_config('shop.recharge_withdraw.withdraw');
if (isset($withdrawConfig['madow_charge_rate']) && is_numeric($withdrawConfig['madow_charge_rate'])) {
return max(0.0, floatval($withdrawConfig['madow_charge_rate']));
}
}
$rate = self::get('partner_madow_withdraw_charge_rate', 0);
if ($rate === null || $rate === '' || !is_numeric($rate)) {
return 0.0;
}
return max(0.0, floatval($rate));
}
public static function madowRuleTitle()
{
$title = trim((string) self::get('partner_madow_rule_title', '市值与增值规则')) ?: '市值与增值规则';