Dashboard scanline: treat partially_refunded as refundable for refund trace
This commit is contained in:
@@ -858,8 +858,11 @@
|
|||||||
|
|
||||||
// 运营扫描用的“治理状态摘要”(不替代下方的治理提示入口,只用于快速判断)
|
// 运营扫描用的“治理状态摘要”(不替代下方的治理提示入口,只用于快速判断)
|
||||||
// 注意:为避免对“未支付订单”造成误导,回执/对账/退款在非 paid/refunded 时显示 "-"。
|
// 注意:为避免对“未支付订单”造成误导,回执/对账/退款在非 paid/refunded 时显示 "-"。
|
||||||
$isPaid = ((string) $po->payment_status === 'paid');
|
$paymentStatus = (string) ($po->payment_status ?? '');
|
||||||
$isRefunded = ((string) $po->payment_status === 'refunded');
|
$isPaid = ($paymentStatus === 'paid');
|
||||||
|
$isRefunded = ($paymentStatus === 'refunded');
|
||||||
|
// partially_refunded 属于“已支付但发生退款”的治理集合:扫描行应展示退款轨迹(避免显示 "-" 造成误判)。
|
||||||
|
$isPartiallyRefunded = ($paymentStatus === 'partially_refunded');
|
||||||
|
|
||||||
$receiptStatusText = $isPaid ? ($hasReceiptEvidence ? '有' : '无') : '-';
|
$receiptStatusText = $isPaid ? ($hasReceiptEvidence ? '有' : '无') : '-';
|
||||||
$reconcileStatusText = ($isPaid && $hasReceiptEvidence)
|
$reconcileStatusText = ($isPaid && $hasReceiptEvidence)
|
||||||
@@ -872,7 +875,7 @@
|
|||||||
// - 有退款且一致:"有"(直达 #add-refund-receipt,便于核对退款轨迹)
|
// - 有退款且一致:"有"(直达 #add-refund-receipt,便于核对退款轨迹)
|
||||||
// - 无退款:"无"
|
// - 无退款:"无"
|
||||||
$hasRefundTrace = ((float) $po->refundTotal()) > 0;
|
$hasRefundTrace = ((float) $po->refundTotal()) > 0;
|
||||||
$refundStatusText = ($isPaid || $isRefunded)
|
$refundStatusText = ($isPaid || $isRefunded || $isPartiallyRefunded)
|
||||||
? ($po->isRefundInconsistent() ? '异常' : ($hasRefundTrace ? '有' : '无'))
|
? ($po->isRefundInconsistent() ? '异常' : ($hasRefundTrace ? '有' : '无'))
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminDashboardRecentPlatformOrdersScanlineShouldShowRefundTraceWhenPartiallyRefundedTest 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_dashboard_recent_platform_orders_scanline_should_show_refund_trace_when_partially_refunded(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
// 清理 seed 订单,避免最近订单列表被 seed 污染导致断言不稳定。
|
||||||
|
PlatformOrder::query()->delete();
|
||||||
|
|
||||||
|
$merchantId = (int) Merchant::query()->value('id');
|
||||||
|
$platformAdminId = (int) Admin::query()->where('email', 'platform.admin@demo.local')->value('id');
|
||||||
|
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchantId,
|
||||||
|
'plan_id' => null,
|
||||||
|
'site_subscription_id' => null,
|
||||||
|
'created_by_admin_id' => $platformAdminId ?: null,
|
||||||
|
'order_no' => 'PO_DASH_SCANLINE_PARTIAL_REFUND_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'pending',
|
||||||
|
'payment_status' => 'partially_refunded',
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'refund_summary' => [
|
||||||
|
'total_amount' => 1,
|
||||||
|
'count' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$res->assertSee('PO_DASH_SCANLINE_PARTIAL_REFUND_0001');
|
||||||
|
|
||||||
|
// partially_refunded 也应展示退款轨迹(不应为 "-")
|
||||||
|
$res->assertSee('退款:', false);
|
||||||
|
$res->assertSee('<strong>有</strong>', false);
|
||||||
|
|
||||||
|
// 并保持最短治理入口:直达 add-refund-receipt
|
||||||
|
$res->assertSee('#add-refund-receipt', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user