feat(withdraw): DMEPA提现手续费与最小提现额度配置收敛至商城配置页面并实现内扣闭环
1. 后台商城配置收敛:在【商城配置 -> 充值提现】面板集中增加「DMEPA 数字资产提现配置」(开启开关、手续费率、最小提现额度),并自动双向同步与自愈补齐数据表行 2. 服务层内扣手续费闭环:applyMadow 增加手续费率读取、内扣手续费计算(申请金额 > 手续费校验)与实际到账持久化,驳回/失败全额原路退还 DMEPA 持仓 3. API 与前台联动:rules() 与 madow() 接口返回手续费率,withdraw.vue 实时动态计算扣除 DMEPA 枚数、手续费内扣金额与预计到账金额 4. 后台列表与导出优化:提现管理列表与导出功能支持展示换算市值、手续费与到账金额 5. 新增及更新 3 套自动化规格测试(累计 130 项断言全部通过)
这个提交包含在:
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* DMEPA 提现手续费与最小提现额度(收敛至商城配置页面)规格验证测试
|
||||
*
|
||||
* 覆盖范围:
|
||||
* 1. 商城配置视图 (index.html) 在充值提现面板下具备 DMEPA 提现开关、手续费率与最小提现金额表单
|
||||
* 2. 商城配置脚本 (config.js) 正确初始化 withdraw.madow_* 默认属性
|
||||
* 3. Config.php 控制器中 rechargeWithdraw 支持读取与保存 madow_* 并双向同步至 shop.commission
|
||||
* 4. Config.php 模型自愈补齐 shop.recharge_withdraw.withdraw.madow_* 与 shop.commission 缺失行
|
||||
* 5. PartnerConfig.php 优先读取提现配置并回落读取合伙人配置,提供 madowWithdrawChargeRate
|
||||
* 6. Withdraw.php 服务层 applyMadow 执行内扣手续费计算、金额合法性校验与单据记录
|
||||
* 7. Withdraw.php 模型 getWithdrawInfoDisplayAttr 规范格式化提现手续费与预计到账
|
||||
* 8. withdraw.vue 前端组件实现 DMEPA 提现手续费内扣动态预览与超额校验
|
||||
* 9. API 层 (Withdraw.php::rules 与 partner/Index.php::madow) 正确输出手续费配置
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let passCount = 0;
|
||||
let failCount = 0;
|
||||
|
||||
function assert(condition, testName, detail = '') {
|
||||
if (condition) {
|
||||
console.log(` \x1b[32m[PASS]\x1b[0m ${testName}`);
|
||||
passCount++;
|
||||
} else {
|
||||
console.error(` \x1b[31m[FAIL]\x1b[0m ${testName} - ${detail}`);
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('========================================================');
|
||||
console.log(' DMEPA 提现手续费与最小提现额度(商城配置页面)规格测试');
|
||||
console.log('========================================================\n');
|
||||
|
||||
// 1. 验证 application/admin/view/shopro/config/index.html
|
||||
console.log('--- 1. 商城配置视图 (index.html) 提现配置面板中的 DMEPA 配置 ---');
|
||||
const indexHtmlPath = path.resolve(__dirname, '../../application/admin/view/shopro/config/index.html');
|
||||
assert(fs.existsSync(indexHtmlPath), 'index.html 存在');
|
||||
const indexHtmlContent = fs.readFileSync(indexHtmlPath, 'utf-8');
|
||||
|
||||
assert(
|
||||
indexHtmlContent.includes('form.model.withdraw.madow_withdraw_enable'),
|
||||
'充值提现面板包含「开启DMEPA提现」开关 (withdraw.madow_withdraw_enable)'
|
||||
);
|
||||
assert(
|
||||
indexHtmlContent.includes('form.model.withdraw.madow_charge_rate'),
|
||||
'充值提现面板包含「DMEPA提现手续费」输入框 (withdraw.madow_charge_rate)'
|
||||
);
|
||||
assert(
|
||||
indexHtmlContent.includes('form.model.withdraw.madow_min_amount'),
|
||||
'充值提现面板包含「DMEPA最小提现金额」输入框 (withdraw.madow_min_amount)'
|
||||
);
|
||||
assert(
|
||||
indexHtmlContent.includes('DMEPA 数字资产提现配置'),
|
||||
'充值提现面板具备「DMEPA 数字资产提现配置」小节标题'
|
||||
);
|
||||
|
||||
// 2. 验证 public/assets/js/backend/shopro/config.js
|
||||
console.log('\n--- 2. 后台配置脚本 (config.js) 初始化与默认值 ---');
|
||||
const configJsPath = path.resolve(__dirname, '../../public/assets/js/backend/shopro/config.js');
|
||||
assert(fs.existsSync(configJsPath), 'config.js 存在');
|
||||
const configJsContent = fs.readFileSync(configJsPath, 'utf-8');
|
||||
|
||||
assert(
|
||||
configJsContent.includes("state.tabActive == 'shopro/config/rechargewithdraw'") &&
|
||||
configJsContent.includes("form.model.withdraw.madow_withdraw_enable") &&
|
||||
configJsContent.includes("form.model.withdraw.madow_charge_rate") &&
|
||||
configJsContent.includes("form.model.withdraw.madow_min_amount"),
|
||||
'config.js 对 rechargewithdraw 下的 madow_* 字段进行完整默认值兜底'
|
||||
);
|
||||
|
||||
// 3. 验证 application/admin/controller/shopro/Config.php
|
||||
console.log('\n--- 3. 后台控制器 (Config.php) rechargeWithdraw 与双向同步 ---');
|
||||
const configPhpPath = path.resolve(__dirname, '../../application/admin/controller/shopro/Config.php');
|
||||
assert(fs.existsSync(configPhpPath), 'Config.php 控制器存在');
|
||||
const configPhpContent = fs.readFileSync(configPhpPath, 'utf-8');
|
||||
|
||||
assert(
|
||||
configPhpContent.includes("rechargeWithdraw") &&
|
||||
configPhpContent.includes("madow_withdraw_enable") &&
|
||||
configPhpContent.includes("madow_charge_rate") &&
|
||||
configPhpContent.includes("madow_min_amount"),
|
||||
'rechargeWithdraw() 读取并清洗 DMEPA 提现配置字段'
|
||||
);
|
||||
assert(
|
||||
configPhpContent.includes("ShoproConfig::setConfigs('shop.commission'") &&
|
||||
configPhpContent.includes("partner_madow_withdraw_charge_rate"),
|
||||
'rechargeWithdraw() 保存时双向同步至 shop.commission 保持完全兼容'
|
||||
);
|
||||
|
||||
// 4. 验证 application/admin/model/shopro/Config.php
|
||||
console.log('\n--- 4. 配置模型 (Config.php) 自愈与默认加载 ---');
|
||||
const configModelPath = path.resolve(__dirname, '../../application/admin/model/shopro/Config.php');
|
||||
assert(fs.existsSync(configModelPath), 'Config.php 模型存在');
|
||||
const configModelContent = fs.readFileSync(configModelPath, 'utf-8');
|
||||
|
||||
assert(
|
||||
configModelContent.includes("shop.recharge_withdraw.withdraw.madow_withdraw_enable") &&
|
||||
configModelContent.includes("shop.recharge_withdraw.withdraw.madow_charge_rate") &&
|
||||
configModelContent.includes("shop.recharge_withdraw.withdraw.madow_min_amount"),
|
||||
'Config 模型在 setConfigField 中自动补齐创建提现配置行'
|
||||
);
|
||||
assert(
|
||||
configModelContent.includes("shop.commission.partner_madow_withdraw_charge_rate"),
|
||||
'Config 模型在 setConfigField 中自动补齐创建合伙人专属手续费行'
|
||||
);
|
||||
|
||||
// 5. 验证 PartnerConfig.php 服务层读取
|
||||
console.log('\n--- 5. 服务层 PartnerConfig.php 优先级与手续费读取 ---');
|
||||
const partnerConfigPath = path.resolve(__dirname, '../../addons/shopro/service/partner/PartnerConfig.php');
|
||||
assert(fs.existsSync(partnerConfigPath), 'PartnerConfig.php 存在');
|
||||
const partnerConfigContent = fs.readFileSync(partnerConfigPath, 'utf-8');
|
||||
|
||||
assert(
|
||||
partnerConfigContent.includes("function madowWithdrawChargeRate"),
|
||||
'PartnerConfig 提供 madowWithdrawChargeRate() 读取方法'
|
||||
);
|
||||
assert(
|
||||
partnerConfigContent.includes("shop.recharge_withdraw.withdraw") &&
|
||||
partnerConfigContent.includes("madow_charge_rate"),
|
||||
'madowWithdrawChargeRate 优先从商城提现配置中读取'
|
||||
);
|
||||
|
||||
// 6. 验证 Withdraw.php 服务层内扣手续费计算
|
||||
console.log('\n--- 6. 提现服务层 (Withdraw.php) applyMadow 内扣手续费计算与单据 ---');
|
||||
const withdrawServicePath = path.resolve(__dirname, '../../addons/shopro/service/Withdraw.php');
|
||||
assert(fs.existsSync(withdrawServicePath), 'Withdraw.php 存在');
|
||||
const withdrawServiceContent = fs.readFileSync(withdrawServicePath, 'utf-8');
|
||||
|
||||
assert(
|
||||
withdrawServiceContent.includes("PartnerConfig::madowWithdrawChargeRate()"),
|
||||
'applyMadow 调用 PartnerConfig::madowWithdrawChargeRate() 获取费率'
|
||||
);
|
||||
assert(
|
||||
withdrawServiceContent.includes("提现金额必须大于手续费"),
|
||||
'applyMadow 校验提现金额必须大于内扣手续费'
|
||||
);
|
||||
assert(
|
||||
withdrawServiceContent.includes("$withdrawInfo['提现手续费']") &&
|
||||
withdrawServiceContent.includes("$withdrawInfo['预计到账']"),
|
||||
'applyMadow 在单据中清晰写入提现手续费与预计到账金额'
|
||||
);
|
||||
assert(
|
||||
withdrawServiceContent.includes("$withdraw->charge_fee = $chargeFee") &&
|
||||
withdrawServiceContent.includes("$withdraw->charge_rate = $chargeRate"),
|
||||
'applyMadow 在提现模型主记录中持久化 charge_fee 与 charge_rate'
|
||||
);
|
||||
|
||||
// 7. 验证 application/admin/model/shopro/Withdraw.php
|
||||
console.log('\n--- 7. 后台提现模型 (Withdraw.php) 展示格式化 ---');
|
||||
const adminWithdrawModelPath = path.resolve(__dirname, '../../application/admin/model/shopro/Withdraw.php');
|
||||
assert(fs.existsSync(adminWithdrawModelPath), 'application/admin/model/shopro/Withdraw.php 存在');
|
||||
const adminWithdrawModelContent = fs.readFileSync(adminWithdrawModelPath, 'utf-8');
|
||||
|
||||
assert(
|
||||
adminWithdrawModelContent.includes("$display['提现手续费']") &&
|
||||
adminWithdrawModelContent.includes("$display['预计到账']"),
|
||||
'Withdraw 模型在 getWithdrawInfoDisplayAttr 中为 DMEPA 提现输出手续费与预计到账'
|
||||
);
|
||||
|
||||
// 8. 验证 用户端组件 uniapp/pages/pay/withdraw.vue
|
||||
console.log('\n--- 8. 用户端提现页 (withdraw.vue) 实时动态计算与展示 ---');
|
||||
const withdrawVuePath = path.resolve(__dirname, '../../uniapp/pages/pay/withdraw.vue');
|
||||
assert(fs.existsSync(withdrawVuePath), 'withdraw.vue 存在');
|
||||
const withdrawVueContent = fs.readFileSync(withdrawVuePath, 'utf-8');
|
||||
|
||||
assert(
|
||||
withdrawVueContent.includes("estimatedMadowChargeFee") &&
|
||||
withdrawVueContent.includes("estimatedMadowArrivalMoney"),
|
||||
'withdraw.vue 具备 DMEPA 专属预计内扣手续费与预计到账计算属性'
|
||||
);
|
||||
assert(
|
||||
withdrawVueContent.includes("预计到账:¥{{ estimatedMadowArrivalMoney }}(手续费内扣 ¥{{ estimatedMadowChargeFee }})"),
|
||||
'withdraw.vue 在 DMEPA 模式下输入金额时实时展示预计到账与手续费'
|
||||
);
|
||||
assert(
|
||||
withdrawVueContent.includes("提现金额须大于手续费"),
|
||||
'withdraw.vue 提交前严格校验提现金额必须大于内扣手续费'
|
||||
);
|
||||
assert(
|
||||
withdrawVueContent.includes("madow_withdraw_charge_rate"),
|
||||
'withdraw.vue 从接口解析服务端下发的 madow_withdraw_charge_rate'
|
||||
);
|
||||
|
||||
// 9. 验证 API 输出
|
||||
console.log('\n--- 9. API 接口 (Withdraw.php::rules 与 partner/Index.php::madow) ---');
|
||||
const apiRulesPath = path.resolve(__dirname, '../../addons/shopro/controller/Withdraw.php');
|
||||
const apiRulesContent = fs.readFileSync(apiRulesPath, 'utf-8');
|
||||
assert(
|
||||
apiRulesContent.includes("madow_charge_rate"),
|
||||
'Withdraw.php rules() 下发 madow_charge_rate'
|
||||
);
|
||||
|
||||
const partnerIndexPath = path.resolve(__dirname, '../../addons/shopro/controller/partner/Index.php');
|
||||
const partnerIndexContent = fs.readFileSync(partnerIndexPath, 'utf-8');
|
||||
assert(
|
||||
partnerIndexContent.includes("'madow_withdraw_charge_rate' => PartnerConfig::madowWithdrawChargeRate()"),
|
||||
'partner/Index.php madow() 接口返回 madow_withdraw_charge_rate'
|
||||
);
|
||||
|
||||
console.log('--------------------------------------------------------');
|
||||
console.log(`测试执行结果: 通过 ${passCount} 项, 失败 ${failCount} 项`);
|
||||
console.log('========================================================\n');
|
||||
|
||||
if (failCount > 0) {
|
||||
process.exit(1);
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户