From ffbf68679b0d6f49a7fed3ac7cf1612336a4e074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 13 Mar 2026 11:25:31 +0000 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=AF=B9=E8=B4=A6=E5=B7=AE?= =?UTF-8?q?=E9=A2=9D=E9=98=88=E5=80=BC=E4=BD=BF=E7=94=A8=20amounts.toleran?= =?UTF-8?q?ce=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/PlatformOrder.php | 7 ++++++- config/saasshop.php | 7 +++++++ resources/views/admin/platform_orders/index.blade.php | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Models/PlatformOrder.php b/app/Models/PlatformOrder.php index fedd461..d4853d3 100644 --- a/app/Models/PlatformOrder.php +++ b/app/Models/PlatformOrder.php @@ -69,7 +69,12 @@ class PlatformOrder extends Model $receiptCents = (int) round(((float) $this->receiptTotal()) * 100); $paidCents = (int) round(((float) ($this->paid_amount ?? 0)) * 100); - return abs($receiptCents - $paidCents) >= 1; + $tol = (float) config('saasshop.amounts.tolerance', 0.01); + $tolCents = (int) round($tol * 100); + // 以“分”为最小粒度,至少 1 分(若配置 0,则视为要求严格一致) + $tolCents = max(1, $tolCents); + + return abs($receiptCents - $paidCents) >= $tolCents; } protected $fillable = [ diff --git a/config/saasshop.php b/config/saasshop.php index 5b9a828..5288424 100644 --- a/config/saasshop.php +++ b/config/saasshop.php @@ -12,4 +12,11 @@ return [ // 同步失败原因展示截断长度(用于列表/聚合展示,避免撑坏布局)。 'sync_failed_reason_display_truncate_len' => 60, ], + + // 金额对账相关配置(统一按分取整后做比较,避免浮点误差)。 + 'amounts' => [ + // 允许的金额差异容差(单位:元),默认 0.01。 + // 用于对账不一致、退款不一致等口径判断。 + 'tolerance' => 0.01, + ], ]; diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index a56530b..a826918 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -227,7 +227,8 @@
对账不一致订单: {{ $summaryStats['reconcile_mismatch_orders'] ?? 0 }}
- @if(abs($delta) >= 0.01) + @php $tol = (float) config('saasshop.amounts.tolerance', 0.01); @endphp + @if(abs($delta) >= $tol)
提示:差额非 0,可能存在回执金额与订单金额不一致的订单。
@endif