feat:【MALL 商城】商城分佣提现,完成对微信转账(小程序)的对接
parent
62d1f4f273
commit
5071816ea0
|
@ -194,6 +194,7 @@
|
|||
import BrokerageApi from '@/sheep/api/trade/brokerage';
|
||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||
import { resetPagination } from '@/sheep/helper/utils';
|
||||
import PayTransferApi from '@/sheep/api/pay/transfer';
|
||||
|
||||
const headerBg = sheep.$url.css('/static/img/shop/user/wallet_card_bg.png');
|
||||
|
||||
|
@ -322,12 +323,41 @@
|
|||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
if (data.status === 11) {
|
||||
sheep.$helper.toast('该提现单已确认收款');
|
||||
item.status = 11;
|
||||
return;
|
||||
}
|
||||
if (!data.transferChannelMchId || !data.transferChannelPackageInfo) {
|
||||
sheep.$helper.toast('提现信息异常,请稍后再试');
|
||||
return;
|
||||
}
|
||||
// 调用微信确认收款
|
||||
const payTransferId = data.payTransferId;
|
||||
await requestMerchantTransfer(
|
||||
data.transferChannelMchId,
|
||||
data.transferChannelPackageInfo,
|
||||
(res) => {
|
||||
debugger;
|
||||
async (res) => {
|
||||
if (res.result !== 'success') {
|
||||
sheep.$helper.toast(res.errMsg);
|
||||
return;
|
||||
}
|
||||
// 同步转账单状态
|
||||
try {
|
||||
const syncTransferResult = await PayTransferApi.syncTransfer(payTransferId);
|
||||
console.log('syncTransferResult 结果', syncTransferResult);
|
||||
} catch (e) {
|
||||
console.error('syncTransferResult 异常', e);
|
||||
}
|
||||
// 查询提现单最新状态
|
||||
const { data } = await BrokerageApi.getBrokerageWithdraw(item.id);
|
||||
if (data && data.status !== 11) {
|
||||
sheep.$helper.toast('确认收款成功,但数据存在延迟,请以实际【微信支付】到账为准');
|
||||
return;
|
||||
}
|
||||
sheep.$helper.toast('确认收款成功');
|
||||
// 更新到列表中
|
||||
item.status = 11;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
import BrokerageApi from '@/sheep/api/trade/brokerage';
|
||||
import DictApi from '@/sheep/api/system/dict';
|
||||
import SLayout from '@/sheep/components/s-layout/s-layout.vue';
|
||||
import { goBindWeixin } from '@/sheep/platform/pay';
|
||||
import { getWeixinPayChannelCode, goBindWeixin } from '@/sheep/platform/pay';
|
||||
|
||||
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
|
||||
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
||||
|
@ -236,6 +236,10 @@
|
|||
};
|
||||
if (state.accountInfo.type === '5') {
|
||||
data.userAccount = openid;
|
||||
data.transferChannelCode = getWeixinPayChannelCode();
|
||||
} else {
|
||||
delete data.userAccount;
|
||||
delete data.transferChannelCode;
|
||||
}
|
||||
let { code } = await BrokerageApi.createBrokerageWithdraw(data);
|
||||
if (code !== 0) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import request from '@/sheep/request';
|
||||
|
||||
const PayTransferApi = {
|
||||
// 同步转账单
|
||||
syncTransfer: (id) => {
|
||||
return request({
|
||||
url: '/pay/transfer/sync',
|
||||
method: 'GET',
|
||||
params: { id },
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default PayTransferApi;
|
|
@ -387,3 +387,20 @@ export function goBindWeixin() {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 获取微信支付渠道码
|
||||
export function getWeixinPayChannelCode() {
|
||||
const platform = sheep.$platform.name;
|
||||
switch (platform) {
|
||||
case 'WechatOfficialAccount':
|
||||
return 'wx_pub';
|
||||
case 'WechatMiniProgram':
|
||||
return 'wx_lite';
|
||||
case 'App':
|
||||
return 'wx_app';
|
||||
case 'H5':
|
||||
return 'wx_wap';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue