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