代币优化
This commit is contained in:
@@ -151,6 +151,8 @@ class DemandService
|
||||
'files' => $data['files'] ?? [],
|
||||
'budget_amount' => $data['budget_amount'] ?? 0,
|
||||
'limit_time' => $data['limit_time'] ?? 0,
|
||||
// 客户发布需求时的手机系统,报价预估按这个终端。真正付款可能换设备,以支付记录为准
|
||||
'pay_platform' => VirtualPayService::normalizePayPlatform($data['pay_platform'] ?? '') ?: 'android',
|
||||
'publish_status' => CommonService::ONGOING,
|
||||
'status' => self::STATUS_NO
|
||||
];
|
||||
|
||||
@@ -481,8 +481,9 @@ class VirtualPayService
|
||||
}
|
||||
|
||||
/**
|
||||
* 代币数量,保留两位小数。1元=1代币时,0.01元对应 0.01 个代币
|
||||
* @param float|string $amountYuan
|
||||
* @return int
|
||||
* @return float
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function coinQuantity($amountYuan)
|
||||
@@ -495,11 +496,9 @@ class VirtualPayService
|
||||
if ($coinPerYuan < 1) {
|
||||
$coinPerYuan = 1;
|
||||
}
|
||||
if (($fen * $coinPerYuan) % 100 !== 0) {
|
||||
throw new \Exception('订单金额须为整数元才能按1元=1代币支付');
|
||||
}
|
||||
$quantity = bcdiv(bcmul((string)$fen, (string)$coinPerYuan, 0), '100', 2);
|
||||
|
||||
return intdiv($fen * $coinPerYuan, 100);
|
||||
return (float)$quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user