平台订单列表:差额/退款金额链接带 back 并直达区块
This commit is contained in:
@@ -935,15 +935,15 @@
|
|||||||
$rowDelta = (float) ($order->reconciliation_delta_row ?? 0);
|
$rowDelta = (float) ($order->reconciliation_delta_row ?? 0);
|
||||||
// 统一口径:按分取整判断是否对账不一致,避免浮点误差导致 0.01 边界不稳定
|
// 统一口径:按分取整判断是否对账不一致,避免浮点误差导致 0.01 边界不稳定
|
||||||
$isReconcileMismatchRow = (bool) $order->isReconcileMismatch();
|
$isReconcileMismatchRow = (bool) $order->isReconcileMismatch();
|
||||||
$reconcileShowUrl = '/admin/platform-orders/' . $order->id . '#payment-receipts';
|
$reconcileShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#payment-receipts';
|
||||||
@endphp
|
@endphp
|
||||||
@if($isReconcileMismatchRow)
|
@if($isReconcileMismatchRow)
|
||||||
@php $reconcileFixUrl = '/admin/platform-orders/' . $order->id . '#add-payment-receipt'; @endphp
|
@php $reconcileFixUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#add-payment-receipt'; @endphp
|
||||||
<a class="link text-danger" href="{{ $reconcileShowUrl }}">¥{{ number_format($rowDelta, 2) }}</a>
|
<a class="link text-danger" href="{!! $reconcileShowUrl !!}">¥{{ number_format($rowDelta, 2) }}</a>
|
||||||
<div class="muted text-danger muted-xs">
|
<div class="muted text-danger muted-xs">
|
||||||
对账不一致
|
对账不一致
|
||||||
<span class="muted">|</span>
|
<span class="muted">|</span>
|
||||||
<a class="link" href="{{ $reconcileFixUrl }}">去补回执</a>
|
<a class="link" href="{!! $reconcileFixUrl !!}">去补回执</a>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<span class="muted">¥0.00</span>
|
<span class="muted">¥0.00</span>
|
||||||
@@ -984,23 +984,23 @@
|
|||||||
$refundTotal = (float) $order->refundTotal();
|
$refundTotal = (float) $order->refundTotal();
|
||||||
$isRefundInconsistent = (bool) $order->isRefundInconsistent();
|
$isRefundInconsistent = (bool) $order->isRefundInconsistent();
|
||||||
|
|
||||||
$refundShowUrl = '/admin/platform-orders/' . $order->id . '#refund-receipts';
|
$refundShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#refund-receipts';
|
||||||
@endphp
|
@endphp
|
||||||
@if($refundTotal > 0)
|
@if($refundTotal > 0)
|
||||||
@if($isRefundInconsistent)
|
@if($isRefundInconsistent)
|
||||||
@php $refundFixUrl = '/admin/platform-orders/' . $order->id . '#refund-receipts'; @endphp
|
@php $refundFixUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#refund-receipts'; @endphp
|
||||||
<a class="link text-danger" href="{{ $refundShowUrl }}">¥{{ number_format($refundTotal, 2) }}</a>
|
<a class="link text-danger" href="{!! $refundShowUrl !!}">¥{{ number_format($refundTotal, 2) }}</a>
|
||||||
<div class="muted text-danger muted-xs">
|
<div class="muted text-danger muted-xs">
|
||||||
疑似不一致
|
疑似不一致
|
||||||
<span class="muted">|</span>
|
<span class="muted">|</span>
|
||||||
<a class="link" href="{{ $refundFixUrl }}">去核对退款</a>
|
<a class="link" href="{!! $refundFixUrl !!}">去核对退款</a>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<a class="muted" href="{{ $refundShowUrl }}">¥{{ number_format($refundTotal, 2) }}</a>
|
<a class="muted" href="{!! $refundShowUrl !!}">¥{{ number_format($refundTotal, 2) }}</a>
|
||||||
@endif
|
@endif
|
||||||
@else
|
@else
|
||||||
@if($isRefundInconsistent)
|
@if($isRefundInconsistent)
|
||||||
<a class="link text-danger" href="{{ $refundShowUrl }}">-</a>
|
<a class="link text-danger" href="{!! $refundShowUrl !!}">-</a>
|
||||||
<div class="muted text-danger muted-xs">疑似不一致</div>
|
<div class="muted text-danger muted-xs">疑似不一致</div>
|
||||||
@else
|
@else
|
||||||
<span class="muted">-</span>
|
<span class="muted">-</span>
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexReconcileRefundDeltaLinksContainBackTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->post('/admin/login', [
|
||||||
|
'email' => 'platform.admin@demo.local',
|
||||||
|
'password' => 'Platform@123456',
|
||||||
|
])->assertRedirect('/admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_reconcile_delta_and_refund_total_links_should_carry_back_and_anchor(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'po_index_delta_refund_back_plan',
|
||||||
|
'name' => '平台订单列表差额/退款总额 back 链接测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$order = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_INDEX_DELTA_BACK_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'unpaid',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
// 制造对账不一致(receipt_total != paid_amount)
|
||||||
|
'payment_summary' => ['count' => 1, 'total' => 9],
|
||||||
|
'payment_receipts' => [
|
||||||
|
['amount' => 9, 'paid_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'],
|
||||||
|
],
|
||||||
|
// 制造退款轨迹
|
||||||
|
'refund_summary' => ['count' => 1, 'total' => 1],
|
||||||
|
'refund_receipts' => [
|
||||||
|
['amount' => 1, 'refunded_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?status=pending&back=' . urlencode('/admin/plans'));
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$indexSelfWithoutBack = '/admin/platform-orders?' . Arr::query([
|
||||||
|
'status' => 'pending',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$reconcileShowUrl = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
|
||||||
|
'back' => $indexSelfWithoutBack,
|
||||||
|
]) . '#payment-receipts';
|
||||||
|
|
||||||
|
$reconcileFixUrl = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
|
||||||
|
'back' => $indexSelfWithoutBack,
|
||||||
|
]) . '#add-payment-receipt';
|
||||||
|
|
||||||
|
$refundShowUrl = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
|
||||||
|
'back' => $indexSelfWithoutBack,
|
||||||
|
]) . '#refund-receipts';
|
||||||
|
|
||||||
|
$res->assertSee($reconcileShowUrl, false);
|
||||||
|
$res->assertSee($reconcileFixUrl, false);
|
||||||
|
$res->assertSee($refundShowUrl, false);
|
||||||
|
|
||||||
|
$res->assertDontSee('back%3D', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user