feat(platform-orders): 增加回执状态筛选(有回执/无回执)
This commit is contained in:
@@ -138,6 +138,8 @@ class PlatformOrderController extends Controller
|
||||
'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', ''),
|
||||
// 支付回执筛选:has(有回执)/none(无回执)
|
||||
'receipt_status' => trim((string) $request->query('receipt_status', '')),
|
||||
];
|
||||
|
||||
|
||||
@@ -571,6 +573,8 @@ class PlatformOrderController extends Controller
|
||||
'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', ''),
|
||||
// 支付回执筛选:has(有回执)/none(无回执)
|
||||
'receipt_status' => trim((string) $request->query('receipt_status', '')),
|
||||
];
|
||||
|
||||
|
||||
@@ -1115,6 +1119,22 @@ class PlatformOrderController extends Controller
|
||||
// total_cents = (payment_summary.total_amount 存在 ? summary*100 : SUM(payment_receipts[].amount)*100)
|
||||
$builder->whereRaw("ABS(ROUND((CASE WHEN JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NOT NULL THEN CAST(JSON_UNQUOTE(JSON_EXTRACT(meta, '$.payment_summary.total_amount')) AS DECIMAL(12,2)) ELSE (SELECT IFNULL(SUM(j.amount), 0) FROM JSON_TABLE(meta, '$.payment_receipts[*]' COLUMNS(amount DECIMAL(12,2) PATH '$.amount')) j) END) * 100) - ROUND(paid_amount * 100)) >= 1");
|
||||
}
|
||||
})
|
||||
->when(($filters['receipt_status'] ?? '') !== '', function (Builder $builder) use ($filters) {
|
||||
// 支付回执筛选:
|
||||
// - has:有回执(payment_summary.total_amount 存在 或 payment_receipts[0].amount 存在)
|
||||
// - none:无回执(两者都不存在)
|
||||
$status = (string) ($filters['receipt_status'] ?? '');
|
||||
|
||||
if ($status === 'has') {
|
||||
$builder->where(function (Builder $q) {
|
||||
$q->whereRaw("JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NOT NULL")
|
||||
->orWhereRaw("JSON_EXTRACT(meta, '$.payment_receipts[0].amount') IS NOT NULL");
|
||||
});
|
||||
} elseif ($status === 'none') {
|
||||
$builder->whereRaw("JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NULL")
|
||||
->whereRaw("JSON_EXTRACT(meta, '$.payment_receipts[0].amount') IS NULL");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user