feat(withdraw): 提现金额限制100的整数倍,完善全部提现取整与分红规则文案规范

这个提交包含在:
chen
2026-09-20 15:05:10 +08:00
父节点 2b7c34c7f7
当前提交 d8639d8e32
共有 6 个文件被更改,包括 288 次插入 和 26 次删除

查看文件

@@ -676,10 +676,16 @@ class Withdraw
throw new ShoproException('暂不支持该提现方式'); throw new ShoproException('暂不支持该提现方式');
} }
if ($money <= 0) { if (!is_numeric($money) || floatval($money) <= 0) {
throw new ShoproException('请输入正确的提现金额'); throw new ShoproException('请输入正确的提现金额');
} }
$floatMoney = floatval($money);
// 提现金额必须为整数且为 100 的整数倍(如 100、200、1200 等)
if (floor($floatMoney) != $floatMoney || (intval($floatMoney) % 100 !== 0)) {
throw new ShoproException('提现金额必须为100的整数倍');
}
// 检查最小提现金额 // 检查最小提现金额
if ($this->config['min_amount'] > 0 && $money < $this->config['min_amount']) { if ($this->config['min_amount'] > 0 && $money < $this->config['min_amount']) {
throw new ShoproException('提现金额不能少于 ' . $this->config['min_amount'] . '元'); throw new ShoproException('提现金额不能少于 ' . $this->config['min_amount'] . '元');

查看文件

@@ -355,7 +355,7 @@ class Config extends Common
if (isset($save['partner_team_total'], $save['partner_venue_split']) if (isset($save['partner_team_total'], $save['partner_venue_split'])
&& (float) $save['partner_venue_split'] > (float) $save['partner_team_total']) { && (float) $save['partner_venue_split'] > (float) $save['partner_team_total']) {
$venueName = !empty($save['partner_role_name_venue']) ? $save['partner_role_name_venue'] : '酒道馆'; $venueName = !empty($save['partner_role_name_venue']) ? $save['partner_role_name_venue'] : '酒道馆';
$this->error($venueName . '份额不能大于团队拆分总额'); $this->error($venueName . '管理奖不能大于团队管理奖总预算');
} }
$configs = ShoproConfig::setConfigs('shop.commission', $save); $configs = ShoproConfig::setConfigs('shop.commission', $save);
$this->success('规则已更新,仅对之后的新订单生效。', null, $configs); $this->success('规则已更新,仅对之后的新订单生效。', null, $configs);

查看文件

@@ -1034,27 +1034,50 @@
<template #append>小数,如 0.05</template> <template #append>小数,如 0.05</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<div class="sa-title is-line">团队拆分 / 均分</div> <div class="sa-title is-line">渠道管理奖(即时按单结算)</div>
<el-form-item label="拆分总额"> <el-form-item label="团队管理奖总预算">
<el-input class="sa-w-360" v-model="form.model.partner_team_total"></el-input> <el-input class="sa-w-360" v-model="form.model.partner_team_total">
<template #append>元/单</template>
</el-input>
<div class="tip">单笔订单用于该链路酒道馆与区县代理团队管理奖的总预算上限(默认 100 元)</div>
</el-form-item> </el-form-item>
<el-form-item label="酒道馆份额"> <el-form-item label="酒道馆管理奖(有馆)">
<el-input class="sa-w-360" v-model="form.model.partner_venue_split"></el-input> <el-input class="sa-w-360" v-model="form.model.partner_venue_split">
<template #append>元/单</template>
</el-input>
<div class="tip">买家推荐链上存在酒道馆时分配的金额。若上级同时存在区县代理,区县代理得剩余部分(总预算 - 酒道馆)</div>
</el-form-item> </el-form-item>
<el-form-item label="无馆区县全额"> <el-form-item label="区县管理奖(无馆独享)">
<el-input class="sa-w-360" v-model="form.model.partner_county_full"></el-input> <el-input class="sa-w-360" v-model="form.model.partner_county_full">
<template #append>元/单</template>
</el-input>
<div class="tip">买家推荐链上无酒道馆时,首个区县代理独享的团队管理奖全额(默认 100 元)</div>
</el-form-item> </el-form-item>
<el-form-item label="酒道馆每单奖池">
<el-input class="sa-w-360" v-model="form.model.partner_venue_share_per_order"></el-input> <div class="sa-title is-line">公共分红池与平级协同(次日00:30日结)</div>
<el-form-item label="酒道馆日结每单注入">
<el-input class="sa-w-360" v-model="form.model.partner_venue_share_per_order">
<template #append>元/单</template>
</el-input>
<div class="tip">全网每产生 1 笔合格订单向酒道馆公共奖池注入的金额,次日 00:30 由近 30 天合格酒道馆平分</div>
</el-form-item> </el-form-item>
<el-form-item label="区县每单奖池"> <el-form-item label="区县代理日结每单注入">
<el-input class="sa-w-360" v-model="form.model.partner_county_share_per_order"></el-input> <el-input class="sa-w-360" v-model="form.model.partner_county_share_per_order">
<template #append>元/单</template>
</el-input>
<div class="tip">全网每产生 1 笔合格订单向区县代理公共奖池注入的金额,次日 00:30 由近 30 天合格区县代理平分</div>
</el-form-item> </el-form-item>
<el-form-item label="酒道馆平级比例"> <el-form-item label="酒道馆平级协同比例">
<el-input class="sa-w-360" v-model="form.model.partner_venue_peer_rate"></el-input> <el-input class="sa-w-360" v-model="form.model.partner_venue_peer_rate">
<template #append>如 0.10 代表 10%</template>
</el-input>
<div class="tip">直属推荐人也是酒道馆时,上级酒道馆按下级获得管理奖金额的该比例提取平级协同奖</div>
</el-form-item> </el-form-item>
<el-form-item label="区县平级比例"> <el-form-item label="区县代理平级协同比例">
<el-input class="sa-w-360" v-model="form.model.partner_county_peer_rate"></el-input> <el-input class="sa-w-360" v-model="form.model.partner_county_peer_rate">
<template #append>如 0.10 代表 10%</template>
</el-input>
<div class="tip">直属推荐人也是区县代理时,上级区县代理按下级获得管理奖金额的该比例提取平级协同奖</div>
</el-form-item> </el-form-item>
</template> </template>

查看文件

@@ -124,7 +124,8 @@ assert(fs.existsSync(withdrawServicePath), 'Withdraw.php 服务文件存在');
const withdrawServiceContent = fs.readFileSync(withdrawServicePath, 'utf-8'); const withdrawServiceContent = fs.readFileSync(withdrawServicePath, 'utf-8');
assert( assert(
withdrawServiceContent.includes("params['wallet_type'] ?? 'commission'") && (withdrawServiceContent.includes("params['wallet_type'] ?? 'commission'") ||
withdrawServiceContent.includes("params['wallet_type'] ?? 'money'")) &&
withdrawServiceContent.includes("applyMadow"), withdrawServiceContent.includes("applyMadow"),
'Withdraw.php::apply 支持 wallet_type=madow 并分流至 applyMadow' 'Withdraw.php::apply 支持 wallet_type=madow 并分流至 applyMadow'
); );

查看文件

@@ -0,0 +1,203 @@
/**
* 提现金额 100 整数倍规则全链路验证测试
*
* 核心规则要求:
* 1. 提现金额必须为整数且为 100 的整数倍(如 100、200、1200 等)。
* 2. 举例场景:余额有 115 元,只能提现 100 元;余额有 1260 元,只能提现 1200 元。
* 3. 余额不足 100 元时,点击全部提现提示“余额满100元方可申请提现”,输入框置空。
* 4. 前端提现输入框占位符、提现说明 Banner、提现规则列表同步展示 100 整数倍规则。
* 5. 前端确认提交时拦截非 100 整数倍,后端 checkApply 抛出对应异常。
*/
const fs = require('fs');
const path = require('path');
const assert = require('assert');
let passCount = 0;
let failCount = 0;
function testAssert(condition, message) {
if (condition) {
console.log(` \x1b[32m[PASS]\x1b[0m ${message}`);
passCount++;
} else {
console.error(` \x1b[31m[FAIL]\x1b[0m ${message}`);
failCount++;
}
}
console.log('========================================================');
console.log(' 提现金额 100 整数倍限制规则全链路验证测试');
console.log('========================================================\n');
// ----------------------------------------------------
// 1. 服务端 addons/shopro/service/Withdraw.php 校验规则
// ----------------------------------------------------
console.log('--- 1. 服务端 Withdraw.php 校验规则断言 ---');
const withdrawServicePath = path.resolve(__dirname, '../../addons/shopro/service/Withdraw.php');
testAssert(fs.existsSync(withdrawServicePath), 'Withdraw.php 服务层文件存在');
if (fs.existsSync(withdrawServicePath)) {
const phpContent = fs.readFileSync(withdrawServicePath, 'utf-8');
testAssert(
phpContent.includes('!is_numeric($money) || floatval($money) <= 0'),
'Withdraw.php checkApply 校验 is_numeric 与 floatval($money) <= 0'
);
testAssert(
phpContent.includes('floor($floatMoney) != $floatMoney || (intval($floatMoney) % 100 !== 0)'),
'Withdraw.php checkApply 校验必须为整数且为 100 的整数倍'
);
testAssert(
phpContent.includes("throw new ShoproException('提现金额必须为100的整数倍')"),
'Withdraw.php 非 100 整数倍时抛出 ShoproException(\'提现金额必须为100的整数倍\')'
);
}
// ----------------------------------------------------
// 2. 客户端 uniapp/pages/pay/withdraw.vue 界面与逻辑
// ----------------------------------------------------
console.log('\n--- 2. 客户端 withdraw.vue 界面与逻辑断言 ---');
const withdrawVuePath = path.resolve(__dirname, '../../uniapp/pages/pay/withdraw.vue');
testAssert(fs.existsSync(withdrawVuePath), 'withdraw.vue 前端源码文件存在');
if (fs.existsSync(withdrawVuePath)) {
const vueContent = fs.readFileSync(withdrawVuePath, 'utf-8');
testAssert(
vueContent.includes("placeholder=\"state.walletType === 'madow' ? '请输入提现金额' : '请输入100的整数倍金额(如100、1200)'\""),
'输入框占位符提示请输入100的整数倍金额'
);
testAssert(
vueContent.includes("提现金额须为100的整数倍(如100、200、1200等)"),
'提现说明 Banner 提示提现金额须为100的整数倍'
);
testAssert(
vueContent.includes("list.push('单次提现金额须为 100 元的整数倍(如 100、200、1200 等);')"),
'filterRules 规则列表包含 100 元整数倍规则'
);
testAssert(
vueContent.includes("Math.floor(total / 100) * 100"),
'onWithdrawAllMoney / onWithdrawAllCommission 采用 Math.floor(total / 100) * 100 向下取整'
);
testAssert(
vueContent.includes("sheep.$helper.toast('余额满100元方可申请提现')"),
'onWithdrawAllMoney 不足 100 元时提示余额满100元方可申请提现'
);
testAssert(
vueContent.includes("sheep.$helper.toast('佣金满100元方可申请提现')"),
'onWithdrawAllCommission 不足 100 元时提示佣金满100元方可申请提现'
);
testAssert(
vueContent.includes("!Number.isInteger(moneyVal) || moneyVal % 100 !== 0"),
'onConfirm 提现提交前前端强校验 100 的整数倍'
);
testAssert(
vueContent.includes("sheep.$helper.toast('提现金额须为100的整数倍')"),
'onConfirm 非 100 整数倍时前端友好 toast 提示'
);
}
// ----------------------------------------------------
// 3. 小程序开发包编译产物一致性验证
// ----------------------------------------------------
console.log('\n--- 3. 小程序编译包一致性断言 ---');
const distDevWithdrawJsPath = path.resolve(__dirname, '../../uniapp/unpackage/dist/dev/mp-weixin/pages/pay/withdraw.js');
testAssert(fs.existsSync(distDevWithdrawJsPath), 'dev 编译产物 withdraw.js 存在');
if (fs.existsSync(distDevWithdrawJsPath)) {
const distContent = fs.readFileSync(distDevWithdrawJsPath, 'utf-8');
testAssert(
distContent.includes("Math.floor(total / 100) * 100"),
'dev 编译产物已同步 Math.floor(total / 100) * 100'
);
testAssert(
distContent.includes("!Number.isInteger(moneyVal) || moneyVal % 100 !== 0"),
'dev 编译产物已同步 onConfirm 校验'
);
}
// ----------------------------------------------------
// 4. 业务场景算法断言(覆盖用户指定举例)
// ----------------------------------------------------
console.log('\n--- 4. 核心算法与用户场景模拟测试 ---');
// 模拟前端 onWithdrawAllMoney 计算函数
function calculateWithdrawAll(balance) {
const total = parseFloat(balance || 0);
const amount = Math.floor(total / 100) * 100;
if (amount <= 0) {
return { success: false, amount: '', message: '余额满100元方可申请提现' };
}
return { success: true, amount: String(amount), message: '操作成功' };
}
// 模拟服务端 checkApply 提现金额校验函数
function validateWithdrawMoney(moneyInput, userBalance) {
if (!isFinite(moneyInput) || parseFloat(moneyInput) <= 0) {
return { valid: false, message: '请输入正确的提现金额' };
}
const floatMoney = parseFloat(moneyInput);
if (Math.floor(floatMoney) !== floatMoney || (Math.floor(floatMoney) % 100 !== 0)) {
return { valid: false, message: '提现金额必须为100的整数倍' };
}
if (floatMoney > userBalance) {
return { valid: false, message: '商城可用余额不足' };
}
return { valid: true, message: '验证通过' };
}
// 场景 1:用户余额 115 元 -> 点击「全部提现」自动填入 100
const res115 = calculateWithdrawAll(115);
testAssert(res115.success === true && res115.amount === '100', '用户场景1:余额 115 元点击「全部提现」,填入 100 元');
// 场景 2:用户余额 1260 元 -> 点击「全部提现」自动填入 1200
const res1260 = calculateWithdrawAll(1260);
testAssert(res1260.success === true && res1260.amount === '1200', '用户场景2:余额 1260 元点击「全部提现」,填入 1200 元');
// 场景 3:用户余额 99 元 -> 点击「全部提现」提示余额满100元方可申请提现
const res99 = calculateWithdrawAll(99);
testAssert(res99.success === false && res99.amount === '' && res99.message === '余额满100元方可申请提现', '用户场景3:余额 99 元点击「全部提现」,提示满100元方可提现并置空');
// 场景 4:用户余额 100 元 -> 点击「全部提现」填入 100 元
const res100 = calculateWithdrawAll(100);
testAssert(res100.success === true && res100.amount === '100', '用户场景4:余额 100 元点击「全部提现」,填入 100 元');
// 场景 5:用户余额 2000.88 元 -> 点击「全部提现」填入 2000 元
const res2000 = calculateWithdrawAll(2000.88);
testAssert(res2000.success === true && res2000.amount === '2000', '用户场景5:余额 2000.88 元点击「全部提现」,填入 2000 元');
// 校验服务端验证用例
const val100 = validateWithdrawMoney(100, 115);
testAssert(val100.valid === true, '校验用例:提现 100 元(余额 115 元)服务端校验通过');
const val1200 = validateWithdrawMoney(1200, 1260);
testAssert(val1200.valid === true, '校验用例:提现 1200 元(余额 1260 元)服务端校验通过');
const val115 = validateWithdrawMoney(115, 115);
testAssert(val115.valid === false && val115.message === '提现金额必须为100的整数倍', '校验用例:直接提交 115 元被服务端拦截(必须为100的整数倍)');
const val1260 = validateWithdrawMoney(1260, 1260);
testAssert(val1260.valid === false && val1260.message === '提现金额必须为100的整数倍', '校验用例:直接提交 1260 元被服务端拦截(必须为100的整数倍)');
const valDecimal = validateWithdrawMoney(100.5, 200);
testAssert(valDecimal.valid === false && valDecimal.message === '提现金额必须为100的整数倍', '校验用例:小数 100.5 元被服务端拦截(必须为100的整数倍)');
const valZero = validateWithdrawMoney(0, 500);
testAssert(valZero.valid === false && valZero.message === '请输入正确的提现金额', '校验用例:金额 0 元被拦截');
const valNegative = validateWithdrawMoney(-100, 500);
testAssert(valNegative.valid === false && valNegative.message === '请输入正确的提现金额', '校验用例:金额 -100 元被拦截');
const valExceed = validateWithdrawMoney(200, 150);
testAssert(valExceed.valid === false && valExceed.message === '商城可用余额不足', '校验用例:金额 200 元(余额 150 元)超额拦截');
console.log('\n========================================================');
console.log(` 测试结果汇总:共 ${passCount + failCount} 项测试,通过: ${passCount},失败: ${failCount}`);
console.log('========================================================');
if (failCount > 0) {
process.exit(1);
} else {
process.exit(0);
}

查看文件

@@ -68,7 +68,7 @@
class="ss-flex-1 ss-p-l-10" class="ss-flex-1 ss-p-l-10"
v-model="state.amount" v-model="state.amount"
type="number" type="number"
placeholder="请输入提现金额" :placeholder="state.walletType === 'madow' ? '请输入提现金额' : '请输入100的整数倍金额(如100、1200)'"
/> />
</view> </view>
<view <view
@@ -115,7 +115,7 @@
<view class="draw-notice"> <view class="draw-notice">
<view class="title ss-m-b-20">提现说明</view> <view class="title ss-m-b-20">提现说明</view>
<view class="tip-banner ss-m-b-20" v-if="state.walletType !== 'madow'" style="background: #fff8f2; color: #ff6000; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;"> <view class="tip-banner ss-m-b-20" v-if="state.walletType !== 'madow'" style="background: #fff8f2; color: #ff6000; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;">
💡 提示:商城收益分成已全额直接入账商城余额,支持随时申请提现至银行卡/微信/支付宝,也可用于下单直接抵扣。历史存量佣金可转入商城余额消费。 💡 提示:提现金额须为100的整数倍(如100、200、1200等)。商城收益分成已全额直接入账商城余额,支持随时申请提现至银行卡/微信/支付宝,也可用于下单直接抵扣。历史存量佣金可转入商城余额消费。
</view> </view>
<view class="tip-banner ss-m-b-20" v-else style="background: #fdfbf7; color: #b78328; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;"> <view class="tip-banner ss-m-b-20" v-else style="background: #fdfbf7; color: #b78328; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;">
💡 提示:dmepa 按大盘实时汇率折算为现金扣除持仓,提现渠道限定为银行卡转账。审核驳回后对应 dmepa 将全额原路退回。 💡 提示:dmepa 按大盘实时汇率折算为现金扣除持仓,提现渠道限定为银行卡转账。审核驳回后对应 dmepa 将全额原路退回。
@@ -157,6 +157,7 @@
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
function filterRules(rules) { function filterRules(rules) {
let list = []; let list = [];
list.push('单次提现金额须为 100 元的整数倍(如 100、200、1200 等);');
let str1 = ''; let str1 = '';
if (rules.min_amount > 0) { if (rules.min_amount > 0) {
str1 += `最少 ${rules.min_amount}元; `; str1 += `最少 ${rules.min_amount}元; `;
@@ -238,15 +239,25 @@
} }
function onWithdrawAllMoney() { function onWithdrawAllMoney() {
if (userInfo.value?.money) { const total = parseFloat(userInfo.value?.money || 0);
state.amount = String(userInfo.value.money); const amount = Math.floor(total / 100) * 100;
if (amount <= 0) {
sheep.$helper.toast('余额满100元方可申请提现');
state.amount = '';
return;
} }
state.amount = String(amount);
} }
function onWithdrawAllCommission() { function onWithdrawAllCommission() {
if (userInfo.value?.commission) { const total = parseFloat(userInfo.value?.commission || 0);
state.amount = String(userInfo.value.commission); const amount = Math.floor(total / 100) * 100;
if (amount <= 0) {
sheep.$helper.toast('佣金满100元方可申请提现');
state.amount = '';
return;
} }
state.amount = String(amount);
} }
async function fetchUserBankAccount() { async function fetchUserBankAccount() {
@@ -330,10 +341,19 @@
} }
} else if (state.walletType === 'commission') { } else if (state.walletType === 'commission') {
payload.wallet_type = 'commission'; payload.wallet_type = 'commission';
if (Number(payload.money) > Number(userInfo.value?.commission || 0) || Number(payload.money) <= 0) { const moneyVal = Number(payload.money);
if (isNaN(moneyVal) || moneyVal <= 0) {
sheep.$helper.toast('请输入正确的提现金额'); sheep.$helper.toast('请输入正确的提现金额');
return; return;
} }
if (!Number.isInteger(moneyVal) || moneyVal % 100 !== 0) {
sheep.$helper.toast('提现金额须为100的整数倍');
return;
}
if (Number(payload.money) > Number(userInfo.value?.commission || 0)) {
sheep.$helper.toast('可提现佣金不足');
return;
}
if (!payload.type) { if (!payload.type) {
sheep.$helper.toast('请选择提现方式'); sheep.$helper.toast('请选择提现方式');
@@ -341,10 +361,19 @@
} }
} else { } else {
payload.wallet_type = 'money'; payload.wallet_type = 'money';
if (Number(payload.money) > Number(userInfo.value?.money || 0) || Number(payload.money) <= 0) { const moneyVal = Number(payload.money);
if (isNaN(moneyVal) || moneyVal <= 0) {
sheep.$helper.toast('请输入正确的提现金额'); sheep.$helper.toast('请输入正确的提现金额');
return; return;
} }
if (!Number.isInteger(moneyVal) || moneyVal % 100 !== 0) {
sheep.$helper.toast('提现金额须为100的整数倍');
return;
}
if (Number(payload.money) > Number(userInfo.value?.money || 0)) {
sheep.$helper.toast('商城可用余额不足');
return;
}
if (!payload.type) { if (!payload.type) {
sheep.$helper.toast('请选择提现方式'); sheep.$helper.toast('请选择提现方式');