From 9d231881d70a22e7555bb02a02f71559ce98473e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 9 Oct 2024 21:31:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=9A=84=E7=BB=9F=E8=AE=A1=E7=B2=BE=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/think-plugs-payment/src/service/Payment.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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);