添加支付费率扣除
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// pages/demand/detail.js
|
||||
import { fetchDemandDetail, joinDemandBidding, demandOperate } from '../../../services/demand/fetchDemand';
|
||||
import { fetchPlatformCommissionRatio, calcActualAccount } from '../../../services/home/home';
|
||||
import { fetchIncomeRates, calcActualAccount, toPercent } from '../../../services/home/home';
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -11,9 +11,14 @@ Page({
|
||||
quotedPrice: '',
|
||||
needDays: '',
|
||||
remark: '',
|
||||
actualAccount: 0,
|
||||
androidAccount: 0,
|
||||
iosAccount: 0,
|
||||
commissionRatio: 0.1, // 平台服务费比例,来自 common/getMiniConfig
|
||||
commissionPercent: 10, // 平台服务费百分比,用于提示文案
|
||||
commissionPercent: 10,
|
||||
androidPayFeeRate: 0.01,
|
||||
iosPayFeeRate: 0.12,
|
||||
androidFeePercent: 1,
|
||||
iosFeePercent: 12,
|
||||
activeValues: [0, 1, 2, 3, 4],
|
||||
demandInfo: null,
|
||||
freshPage: false, // 返回本页时是否需要重新拉取详情(签约/发货/支付后置为 true)
|
||||
@@ -36,7 +41,7 @@ Page({
|
||||
const demandInfo = res.data;
|
||||
this.setData({
|
||||
demandInfo,
|
||||
actualAccount: calcActualAccount(this.getQuoteAmount(demandInfo), this.data.commissionRatio)
|
||||
...this.incomePreview(this.getQuoteAmount(demandInfo))
|
||||
}, () => resolve()); // setData 回调:页面已重新渲染
|
||||
},
|
||||
() => {
|
||||
@@ -50,13 +55,27 @@ Page({
|
||||
getQuoteAmount(demandInfo) {
|
||||
return demandInfo?.myBidding?.quoted_price || demandInfo?.demand_contracts?.total_amount || this.data.quotedPrice || 0;
|
||||
},
|
||||
// 拉取平台服务费比例,并按新比例重算预计到手金额
|
||||
// 按当前报价计算安卓、iOS 两种预计到手
|
||||
incomePreview(amount, rates) {
|
||||
const commissionRatio = rates ? rates.commissionRatio : this.data.commissionRatio;
|
||||
const androidPayFeeRate = rates ? rates.androidPayFeeRate : this.data.androidPayFeeRate;
|
||||
const iosPayFeeRate = rates ? rates.iosPayFeeRate : this.data.iosPayFeeRate;
|
||||
return {
|
||||
androidAccount: calcActualAccount(amount, commissionRatio, androidPayFeeRate),
|
||||
iosAccount: calcActualAccount(amount, commissionRatio, iosPayFeeRate),
|
||||
};
|
||||
},
|
||||
// 拉取平台服务费和支付费率,并重算预计到手金额
|
||||
async loadCommissionRatio() {
|
||||
const ratio = await fetchPlatformCommissionRatio();
|
||||
const rates = await fetchIncomeRates();
|
||||
this.setData({
|
||||
commissionRatio: ratio,
|
||||
commissionPercent: Math.round(ratio * 10000) / 100,
|
||||
actualAccount: calcActualAccount(this.getQuoteAmount(this.data.demandInfo), ratio)
|
||||
commissionRatio: rates.commissionRatio,
|
||||
commissionPercent: toPercent(rates.commissionRatio),
|
||||
androidPayFeeRate: rates.androidPayFeeRate,
|
||||
iosPayFeeRate: rates.iosPayFeeRate,
|
||||
androidFeePercent: toPercent(rates.androidPayFeeRate),
|
||||
iosFeePercent: toPercent(rates.iosPayFeeRate),
|
||||
...this.incomePreview(this.getQuoteAmount(this.data.demandInfo), rates),
|
||||
});
|
||||
},
|
||||
// 取文件扩展名对应的 openDocument 类型(默认 pdf)
|
||||
@@ -194,7 +213,7 @@ Page({
|
||||
const field = e.currentTarget.dataset.field;
|
||||
const value = e.detail.value;
|
||||
if (field == 'quotedPrice') {
|
||||
this.setData({ actualAccount: calcActualAccount(value, this.data.commissionRatio) });
|
||||
this.setData(this.incomePreview(value));
|
||||
}
|
||||
this.setData({
|
||||
[`${field}`]: value
|
||||
|
||||
Reference in New Issue
Block a user