From f258aab657229877f270417bd24dcf2dc8208014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 10 Mar 2026 23:48:28 +0000 Subject: [PATCH] =?UTF-8?q?feat(platform-orders):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E8=BD=A8=E8=BF=B9=E7=AD=9B=E9=80=89=20refund?= =?UTF-8?q?=5Fstatus=EF=BC=88=E5=90=ABUI/=E5=AF=BC=E5=87=BA/=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E9=80=8F=E4=BC=A0/=E6=B5=8B=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/PlatformOrderController.php | 23 ++++ .../admin/platform_orders/index.blade.php | 14 ++ ...minPlatformOrderRefundStatusFilterTest.php | 122 ++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderRefundStatusFilterTest.php diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index a424763..e05dfb5 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -140,6 +140,8 @@ class PlatformOrderController extends Controller 'reconcile_mismatch' => (string) $request->query('reconcile_mismatch', ''), // 支付回执筛选:has(有回执)/none(无回执) 'receipt_status' => trim((string) $request->query('receipt_status', '')), + // 退款轨迹筛选:has(有退款)/none(无退款) + 'refund_status' => trim((string) $request->query('refund_status', '')), ]; @@ -591,6 +593,8 @@ class PlatformOrderController extends Controller 'reconcile_mismatch' => (string) $request->query('reconcile_mismatch', ''), // 支付回执筛选:has(有回执)/none(无回执) 'receipt_status' => trim((string) $request->query('receipt_status', '')), + // 退款轨迹筛选:has(有退款)/none(无退款) + 'refund_status' => trim((string) $request->query('refund_status', '')), ]; @@ -771,6 +775,7 @@ class PlatformOrderController extends Controller 'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''), 'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''), 'receipt_status' => trim((string) $request->input('receipt_status', '')), + 'refund_status' => trim((string) $request->input('refund_status', '')), ]; // 防误操作:批量同步默认要求先勾选“只看可同步”,避免无意识扩大处理范围 @@ -901,6 +906,7 @@ class PlatformOrderController extends Controller 'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''), 'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''), 'receipt_status' => trim((string) $request->input('receipt_status', '')), + 'refund_status' => trim((string) $request->input('refund_status', '')), ]; // 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending)」 @@ -1009,6 +1015,7 @@ class PlatformOrderController extends Controller 'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''), 'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''), 'receipt_status' => trim((string) $request->input('receipt_status', '')), + 'refund_status' => trim((string) $request->input('refund_status', '')), ]; $query = PlatformOrder::query() @@ -1168,6 +1175,22 @@ class PlatformOrderController extends Controller $builder->whereRaw("JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NULL") ->whereRaw("JSON_EXTRACT(meta, '$.payment_receipts[0].amount') IS NULL"); } + }) + ->when(($filters['refund_status'] ?? '') !== '', function (Builder $builder) use ($filters) { + // 退款轨迹筛选: + // - has:有退款(refund_summary.total_amount 存在 或 refund_receipts[0].amount 存在) + // - none:无退款(两者都不存在) + $status = (string) ($filters['refund_status'] ?? ''); + + if ($status === 'has') { + $builder->where(function (Builder $q) { + $q->whereRaw("JSON_EXTRACT(meta, '$.refund_summary.total_amount') IS NOT NULL") + ->orWhereRaw("JSON_EXTRACT(meta, '$.refund_receipts[0].amount') IS NOT NULL"); + }); + } elseif ($status === 'none') { + $builder->whereRaw("JSON_EXTRACT(meta, '$.refund_summary.total_amount') IS NULL") + ->whereRaw("JSON_EXTRACT(meta, '$.refund_receipts[0].amount') IS NULL"); + } }); } diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 94b4398..7996f28 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -29,6 +29,10 @@ 无回执 + 有退款 + + 无退款 + 对账不一致 @@ -71,6 +75,11 @@ +