更新若干功能

This commit is contained in:
2026-08-19 08:16:49 +08:00
parent 4979bb83d2
commit 72bc6502eb
56 changed files with 3627 additions and 343 deletions

View File

@@ -139,6 +139,19 @@ class PriceService
return number_format($cents / 100, 2, '.', '');
}
/**
* 元转分。套餐报价后台按元录入,入库前走这里,避免前端自己乘 100 对不齐。
* 可选倍率:小程序把基准套餐价乘用户 price_number 时复用。
*/
public function yuanToCents(mixed $yuan, mixed $multiplier = 1): int
{
if (!is_numeric($yuan)) {
return 0;
}
$scaled = bcmul((string) $yuan, $this->normalizeMultiplier($multiplier), 2);
return (int) bcmul($scaled, '100', 0);
}
/**
* 倍率兜底库里可能是空串、0 或负数,直接拿去 bcmul 会把价格清零
*/