支付金额取整
This commit is contained in:
@@ -54,7 +54,10 @@ Page({
|
||||
attachFiles: [],
|
||||
// 签约条款
|
||||
agreementChecked: false
|
||||
}
|
||||
},
|
||||
firstAmount: '',
|
||||
finalAmount: '',
|
||||
costTips: '首付款按总费用的50%四舍五入到整数元,尾款为剩余未付金额'
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -88,20 +91,65 @@ Page({
|
||||
platformName: payPlatform === 'ios' ? 'iOS' : '安卓',
|
||||
};
|
||||
},
|
||||
|
||||
// 首付为总金额 50% 四舍五入到整数元,尾款为剩余未付金额。与后端 splitDemandPayment 一致
|
||||
installmentPreview(amount) {
|
||||
const text = String(amount == null ? '' : amount).trim();
|
||||
if (!text || Number(text) <= 0) {
|
||||
return { firstAmount: '', finalAmount: '' };
|
||||
}
|
||||
const parts = text.split('.');
|
||||
const yuanPart = parseInt(parts[0], 10);
|
||||
if (Number.isNaN(yuanPart)) {
|
||||
return { firstAmount: '', finalAmount: '' };
|
||||
}
|
||||
const dec = (parts[1] || '0').padEnd(2, '0').slice(0, 2);
|
||||
const fen = yuanPart * 100 + parseInt(dec, 10);
|
||||
const firstYuan = Math.floor((fen + 100) / 200);
|
||||
const firstFen = Math.min(firstYuan * 100, fen);
|
||||
const finalFen = fen - firstFen;
|
||||
const format = (value) => (value / 100).toFixed(2);
|
||||
return {
|
||||
firstAmount: format(firstFen),
|
||||
finalAmount: format(finalFen),
|
||||
};
|
||||
},
|
||||
|
||||
buildCostTips(installment, income, commissionPercent) {
|
||||
const percent = commissionPercent !== undefined ? commissionPercent : this.data.commissionPercent;
|
||||
const splitText = installment.firstAmount
|
||||
? `首付款${installment.firstAmount}元(总费用的50%四舍五入到整数元),尾款${installment.finalAmount}元(剩余未付金额)`
|
||||
: '首付款按总费用的50%四舍五入到整数元,尾款为剩余未付金额';
|
||||
if (this.data.source == 'dev') {
|
||||
return `预计到手金额 ${income.actualAccount}元,已扣平台服务费${percent}%和${income.platformName}支付费率${income.payFeePercent}%。${splitText}`;
|
||||
}
|
||||
return splitText;
|
||||
},
|
||||
|
||||
fillPaymentPreview(amount, incomePatch, commissionPercent) {
|
||||
const income = this.incomePreview(amount, incomePatch);
|
||||
const installment = this.installmentPreview(amount);
|
||||
return {
|
||||
...income,
|
||||
...installment,
|
||||
costTips: this.buildCostTips(installment, income, commissionPercent),
|
||||
};
|
||||
},
|
||||
// 拉取平台服务费和支付费率,并重算预计到手金额
|
||||
async loadCommissionRatio() {
|
||||
const rates = await fetchIncomeRates();
|
||||
const commissionPercent = toPercent(rates.commissionRatio);
|
||||
this.setData({
|
||||
commissionRatio: rates.commissionRatio,
|
||||
commissionPercent: toPercent(rates.commissionRatio),
|
||||
commissionPercent,
|
||||
androidPayFeeRate: rates.androidPayFeeRate,
|
||||
iosPayFeeRate: rates.iosPayFeeRate,
|
||||
androidFeePercent: toPercent(rates.androidPayFeeRate),
|
||||
iosFeePercent: toPercent(rates.iosPayFeeRate),
|
||||
...this.incomePreview(this.data.formData?.totalCost, {
|
||||
...this.fillPaymentPreview(this.data.formData?.totalCost, {
|
||||
...rates,
|
||||
payPlatform: this.data.payPlatform,
|
||||
}),
|
||||
}, commissionPercent),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -235,7 +283,7 @@ Page({
|
||||
onTotalCostChange(e) {
|
||||
this.setData({
|
||||
'formData.totalCost': e.detail.value,
|
||||
...this.incomePreview(e.detail.value),
|
||||
...this.fillPaymentPreview(e.detail.value),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -559,7 +607,7 @@ Page({
|
||||
'formData.taskContent': resData.task_content,
|
||||
'formData.needDays': resData.need_days,
|
||||
'formData.totalCost': resData.total_amount,
|
||||
...this.incomePreview(resData.total_amount, { payPlatform: resData.pay_platform }),
|
||||
...this.fillPaymentPreview(resData.total_amount, { payPlatform: resData.pay_platform }),
|
||||
});
|
||||
|
||||
// 客户签约时,附件展示开发者签约时上传的附件,仅可预览,不可删除和上传
|
||||
@@ -690,10 +738,13 @@ Page({
|
||||
});
|
||||
return;
|
||||
}
|
||||
const payAmount = res.data && res.data.payment_amount ? res.data.payment_amount : '';
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
showCancel: false,
|
||||
content: '签约完成,去支付首付款(总金额的50%)',
|
||||
content: payAmount
|
||||
? `签约完成,去支付首付款${payAmount}元。尾款为合同剩余未付金额`
|
||||
: '签约完成,去支付首付款',
|
||||
success: (res2) => {
|
||||
if (res2.confirm) {
|
||||
//支付预付款
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<t-input label="总费用" placeholder="请输入总费用" suffix="元" align="right" type="number" tips="{{source == 'dev' ? '预计到手金额 ' + actualAccount + '元,已扣平台服务费' + commissionPercent + '%和' + platformName + '支付费率' + payFeePercent + '%' : '总费用 = 首付款50% + 尾款50%'}}" disabled="{{source != 'dev'}}" value="{{formData.totalCost}}" bind:change="onTotalCostChange" />
|
||||
<t-input label="总费用" placeholder="请输入总费用" suffix="元" align="right" type="number" tips="{{costTips}}" disabled="{{source != 'dev'}}" value="{{formData.totalCost}}" bind:change="onTotalCostChange" />
|
||||
<t-input label="开发工期" placeholder="请输入开发工期" suffix="天" align="right" type="number" disabled="{{source != 'dev'}}" value="{{formData.needDays}}" bind:change="onDevelopmentPeriodChange" />
|
||||
</view>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user