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')),
|
||||
];
|
||||
|
||||
@@ -199,6 +199,10 @@
|
||||
无退款订单:
|
||||
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'refund_status' => 'none']) !!}">{{ $summaryStats['no_refund_orders'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
退款不一致订单:
|
||||
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'refund_inconsistent' => '1']) !!}">{{ $summaryStats['refund_inconsistent_orders'] ?? 0 }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
@@ -130,6 +130,7 @@ class AdminSiteSubscriptionShowTest extends TestCase
|
||||
->assertSee('有退款订单 / 退款总额')
|
||||
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&refund_status=has', false)
|
||||
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&refund_status=none', false)
|
||||
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&refund_inconsistent=1', false)
|
||||
->assertSee('对账差额(回执-已付)')
|
||||
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&reconcile_mismatch=1', false)
|
||||
->assertSee('关联平台订单')
|
||||
|
||||
Reference in New Issue
Block a user