添加支付费率扣除
This commit is contained in:
@@ -8,6 +8,7 @@ return [
|
||||
'Currency' => '货币类型',
|
||||
'Pay_type' => '支付类型',
|
||||
'Pay_way' => '支付方式',
|
||||
'Pay_platform' => '支付终端',
|
||||
'Interact_id' => '交互ID',
|
||||
'Trace_no' => '追踪号',
|
||||
'Channel_trx_no' => '渠道交易号',
|
||||
|
||||
@@ -193,6 +193,9 @@ class Common extends Api
|
||||
'developTypes' => $developTypes,
|
||||
// 平台服务费比例(0~1),前端据此计算开发者预计到手金额
|
||||
'platform_commission_ratio' => (float)DemandService::getPlatformCommissionRatio(),
|
||||
// 虚拟支付渠道费率(0~1):安卓 1%,iOS 12%,报价页按两端分别估算到手
|
||||
'android_pay_fee_rate' => (float)DemandService::getPayFeeRate('android'),
|
||||
'ios_pay_fee_rate' => (float)DemandService::getPayFeeRate('ios'),
|
||||
// 推广分享卡片预览图,未配置时为空
|
||||
'promotion_share_image' => $shareImage ? cdnurl($shareImage, true) : '',
|
||||
// 商品按案例展示:不显示价格和购买入口
|
||||
|
||||
@@ -308,7 +308,8 @@ class Order extends Api
|
||||
if (!$orderNo) {
|
||||
$this->error('订单号不能为空');
|
||||
}
|
||||
$res = OrderService::confirmVirtualPay($orderNo, $this->auth->id);
|
||||
$payPlatform = $this->request->post('payPlatform', '');
|
||||
$res = OrderService::confirmVirtualPay($orderNo, $this->auth->id, $payPlatform);
|
||||
$this->success('支付成功', $res);
|
||||
} catch (\Exception $e) {
|
||||
if ($e instanceof HttpResponseException) {
|
||||
|
||||
@@ -91,15 +91,42 @@ class DemandService
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算扣除平台服务费后开发者实得金额
|
||||
* @param mixed $amount 订单金额(元)
|
||||
* 虚拟支付渠道费率。iOS 走苹果,其余终端按安卓费率
|
||||
* @param string $platform android|ios
|
||||
* @return string
|
||||
*/
|
||||
public static function getDeveloperIncome($amount): string
|
||||
public static function getPayFeeRate($platform): string
|
||||
{
|
||||
$config = config('common.virtual_pay');
|
||||
if (!is_array($config)) {
|
||||
$config = [];
|
||||
}
|
||||
$isIos = $platform === 'ios';
|
||||
$raw = $isIos ? ($config['ios_pay_fees'] ?? '0.12') : ($config['android_pay_fees'] ?? '0.01');
|
||||
if (!is_numeric($raw) || $raw < 0) {
|
||||
$raw = $isIos ? '0.12' : '0.01';
|
||||
}
|
||||
$rate = sprintf('%.4f', (float)$raw);
|
||||
|
||||
return bccomp($rate, '1', 4) > 0 ? '1.0000' : $rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开发者实得 = 支付金额 - 平台服务费 - 安卓/iOS 支付费率
|
||||
* @param mixed $amount 订单金额(元)
|
||||
* @param string $platform android|ios
|
||||
* @return string
|
||||
*/
|
||||
public static function getDeveloperIncome($amount, $platform = 'android'): string
|
||||
{
|
||||
$ratio = self::getPlatformCommissionRatio();
|
||||
$payFee = self::getPayFeeRate($platform);
|
||||
$remain = bcsub(bcsub('1', $ratio, 4), $payFee, 4);
|
||||
if (bccomp($remain, '0', 4) < 0) {
|
||||
$remain = '0';
|
||||
}
|
||||
|
||||
return bcmul((string)$amount, bcsub('1', $ratio, 4), 2);
|
||||
return bcmul((string)$amount, $remain, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -630,7 +657,8 @@ class DemandService
|
||||
$userId = $contract->demandBidding->user_id;
|
||||
//开发者冻结金额增加
|
||||
$demandOrder = OrderService::getDemandOrder($demand->parent_order_no, OrderService::ORDER_TYPE_FIRST_PAYMENT);
|
||||
$amount = self::getDeveloperIncome($demandOrder->payment_amount);
|
||||
$payPlatform = OrderPaymentService::where('order_no', $demandOrder->order_no)->order('id desc')->value('pay_platform');
|
||||
$amount = self::getDeveloperIncome($demandOrder->payment_amount, $payPlatform ?: 'android');
|
||||
$title = OrderService::ORDER_TYPE_MAP[$demandOrder->order_type] ?? '需求收益';
|
||||
$log_res = AccountLogService::addLog(AccountLogService::ACCOUNT_TYPE_FREEZE, $userId, $amount, $title . '-冻结金额增加', AccountLogService::TYPE_FREEZE, 0, AccountLogService::INC_EXP_INCREASE, $demandOrder->id);
|
||||
AccountService::updateData($userId, 0, $amount, 0, 0, $log_res->id);
|
||||
@@ -667,7 +695,8 @@ class DemandService
|
||||
$userId = $demand->winBidding->user_id;
|
||||
//开发者冻结金额增加
|
||||
$demandOrder = OrderService::getDemandOrder($demand->parent_order_no, OrderService::ORDER_TYPE_FINAL_PAYMENT);
|
||||
$amount = self::getDeveloperIncome($demandOrder->payment_amount);
|
||||
$payPlatform = OrderPaymentService::where('order_no', $demandOrder->order_no)->order('id desc')->value('pay_platform');
|
||||
$amount = self::getDeveloperIncome($demandOrder->payment_amount, $payPlatform ?: 'android');
|
||||
$title = OrderService::ORDER_TYPE_MAP[$demandOrder->order_type] ?? '需求收益';
|
||||
$log_res = AccountLogService::addLog(AccountLogService::ACCOUNT_TYPE_FREEZE, $userId, $amount, $title . '-冻结金额增加', AccountLogService::TYPE_FREEZE, 0, AccountLogService::INC_EXP_INCREASE, $demandOrder->id);
|
||||
AccountService::updateData($userId, 0, $amount, 0, 0, $log_res->id);
|
||||
@@ -768,7 +797,15 @@ class DemandService
|
||||
$demand->status = DemandService::STATUS_FINISHED;
|
||||
$demand->settle_status = CommonService::SUCCESS;
|
||||
$demand->save();
|
||||
$amount = self::getDeveloperIncome($demand->demandContracts->total_amount ?? 0);
|
||||
$amount = '0';
|
||||
foreach ([OrderService::ORDER_TYPE_FIRST_PAYMENT, OrderService::ORDER_TYPE_FINAL_PAYMENT] as $orderType) {
|
||||
$demandOrder = OrderService::getDemandOrder($demand->parent_order_no, $orderType);
|
||||
if (!$demandOrder) {
|
||||
continue;
|
||||
}
|
||||
$payPlatform = OrderPaymentService::where('order_no', $demandOrder->order_no)->order('id desc')->value('pay_platform');
|
||||
$amount = bcadd($amount, self::getDeveloperIncome($demandOrder->payment_amount, $payPlatform ?: 'android'), 2);
|
||||
}
|
||||
//写入余额日志
|
||||
$log_res = AccountLogService::addLog(AccountLogService::ACCOUNT_TYPE_FREEZE, -$amount, '需求收益解冻-冻结扣除', AccountLogService::TYPE_UNFREEZE, 0, $demand->id, $demand->order_amount);
|
||||
$log_res = AccountLogService::addLog(AccountLogService::ACCOUNT_TYPE_AMOUNT, +$amount, '需求收益解冻-余额增加', AccountLogService::TYPE_UNFREEZE, 0, $demand->id, $demand->order_amount);
|
||||
|
||||
@@ -148,6 +148,7 @@ class OrderService
|
||||
'promoter_id' => PromotionService::getPromoterId(intval($userId)),
|
||||
];
|
||||
$orderData['parent_order_no'] = $orderData['order_no'];
|
||||
VirtualPayService::rememberPayPlatform($orderData['order_no'], $requestData['payPlatform'] ?? '');
|
||||
$existed = OrderService::getOne(['order_no' => $orderData['order_no']]);
|
||||
if (!$existed) {
|
||||
//创建订单及订单商品
|
||||
@@ -290,6 +291,7 @@ class OrderService
|
||||
throw new \Exception('该订单不存在');
|
||||
}
|
||||
$orderData = $orderInfo->toArray();
|
||||
VirtualPayService::rememberPayPlatform($orderNo, $requestData['payPlatform'] ?? '');
|
||||
Log::info('微信下单[发起支付] ' . json_encode([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $userId,
|
||||
@@ -516,14 +518,22 @@ class OrderService
|
||||
* @param string $payWay
|
||||
* @param int $paidTime
|
||||
* @param string $traceId
|
||||
* @param string $payPlatform android|ios,空则用下单时记下的终端
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function finishPaid($orderNo, $amountFen, $transactionId, $payWay, $paidTime, $traceId = '')
|
||||
public static function finishPaid($orderNo, $amountFen, $transactionId, $payWay, $paidTime, $traceId = '', $payPlatform = '')
|
||||
{
|
||||
$payPlatform = VirtualPayService::normalizePayPlatform($payPlatform);
|
||||
if ($payPlatform === '') {
|
||||
$payPlatform = VirtualPayService::payPlatformOf($orderNo);
|
||||
}
|
||||
if ($payPlatform === '') {
|
||||
$payPlatform = 'android';
|
||||
}
|
||||
$prefix = '订单支付入账 trace=' . $traceId . ' ';
|
||||
try {
|
||||
Db::transaction(function () use ($orderNo, $amountFen, $transactionId, $payWay, $paidTime, $prefix) {
|
||||
Db::transaction(function () use ($orderNo, $amountFen, $transactionId, $payWay, $paidTime, $prefix, $payPlatform) {
|
||||
$orderInfo = self::where('order_no', $orderNo)->lock(true)->find();
|
||||
if (!$orderInfo) {
|
||||
Log::error($prefix . '订单不存在: ' . $orderNo);
|
||||
@@ -551,6 +561,7 @@ class OrderService
|
||||
'currency' => 'CNY',
|
||||
'pay_type' => '1',
|
||||
'pay_way' => $payWay ?: 'XPAY',
|
||||
'pay_platform' => $payPlatform,
|
||||
'trace_no' => $transactionId,
|
||||
'pay_time' => time(),
|
||||
'pay_success_time' => $paidTime > 0 ? $paidTime : time(),
|
||||
@@ -615,8 +626,9 @@ class OrderService
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function confirmVirtualPay($orderNo, $userId)
|
||||
public static function confirmVirtualPay($orderNo, $userId, $payPlatform = '')
|
||||
{
|
||||
VirtualPayService::rememberPayPlatform($orderNo, $payPlatform);
|
||||
$order = self::getOne(['order_no' => $orderNo, 'user_id' => $userId]);
|
||||
if (!$order) {
|
||||
throw new \Exception('订单不存在');
|
||||
|
||||
@@ -18,6 +18,7 @@ class VirtualPayService
|
||||
const SESSION_PREFIX = 'wx_session_key:';
|
||||
const TRADE_PREFIX = 'vp_trade:';
|
||||
const LATEST_PREFIX = 'vp_order_latest:';
|
||||
const PLATFORM_PREFIX = 'vp_pay_platform:';
|
||||
const CACHE_TTL = 1296000; // 15天
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,50 @@ class VirtualPayService
|
||||
Cache::set(self::SESSION_PREFIX . $userId, $sessionKey, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记下客户拉起支付时的终端。iOS 单独记,鸿蒙、Windows 等按安卓费率
|
||||
* @param string $orderNo
|
||||
* @param string $platform
|
||||
* @return string
|
||||
*/
|
||||
public static function rememberPayPlatform($orderNo, $platform)
|
||||
{
|
||||
$normalized = self::normalizePayPlatform($platform);
|
||||
if ($orderNo !== '' && $normalized !== '') {
|
||||
Cache::set(self::PLATFORM_PREFIX . $orderNo, $normalized, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $orderNo
|
||||
* @return string
|
||||
*/
|
||||
public static function payPlatformOf($orderNo)
|
||||
{
|
||||
$cached = $orderNo ? Cache::get(self::PLATFORM_PREFIX . $orderNo) : '';
|
||||
|
||||
return self::normalizePayPlatform($cached);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $platform
|
||||
* @return string android|ios|空
|
||||
*/
|
||||
public static function normalizePayPlatform($platform)
|
||||
{
|
||||
$platform = strtolower(trim((string)$platform));
|
||||
if ($platform === 'ios' || $platform === 'iphone') {
|
||||
return 'ios';
|
||||
}
|
||||
if ($platform === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return 'android';
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 wx.requestVirtualPayment 参数。signData 必须原样传给客户端,不能再 JSON.stringify
|
||||
* @param string $orderNo
|
||||
@@ -239,7 +284,8 @@ class VirtualPayService
|
||||
$transactionId,
|
||||
'XPAY',
|
||||
$paidTime > 0 ? $paidTime : time(),
|
||||
'settle'
|
||||
'settle',
|
||||
self::payPlatformOf($order->order_no)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -266,7 +312,8 @@ class VirtualPayService
|
||||
(string)($payInfo['TransactionId'] ?? ''),
|
||||
'XPAY',
|
||||
$paidTime > 0 ? $paidTime : time(),
|
||||
'coin_notify'
|
||||
'coin_notify',
|
||||
self::payPlatformOf($orderNo)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
{field: 'currency', title: __('Currency'), operate: 'LIKE'},
|
||||
{field: 'pay_type', title: __('Pay_type')},
|
||||
{field: 'pay_way', title: __('Pay_way'), operate: 'LIKE'},
|
||||
{field: 'pay_platform', title: __('Pay_platform'), searchList: {"android":"安卓","ios":"苹果"}, formatter: Table.api.formatter.normal},
|
||||
{field: 'interact_id', title: __('Interact_id'), operate: 'LIKE'},
|
||||
{field: 'trace_no', title: __('Trace_no'), operate: 'LIKE'},
|
||||
{field: 'channel_trx_no', title: __('Channel_trx_no'), operate: 'LIKE'},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import { fetchDemandContractDetail, demandOperate } from '../../../services/demand/fetchDemand';
|
||||
import { fetchPlatformCommissionRatio, calcActualAccount } from '../../../services/home/home';
|
||||
import { fetchIncomeRates, calcActualAccount, toPercent } from '../../../services/home/home';
|
||||
// pages/demand/contract/index.js
|
||||
Page({
|
||||
|
||||
@@ -9,9 +9,14 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
demandId: 0,
|
||||
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,
|
||||
contract: null,
|
||||
agreementUrl: '', // 签约条款URL
|
||||
phoneError: '', // 个人联系电话错误提示
|
||||
@@ -67,13 +72,26 @@ Page({
|
||||
this.loadCommissionRatio();
|
||||
},
|
||||
|
||||
// 拉取平台服务费比例,并按新比例重算预计到手金额
|
||||
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.data.formData?.totalCost, 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.data.formData?.totalCost, rates),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -207,7 +225,7 @@ Page({
|
||||
onTotalCostChange(e) {
|
||||
this.setData({
|
||||
'formData.totalCost': e.detail.value,
|
||||
actualAccount: calcActualAccount(e.detail.value, this.data.commissionRatio)
|
||||
...this.incomePreview(e.detail.value),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -531,7 +549,7 @@ Page({
|
||||
'formData.taskContent': resData.task_content,
|
||||
'formData.needDays': resData.need_days,
|
||||
'formData.totalCost': resData.total_amount,
|
||||
actualAccount: calcActualAccount(resData.total_amount, this.data.commissionRatio),
|
||||
...this.incomePreview(resData.total_amount),
|
||||
});
|
||||
|
||||
// 客户签约时,附件展示开发者签约时上传的附件,仅可预览,不可删除和上传
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<t-input label="总费用" placeholder="请输入总费用" suffix="元" align="right" type="number" tips="{{source == 'dev' ? '预计到手金额 ' + actualAccount + '元 + ' + commissionPercent + '%的平台服务费' : '总费用 = 首付款50% + 尾款50%'}}" disabled="{{source != 'dev'}}" value="{{formData.totalCost}}" bind:change="onTotalCostChange" />
|
||||
<t-input label="总费用" placeholder="请输入总费用" suffix="元" align="right" type="number" tips="{{source == 'dev' ? '预计到手 安卓' + androidAccount + '元 / iOS' + iosAccount + '元,已扣平台服务费' + commissionPercent + '%和支付费率' + androidFeePercent + '%/' + iosFeePercent + '%' : '总费用 = 首付款50% + 尾款50%'}}" 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>
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -3,6 +3,17 @@ import Toast from 'tdesign-miniprogram/toast/index';
|
||||
|
||||
import { confirmVirtualPay, dispatchCommitPay } from '../../../services/order/orderConfirm';
|
||||
|
||||
// iOS 单独记,其余终端按安卓支付费率
|
||||
function currentPayPlatform() {
|
||||
let platform = '';
|
||||
try {
|
||||
platform = String((wx.getSystemInfoSync() || {}).platform || '').toLowerCase();
|
||||
} catch (err) {
|
||||
platform = '';
|
||||
}
|
||||
return platform === 'ios' ? 'ios' : 'android';
|
||||
}
|
||||
|
||||
// 真实的提交支付
|
||||
export const commitPay = (params) => {
|
||||
return dispatchCommitPay({
|
||||
@@ -23,6 +34,7 @@ export const commitPay = (params) => {
|
||||
storeInfoList: params.storeInfoList, //备注信息列表
|
||||
couponList: params.couponList,
|
||||
groupInfo: params.groupInfo,
|
||||
payPlatform: currentPayPlatform(),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -129,7 +141,7 @@ export const wechatPayOrder = (payOrderInfo) => {
|
||||
signature: payInfo.signature,
|
||||
mode: payInfo.mode,
|
||||
success() {
|
||||
confirmVirtualPay(payOrderInfo.tradeNo).then((res) => {
|
||||
confirmVirtualPay(payOrderInfo.tradeNo, currentPayPlatform()).then((res) => {
|
||||
if (!res || res.code !== 1) {
|
||||
payFail(payOrderInfo, (res && res.msg) || '支付结果确认失败,请稍后在订单中再次支付,不会重复扣款');
|
||||
return;
|
||||
|
||||
@@ -143,12 +143,45 @@ export async function fetchGoodsCaseView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算扣除平台服务费后的预计到手金额(保留两位小数)
|
||||
* 预计到手 = 金额 × (1 - 平台服务费 - 支付费率),保留两位小数
|
||||
* @param {number|string} amount 报价/总费用(元)
|
||||
* @param {number} ratio 平台服务费比例
|
||||
* @param {number} payFeeRate 安卓或 iOS 支付费率
|
||||
* @returns {number}
|
||||
*/
|
||||
export function calcActualAccount(amount, ratio) {
|
||||
export function calcActualAccount(amount, ratio, payFeeRate = 0) {
|
||||
const value = Number(amount) || 0;
|
||||
return Math.round(value * (1 - ratio) * 100) / 100;
|
||||
const remain = 1 - (Number(ratio) || 0) - (Number(payFeeRate) || 0);
|
||||
return Math.round(value * (remain > 0 ? remain : 0) * 100) / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台服务费和两端支付费率。费率来自 getMiniConfig,失败时用 1% / 12%
|
||||
* @returns {Promise<{commissionRatio:number, androidPayFeeRate:number, iosPayFeeRate:number}>}
|
||||
*/
|
||||
export async function fetchIncomeRates() {
|
||||
const commissionRatio = await fetchPlatformCommissionRatio();
|
||||
let androidPayFeeRate = 0.01;
|
||||
let iosPayFeeRate = 0.12;
|
||||
try {
|
||||
const res = await fetchConfig();
|
||||
if (res && res.code === 1) {
|
||||
const android = Number(res.data?.android_pay_fee_rate);
|
||||
const ios = Number(res.data?.ios_pay_fee_rate);
|
||||
if (android >= 0 && android < 1) {
|
||||
androidPayFeeRate = android;
|
||||
}
|
||||
if (ios >= 0 && ios < 1) {
|
||||
iosPayFeeRate = ios;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('fetchIncomeRates failed:', err);
|
||||
}
|
||||
return { commissionRatio, androidPayFeeRate, iosPayFeeRate };
|
||||
}
|
||||
|
||||
/** 比例转百分比,1% 显示为 1,12% 显示为 12 */
|
||||
export function toPercent(rate) {
|
||||
return Math.round((Number(rate) || 0) * 10000) / 100;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ export function dispatchCommitPay(params) {
|
||||
}
|
||||
|
||||
/** 虚拟支付收银台成功后,通知服务端查单并入账 */
|
||||
export function confirmVirtualPay(orderNo) {
|
||||
return wx.$util.request(wx.$api.OrderVirtualPayConfirm, { orderNo }, 'POST');
|
||||
export function confirmVirtualPay(orderNo, payPlatform) {
|
||||
return wx.$util.request(wx.$api.OrderVirtualPayConfirm, { orderNo, payPlatform }, 'POST');
|
||||
}
|
||||
|
||||
/* 订单操作 */
|
||||
|
||||
Reference in New Issue
Block a user