fix(product): 修复产品列表中点数显示问题

- 在 RechargeProductsDto 类中,修改了 bonus_rate_pct 的计算方式
- 使用 round 函数对结果进行四舍五入,提高精度
- 调整 scale 参数为3,增加小数位数- 这些修改提高了点数计算的准确性,解决了产品列表中的点数显示问题
This commit is contained in:
李东云
2025-09-19 15:35:27 +08:00
parent 3af39e4254
commit eb44b6e3b6

View File

@@ -54,17 +54,19 @@ final class RechargeProductsDto extends AbstractDto
if (!$is_ftai) { if (!$is_ftai) {
$result += [ $result += [
'total_points' => $effect->getPointTotal(), 'total_points' => $effect->getPointTotal(),
'bonus_rate_pct' => (float)(bcmul( 'bonus_rate_pct' => round(
num1: $effect->getPointTotal() == 0 (float)(bcmul(
? '0' num1: $effect->getPointTotal() == 0
: bcdiv( ? '0'
(string)$effect->pointBonus, : bcdiv(
(string)$effect->getPointTotal(), (string)$effect->pointBonus,
3, (string)$effect->getPointTotal(),
), 3,
num2: '100', ),
scale: 0, num2: '100',
)), scale: 3,
)),
),
'point' => [ 'point' => [
'total' => $effect->getPointTotal(), 'total' => $effect->getPointTotal(),
'number' => $effect->pointBasic, 'number' => $effect->pointBasic,