添加支付费率扣除

This commit is contained in:
Dev
2026-10-27 18:10:51 +08:00
parent 20f9113d94
commit f53c142a56
14 changed files with 225 additions and 41 deletions
+29 -10
View File
@@ -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
@@ -44,7 +44,7 @@
</t-collapse-panel>
<t-collapse-panel header="{{opType=='quote' ? '我的报价' : '开发人员报价'}}" value="{{3}}" expandIcon>
<view>
<t-input style="--td-input-border-color: rgb(238, 116, 2);" placeholder="填写报价金额" suffix="元" align="right" type="number" value="{{opType=='quote' ? demandInfo.myBidding.quoted_price || demandInfo.demand_contracts.total_amount ||quotedPrice : demandInfo.winBidding.quoted_price}}" disabled="{{opType=='quote' && (!demandInfo.myBidding && !demandInfo.demand_contracts) ? false : true}}" tips="{{opType=='quote' && actualAccount > 0 ? '预计到手金额 ' + actualAccount + '元 + ' + commissionPercent + '%的平台服务费' : ''}}" data-field="quotedPrice" bindchange="onInputChange">
<t-input style="--td-input-border-color: rgb(238, 116, 2);" placeholder="填写报价金额" suffix="元" align="right" type="number" value="{{opType=='quote' ? demandInfo.myBidding.quoted_price || demandInfo.demand_contracts.total_amount ||quotedPrice : demandInfo.winBidding.quoted_price}}" disabled="{{opType=='quote' && (!demandInfo.myBidding && !demandInfo.demand_contracts) ? false : true}}" tips="{{opType=='quote' && androidAccount > 0 ? '预计到手 安卓' + androidAccount + '元 / iOS' + iosAccount + '元,已扣平台服务费' + commissionPercent + '%和支付费率' + androidFeePercent + '%/' + iosFeePercent + '%' : ''}}" data-field="quotedPrice" bindchange="onInputChange">
<view slot="label" class="custom-label">报价</view>
</t-input>
<t-input placeholder="填写预计工期" suffix="天" align="right" disabled="{{opType=='quote' && (!demandInfo.myBidding && !demandInfo.demand_contracts) ? false : true}}" type="number" value="{{opType=='quote' ? demandInfo.myBidding.need_days || demandInfo.demand_contracts.need_days || needDays : demandInfo.winBidding.need_days}}" data-field="needDays" bindchange="onInputChange">