feat:【MALL 商城】商城分佣提现,初步对接成功微信支付
parent
098057b2de
commit
62d1f4f273
|
@ -114,6 +114,8 @@
|
||||||
|
|
||||||
<!-- 钱包记录 -->
|
<!-- 钱包记录 -->
|
||||||
<view v-if="state.pagination.total > 0">
|
<view v-if="state.pagination.total > 0">
|
||||||
|
<!-- 分佣列表 -->
|
||||||
|
<view v-if="state.currentTab === 0">
|
||||||
<view
|
<view
|
||||||
class="wallet-list ss-flex border-bottom"
|
class="wallet-list ss-flex border-bottom"
|
||||||
v-for="item in state.pagination.list"
|
v-for="item in state.pagination.list"
|
||||||
|
@ -127,12 +129,50 @@
|
||||||
<text v-else class="minus">{{ fen2yuan(item.price) }}</text>
|
<text v-else class="minus">{{ fen2yuan(item.price) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="time">{{
|
<view class="ss-flex ss-row-between ss-col-center">
|
||||||
sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss')
|
<text class="time">
|
||||||
|
{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
|
||||||
|
</text>
|
||||||
|
<view class="ss-flex ss-col-center">
|
||||||
|
<text class="status" :class="'status-' + item.status">{{ item.statusName }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 提现列表 -->
|
||||||
|
<view v-else>
|
||||||
|
<view
|
||||||
|
class="wallet-list ss-flex border-bottom"
|
||||||
|
v-for="item in state.pagination.list"
|
||||||
|
:key="item.id"
|
||||||
|
>
|
||||||
|
<view class="list-content">
|
||||||
|
<view class="title-box ss-flex ss-row-between ss-m-b-20">
|
||||||
|
<text class="title ss-line-1">{{ item.typeName }}</text>
|
||||||
|
<view class="money">
|
||||||
|
<text class="minus">{{ fen2yuan(item.price) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="ss-flex ss-row-between ss-col-center">
|
||||||
|
<text class="time">
|
||||||
|
{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
|
||||||
|
</text>
|
||||||
|
<button
|
||||||
|
v-if="item.status === 10 && item.type === 5 && item.payTransferId > 0"
|
||||||
|
class="ss-reset-button confirm-btn ss-m-l-20"
|
||||||
|
@tap="onRequestMerchantTransfer(item)"
|
||||||
|
>
|
||||||
|
确认收款
|
||||||
|
</button>
|
||||||
|
<text v-else class="status" :class="'status-' + item.status">{{
|
||||||
|
item.statusName
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- <u-gap></u-gap> -->
|
<!-- <u-gap></u-gap> -->
|
||||||
<uni-load-more
|
<uni-load-more
|
||||||
|
@ -179,11 +219,11 @@
|
||||||
const tabMaps = [
|
const tabMaps = [
|
||||||
{
|
{
|
||||||
name: '分佣',
|
name: '分佣',
|
||||||
value: '1', // BrokerageRecordBizTypeEnum.ORDER
|
value: '1',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '提现',
|
name: '提现',
|
||||||
value: '2', // BrokerageRecordBizTypeEnum.WITHDRAW
|
value: '2',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -197,13 +237,19 @@
|
||||||
|
|
||||||
async function getLogList() {
|
async function getLogList() {
|
||||||
state.loadStatus = 'loading';
|
state.loadStatus = 'loading';
|
||||||
let { code, data } = await BrokerageApi.getBrokerageRecordPage({
|
let { code, data } = await (state.currentTab === 0
|
||||||
|
? BrokerageApi.getBrokerageRecordPage({
|
||||||
pageSize: state.pagination.pageSize,
|
pageSize: state.pagination.pageSize,
|
||||||
pageNo: state.pagination.pageNo,
|
pageNo: state.pagination.pageNo,
|
||||||
bizType: tabMaps[state.currentTab].value,
|
|
||||||
'createTime[0]': state.date[0] + ' 00:00:00',
|
'createTime[0]': state.date[0] + ' 00:00:00',
|
||||||
'createTime[1]': state.date[1] + ' 23:59:59',
|
'createTime[1]': state.date[1] + ' 23:59:59',
|
||||||
});
|
})
|
||||||
|
: BrokerageApi.getBrokerageWithdrawPage({
|
||||||
|
pageSize: state.pagination.pageSize,
|
||||||
|
pageNo: state.pagination.pageNo,
|
||||||
|
'createTime[0]': state.date[0] + ' 00:00:00',
|
||||||
|
'createTime[1]': state.date[1] + ' 23:59:59',
|
||||||
|
}));
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -261,11 +307,36 @@
|
||||||
state.summary = data;
|
state.summary = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 微信场景下:用户确认收款
|
||||||
|
// 可见 https://pay.weixin.qq.com/doc/v3/merchant/4012716430 文档
|
||||||
|
async function onRequestMerchantTransfer(item) {
|
||||||
|
const requestMerchantTransfer = sheep.$platform.useProvider()
|
||||||
|
? sheep.$platform.useProvider().requestMerchantTransfer
|
||||||
|
: undefined;
|
||||||
|
if (!requestMerchantTransfer) {
|
||||||
|
sheep.$helper.toast('仅微信平台支持该功能');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取提现详情
|
||||||
|
const { code, data } = await BrokerageApi.getBrokerageWithdraw(item.id);
|
||||||
|
if (code !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 调用微信确认收款
|
||||||
|
await requestMerchantTransfer(
|
||||||
|
data.transferChannelMchId,
|
||||||
|
data.transferChannelPackageInfo,
|
||||||
|
(res) => {
|
||||||
|
debugger;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
state.today = dayjs().format('YYYY-MM-DD');
|
state.today = dayjs().format('YYYY-MM-DD');
|
||||||
state.date = [state.today, state.today];
|
state.date = [state.today, state.today];
|
||||||
if (options.type === 2) {
|
if (options.type === '2') {
|
||||||
// 切换到“提现” tab 下
|
// 切换到"提现" tab 下
|
||||||
state.currentTab = 1;
|
state.currentTab = 1;
|
||||||
}
|
}
|
||||||
getLogList();
|
getLogList();
|
||||||
|
@ -476,6 +547,17 @@
|
||||||
color: $dark-3;
|
color: $dark-3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.confirm-btn {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: var(--ui-BG-Main);
|
||||||
|
background: rgba(var(--ui-BG-Main-rgb), 0.1);
|
||||||
|
padding: 4rpx 16rpx;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.4;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
border: 1px solid var(--ui-BG-Main);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.model-title {
|
.model-title {
|
||||||
|
@ -515,4 +597,17 @@
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
font-size: 22rpx;
|
||||||
|
&.status-0 {
|
||||||
|
color: #ff9900;
|
||||||
|
}
|
||||||
|
&.status-1 {
|
||||||
|
color: #19be6b;
|
||||||
|
}
|
||||||
|
&.status-2 {
|
||||||
|
color: #fa3534;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
</view>
|
</view>
|
||||||
<!-- 持卡人姓名 -->
|
<!-- 持卡人姓名 -->
|
||||||
<view class="card-title" v-show="['2', '5', '6'].includes(state.accountInfo.type)">
|
<view class="card-title" v-show="['2', '5', '6'].includes(state.accountInfo.type)">
|
||||||
收款款真名
|
收款真名
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="input-box ss-flex ss-col-center border-bottom"
|
class="input-box ss-flex ss-col-center border-bottom"
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
:inputBorder="false"
|
:inputBorder="false"
|
||||||
class="ss-flex-1 ss-p-l-10"
|
class="ss-flex-1 ss-p-l-10"
|
||||||
v-model="state.accountInfo.userName"
|
v-model="state.accountInfo.userName"
|
||||||
placeholder="请输入收款款真名"
|
placeholder="请输入收款真名"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<!-- 提现银行 -->
|
<!-- 提现银行 -->
|
||||||
|
|
|
@ -2,18 +2,18 @@ import request from '@/sheep/request';
|
||||||
|
|
||||||
const BrokerageApi = {
|
const BrokerageApi = {
|
||||||
// 绑定分销用户
|
// 绑定分销用户
|
||||||
bindBrokerageUser: (data)=>{
|
bindBrokerageUser: (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/brokerage-user/bind',
|
url: '/trade/brokerage-user/bind',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
data
|
data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得个人分销信息
|
// 获得个人分销信息
|
||||||
getBrokerageUser: () => {
|
getBrokerageUser: () => {
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/brokerage-user/get',
|
url: '/trade/brokerage-user/get',
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得个人分销统计
|
// 获得个人分销统计
|
||||||
|
@ -24,12 +24,12 @@ const BrokerageApi = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得分销记录分页
|
// 获得分销记录分页
|
||||||
getBrokerageRecordPage: params => {
|
getBrokerageRecordPage: (params) => {
|
||||||
if (params.status === undefined) {
|
if (params.status === undefined) {
|
||||||
delete params.status
|
delete params.status;
|
||||||
}
|
}
|
||||||
const queryString = Object.keys(params)
|
const queryString = Object.keys(params)
|
||||||
.map(key => encodeURIComponent(key) + '=' + params[key])
|
.map((key) => encodeURIComponent(key) + '=' + params[key])
|
||||||
.join('&');
|
.join('&');
|
||||||
return request({
|
return request({
|
||||||
url: `/trade/brokerage-record/page?${queryString}`,
|
url: `/trade/brokerage-record/page?${queryString}`,
|
||||||
|
@ -37,23 +37,41 @@ const BrokerageApi = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 创建分销提现
|
// 创建分销提现
|
||||||
createBrokerageWithdraw: data => {
|
createBrokerageWithdraw: (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/brokerage-withdraw/create',
|
url: '/trade/brokerage-withdraw/create',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 获得分销提现分页
|
||||||
|
getBrokerageWithdrawPage: (params) => {
|
||||||
|
const queryString = Object.keys(params)
|
||||||
|
.map((key) => encodeURIComponent(key) + '=' + params[key])
|
||||||
|
.join('&');
|
||||||
|
return request({
|
||||||
|
url: `/trade/brokerage-withdraw/page?${queryString}`,
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 获得分销提现详情
|
||||||
|
getBrokerageWithdraw: (id) => {
|
||||||
|
return request({
|
||||||
|
url: `/trade/brokerage-withdraw/get`,
|
||||||
|
method: 'GET',
|
||||||
|
params: { id },
|
||||||
|
});
|
||||||
|
},
|
||||||
// 获得商品的分销金额
|
// 获得商品的分销金额
|
||||||
getProductBrokeragePrice: spuId => {
|
getProductBrokeragePrice: (spuId) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/brokerage-record/get-product-brokerage-price',
|
url: '/trade/brokerage-record/get-product-brokerage-price',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: { spuId }
|
params: { spuId },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得分销用户排行(基于佣金)
|
// 获得分销用户排行(基于佣金)
|
||||||
getRankByPrice: params => {
|
getRankByPrice: (params) => {
|
||||||
const queryString = `times=${params.times[0]}×=${params.times[1]}`;
|
const queryString = `times=${params.times[0]}×=${params.times[1]}`;
|
||||||
return request({
|
return request({
|
||||||
url: `/trade/brokerage-user/get-rank-by-price?${queryString}`,
|
url: `/trade/brokerage-user/get-rank-by-price?${queryString}`,
|
||||||
|
@ -61,9 +79,9 @@ const BrokerageApi = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得分销用户排行分页(基于佣金)
|
// 获得分销用户排行分页(基于佣金)
|
||||||
getBrokerageUserChildSummaryPageByPrice: params => {
|
getBrokerageUserChildSummaryPageByPrice: (params) => {
|
||||||
const queryString = Object.keys(params)
|
const queryString = Object.keys(params)
|
||||||
.map(key => encodeURIComponent(key) + '=' + params[key])
|
.map((key) => encodeURIComponent(key) + '=' + params[key])
|
||||||
.join('&');
|
.join('&');
|
||||||
return request({
|
return request({
|
||||||
url: `/trade/brokerage-user/rank-page-by-price?${queryString}`,
|
url: `/trade/brokerage-user/rank-page-by-price?${queryString}`,
|
||||||
|
@ -71,9 +89,9 @@ const BrokerageApi = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得分销用户排行分页(基于用户量)
|
// 获得分销用户排行分页(基于用户量)
|
||||||
getBrokerageUserRankPageByUserCount: params => {
|
getBrokerageUserRankPageByUserCount: (params) => {
|
||||||
const queryString = Object.keys(params)
|
const queryString = Object.keys(params)
|
||||||
.map(key => encodeURIComponent(key) + '=' + params[key])
|
.map((key) => encodeURIComponent(key) + '=' + params[key])
|
||||||
.join('&');
|
.join('&');
|
||||||
return request({
|
return request({
|
||||||
url: `/trade/brokerage-user/rank-page-by-user-count?${queryString}`,
|
url: `/trade/brokerage-user/rank-page-by-user-count?${queryString}`,
|
||||||
|
@ -81,13 +99,13 @@ const BrokerageApi = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获得下级分销统计分页
|
// 获得下级分销统计分页
|
||||||
getBrokerageUserChildSummaryPage: params => {
|
getBrokerageUserChildSummaryPage: (params) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/brokerage-user/child-summary-page',
|
url: '/trade/brokerage-user/child-summary-page',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params,
|
params,
|
||||||
})
|
});
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export default BrokerageApi
|
export default BrokerageApi;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import AuthUtil from '@/sheep/api/member/auth';
|
import AuthUtil from '@/sheep/api/member/auth';
|
||||||
import SocialApi from '@/sheep/api/member/social';
|
import SocialApi from '@/sheep/api/member/social';
|
||||||
import UserApi from '@/sheep/api/member/user';
|
import UserApi from '@/sheep/api/member/user';
|
||||||
|
import sheep from '@/sheep';
|
||||||
|
|
||||||
const socialType = 34; // 社交类型 - 微信小程序
|
const socialType = 34; // 社交类型 - 微信小程序
|
||||||
|
|
||||||
|
@ -126,14 +127,14 @@ async function getInfo() {
|
||||||
const checkUpdate = async (silence = true) => {
|
const checkUpdate = async (silence = true) => {
|
||||||
if (uni.canIUse('getUpdateManager')) {
|
if (uni.canIUse('getUpdateManager')) {
|
||||||
const updateManager = uni.getUpdateManager();
|
const updateManager = uni.getUpdateManager();
|
||||||
updateManager.onCheckForUpdate(function(res) {
|
updateManager.onCheckForUpdate(function (res) {
|
||||||
// 请求完新版本信息的回调
|
// 请求完新版本信息的回调
|
||||||
if (res.hasUpdate) {
|
if (res.hasUpdate) {
|
||||||
updateManager.onUpdateReady(function() {
|
updateManager.onUpdateReady(function () {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '更新提示',
|
title: '更新提示',
|
||||||
content: '新版本已经准备好,是否重启应用?',
|
content: '新版本已经准备好,是否重启应用?',
|
||||||
success: function(res) {
|
success: function (res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||||
updateManager.applyUpdate();
|
updateManager.applyUpdate();
|
||||||
|
@ -141,7 +142,7 @@ const checkUpdate = async (silence = true) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
updateManager.onUpdateFailed(function() {
|
updateManager.onUpdateFailed(function () {
|
||||||
// 新的版本下载失败
|
// 新的版本下载失败
|
||||||
// uni.showModal({
|
// uni.showModal({
|
||||||
// title: '已经有新版本了哟~',
|
// title: '已经有新版本了哟~',
|
||||||
|
@ -169,17 +170,17 @@ async function getSubscribeTemplate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订阅消息
|
// 订阅消息
|
||||||
function subscribeMessage(event, callback= undefined) {
|
function subscribeMessage(event, callback = undefined) {
|
||||||
let tmplIds = [];
|
let tmplIds = [];
|
||||||
if (typeof event === 'string') {
|
if (typeof event === 'string') {
|
||||||
const temp = subscribeEventList.find(item => item.title.includes(event));
|
const temp = subscribeEventList.find((item) => item.title.includes(event));
|
||||||
if (temp) {
|
if (temp) {
|
||||||
tmplIds.push(temp.id);
|
tmplIds.push(temp.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof event === 'object') {
|
if (typeof event === 'object') {
|
||||||
event.forEach((e) => {
|
event.forEach((e) => {
|
||||||
const temp = subscribeEventList.find(item => item.title.includes(e));
|
const temp = subscribeEventList.find((item) => item.title.includes(e));
|
||||||
if (temp) {
|
if (temp) {
|
||||||
tmplIds.push(temp.id);
|
tmplIds.push(temp.id);
|
||||||
}
|
}
|
||||||
|
@ -189,9 +190,9 @@ function subscribeMessage(event, callback= undefined) {
|
||||||
|
|
||||||
uni.requestSubscribeMessage({
|
uni.requestSubscribeMessage({
|
||||||
tmplIds,
|
tmplIds,
|
||||||
success: ()=>{
|
success: () => {
|
||||||
// 不管是拒绝还是同意都触发
|
// 不管是拒绝还是同意都触发
|
||||||
callback && callback()
|
callback && callback();
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -199,6 +200,32 @@ function subscribeMessage(event, callback= undefined) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 商家转账用户确认模式下,拉起页面请求用户确认收款 Transfer
|
||||||
|
function requestMerchantTransfer(mchId, packageInfo, successCallback, failCallback) {
|
||||||
|
if (!wx.canIUse('requestMerchantTransfer')) {
|
||||||
|
wx.showModal({
|
||||||
|
content: '你的微信版本过低,请更新至最新版本。',
|
||||||
|
showCancel: false,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wx.requestMerchantTransfer({
|
||||||
|
mchId: mchId,
|
||||||
|
appId: wx.getAccountInfoSync().miniProgram.appId,
|
||||||
|
package: packageInfo,
|
||||||
|
success: (res) => {
|
||||||
|
// res.err_msg 将在页面展示成功后返回应用时返回 ok,并不代表付款成功
|
||||||
|
console.log('success:', res);
|
||||||
|
successCallback && successCallback(res);
|
||||||
|
},
|
||||||
|
fail: (res) => {
|
||||||
|
console.log('fail:', res);
|
||||||
|
sheep.$helper.toast(res.errMsg);
|
||||||
|
failCallback && failCallback(res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
load,
|
load,
|
||||||
login,
|
login,
|
||||||
|
@ -210,4 +237,5 @@ export default {
|
||||||
getOpenid,
|
getOpenid,
|
||||||
subscribeMessage,
|
subscribeMessage,
|
||||||
checkUpdate,
|
checkUpdate,
|
||||||
|
requestMerchantTransfer,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue