platform orders: show bmpa error message in row and link to filter
This commit is contained in:
@@ -771,8 +771,19 @@
|
|||||||
@php
|
@php
|
||||||
$syncErrMsg = (string) (data_get($order->meta, 'subscription_activation_error.message') ?? '');
|
$syncErrMsg = (string) (data_get($order->meta, 'subscription_activation_error.message') ?? '');
|
||||||
$syncErrTooLong = $syncErrMsg !== '' && mb_strlen($syncErrMsg) > $SYNC_ERROR_KEYWORD_LINK_MAX_LEN;
|
$syncErrTooLong = $syncErrMsg !== '' && mb_strlen($syncErrMsg) > $SYNC_ERROR_KEYWORD_LINK_MAX_LEN;
|
||||||
|
|
||||||
|
$bmpaErrMsg = (string) (data_get($order->meta, 'batch_mark_paid_and_activate_error.message') ?? '');
|
||||||
|
$bmpaErrTooLong = $bmpaErrMsg !== '' && mb_strlen($bmpaErrMsg) > $SYNC_ERROR_KEYWORD_LINK_MAX_LEN;
|
||||||
|
|
||||||
|
$hasAnyErr = ($syncErrMsg !== '') || ($bmpaErrMsg !== '');
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
@if(! $hasAnyErr)
|
||||||
|
<span class="muted">-</span>
|
||||||
|
@else
|
||||||
@if($syncErrMsg !== '')
|
@if($syncErrMsg !== '')
|
||||||
|
<div>
|
||||||
|
<span class="muted muted-xs">同步:</span>
|
||||||
@if($syncErrTooLong)
|
@if($syncErrTooLong)
|
||||||
<span class="muted text-danger" title="{{ $syncErrMsg }}">{{ mb_substr($syncErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</span>
|
<span class="muted text-danger" title="{{ $syncErrMsg }}">{{ mb_substr($syncErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</span>
|
||||||
<div class="muted text-danger muted-xs">原因过长,请复制到筛选框</div>
|
<div class="muted text-danger muted-xs">原因过长,请复制到筛选框</div>
|
||||||
@@ -780,8 +791,21 @@
|
|||||||
@else
|
@else
|
||||||
<a class="link text-danger" href="{!! request()->fullUrlWithQuery(['sync_error_keyword' => $syncErrMsg, 'sync_status' => 'failed', 'page' => null]) !!}">{{ mb_substr($syncErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</a>
|
<a class="link text-danger" href="{!! request()->fullUrlWithQuery(['sync_error_keyword' => $syncErrMsg, 'sync_status' => 'failed', 'page' => null]) !!}">{{ mb_substr($syncErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</a>
|
||||||
@endif
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($bmpaErrMsg !== '')
|
||||||
|
<div class="mt-6">
|
||||||
|
<span class="muted muted-xs">BMPA:</span>
|
||||||
|
@if($bmpaErrTooLong)
|
||||||
|
<span class="muted text-danger" title="{{ $bmpaErrMsg }}">{{ mb_substr($bmpaErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</span>
|
||||||
|
<div class="muted text-danger muted-xs">原因过长,请复制到筛选框</div>
|
||||||
|
<a class="link" href="{{ request()->fullUrlWithQuery(['bmpa_failed_only' => '1', 'page' => null]) }}">进入批量标记支付失败集合</a>
|
||||||
@else
|
@else
|
||||||
<span class="muted">-</span>
|
<a class="link text-danger" href="{!! request()->fullUrlWithQuery(['bmpa_error_keyword' => $bmpaErrMsg, 'page' => null]) !!}">{{ mb_substr($bmpaErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
72
tests/Feature/AdminPlatformOrderRowBmpaErrorLinkTest.php
Normal file
72
tests/Feature/AdminPlatformOrderRowBmpaErrorLinkTest.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderRowBmpaErrorLinkTest 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_row_bmpa_error_message_is_clickable_to_filter_by_bmpa_error_keyword(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'row_bmpa_error_link_plan',
|
||||||
|
'name' => '行BMPA失败原因链接测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$reason = '回执总额与应付金额不一致';
|
||||||
|
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_ROW_BMPA_ERR_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' => 0,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'batch_mark_paid_and_activate_error' => [
|
||||||
|
'message' => $reason,
|
||||||
|
'at' => now()->toDateTimeString(),
|
||||||
|
'admin_id' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$res->assertSee('BMPA:');
|
||||||
|
$res->assertSee('/admin/platform-orders?bmpa_error_keyword=' . urlencode($reason), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user