feat: site subscription show add refund_inconsistent summary link
This commit is contained in:
@@ -56,6 +56,9 @@ class SiteSubscriptionController extends Controller
|
||||
$refundOrders = 0;
|
||||
$noRefundOrders = 0;
|
||||
|
||||
// 订阅维度:退款不一致订单数(与平台订单列表 refund_inconsistent 口径保持一致)
|
||||
$refundInconsistentOrders = 0;
|
||||
|
||||
foreach ($metaOrders as $o) {
|
||||
$meta = $o->meta ?? [];
|
||||
|
||||
@@ -88,6 +91,26 @@ class SiteSubscriptionController extends Controller
|
||||
} else {
|
||||
$noRefundOrders++;
|
||||
}
|
||||
|
||||
// refund_inconsistent 口径:
|
||||
// 1) payment_status=refunded 但 refund_total < paid_amount(按分取整 + 0.01 容差)
|
||||
// 2) payment_status!=refunded 且 paid_amount>0 且 refund_total >= paid_amount
|
||||
$paidAmount = (float) ($o->paid_amount ?? 0);
|
||||
$paymentStatus = (string) ($o->payment_status ?? '');
|
||||
$refundTotalCents = (int) round($refundTotal * 100);
|
||||
$paidCents = (int) round($paidAmount * 100);
|
||||
|
||||
$isRefundInconsistent = false;
|
||||
if ($paymentStatus === 'refunded') {
|
||||
// 允许 0.01 容差:refund_total + 0.01 < paid
|
||||
$isRefundInconsistent = ($refundTotalCents + 1) < $paidCents;
|
||||
} else {
|
||||
$isRefundInconsistent = $paidCents > 0 && $refundTotalCents >= $paidCents;
|
||||
}
|
||||
|
||||
if ($isRefundInconsistent) {
|
||||
$refundInconsistentOrders++;
|
||||
}
|
||||
}
|
||||
|
||||
$summaryStats = $summaryStats + [
|
||||
@@ -97,6 +120,8 @@ class SiteSubscriptionController extends Controller
|
||||
'refund_orders' => $refundOrders,
|
||||
'no_refund_orders' => $noRefundOrders,
|
||||
'total_refunded_amount' => (float) $totalRefundedAmount,
|
||||
// 退款不一致订单(订阅维度)
|
||||
'refund_inconsistent_orders' => (int) $refundInconsistentOrders,
|
||||
// 对账差额:回执总额 - 已付总额(订阅维度)
|
||||
'reconciliation_delta' => (float) ($totalReceiptAmount - (float) $metaOrders->sum('paid_amount')),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user