代币优化
This commit is contained in:
@@ -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