提现规则优化

This commit is contained in:
Dev
2026-09-23 14:30:46 +08:00
parent 5db3a4137a
commit 5cc504bb44
6 changed files with 214 additions and 1 deletions
@@ -42,6 +42,14 @@ class AccountWithdrawService
*/
public static function applyWithdraw($userId, $amount, string $name = '')
{
//每个自然日仅可发起一次提现申请
$todayCount = self::$Model::where('user_id', $userId)
->whereTime('createtime', 'today')
->count();
if ($todayCount >= 10) {
throw new \Exception('每个自然日仅可发起10次提现申请,请明日再试');
}
//开启事务 抛出异常时自动回滚
Db::transaction(function () use ($userId, $amount, $name) {
if($name){
+1 -1
View File
@@ -1,7 +1,7 @@
// 接口环境:按小程序运行版本自动切换,无需注释切换域名
// develop: 开发者工具运行/真机预览调试 | trial: 上传后的体验版 | release: 审核发布的正式版
const API_ROOTS = {
develop: 'http://code.syoai.cn', // 本地开发(phpStudy,hosts 需将 codebg.cn 指向 127.0.0.1)
develop: 'https://code.syoai.cn', // 本地开发(phpStudy,hosts 需将 codebg.cn 指向 127.0.0.1)
trial: 'https://code.syoai.cn', // 体验版(线上,需 https + 备案域名)
release: 'https://code.syoai.cn', // 正式版(线上,需 https + 备案域名)
};
@@ -17,6 +17,18 @@ Page({
withdrawAmount: '',
withdrawName: '',
cancelBtnStyle: 'color: #ff0000; border-color: #ff0000; background-color: #fff;',
// 提现规则:默认折叠,仅展示核心摘要
rulesExpanded: false,
briefRules: ['单笔 1-200 元', '每日限 10 次', '单日限额 2000 元', '1-3 个工作日到账'],
ruleList: [
{ title: '单笔额度', desc: '单笔最低 1 元,最高 200 元,以「可提现余额」为准' },
{ title: '提现次数', desc: '每个自然日最多可发起 10 次提现申请' },
{ title: '单日限额', desc: '同一自然日累计提现金额不超过 2000 元,超出请次日再试' },
{ title: '到账方式', desc: '转账至本人微信零钱,需填写与微信实名一致的姓名' },
{ title: '到账时间', desc: '审核通过后 1-3 个工作日内到账,节假日顺延' },
{ title: '审核说明', desc: '工作日统一审核处理,审核期间该笔金额将暂时冻结' },
{ title: '驳回处理', desc: '被驳回的提现金额将自动退回可提现余额,可重新发起' },
],
},
/**
@@ -130,6 +142,10 @@ Page({
onWithdraw() {
this.setData({ showWithdrawDialog: true });
},
// 展开/收起提现规则
onToggleRules() {
this.setData({ rulesExpanded: !this.data.rulesExpanded });
},
onWithdrawAmountInput(e) {
this.setData({ withdrawAmount: e.detail.value });
},
@@ -2,6 +2,7 @@
"usingComponents": {
"t-button": "tdesign-miniprogram/button/button",
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-input": "tdesign-miniprogram/input/input",
"t-empty": "tdesign-miniprogram/empty/empty",
"t-load-more": "/components/load-more/index",
@@ -23,6 +23,41 @@
<t-button block theme="primary" class="withdraw-btn" style="width:320rpx;margin:0 auto;" bindtap="onWithdraw">提现</t-button>
</view>
<!-- 提现规则:默认折叠,展示核心摘要;点击展开完整规则 -->
<view class="rules-card">
<view class="rules-header" hover-class="rules-header--hover" bindtap="onToggleRules">
<view class="rules-header-left">
<t-icon name="info-circle-filled" size="34rpx" color="#ff5f15" />
<text class="rules-header-title">提现规则</text>
</view>
<view class="rules-header-right">
<text class="rules-toggle-text">{{rulesExpanded ? '收起' : '展开'}}</text>
<t-icon name="chevron-down" size="30rpx" color="#a9aeb8" class="rules-arrow {{rulesExpanded ? 'is-expand' : ''}}" />
</view>
</view>
<!-- 折叠态:核心要点摘要 -->
<view class="rules-brief {{rulesExpanded ? 'is-hide' : ''}}">
<view class="brief-item" wx:for="{{briefRules}}" wx:key="*this">
<t-icon name="check-circle-filled" size="24rpx" color="#ff5f15" class="brief-icon" />
<text class="brief-text">{{item}}</text>
</view>
</view>
<!-- 展开态:完整规则 -->
<view class="rules-body {{rulesExpanded ? 'is-expand' : ''}}">
<view class="rules-body-inner">
<view class="rule-item" wx:for="{{ruleList}}" wx:key="title">
<view class="rule-index">{{index + 1}}</view>
<view class="rule-content">
<view class="rule-title">{{item.title}}</view>
<view class="rule-desc">{{item.desc}}</view>
</view>
</view>
</view>
</view>
</view>
<view class="balance-detail">
<view class="detail-title">余额明细</view>
<view class="tab-bar">
@@ -56,5 +91,6 @@
<view class="dialog-content" slot="content">
<t-input label="真实姓名" placeholder="请输入姓名" value="{{withdrawName}}" bindchange="onWithdrawNameInput" />
<t-input label="提现金额" placeholder="请输入提现金额" type="number" value="{{withdrawAmount}}" bindchange="onWithdrawAmountInput" />
<view class="dialog-tips">单笔 1-200 元,每日最多 10 次,单日累计不超过 2000 元;到账至微信零钱,1-3 个工作日内到账</view>
</view>
</t-dialog>
@@ -83,6 +83,158 @@
border-color: #ffffff;
}
/* ================= 提现规则(可折叠) ================= */
.rules-card {
margin: 0 24rpx 24rpx;
background: var(--bg-card);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-card);
overflow: hidden;
}
.rules-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 32rpx;
}
.rules-header--hover {
background: var(--bg-grey);
}
.rules-header-left {
display: flex;
align-items: center;
}
.rules-header-title {
margin-left: 12rpx;
font-size: 30rpx;
font-weight: 600;
color: var(--text-primary);
}
.rules-header-right {
display: flex;
align-items: center;
}
.rules-toggle-text {
font-size: 24rpx;
color: var(--brand);
margin-right: 4rpx;
}
.rules-arrow {
transition: transform 0.28s ease;
transform: rotate(0deg);
}
.rules-arrow.is-expand {
transform: rotate(180deg);
}
/* 折叠态:核心要点 */
.rules-brief {
display: flex;
flex-wrap: wrap;
max-height: 220rpx;
padding: 0 24rpx 28rpx;
overflow: hidden;
opacity: 1;
transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
}
.rules-brief.is-hide {
max-height: 0;
padding-top: 0;
padding-bottom: 0;
opacity: 0;
}
.brief-item {
display: flex;
align-items: center;
height: 52rpx;
margin: 8rpx 8rpx 0 0;
padding: 0 20rpx;
background: var(--brand-light);
border-radius: var(--radius-round);
}
.brief-icon {
margin-right: 8rpx;
}
.brief-text {
font-size: 24rpx;
color: var(--brand);
line-height: 52rpx;
}
/* 展开态:完整规则(max-height 过渡动画) */
.rules-body {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
}
.rules-body.is-expand {
max-height: 1400rpx;
}
.rules-body-inner {
padding: 4rpx 32rpx 28rpx;
border-top: 1px solid var(--border-level-1);
}
.rule-item {
display: flex;
align-items: flex-start;
padding: 20rpx 0 0;
}
.rule-index {
flex: 0 0 36rpx;
height: 36rpx;
margin-top: 6rpx;
border-radius: var(--radius-round);
background: var(--brand-light);
color: var(--brand);
font-size: 22rpx;
font-weight: 600;
line-height: 36rpx;
text-align: center;
}
.rule-content {
flex: 1;
margin-left: 16rpx;
}
.rule-title {
font-size: 26rpx;
font-weight: 600;
color: var(--text-primary);
line-height: 40rpx;
}
.rule-desc {
margin-top: 2rpx;
font-size: 24rpx;
color: var(--text-tertiary);
line-height: 38rpx;
}
/* 提现弹窗内提示 */
.dialog-tips {
padding: 24rpx 8rpx 8rpx;
font-size: 22rpx;
color: var(--text-placeholder);
line-height: 36rpx;
}
.balance-detail {
margin: 24rpx;
background: var(--bg-card);