feat: 增加现金支付

This commit is contained in:
HongRun Liu
2026-08-05 10:51:29 +08:00
parent 1daec0121b
commit 25da673443
16 changed files with 1535 additions and 1230 deletions
+28 -3
View File
@@ -60,6 +60,9 @@
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button v-else-if="state.payStatus === 3" class="ai-button2" @tap="onPay">
切换支付方式
</button>
<button
v-else
class="ai-button2"
@@ -89,6 +92,7 @@
import * as api from '@/sheep/api/ai/index';
import sheep from '@/sheep';
import PayChannelApi from '@/sheep/api/pay/channel';
import PayOrderApi from '@/sheep/api/pay/order';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
import { SYSCONST } from '@/sheep/helper/const';
@@ -104,7 +108,7 @@
const state = reactive({
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
@@ -123,11 +127,25 @@
// 获得支付方式
async function setPayMethods() {
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
// 业务订单详情不含支付应用编号,拆分后需从支付单获取真实 appId,避免误用商城应用渠道
let appId = Number(state.orderInfo.appId);
if (!appId && payOrderId.value) {
const payOrderRes = await PayOrderApi.getOrder(payOrderId.value, false);
appId = Number(payOrderRes?.data?.appId);
}
if (!appId) {
sheep.$helper.toast('支付应用信息异常');
state.payMethods = [];
return;
}
const { data, code } = await PayChannelApi.getEnableChannelCodeList(appId);
if (code !== 0) {
return;
}
state.payMethods = getPayMethods(data);
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
state.payMethods = getPayMethods(data).filter(
(item) => item.value !== 'cash' || state.payStatus !== 3,
);
// 金额超出阈值,仅允许余额支付
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
state.payMethods = state.payMethods.map((item) => ({
@@ -148,6 +166,9 @@
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 3) {
return '现金待确认';
}
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
const time = useDurationTime(state.orderInfo.payExpireTime);
if (time?.ms <= 0) {
@@ -184,6 +205,10 @@
state.payStatus = -1;
return;
}
if (Number(state.orderInfo.status) === 70) {
state.payStatus = 3;
return;
}
state.payStatus = 1; // 待支付
}