feat: site subscription show add reconcile mismatch orders count link
This commit is contained in:
@@ -59,6 +59,9 @@ class SiteSubscriptionController extends Controller
|
|||||||
// 订阅维度:退款不一致订单数(与平台订单列表 refund_inconsistent 口径保持一致)
|
// 订阅维度:退款不一致订单数(与平台订单列表 refund_inconsistent 口径保持一致)
|
||||||
$refundInconsistentOrders = 0;
|
$refundInconsistentOrders = 0;
|
||||||
|
|
||||||
|
// 订阅维度:对账不一致订单数(与平台订单列表 reconcile_mismatch 口径保持一致)
|
||||||
|
$reconcileMismatchOrders = 0;
|
||||||
|
|
||||||
foreach ($metaOrders as $o) {
|
foreach ($metaOrders as $o) {
|
||||||
$meta = $o->meta ?? [];
|
$meta = $o->meta ?? [];
|
||||||
|
|
||||||
@@ -71,6 +74,13 @@ class SiteSubscriptionController extends Controller
|
|||||||
$noReceiptOrders++;
|
$noReceiptOrders++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reconcile_mismatch 口径:支付回执总额 与订单 paid_amount 不一致(按分取整,差额>=0.01)
|
||||||
|
$receiptCents = (int) round($receiptTotal * 100);
|
||||||
|
$paidCents = (int) round(((float) ($o->paid_amount ?? 0)) * 100);
|
||||||
|
if (abs($receiptCents - $paidCents) >= 1) {
|
||||||
|
$reconcileMismatchOrders++;
|
||||||
|
}
|
||||||
|
|
||||||
$refundTotal = (float) $o->refundTotal();
|
$refundTotal = (float) $o->refundTotal();
|
||||||
|
|
||||||
if ($refundTotal > 0) {
|
if ($refundTotal > 0) {
|
||||||
@@ -94,6 +104,8 @@ class SiteSubscriptionController extends Controller
|
|||||||
'total_refunded_amount' => (float) $totalRefundedAmount,
|
'total_refunded_amount' => (float) $totalRefundedAmount,
|
||||||
// 退款不一致订单(订阅维度)
|
// 退款不一致订单(订阅维度)
|
||||||
'refund_inconsistent_orders' => (int) $refundInconsistentOrders,
|
'refund_inconsistent_orders' => (int) $refundInconsistentOrders,
|
||||||
|
// 对账不一致订单(订阅维度)
|
||||||
|
'reconcile_mismatch_orders' => (int) $reconcileMismatchOrders,
|
||||||
// 对账差额:回执总额 - 已付总额(订阅维度)
|
// 对账差额:回执总额 - 已付总额(订阅维度)
|
||||||
'reconciliation_delta' => (float) ($totalReceiptAmount - (float) $metaOrders->sum('paid_amount')),
|
'reconciliation_delta' => (float) ($totalReceiptAmount - (float) $metaOrders->sum('paid_amount')),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -219,6 +219,10 @@
|
|||||||
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'reconcile_mismatch' => '1']) !!}">¥{{ number_format($delta, 2) }}</a>
|
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'reconcile_mismatch' => '1']) !!}">¥{{ number_format($delta, 2) }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="muted muted-xs">点击差额可跳转:该订阅下「对账不一致」订单</div>
|
<div class="muted muted-xs">点击差额可跳转:该订阅下「对账不一致」订单</div>
|
||||||
|
<div class="muted muted-xs">
|
||||||
|
对账不一致订单:
|
||||||
|
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'reconcile_mismatch' => '1']) !!}">{{ $summaryStats['reconcile_mismatch_orders'] ?? 0 }}</a>
|
||||||
|
</div>
|
||||||
@if(abs($delta) >= 0.01)
|
@if(abs($delta) >= 0.01)
|
||||||
<div class="muted muted-xs text-danger">提示:差额非 0,可能存在回执金额与订单已付金额不一致。</div>
|
<div class="muted muted-xs text-danger">提示:差额非 0,可能存在回执金额与订单已付金额不一致。</div>
|
||||||
@else
|
@else
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ class AdminSiteSubscriptionShowTest extends TestCase
|
|||||||
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&refund_inconsistent=1', false)
|
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&refund_inconsistent=1', false)
|
||||||
->assertSee('对账差额(回执-已付)')
|
->assertSee('对账差额(回执-已付)')
|
||||||
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&reconcile_mismatch=1', false)
|
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&reconcile_mismatch=1', false)
|
||||||
|
->assertSee('对账不一致订单:')
|
||||||
->assertSee('关联平台订单')
|
->assertSee('关联平台订单')
|
||||||
->assertSee('PO_SUB_SHOW_0001')
|
->assertSee('PO_SUB_SHOW_0001')
|
||||||
->assertSee('同步时间')
|
->assertSee('同步时间')
|
||||||
|
|||||||
Reference in New Issue
Block a user