feat(split): 新增分账订单线下结案功能

- 添加 SplitCloseService 类用于处理订单结案逻辑
- 实现订单结案状态检查和标记功能
- 在汇付分账重试逻辑中加入结案状态验证,防止已结案订单继续重试
- 更新分账手动服务,添加结案操作类型
- 扩展钱包结算类,增加结案相关诊断方法
- 修改测试脚本,支持批量标记订单为已结案状态
- 添加数据库升级脚本,增加结案相关字段和菜单权限
```
这个提交包含在:
可乐加冰
2026-10-24 21:18:48 +08:00
父节点 557d3e69ba
当前提交 6a654070ed
共有 16 个文件被更改,包括 1314 次插入 和 96 次删除

查看文件

@@ -1,57 +1,84 @@
{
"name": "shopro-plus",
"version": "1.0.0",
"lockfileVersion": 1,
"lockfileVersion": 3,
"requires": true,
"dependencies": {
"@babel/runtime": {
"packages": {
"": {
"name": "shopro-plus",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"jweixin-module": "^1.6.0",
"uni-read-pages": "^1.0.5",
"uni-simple-router": "^2.0.6",
"vconsole": "^3.7.0"
},
"devDependencies": {}
},
"node_modules/@babel/runtime": {
"version": "7.20.0",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.0.tgz",
"integrity": "sha512-NDYdls71fTXoU8TZHfbBWg7DiZfNzClcKui/+kyi6ppD2L1qnWW3VV6CjtaBXSUGGhiTWJ6ereOIkUvenif66Q==",
"requires": {
"dependencies": {
"regenerator-runtime": "^0.13.10"
},
"engines": {
"node": ">=6.9.0"
}
},
"copy-text-to-clipboard": {
"node_modules/copy-text-to-clipboard": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz",
"integrity": "sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q=="
"integrity": "sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"core-js": {
"node_modules/core-js": {
"version": "3.26.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.26.0.tgz",
"integrity": "sha512-+DkDrhoR4Y0PxDz6rurahuB+I45OsEUv8E1maPTB6OuHRohMMcznBq9TMpdpDMm/hUPob/mJJS3PqgbHpMTQgw=="
"integrity": "sha512-+DkDrhoR4Y0PxDz6rurahuB+I45OsEUv8E1maPTB6OuHRohMMcznBq9TMpdpDMm/hUPob/mJJS3PqgbHpMTQgw==",
"hasInstallScript": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"jweixin-module": {
"node_modules/jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w=="
},
"mutation-observer": {
"node_modules/mutation-observer": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/mutation-observer/-/mutation-observer-1.0.3.tgz",
"integrity": "sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA=="
},
"regenerator-runtime": {
"node_modules/regenerator-runtime": {
"version": "0.13.10",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz",
"integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw=="
},
"uni-read-pages": {
"node_modules/uni-read-pages": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/uni-read-pages/-/uni-read-pages-1.0.5.tgz",
"integrity": "sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA=="
"integrity": "sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA==",
"hasInstallScript": true
},
"uni-simple-router": {
"node_modules/uni-simple-router": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/uni-simple-router/-/uni-simple-router-2.0.7.tgz",
"integrity": "sha512-8FKv5dw7Eoonm0gkO8udprrxzin0fNUI0+AvIphFkFRH5ZmP5ZWJ2pvnWzb2NiiqQSECTSU5VSB7HhvOSwD5eA=="
},
"vconsole": {
"node_modules/vconsole": {
"version": "3.14.7",
"resolved": "https://registry.npmjs.org/vconsole/-/vconsole-3.14.7.tgz",
"integrity": "sha512-48byrra1sZk0zJfUM8HFN/ZKtMzvd7Sirt2h5Hfnf7txKOxL9JfoFKB2uLixmOF3jjxCpwnLLb1tsHlg4YzoyA==",
"requires": {
"dependencies": {
"@babel/runtime": "^7.17.2",
"copy-text-to-clipboard": "^3.0.1",
"core-js": "^3.11.0",

查看文件

@@ -8,6 +8,7 @@
v-if="userHeadData && userHeadData.style"
:scrollTop="scrollTop"
:detail="userHeadData"
:refreshKey="incomeRefreshKey"
@onShare="onShare"
></userinfo-card>
@@ -109,7 +110,8 @@ export default {
scrollTop: 0,
showShare: false,
enable: false,
userData: {}
userData: {},
incomeRefreshKey: 0
};
},
computed: {
@@ -150,6 +152,7 @@ export default {
this.init();
this.getUserData();
this.getAgent();
this.incomeRefreshKey += 1;
}
this.enable = true;
},

查看文件

@@ -52,21 +52,91 @@
</view>
</view>
<view class="asset-bar u-flex">
<view class="asset-item u-flex-1 u-flex-col u-col-center" @tap="jump('/pages/user/wallet/index')">
<text class="asset-value font-OPPOSANS">{{ userInfo.money || '0.00' }}</text>
<text class="asset-label">余额(元)</text>
<!-- 普通用户:余额 / 积分 / 优惠券 -->
<view class="asset-bar u-flex" v-if="!showIncomePanel">
<view
class="asset-item u-flex-1 u-flex-col u-col-center"
v-for="item in walletItems"
:key="item.key"
@tap="onAssetTap(item)"
>
<text class="asset-value font-OPPOSANS">{{ item.displayValue }}</text>
<text class="asset-label">{{ item.label }}</text>
</view>
<view class="asset-divider"></view>
<view class="asset-item u-flex-1 u-flex-col u-col-center" @tap="jump('/pages/user/wallet/score-balance')">
<text class="asset-value font-OPPOSANS">{{ userInfo.score || '0' }}</text>
<text class="asset-label">积分</text>
</view>
</view>
<!-- 分销商 / 区域代理:汇付分账收益面板 -->
<view class="split-income-card brand-card" v-if="showIncomePanel">
<view class="split-income-card__head u-flex u-row-between u-col-center">
<view>
<text class="split-income-card__title">分账收益</text>
<text class="split-income-card__sub">平台钱包可提现 · 汇付已进件走子户</text>
</view>
<view class="asset-divider"></view>
<view class="asset-item u-flex-1 u-flex-col u-col-center" @tap="jump('/pages/app/coupon/list')">
<text class="asset-value font-OPPOSANS">{{ userOtherData.coupons_num || '0' }}</text>
<text class="asset-label">优惠券</text>
<text class="split-income-card__role">{{ incomeRoleText }}</text>
</view>
<!-- 平台钱包余额(兜底入账部分) -->
<view class="split-wallet" @tap="onAssetTap(balanceItem)">
<view class="split-wallet__top u-flex u-row-between u-col-center">
<text class="split-wallet__label">平台钱包 · 可提现(元)</text>
<text class="split-wallet__state">余额</text>
</view>
<text class="split-wallet__amount font-OPPOSANS">¥{{ balanceItem.displayValue }}</text>
<view class="split-wallet__foot u-flex u-row-between u-col-center">
<text class="split-wallet__tip">含未进件/分账失败的兜底入账;已进件部分直达汇付子户</text>
<text class="u-iconfont uicon-arrow-right split-wallet__arrow"></text>
</view>
</view>
<!-- 已结算:累计收益(非钱包余额) -->
<view class="split-settled u-flex" v-if="showCommissionMetric || showRegionalMetric">
<view
class="split-settled__item u-flex-1"
v-if="showCommissionMetric"
@tap="onAssetTap(commissionItem)"
>
<text class="split-settled__label">分销收益</text>
<text class="split-settled__value font-OPPOSANS">¥{{ commissionItem.displayValue }}</text>
<text class="split-settled__hint">累计已结算(含汇付子户,非可提现余额)</text>
</view>
<view
class="split-settled__item u-flex-1"
v-if="showRegionalMetric"
:class="{ 'split-settled__item--solo': !showCommissionMetric }"
@tap="onAssetTap(regionalItem)"
>
<text class="split-settled__label">区县收益</text>
<text class="split-settled__value font-OPPOSANS">¥{{ regionalItem.displayValue }}</text>
<text class="split-settled__hint">累计已结算(含汇付子户)</text>
</view>
</view>
<!-- 非终态:分账待到账 -->
<view class="split-pending u-flex u-row-between u-col-center" @tap="onAssetTap(pendingItem)">
<view class="split-pending__main">
<view class="split-pending__title-row u-flex u-col-center">
<text class="split-pending__dot"></text>
<text class="split-pending__title">待入账收益</text>
</view>
<text class="split-pending__desc">订单已产生,等待结算或汇付分账确认</text>
</view>
<view class="split-pending__right u-flex u-col-center">
<text class="split-pending__amount font-OPPOSANS">¥{{ pendingItem.displayValue }}</text>
<text class="u-iconfont uicon-arrow-right split-pending__arrow"></text>
</view>
</view>
<view
class="split-onboard-nudge u-flex u-row-between u-col-center"
v-if="showOnboardNudge"
@tap="jump('/pages/user/wallet/onboard-bind')"
>
<view class="split-onboard-nudge__text">
<text class="split-onboard-nudge__title">有待入账收益,建议完成汇付进件</text>
<text class="split-onboard-nudge__sub">进件通过后新单收益直达汇付子户;未完成时走平台钱包兜底</text>
</view>
<text class="split-onboard-nudge__link">去进件 ›</text>
</view>
</view>
</view>
@@ -125,15 +195,28 @@
isFixed: false,
navBackground: {
background: 'none'
}
},
regionalIncome: '0.00',
regionalDelayMoney: '0.00',
hasRegionalAgent: false,
huifuOnboard: null
};
},
mounted() {},
mounted() {
if (this.isLogin) {
this.loadRegionalIncome();
this.loadHuifuOnboardHint();
}
},
props: {
detail: {},
scrollTop: {
type: Number,
default: 0
},
refreshKey: {
type: Number,
default: 0
}
},
watch: {
@@ -142,6 +225,23 @@
this.navBackground.background = val > 50
? `linear-gradient(180deg, ${theme.navy} 0%, ${theme.navyLight} 100%)`
: 'none';
},
isLogin(val) {
if (val) {
this.loadRegionalIncome();
this.loadHuifuOnboardHint();
} else {
this.regionalIncome = '0.00';
this.regionalDelayMoney = '0.00';
this.hasRegionalAgent = false;
this.huifuOnboard = null;
}
},
refreshKey() {
if (this.isLogin) {
this.loadRegionalIncome();
this.loadHuifuOnboardHint();
}
}
},
computed: {
@@ -202,10 +302,168 @@
tags.push(this.agentInfo.agent_level.name);
}
return tags;
},
isCommissionAgent() {
return !!(this.agentInfo && this.agentInfo.agent_level);
},
showIncomePanel() {
return this.isLogin && (this.isCommissionAgent || this.hasRegionalAgent);
},
incomeRoleText() {
if (this.isCommissionAgent && this.hasRegionalAgent) {
return '分销商 · 区域代理';
}
if (this.isCommissionAgent) {
return '分销商';
}
if (this.hasRegionalAgent) {
return '区域代理';
}
return '';
},
walletItems() {
return [{
key: 'money',
label: '余额(元)',
displayValue: this.formatMoney(this.userInfo.money),
path: '/pages/user/wallet/index'
}, {
key: 'score',
label: '积分',
displayValue: String(this.userInfo.score || '0'),
path: '/pages/user/wallet/score-balance'
}, {
key: 'coupon',
label: '优惠券',
displayValue: String(this.userOtherData.coupons_num || '0'),
path: '/pages/app/coupon/list'
}];
},
pendingIncome() {
const commissionPending = parseFloat(this.agentInfo?.delay_money || 0) || 0;
const regionalPending = parseFloat(this.regionalDelayMoney || 0) || 0;
return this.formatMoney(commissionPending + regionalPending);
},
showCommissionMetric() {
return this.isCommissionAgent;
},
showRegionalMetric() {
return this.hasRegionalAgent;
},
balanceItem() {
return {
key: 'balance',
displayValue: this.formatMoney(this.userInfo.money),
path: '/pages/user/wallet/index'
};
},
commissionItem() {
return {
key: 'commission',
displayValue: this.formatMoney(this.agentInfo?.total_income),
path: '/pages/app/commission/index'
};
},
regionalItem() {
return {
key: 'regional',
displayValue: this.formatMoney(this.regionalIncome),
path: '/pages/app/regional-agent/index'
};
},
pendingItem() {
return {
key: 'pending',
displayValue: this.pendingIncome,
path: this.pendingIncomePath
};
},
pendingIncomePath() {
const commissionPending = parseFloat(this.agentInfo?.delay_money || 0) || 0;
const regionalPending = parseFloat(this.regionalDelayMoney || 0) || 0;
if (regionalPending > 0 && commissionPending <= 0) {
return '/pages/app/regional-agent/rewards';
}
return '/pages/app/commission/commission-log';
},
showOnboardNudge() {
if (!this.showIncomePanel || !this.isCommissionAgent) {
return false;
}
const pending = parseFloat(this.pendingIncome) || 0;
if (pending <= 0) {
return false;
}
const h = this.huifuOnboard;
if (!h || !h.required) {
return false;
}
if (h.status === 'approved') {
return false;
}
return !!h.can_submit || !h.status;
}
},
methods: {
...mapActions(['getUserInfo', 'showAuthModal']),
formatMoney(value) {
const num = parseFloat(value);
if (Number.isNaN(num)) {
return '0.00';
}
return num.toFixed(2);
},
loadHuifuOnboardHint() {
if (!this.isCommissionAgent) {
this.huifuOnboard = null;
return;
}
this.$http('commission.auth').then(res => {
if (res.code === 1 && res.data) {
this.huifuOnboard = res.data.huifu_onboard || null;
}
}).catch(() => {});
},
loadRegionalIncome() {
this.$http('regionalAgent.info').then(res => {
if (res.code !== 1 || !res.data || res.data.status === 'close') {
this.regionalIncome = '0.00';
this.regionalDelayMoney = '0.00';
this.hasRegionalAgent = false;
return;
}
this.regionalDelayMoney = res.data.delay_money || '0.00';
const agents = Array.isArray(res.data.agents) ? res.data.agents : [];
this.hasRegionalAgent = agents.some(item => item.status === 'normal');
const total = agents.reduce((sum, item) => {
return sum + (parseFloat(item.total_income) || 0);
}, 0);
if (total > 0) {
this.regionalIncome = total.toFixed(2);
return;
}
this.loadRegionalSummary();
}).catch(() => {
this.regionalIncome = '0.00';
this.regionalDelayMoney = '0.00';
this.hasRegionalAgent = false;
});
},
loadRegionalSummary() {
this.$http('regionalAgent.stats').then(res => {
if (res.code === 1) {
const summary = (res.data && res.data.summary) || {};
this.regionalIncome = this.formatMoney(summary.total_income);
}
}).catch(() => {});
},
onAssetTap(item) {
if (!this.isLogin) {
this.showAuthModal('accountLogin');
return;
}
this.jump(item.path);
},
onProfileTap() {
if (this.isLogin) {
this.$Router.push('/pages/user/info');
@@ -288,14 +546,276 @@
.sh-userinfo-box {
position: relative;
padding-bottom: 0;
padding-bottom: 8rpx;
.head-wrap {
width: 100%;
padding: 0 $brand-page-gutter 28rpx;
padding: 0 $brand-page-gutter 20rpx;
box-sizing: border-box;
}
.asset-bar {
margin-top: 28rpx;
padding: 8rpx 0 4rpx;
}
.asset-item {
min-width: 0;
& + .asset-item {
border-left: 1rpx solid rgba(255, 255, 255, 0.28);
}
}
.asset-value {
font-size: 36rpx;
font-weight: 600;
color: #fff;
line-height: 1.2;
}
.asset-label {
margin-top: 8rpx;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.88);
}
.split-income-card {
margin: 16rpx $brand-page-gutter 0;
padding: 28rpx 24rpx 24rpx;
background: #ffffff;
box-shadow: 0 12rpx 40rpx rgba(10, 36, 99, 0.12);
}
.split-income-card__head {
margin-bottom: 24rpx;
}
.split-income-card__title {
display: block;
font-size: 32rpx;
font-weight: 600;
color: #1D2129;
line-height: 1.4;
}
.split-income-card__sub {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
color: #86909C;
line-height: 1.4;
}
.split-income-card__role {
flex-shrink: 0;
padding: 6rpx 16rpx;
border-radius: 20rpx;
font-size: 22rpx;
font-weight: 500;
color: #1677FF;
background: #E8F3FF;
}
.split-wallet {
padding: 28rpx;
border-radius: 20rpx;
background: $brand-primary-gradient;
margin-bottom: 20rpx;
&:active {
opacity: 0.92;
}
}
.split-wallet__label {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.88);
}
.split-wallet__state {
padding: 4rpx 14rpx;
border-radius: 16rpx;
font-size: 20rpx;
font-weight: 500;
color: #1677FF;
background: rgba(255, 255, 255, 0.92);
}
.split-wallet__amount {
display: block;
margin-top: 16rpx;
font-size: 56rpx;
font-weight: 700;
color: #ffffff;
line-height: 1.2;
}
.split-wallet__foot {
margin-top: 16rpx;
}
.split-wallet__tip {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.78);
line-height: 1.4;
flex: 1;
min-width: 0;
}
.split-wallet__arrow {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.72);
margin-left: 8rpx;
}
.split-settled {
margin-bottom: 20rpx;
border: 1rpx solid #E5E7EB;
border-radius: 16rpx;
overflow: hidden;
background: #F7F8FA;
}
.split-settled__item {
min-width: 0;
padding: 24rpx 20rpx;
text-align: center;
background: #ffffff;
& + .split-settled__item {
border-left: 1rpx solid #E5E7EB;
}
&--solo {
border-left: none;
}
&:active {
background: #F7F8FA;
}
}
.split-settled__label {
display: block;
font-size: 24rpx;
font-weight: 600;
color: #1D2129;
}
.split-settled__value {
display: block;
margin-top: 12rpx;
font-size: 36rpx;
font-weight: 700;
color: #1677FF;
line-height: 1.2;
}
.split-settled__hint {
display: block;
margin-top: 8rpx;
font-size: 20rpx;
color: #86909C;
}
.split-pending {
padding: 24rpx;
border-radius: 16rpx;
background: linear-gradient(135deg, #FFF7E6 0%, #FFFBF0 100%);
border: 1rpx solid rgba(212, 107, 8, 0.22);
&:active {
opacity: 0.92;
}
}
.split-pending__main {
flex: 1;
min-width: 0;
padding-right: 16rpx;
}
.split-pending__title-row {
margin-bottom: 8rpx;
}
.split-pending__dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background: #D46B08;
margin-right: 10rpx;
flex-shrink: 0;
}
.split-pending__title {
font-size: 28rpx;
font-weight: 600;
color: #1D2129;
}
.split-pending__desc {
display: block;
font-size: 22rpx;
color: #86909C;
line-height: 1.45;
}
.split-pending__right {
flex-shrink: 0;
}
.split-pending__amount {
font-size: 36rpx;
font-weight: 700;
color: #D46B08;
line-height: 1.2;
}
.split-pending__arrow {
font-size: 22rpx;
color: rgba(212, 107, 8, 0.55);
margin-left: 8rpx;
}
.split-onboard-nudge {
margin-top: 20rpx;
padding: 20rpx 24rpx;
border-radius: 12rpx;
background: rgba(116, 56, 213, 0.08);
border: 1rpx solid rgba(116, 56, 213, 0.18);
}
.split-onboard-nudge__text {
flex: 1;
min-width: 0;
padding-right: 16rpx;
}
.split-onboard-nudge__title {
display: block;
font-size: 26rpx;
font-weight: 600;
color: #1D2129;
line-height: 1.4;
}
.split-onboard-nudge__sub {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
color: #86909C;
line-height: 1.45;
}
.split-onboard-nudge__link {
flex-shrink: 0;
font-size: 26rpx;
font-weight: 600;
color: #7438D5;
}
.user-head {
width: 100%;
padding-top: 8rpx;
@@ -440,34 +960,6 @@
}
}
.asset-bar {
margin-top: 28rpx;
padding: 8rpx 0 4rpx;
}
.asset-item {
min-width: 0;
}
.asset-value {
font-size: 36rpx;
font-weight: 600;
color: #fff;
line-height: 1.2;
}
.asset-label {
margin-top: 8rpx;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.72);
}
.asset-divider {
width: 1rpx;
height: 56rpx;
background: rgba(255, 255, 255, 0.22);
align-self: center;
}
}
// 绑定微信公众号
@@ -497,9 +989,6 @@
}
}
</style>
}
</style>
</style>

查看文件

@@ -7,8 +7,9 @@
<!-- 可提现 -->
<view class="wallet-num-box u-flex u-col-center u-row-between">
<view class="">
<view class="num-title">可提现金额(元)</view>
<view class="num-title">平台钱包 · 可提现(元)</view>
<view class="wallet-num">{{ userInfo.money || '0.00' }}</view>
<view class="num-tip">不含已进件推广员走汇付子户到账的部分,子户资金请在汇付侧结算/提现</view>
</view>
<button class="u-reset-button log-btn"
@tap="$Router.push({ path: '/pages/user/wallet/withdraw-log' })">提现记录</button>
@@ -358,7 +359,15 @@
font-size: 26rpx;
font-weight: 500;
color: #ffffff;
margin-bottom: 20rpx;
margin-bottom: 12rpx;
}
.num-tip {
font-size: 22rpx;
line-height: 1.45;
color: rgba(255, 255, 255, 0.82);
margin-bottom: 16rpx;
max-width: 520rpx;
}
.wallet-num {