diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php
index 1c3ce10..ca25f0b 100644
--- a/app/Http/Controllers/Admin/PlatformOrderController.php
+++ b/app/Http/Controllers/Admin/PlatformOrderController.php
@@ -136,6 +136,8 @@ class PlatformOrderController extends Controller
'batch_synced_24h' => (string) $request->query('batch_synced_24h', ''),
// 只看最近 24 小时批量“仅标记为已生效”过的订单(可治理追踪)
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
+ // 只看“对账不一致”的订单(粗版):meta.payment_summary.total_amount 与 paid_amount 不一致
+ 'reconcile_mismatch' => (string) $request->query('reconcile_mismatch', ''),
];
@@ -558,6 +560,8 @@ class PlatformOrderController extends Controller
'batch_synced_24h' => (string) $request->query('batch_synced_24h', ''),
// 只看最近 24 小时批量“仅标记为已生效”过的订单(可治理追踪)
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
+ // 只看“对账不一致”的订单(粗版):meta.payment_summary.total_amount 与 paid_amount 不一致
+ 'reconcile_mismatch' => (string) $request->query('reconcile_mismatch', ''),
];
@@ -1062,6 +1066,21 @@ class PlatformOrderController extends Controller
} else {
$builder->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(meta, '$.batch_mark_activated.at')) >= ?", [$since]);
}
+ })
+ ->when(($filters['reconcile_mismatch'] ?? '') !== '', function (Builder $builder) {
+ // 只看“对账不一致”的订单(粗版):支付回执总额(优先 payment_summary.total_amount)与订单 paid_amount 不一致
+ // 注意:该筛选需要读取 JSON 字段,MySQL/SQLite 写法略有差异。
+ $driver = $builder->getQuery()->getConnection()->getDriverName();
+
+ if ($driver === 'sqlite') {
+ // sqlite 下 JSON_EXTRACT 直接返回标量(数值或字符串),这里用“按分”取整避免浮点误差导致 0.01 边界不稳定
+ $builder->whereRaw("JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NOT NULL")
+ ->whereRaw("ABS(ROUND(CAST(JSON_EXTRACT(meta, '$.payment_summary.total_amount') AS REAL) * 100) - ROUND(paid_amount * 100)) >= 1");
+ } else {
+ // MySQL 下 JSON_EXTRACT 返回 JSON,需要 JSON_UNQUOTE 再 cast;同样按分取整避免浮点误差
+ $builder->whereRaw("JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NOT NULL")
+ ->whereRaw("ABS(ROUND(CAST(JSON_UNQUOTE(JSON_EXTRACT(meta, '$.payment_summary.total_amount')) AS DECIMAL(12,2)) * 100) - ROUND(paid_amount * 100)) >= 1");
+ }
});
}
diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php
index 52152a2..07d6512 100644
--- a/resources/views/admin/platform_orders/index.blade.php
+++ b/resources/views/admin/platform_orders/index.blade.php
@@ -82,6 +82,10 @@
最近24小时批量生效过
+
@@ -176,6 +180,7 @@
+