diff --git a/resources/views/banking/marketing_account_bills/partials/embedded-table.blade.php b/resources/views/banking/marketing_account_bills/partials/embedded-table.blade.php index b90fc786..4dd2f26e 100644 --- a/resources/views/banking/marketing_account_bills/partials/embedded-table.blade.php +++ b/resources/views/banking/marketing_account_bills/partials/embedded-table.blade.php @@ -1,25 +1,266 @@ -@php $pageAccountIds = $accounts->pluck('id')->map(fn($id) => (string) $id)->values(); @endphp +@php + $pageAccountIds = $accounts->pluck('id')->map(fn($id) => (string) $id)->values(); + $isJdWallet = $platform === 'jd-wallet'; + $jdLedger = $isJdWallet && request()->query('jd_ledger') === 'consumption' ? 'consumption' : 'recharge'; -
+ $columns = [ + ['field' => 'store_name', 'label' => trans('marketing_account_bills.store_name'), 'kind' => 'text'], + ['field' => 'bill_date', 'label' => trans('marketing_account_bills.bill_date'), 'kind' => 'date'], + ]; + + $rechargeColumns = [ + ['field' => 'total_deposit', 'label' => trans('marketing_account_bills.total_deposit'), 'kind' => 'money'], + ['field' => 'total_transfer_in', 'label' => trans('marketing_account_bills.total_transfer_in'), 'kind' => 'money'], + ['field' => 'total_transfer_out', 'label' => trans('marketing_account_bills.total_transfer_out'), 'kind' => 'money'], + ]; + + $balanceColumns = [ + ['field' => 'daily_total_amount', 'label' => trans('marketing_account_bills.daily_total_amount'), 'kind' => 'money'], + ['field' => 'period_end_balance', 'label' => trans('marketing_account_bills.period_end_balance'), 'kind' => 'money'], + ['field' => 'grant_balance', 'label' => trans('marketing_account_bills.grant_balance'), 'kind' => 'money'], + ['field' => 'non_grant_balance', 'label' => trans('marketing_account_bills.non_grant_balance'), 'kind' => 'money'], + ]; + + $consumptionColumns = [ + ['field' => 'non_grant_consumption', 'label' => trans('marketing_account_bills.non_grant_consumption'), 'kind' => 'money'], + ['field' => 'grant_consumption', 'label' => trans('marketing_account_bills.grant_consumption'), 'kind' => 'money'], + ['field' => 'rebate_redpack_consumption', 'label' => trans('marketing_account_bills.rebate_redpack_consumption'), 'kind' => 'money'], + ['field' => 'discount_redpack_consumption', 'label' => trans('marketing_account_bills.discount_redpack_consumption'), 'kind' => 'money'], + ['field' => 'shared_wallet_consumption', 'label' => trans('marketing_account_bills.shared_wallet_consumption'), 'kind' => 'money'], + ['field' => 'shared_grant_consumption', 'label' => trans('marketing_account_bills.shared_grant_consumption'), 'kind' => 'money'], + ]; + + $consumptionSummaryColumns = [ + ['field' => 'daily_total_amount', 'label' => trans('marketing_account_bills.daily_total_amount'), 'kind' => 'money'], + ['field' => 'period_end_balance', 'label' => trans('marketing_account_bills.period_end_balance'), 'kind' => 'money'], + ]; + + $columns = array_merge( + $columns, + $isJdWallet + ? ($jdLedger === 'consumption' + ? array_merge($consumptionColumns, $consumptionSummaryColumns) + : array_merge($rechargeColumns, $balanceColumns)) + : array_merge($rechargeColumns, $consumptionColumns, $balanceColumns), + [['field' => 'notes', 'label' => trans('marketing_account_bills.notes'), 'kind' => 'text']] + ); + $tableColumnCount = count($columns) + 2; +@endphp + +
+ @if ($isJdWallet) + + @endif + {{-- 操作工具栏 --}} -
+
@can('create-banking-accounts')
+ class="marketing-bills-primary"> {{ trans('marketing_account_bills.add_bill') }} @@ -27,21 +268,21 @@ enctype="multipart/form-data" class="flex flex-wrap items-end gap-3"> @csrf
-
+ class="marketing-bills-secondary"> {{ trans('marketing_account_bills.download_template') }} @@ -50,7 +291,7 @@
@can('update-banking-accounts') @@ -59,49 +300,37 @@
@if ($errors->has('import')) -
+ @endif - {{-- 15列数据表格 --}} -
- +
+
- - - - - - - - - - - - - - - - - - + @foreach ($columns as $column) + + @endforeach + - + @if ($accounts->isEmpty()) - @@ -113,30 +342,31 @@ form="marketing-account-bills-export-form" x-model="selected" aria-label="{{ trans('marketing_account_bills.select_bill') }}" - class="h-4 w-4 rounded border-gray-300 text-green" /> - - - - - - - - - - - - - - - - - + @foreach ($columns as $column) + + @endforeach diff --git a/resources/views/business/pages/show.blade.php b/resources/views/business/pages/show.blade.php index 3689cb65..ef40d2e6 100644 --- a/resources/views/business/pages/show.blade.php +++ b/resources/views/business/pages/show.blade.php @@ -4,6 +4,20 @@ + @php + $isMarketingAccountBillsPage = ($section['slug'] ?? null) === 'billing-transactions' + && ($page['slug'] ?? null) === 'marketing-account-bills'; + $activeContentTitle = $activeTab['title'] ?? ($page['title'] ?? $section['title']); + + if ($isMarketingAccountBillsPage && ($activeTab['slug'] ?? null) === 'taobao-wechat') { + $activeContentTitle = 'Alibaba'; + } + + if ($isMarketingAccountBillsPage && ($activeTab['slug'] ?? null) === 'jd-wallet') { + $activeContentTitle = '京东'; + } + @endphp + -
+
$isMarketingAccountBillsPage, + ])> @if (is_string(session('success')))
{{ session('success') }}
@endif @@ -351,10 +401,21 @@ @if ($errors->has('import')) @endif - @if ($tabs->isNotEmpty()) @@ -393,7 +454,7 @@ @endphp @if (!empty($content) && !empty($content['view'])) -
+
@include($content['view'], $content)
@elseif ($pageView) diff --git a/tests/Feature/Business/MarketingAccountBillsTabsTest.php b/tests/Feature/Business/MarketingAccountBillsTabsTest.php new file mode 100644 index 00000000..5f657dd7 --- /dev/null +++ b/tests/Feature/Business/MarketingAccountBillsTabsTest.php @@ -0,0 +1,70 @@ +allowMarketingAccountBillsPage(); + + $this->loginAs() + ->get(route('business.pages.show', [ + 'section' => 'billing-transactions', + 'page' => 'marketing-account-bills', + 'tab' => 'taobao-wechat', + ])) + ->assertOk() + ->assertSeeText('Alibaba') + ->assertSeeText('京东') + ->assertSee('class="my-6 business-page--marketing-account-bills"', false); + } + + public function testJdWalletHasRechargeAndConsumptionViewsWithoutChangingTheDataSource(): void + { + $this->allowMarketingAccountBillsPage(); + + $base = [ + 'section' => 'billing-transactions', + 'page' => 'marketing-account-bills', + 'tab' => 'jd-wallet', + ]; + + $this->loginAs() + ->get(route('business.pages.show', $base)) + ->assertOk() + ->assertSeeText('充值账单') + ->assertSeeText('消耗账单') + ->assertSeeText('总存入金额(元)') + ->assertDontSeeText('非赠款消耗金额(元)'); + + $this->loginAs() + ->get(route('business.pages.show', array_merge($base, ['jd_ledger' => 'consumption']))) + ->assertOk() + ->assertSeeText('充值账单') + ->assertSeeText('消耗账单') + ->assertSeeText('非赠款消耗金额(元)') + ->assertDontSeeText('总存入金额(元)'); + } + + private function allowMarketingAccountBillsPage(): void + { + $this->user->update(['locale' => 'zh-CN']); + + $this->user->attachPermission( + Permission::where('name', 'read-admin-panel')->firstOrFail() + ); + + $subject = 'user_' . $this->user->id; + + setting()->set('system.sidebar_permissions', json_encode([ + 'configured' => [$subject], + 'subjects' => [ + $subject => ['billing-transactions/marketing-account-bills'], + ], + ], JSON_UNESCAPED_UNICODE)); + } +}
+ isEmpty()) disabled @endif x-on:change="selected = $event.target.checked ? @js($pageAccountIds) : []" x-bind:checked="selected.length === {{ $pageAccountIds->count() }} && selected.length > 0" - class="h-4 w-4 rounded border-gray-300 text-green" /> + class="marketing-bills-checkbox h-4 w-4 rounded" /> {{ trans('marketing_account_bills.store_name') }}{{ trans('marketing_account_bills.bill_date') }}{{ trans('marketing_account_bills.total_deposit') }}{{ trans('marketing_account_bills.total_transfer_in') }}{{ trans('marketing_account_bills.total_transfer_out') }}{{ trans('marketing_account_bills.non_grant_consumption') }}{{ trans('marketing_account_bills.grant_consumption') }}{{ trans('marketing_account_bills.rebate_redpack_consumption') }}{{ trans('marketing_account_bills.discount_redpack_consumption') }}{{ trans('marketing_account_bills.shared_wallet_consumption') }}{{ trans('marketing_account_bills.shared_grant_consumption') }}{{ trans('marketing_account_bills.daily_total_amount') }}{{ trans('marketing_account_bills.period_end_balance') }}{{ trans('marketing_account_bills.grant_balance') }}{{ trans('marketing_account_bills.non_grant_balance') }}{{ trans('marketing_account_bills.notes') }}{{ trans('general.actions') }} $column['kind'] === 'money'])> + {{ $column['label'] }} + {{ trans('general.actions') }}
+ {{ trans('marketing_account_bills.no_records') }}
{{ $account->store_name }}{{ $account->bill_date->format('Y-m-d') }}{{ number_format($account->total_deposit, 2) }}{{ number_format($account->total_transfer_in, 2) }}{{ number_format($account->total_transfer_out, 2) }}{{ number_format($account->non_grant_consumption, 2) }}{{ number_format($account->grant_consumption, 2) }}{{ number_format($account->rebate_redpack_consumption, 2) }}{{ number_format($account->discount_redpack_consumption, 2) }}{{ number_format($account->shared_wallet_consumption, 2) }}{{ number_format($account->shared_grant_consumption, 2) }}{{ number_format($account->daily_total_amount, 2) }}{{ number_format($account->period_end_balance, 2) }}{{ number_format($account->grant_balance, 2) }}{{ number_format($account->non_grant_balance, 2) }} - {{ \Illuminate\Support\Str::limit($account->notes, 20) }} + class="marketing-bills-checkbox h-4 w-4 rounded" /> $column['kind'] === 'money', + 'max-w-xs truncate' => $column['field'] === 'notes', + ]) + @if ($column['field'] === 'notes') title="{{ $account->notes }}" @endif + > + @if ($column['kind'] === 'date') + {{ $account->{$column['field']}?->format('Y-m-d') ?? '—' }} + @elseif ($column['kind'] === 'money') + {{ number_format((float) $account->{$column['field']}, 2) }} + @elseif ($column['field'] === 'notes') + {{ \Illuminate\Support\Str::limit((string) $account->{$column['field']}, 20) }} + @else + {{ $account->{$column['field']} }} + @endif + @can('update-banking-accounts') {{ trans('general.edit') }} + class="marketing-bills-edit mr-3">{{ trans('general.edit') }} @endcan @can('delete-banking-accounts')
@csrf @method('DELETE') - +
@endcan