diff --git a/plugin/think-plugs-payment/src/service/Payment.php b/plugin/think-plugs-payment/src/service/Payment.php index bd559a454..fb1c2c338 100644 --- a/plugin/think-plugs-payment/src/service/Payment.php +++ b/plugin/think-plugs-payment/src/service/Payment.php @@ -442,7 +442,7 @@ abstract class Payment */ public static function leaveAmount(string $orderNo, $orderAmount): float { - $diff = round(floatval($orderAmount) - self::paidAmount($orderNo, true), 2); + $diff = round(round(floatval($orderAmount), 2) - self::paidAmount($orderNo, true), 2); return $diff > 0 ? $diff : 0.00; } @@ -463,9 +463,9 @@ abstract class Payment 'sum(used_integral-refund_integral)' => 'integral', ])->group('channel_type')->select()->map(static function (PluginPaymentRecord $item) use (&$total) { $type = $item->getAttr('channel_type'); - $total['amount'] += $item->getAttr('amount'); + $total['amount'] = round($total['amount'] + $item->getAttr('amount'), 2); if (!in_array($type, [self::INTEGRAL, self::BALANCE])) $type = 'payment'; - $total[$type] += $item[$type] ?? 0; + $total[$type] = round($total[$type] + $item[$type] ?? 0, 2); }); } catch (\Exception $exception) { trace_file($exception); @@ -486,9 +486,9 @@ abstract class Payment 'refund_account', 'sum(refund_amount) amount', 'sum(used_payment)' => 'payment', 'sum(used_balance)' => 'balance', 'sum(used_integral)' => 'integral', ])->group('refund_account')->select()->map(static function (PluginPaymentRefund $item) use (&$total) { $type = $item->getAttr('refund_account'); - $total['amount'] += $item->getAttr('amount'); + $total['amount'] = round($total['amount'] + $item->getAttr('amount'), 2); if (!in_array($type, [self::INTEGRAL, self::BALANCE])) $type = 'payment'; - $total[$type] += $item[$type] ?? 0; + $total[$type] = round($total[$type] + $item[$type] ?? 0, 2); }); } catch (\Exception $exception) { trace_file($exception);