feat: 退款待确认迁入费比异常数据监控
This commit is contained in:
parent
eaac7c68c4
commit
5c8db5a586
@ -989,6 +989,16 @@ class Pages extends Controller
|
||||
return redirect()->to($url . ($query === null ? '' : '?' . $query));
|
||||
}
|
||||
|
||||
if ($section === 'refunds' && $page === 'refund-pending') {
|
||||
$url = route('business.pages.show', [
|
||||
'section' => 'fee-ratio-monitoring',
|
||||
'page' => 'refund-pending',
|
||||
]);
|
||||
$query = request()->getQueryString();
|
||||
|
||||
return redirect()->to($url . ($query === null ? '' : '?' . $query));
|
||||
}
|
||||
|
||||
if ($section === 'billing-transactions' && in_array($page, self::ACCOUNT_BALANCE_PAGES, true)) {
|
||||
$url = route('business.pages.show', array_filter([
|
||||
'section' => self::ACCOUNT_BALANCE_SECTION,
|
||||
@ -7175,7 +7185,7 @@ class Pages extends Controller
|
||||
'refundError' => $error,
|
||||
'refundPending' => $pending,
|
||||
'refundIndexPending' => $indexPending,
|
||||
'refundPageSection' => 'refunds',
|
||||
'refundPageSection' => $pendingConfirmation ? 'fee-ratio-monitoring' : 'refunds',
|
||||
'refundPageSlug' => $pendingConfirmation ? 'refund-pending' : 'non-jingxi-refund-data',
|
||||
'refundPageLabel' => $pageLabel,
|
||||
'refundPendingConfirmationMode' => $pendingConfirmation,
|
||||
@ -7221,7 +7231,7 @@ class Pages extends Controller
|
||||
{
|
||||
return $this->exportRefundRows(
|
||||
$request,
|
||||
'refunds',
|
||||
'fee-ratio-monitoring',
|
||||
'refund-pending',
|
||||
'refund_pending',
|
||||
true,
|
||||
|
||||
@ -54,6 +54,7 @@ class SidebarMenu
|
||||
['prototype-finance-reports', 'asset-report', '公司资产报表', 'account_balance'],
|
||||
]],
|
||||
['title' => '费比异常数据监控', 'items' => [
|
||||
['fee-ratio-monitoring', 'refund-pending', '退款待确认', 'assignment_return'],
|
||||
['fee-ratio-monitoring', 'overview', '异常数据监控', 'monitor_heart'],
|
||||
]],
|
||||
];
|
||||
|
||||
@ -11,6 +11,8 @@ class SidebarPermissions
|
||||
{
|
||||
private const LEGACY_PAGE_KEYS = [
|
||||
'refunds/small-payment-work-orders' => 'financial-operations/small-payment-work-orders',
|
||||
'refunds/refund-pending' => 'fee-ratio-monitoring/refund-pending',
|
||||
'refunds/refund-pending/export-details' => 'fee-ratio-monitoring/refund-pending/export-details',
|
||||
'financial-ledger' => 'financial-operations/ledger',
|
||||
'financial-ledger/ledger' => 'financial-operations/ledger',
|
||||
];
|
||||
@ -66,17 +68,13 @@ class SidebarPermissions
|
||||
$settings = self::settings();
|
||||
$userSubject = 'user_' . $user->id;
|
||||
if (in_array($userSubject, $settings['configured'] ?? [], true)) {
|
||||
return self::withFinanceMonitoringAccess(
|
||||
self::normalizeAllowedKeys((array) ($settings['subjects'][$userSubject] ?? [])),
|
||||
);
|
||||
return self::normalizeAllowedKeys((array) ($settings['subjects'][$userSubject] ?? []));
|
||||
}
|
||||
|
||||
$groups = UserAccessGroup::forUser($user);
|
||||
if ($groups->isNotEmpty()) {
|
||||
return self::withFinanceMonitoringAccess(
|
||||
self::normalizeAllowedKeys(
|
||||
$groups->flatMap(fn ($group) => $group->page_permissions ?? [])->all()
|
||||
),
|
||||
return self::normalizeAllowedKeys(
|
||||
$groups->flatMap(fn ($group) => $group->page_permissions ?? [])->all()
|
||||
);
|
||||
}
|
||||
|
||||
@ -86,19 +84,7 @@ class SidebarPermissions
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::withFinanceMonitoringAccess(
|
||||
self::normalizeAllowedKeys((array) ($settings['subjects'][$subject] ?? [])),
|
||||
);
|
||||
}
|
||||
|
||||
/** @param list<string> $allowed */
|
||||
private static function withFinanceMonitoringAccess(array $allowed): array
|
||||
{
|
||||
if (! in_array('fee-ratio-monitoring/overview', $allowed, true)) {
|
||||
$allowed[] = 'fee-ratio-monitoring/overview';
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
return self::normalizeAllowedKeys((array) ($settings['subjects'][$subject] ?? []));
|
||||
}
|
||||
|
||||
public static function hasLimitedDingTalkAccess(User $user): bool
|
||||
@ -437,6 +423,8 @@ class SidebarPermissions
|
||||
|
||||
if ($key === 'refunds') {
|
||||
$normalized[] = self::LEGACY_PAGE_KEYS['refunds/small-payment-work-orders'];
|
||||
$normalized[] = 'fee-ratio-monitoring/refund-pending';
|
||||
$normalized[] = 'fee-ratio-monitoring/refund-pending/export-details';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -673,17 +673,6 @@ $navigation = [
|
||||
'pages' => [
|
||||
['slug' => 'jingxi-refund-data', 'title' => '京喜退款数据'],
|
||||
['slug' => 'non-jingxi-refund-data', 'title' => '售后(退货退款)'],
|
||||
[
|
||||
'slug' => 'refund-pending',
|
||||
'title' => '退款待确认',
|
||||
'operations' => [
|
||||
[
|
||||
'slug' => 'export-details',
|
||||
'title' => '导出明细',
|
||||
'description' => '允许查看导出按钮并下载全部待确认明细。',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
@ -1042,6 +1031,17 @@ $navigation = [
|
||||
'title' => '费比异常数据监控',
|
||||
'icon' => 'monitor_heart',
|
||||
'pages' => [
|
||||
[
|
||||
'slug' => 'refund-pending',
|
||||
'title' => '退款待确认',
|
||||
'operations' => [
|
||||
[
|
||||
'slug' => 'export-details',
|
||||
'title' => '导出明细',
|
||||
'description' => '允许查看导出按钮并下载全部待确认明细。',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'slug' => 'overview',
|
||||
'title' => '异常数据监控',
|
||||
|
||||
@ -325,7 +325,7 @@
|
||||
@endif
|
||||
</div>
|
||||
<a class="cockpit__risk-link" href="{{ route('business.pages.show', [
|
||||
'section' => 'refunds',
|
||||
'section' => 'fee-ratio-monitoring',
|
||||
'page' => 'refund-pending',
|
||||
]) }}">查看退款待确认</a>
|
||||
</div>
|
||||
|
||||
@ -484,17 +484,35 @@ Route::get('workspace/refunds/non-jingxi-refund-data/export', 'Business\Pages@ex
|
||||
->middleware('business.page:refunds,non-jingxi-refund-data')
|
||||
->name('business.refunds.non-jingxi-refund-data.export');
|
||||
|
||||
Route::get('workspace/refunds/refund-pending/export', 'Business\Pages@exportRefundPending')
|
||||
Route::get('workspace/fee-ratio-monitoring/refund-pending/export', 'Business\Pages@exportRefundPending')
|
||||
->middleware([
|
||||
'business.page:refunds,refund-pending',
|
||||
'business.operation:refunds,refund-pending,export-details',
|
||||
'business.page:fee-ratio-monitoring,refund-pending',
|
||||
'business.operation:fee-ratio-monitoring,refund-pending,export-details',
|
||||
])
|
||||
->name('business.refunds.refund-pending.export');
|
||||
|
||||
Route::get('workspace/refunds/refund-pending/month-details', 'Business\Pages@refundPendingMonthDetails')
|
||||
->middleware('business.page:refunds,refund-pending')
|
||||
Route::get('workspace/fee-ratio-monitoring/refund-pending/month-details', 'Business\Pages@refundPendingMonthDetails')
|
||||
->middleware('business.page:fee-ratio-monitoring,refund-pending')
|
||||
->name('business.refunds.refund-pending.month-details');
|
||||
|
||||
Route::get('workspace/refunds/refund-pending/export', function () {
|
||||
$url = route('business.refunds.refund-pending.export', [
|
||||
'company_id' => request()->route('company_id'),
|
||||
]);
|
||||
$query = request()->getQueryString();
|
||||
|
||||
return redirect()->to($url . ($query === null ? '' : '?' . $query));
|
||||
})->name('business.refunds.refund-pending.legacy-export');
|
||||
|
||||
Route::get('workspace/refunds/refund-pending/month-details', function () {
|
||||
$url = route('business.refunds.refund-pending.month-details', [
|
||||
'company_id' => request()->route('company_id'),
|
||||
]);
|
||||
$query = request()->getQueryString();
|
||||
|
||||
return redirect()->to($url . ($query === null ? '' : '?' . $query));
|
||||
})->name('business.refunds.refund-pending.legacy-month-details');
|
||||
|
||||
Route::get('workspace/other/after-sales-return-refund/export', 'Business\Pages@exportAfterSalesReturnRefunds')
|
||||
->middleware('business.page:other,after-sales-return-refund')
|
||||
->name('business.other.after-sales-return-refund.export');
|
||||
|
||||
@ -181,7 +181,7 @@ class NonJingxiRefundPageTest extends FeatureTestCase
|
||||
$this->app->instance(NonJingxiRefundMirrorRepository::class, $repository);
|
||||
|
||||
$response = $this->loginAs()->get(route('business.pages.show', [
|
||||
'section' => 'refunds',
|
||||
'section' => 'fee-ratio-monitoring',
|
||||
'page' => 'refund-pending',
|
||||
'from' => '2026-11-01',
|
||||
'to' => '2026-11-04',
|
||||
@ -211,7 +211,7 @@ class NonJingxiRefundPageTest extends FeatureTestCase
|
||||
->assertDontSee('data-refund-month-export', false)
|
||||
->assertSee('data-refund-page="pending-confirmation"', false)
|
||||
->assertSee('data-refund-month-summary', false)
|
||||
->assertSee('workspace/refunds/refund-pending/month-details', false);
|
||||
->assertSee('workspace/fee-ratio-monitoring/refund-pending/month-details', false);
|
||||
}
|
||||
|
||||
public function test_refund_pending_hides_export_and_blocks_export_url_without_operation_permission(): void
|
||||
@ -219,7 +219,7 @@ class NonJingxiRefundPageTest extends FeatureTestCase
|
||||
$this->grantAdminPermission();
|
||||
$this->user->syncRoles([Role::where('name', 'user')->firstOrFail()->id]);
|
||||
$subject = 'user_' . $this->user->id;
|
||||
$pageKey = 'refunds/refund-pending';
|
||||
$pageKey = 'fee-ratio-monitoring/refund-pending';
|
||||
setting()->set('system.sidebar_permissions', [
|
||||
'configured' => [$subject],
|
||||
'subjects' => [$subject => [$pageKey]],
|
||||
@ -244,15 +244,15 @@ class NonJingxiRefundPageTest extends FeatureTestCase
|
||||
->andReturn(['months' => [], 'platforms' => []]);
|
||||
$this->app->instance(NonJingxiRefundMirrorRepository::class, $repository);
|
||||
|
||||
$this->assertFalse(BusinessOperationPermissions::can('refunds', 'refund-pending', 'export-details', $this->user));
|
||||
$this->assertFalse(BusinessOperationPermissions::can('fee-ratio-monitoring', 'refund-pending', 'export-details', $this->user));
|
||||
$this->loginAs()->get(route('business.pages.show', [
|
||||
'section' => 'refunds',
|
||||
'section' => 'fee-ratio-monitoring',
|
||||
'page' => 'refund-pending',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertDontSeeText('导出全部明细')
|
||||
->assertDontSee('data-refund-all-export', false)
|
||||
->assertDontSee('workspace/refunds/refund-pending/export', false);
|
||||
->assertDontSee('workspace/fee-ratio-monitoring/refund-pending/export', false);
|
||||
|
||||
$this->withExceptionHandling()
|
||||
->get(route('business.refunds.refund-pending.export'))
|
||||
|
||||
@ -80,7 +80,9 @@ class PagesTest extends FeatureTestCase
|
||||
->assertSeeText('淘系退款清单')
|
||||
->assertSeeText('同步失败,已保留上次成功数据')
|
||||
->assertSeeText('PDOException')
|
||||
->assertSeeText('查看退款待确认');
|
||||
->assertSeeText('查看退款待确认')
|
||||
->assertSee('/workspace/fee-ratio-monitoring/refund-pending', false)
|
||||
->assertDontSee('/workspace/refunds/refund-pending', false);
|
||||
}
|
||||
|
||||
public function testLogStatisticsPageIsAvailableUnderOther(): void
|
||||
|
||||
@ -22,7 +22,8 @@ class NavigationTest extends FeatureTestCase
|
||||
->assertSee('/workspace/order-profit', false)
|
||||
->assertSeeText('订单利润')
|
||||
->assertSee('/workspace/refunds/non-jingxi-refund-data', false)
|
||||
->assertSee('/workspace/refunds/refund-pending', false)
|
||||
->assertDontSee('/workspace/refunds/refund-pending', false)
|
||||
->assertSee('/workspace/fee-ratio-monitoring/refund-pending', false)
|
||||
->assertSee('/workspace/product-inventory/normal-products', false)
|
||||
->assertSee('/workspace/product-inventory/monthly-weighted-average-price', false)
|
||||
->assertSee('/workspace/product-inventory/inventory-report', false);
|
||||
@ -43,7 +44,7 @@ class NavigationTest extends FeatureTestCase
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
'section' => 'refunds',
|
||||
'section' => 'fee-ratio-monitoring',
|
||||
'page' => 'refund-pending',
|
||||
]))
|
||||
->assertOk()
|
||||
@ -52,6 +53,19 @@ class NavigationTest extends FeatureTestCase
|
||||
->assertSeeText('数据来自聚水潭售后共享镜像');
|
||||
}
|
||||
|
||||
public function testLegacyRefundPendingUrlRedirectsToFeeRatioMonitoring(): void
|
||||
{
|
||||
$this->loginAs()
|
||||
->get('/1/workspace/refunds/refund-pending?from=2026-10-01')
|
||||
->assertRedirect('/1/workspace/fee-ratio-monitoring/refund-pending?from=2026-10-01');
|
||||
|
||||
$this->get('/1/workspace/refunds/refund-pending/month-details?month=2026-10')
|
||||
->assertRedirect('/1/workspace/fee-ratio-monitoring/refund-pending/month-details?month=2026-10');
|
||||
|
||||
$this->get('/1/workspace/refunds/refund-pending/export?from=2026-10-01&to=2026-10-31')
|
||||
->assertRedirect('/1/workspace/fee-ratio-monitoring/refund-pending/export?from=2026-10-01&to=2026-10-31');
|
||||
}
|
||||
|
||||
public function testInventoryReportMenuPageIsAvailable(): void
|
||||
{
|
||||
$this->loginAs()
|
||||
@ -288,14 +302,22 @@ class NavigationTest extends FeatureTestCase
|
||||
$this->assertNotNull($section);
|
||||
$this->assertSame('费比异常数据监控', $section['title']);
|
||||
$this->assertSame('monitor_heart', $section['icon']);
|
||||
$this->assertSame('异常数据监控', $section['pages'][0]['title']);
|
||||
$this->assertSame('待接入', $section['pages'][0]['directory']['status']);
|
||||
$this->assertSame(
|
||||
['refund-pending', 'overview'],
|
||||
array_column($section['pages'], 'slug'),
|
||||
);
|
||||
$this->assertSame(
|
||||
['退款待确认', '异常数据监控'],
|
||||
array_column($section['pages'], 'title'),
|
||||
);
|
||||
$this->assertSame('待接入', $section['pages'][1]['directory']['status']);
|
||||
|
||||
$sidebarGroup = collect(SidebarMenu::groups($this->user))
|
||||
->firstWhere('title', '费比异常数据监控');
|
||||
$this->assertNotNull($sidebarGroup);
|
||||
$this->assertSame('fee-ratio-monitoring', $sidebarGroup['items'][0]['section']);
|
||||
$this->assertSame('overview', $sidebarGroup['items'][0]['page']);
|
||||
$this->assertSame('refund-pending', $sidebarGroup['items'][0]['page']);
|
||||
$this->assertSame('overview', $sidebarGroup['items'][1]['page']);
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
@ -308,32 +330,27 @@ class NavigationTest extends FeatureTestCase
|
||||
->assertSeeText('费比异常数据尚未接入');
|
||||
}
|
||||
|
||||
public function testExistingRegularPermissionSetsInheritFeeRatioMonitoring(): void
|
||||
public function testLegacyRefundPendingPermissionFollowsTheMovedPage(): void
|
||||
{
|
||||
$this->user->roles()->sync([Role::where('name', 'user')->firstOrFail()->id]);
|
||||
$subject = 'role_user';
|
||||
setting()->set('system.sidebar_permissions', [
|
||||
'configured' => [$subject],
|
||||
'subjects' => [$subject => [
|
||||
'financial-risk-control/store-violation-alert',
|
||||
'financial-risk-control/process-statistics',
|
||||
'refunds/refund-pending',
|
||||
'refunds/refund-pending/export-details',
|
||||
]],
|
||||
]);
|
||||
setting()->save();
|
||||
|
||||
$this->assertContains(
|
||||
'fee-ratio-monitoring/overview',
|
||||
'fee-ratio-monitoring/refund-pending',
|
||||
SidebarPermissions::allowedKeys($this->user),
|
||||
);
|
||||
$this->assertContains(
|
||||
'fee-ratio-monitoring/refund-pending/export-details',
|
||||
SidebarPermissions::allowedKeys($this->user),
|
||||
);
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
'section' => 'financial-risk-control',
|
||||
'page' => 'store-violation-alert',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSee('/workspace/fee-ratio-monitoring/overview', false)
|
||||
->assertSeeText('费比异常数据监控');
|
||||
}
|
||||
|
||||
public function test_business_pages_render_menu_filter_and_open_page_tabs(): void
|
||||
@ -563,11 +580,11 @@ class NavigationTest extends FeatureTestCase
|
||||
$this->assertSame('退款数据', $refund['title']);
|
||||
$this->assertSame('assignment_return', $refund['icon']);
|
||||
$this->assertSame(
|
||||
['jingxi-refund-data', 'non-jingxi-refund-data', 'refund-pending'],
|
||||
['jingxi-refund-data', 'non-jingxi-refund-data'],
|
||||
array_column($refund['pages'], 'slug')
|
||||
);
|
||||
$this->assertSame(
|
||||
['京喜退款数据', '售后(退货退款)', '退款待确认'],
|
||||
['京喜退款数据', '售后(退货退款)'],
|
||||
array_column($refund['pages'], 'title')
|
||||
);
|
||||
$this->assertNotNull($financialOperations);
|
||||
|
||||
@ -127,7 +127,7 @@ class UserPermissionsTest extends FeatureTestCase
|
||||
->assertSee('aria-label="页面位置"', false)
|
||||
->assertSeeText('主体商标规则')
|
||||
->assertSeeText('退款待确认 · 导出明细')
|
||||
->assertSee('value="refunds/refund-pending/export-details"', false);
|
||||
->assertSee('value="fee-ratio-monitoring/refund-pending/export-details"', false);
|
||||
$this->patch(route('system-settings.sidebar.update'), [
|
||||
'subject' => 'user_'.$target->id, 'permissions' => ['store-management/basic-information'],
|
||||
])->assertRedirect(route('system-settings.sidebar.edit', ['subject' => 'user_'.$target->id]));
|
||||
@ -139,22 +139,22 @@ class UserPermissionsTest extends FeatureTestCase
|
||||
{
|
||||
$target = $this->account('user');
|
||||
$subject = 'user_' . $target->id;
|
||||
$pageKey = 'refunds/refund-pending';
|
||||
$pageKey = 'fee-ratio-monitoring/refund-pending';
|
||||
$operationKey = $pageKey . '/export-details';
|
||||
setting()->set('system.sidebar_permissions', [
|
||||
'configured' => [$subject],
|
||||
'subjects' => [$subject => [$pageKey]],
|
||||
]);
|
||||
|
||||
$this->assertTrue(SidebarPermissions::canViewPage($target, 'refunds', 'refund-pending'));
|
||||
$this->assertFalse(BusinessOperationPermissions::can('refunds', 'refund-pending', 'export-details', $target));
|
||||
$this->assertTrue(SidebarPermissions::canViewPage($target, 'fee-ratio-monitoring', 'refund-pending'));
|
||||
$this->assertFalse(BusinessOperationPermissions::can('fee-ratio-monitoring', 'refund-pending', 'export-details', $target));
|
||||
|
||||
$this->loginAs()->patch(route('system-settings.sidebar.update'), [
|
||||
'subject' => $subject,
|
||||
'permissions' => [$pageKey, $operationKey],
|
||||
])->assertRedirect(route('system-settings.sidebar.edit', ['subject' => $subject]));
|
||||
|
||||
$this->assertTrue(BusinessOperationPermissions::can('refunds', 'refund-pending', 'export-details', $target));
|
||||
$this->assertTrue(BusinessOperationPermissions::can('fee-ratio-monitoring', 'refund-pending', 'export-details', $target));
|
||||
$this->assertSame([$pageKey, $operationKey], SidebarPermissions::allowedKeys($target));
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ class UserPermissionsTest extends FeatureTestCase
|
||||
'subjects' => [$subject => ['refunds']],
|
||||
]);
|
||||
|
||||
$this->assertTrue(BusinessOperationPermissions::can('refunds', 'refund-pending', 'export-details', $target));
|
||||
$this->assertTrue(BusinessOperationPermissions::can('fee-ratio-monitoring', 'refund-pending', 'export-details', $target));
|
||||
}
|
||||
|
||||
public function test_super_admin_cannot_be_limited_by_page_settings_and_regular_users_cannot_configure_access(): void
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user