feat(withdraw): 落地方案B一体化商城余额提现与手续费内扣模式,完善多端打款退款与对账闭环
这个提交包含在:
@@ -95,8 +95,9 @@ export default class SheepPay {
|
||||
if (this.options && Number(this.options.money) > 0) {
|
||||
data.money = Number(this.options.money);
|
||||
}
|
||||
if (uni.getStorageSync('openid')) {
|
||||
data.openid = uni.getStorageSync('openid');
|
||||
const localOpenid = uni.getStorageSync('openid');
|
||||
if (localOpenid) {
|
||||
data.openid = localOpenid;
|
||||
}
|
||||
sheep.$api.pay.prepay(data).then((res) => {
|
||||
if (res && res.code === 1) {
|
||||
@@ -105,10 +106,18 @@ export default class SheepPay {
|
||||
if (res && res.data === -1 && res.msg === 'miss_openid') {
|
||||
uni.showModal({
|
||||
title: '微信支付',
|
||||
content: '请先绑定微信再使用微信支付',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
sheep.$platform.useProvider('wechat').bind();
|
||||
content: '未检测到微信授权绑定,请先绑定微信后再进行支付',
|
||||
confirmText: '前往绑定',
|
||||
success: async (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
try {
|
||||
const bindResult = await sheep.$platform.useProvider('wechat').bind();
|
||||
if (bindResult) {
|
||||
sheep.$helper.toast('微信绑定成功');
|
||||
}
|
||||
} catch (bindErr) {
|
||||
console.log('绑定微信取消或失败', bindErr);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -203,27 +212,57 @@ export default class SheepPay {
|
||||
let that = this;
|
||||
try {
|
||||
let result = await this.prepay();
|
||||
if (result.code !== 1) return;
|
||||
if (result.code !== 1) {
|
||||
const errMsg = result?.msg || '预支付发起失败,请重试';
|
||||
sheep.$helper.toast(errMsg);
|
||||
return;
|
||||
}
|
||||
if (!result.data?.pay_data) {
|
||||
that.payResult('success');
|
||||
return;
|
||||
}
|
||||
uni.requestPayment({
|
||||
const payData = result.data.pay_data;
|
||||
// 严格按微信小程序原生参数规范整理,确保 timeStamp 为 string,过滤多余字段
|
||||
const paymentParams = {
|
||||
provider: 'wxpay',
|
||||
...result.data.pay_data,
|
||||
timeStamp: String(payData.timeStamp || ''),
|
||||
nonceStr: String(payData.nonceStr || ''),
|
||||
package: String(payData.package || ''),
|
||||
signType: payData.signType || 'RSA',
|
||||
paySign: String(payData.paySign || ''),
|
||||
success: (res) => {
|
||||
that.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('微信支付调用失败:', err);
|
||||
if (err.errMsg === 'requestPayment:fail cancel') {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
} else {
|
||||
that.payResult('fail');
|
||||
// 提示具体错误原因,方便用户与管理员定位
|
||||
const errHint = err.errMsg ? err.errMsg.replace('requestPayment:fail', '').trim() : '';
|
||||
if (errHint) {
|
||||
uni.showModal({
|
||||
title: '支付拉取失败',
|
||||
content: '微信支付未成功调起:' + errHint,
|
||||
showCancel: false,
|
||||
confirmText: '我知道了',
|
||||
success: () => {
|
||||
that.payResult('fail');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.payResult('fail');
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
uni.requestPayment(paymentParams);
|
||||
} catch (e) {
|
||||
console.log('预支付未完成:', e);
|
||||
if (e?.msg !== 'miss_openid') {
|
||||
console.error('预支付未完成异常:', e);
|
||||
const hint = e?.msg || (typeof e === 'string' ? e : '支付请求失败,请稍后重试');
|
||||
sheep.$helper.toast(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ function load() {
|
||||
// 微信小程序静默授权登陆
|
||||
const login = async () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const { code } = await third.wechat.login(
|
||||
const res = await third.wechat.login(
|
||||
{
|
||||
platform: 'miniProgram',
|
||||
|
||||
@@ -36,11 +36,14 @@ const login = async () => {
|
||||
},
|
||||
);
|
||||
|
||||
if (code > 0) {
|
||||
resolve(code);
|
||||
if (res?.code > 0) {
|
||||
if (res.data?.openid) {
|
||||
uni.setStorageSync('openid', res.data.openid);
|
||||
}
|
||||
resolve(res.code);
|
||||
}
|
||||
|
||||
if (code === -1) {
|
||||
if (res?.code === -1) {
|
||||
getSessionId(false);
|
||||
}
|
||||
resolve(false);
|
||||
@@ -80,6 +83,9 @@ const mobileLogin = async (e) => {
|
||||
);
|
||||
|
||||
if (res?.code === 1) {
|
||||
if (res.data?.openid) {
|
||||
uni.setStorageSync('openid', res.data.openid);
|
||||
}
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
@@ -104,6 +110,9 @@ const mobileLogin = async (e) => {
|
||||
},
|
||||
);
|
||||
if (retryRes?.code === 1) {
|
||||
if (retryRes.data?.openid) {
|
||||
uni.setStorageSync('openid', retryRes.data.openid);
|
||||
}
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
@@ -195,6 +204,9 @@ const getSessionId = async (auto_login = null) => {
|
||||
});
|
||||
if (code === 1) {
|
||||
uni.setStorageSync('sessionId', data.session_id);
|
||||
if (data.openid) {
|
||||
uni.setStorageSync('openid', data.openid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
在新工单中引用
屏蔽一个用户