diff --git a/resources/views/store_receivables/zhongcai_reconciliations/partials/embedded-table.blade.php b/resources/views/store_receivables/zhongcai_reconciliations/partials/embedded-table.blade.php index a4472292..bc951e9c 100644 --- a/resources/views/store_receivables/zhongcai_reconciliations/partials/embedded-table.blade.php +++ b/resources/views/store_receivables/zhongcai_reconciliations/partials/embedded-table.blade.php @@ -1,5 +1,6 @@ -@php $pageIds = $records->pluck('id')->map(fn($id) => (string) $id)->values(); @endphp +@php + $pageIds = $records->pluck('id')->map(fn($id) => (string) $id)->values(); + $platformTabs = [ + 'jd' => '京东', + 'douyin' => '抖音', + 'tmall' => '天猫', + 'pdd' => '拼多多', + 'taobao' => '淘宝', + 'jingxi' => '京喜', + ]; + $douyinHeaders = [ + '日期', '订单编号', '财务售价', '财务运费', '财务佣金', + '财务空包费', '财务打款金额', '笔数', '备注', '正确店铺', '负责人', + '账户', '类型', '创建人', '标签', '所属利润中心', '负责平台', 'ID', + '实收', '差异', '退款', + ]; + $jdHeaders = [ + '日期', '订单编号', '财务售价', '财务运费', '财务佣金', '财务空包费', + '财务打款金额', '笔数', '备注', '正确店铺', '负责人', '账户', '类型', + '创建人', '标签', '所属利润中心', '负责平台', 'ID', '实收', '运费', + '差异', '是否退款', '备注', '问题件', + ]; + $tmallHeaders = [ + '日期', '订单编号', '财务售价', '财务运费', '财务佣金', '财务空包费', + '财务打款金额', '笔数', '备注', '正确店铺', '负责人', '账户', '类型', + '创建人', '标签', '所属利润中心', '负责平台', 'ID', '实收', '差异', + '是否退款', '备注', '问题件', + ]; + $pddHeaders = [ + '日期', '订单编号', '财务售价', '财务运费', '财务佣金', '财务空包费', + '财务打款金额', '笔数', '备注', '正确店铺', '负责人', '账户', '类型', + '创建人', '标签', '所属利润中心', '负责平台', 'ID', '实收', '差异', + '退款', '小额打款', + ]; + $taobaoHeaders = [ + '日期', '订单编号', '财务售价', '财务运费', '财务佣金', '财务空包费', + '财务打款金额', '笔数', '备注', '正确店铺', '负责人', '账户', '类型', + '创建人', '标签', '所属利润中心', '负责平台', 'ID', '实收', '差异', + '是否退款', '备注', '问题件', + ]; + $platformIds = [ + 'all' => $pageIds->all(), + ] + array_fill_keys(array_keys($platformTabs), []); -
+ foreach ($records as $record) { + $platform = (string) $record->responsible_platform; + $platformKey = str_contains($platform, '京东') + ? 'jd' + : (str_contains($platform, '抖音') + ? 'douyin' + : (str_contains($platform, '天猫') + ? 'tmall' + : (str_contains($platform, '拼多多') + ? 'pdd' + : (str_contains($platform, '淘宝') + ? 'taobao' + : (str_contains($platform, '京喜') ? 'jingxi' : null))))); + + if ($platformKey !== null) { + $platformIds[$platformKey][] = (string) $record->id; + } + } +@endphp + +
@@ -63,16 +126,35 @@
@endif +
+ 平台筛选 + @foreach ($platformTabs as $key => $label) + + @endforeach +
+ {{-- 21列数据表格 --}}
- +
- + @@ -98,17 +180,98 @@ + + + @foreach ($jdHeaders as $header) + + @endforeach + + + + @foreach ($douyinHeaders as $header) + + @endforeach + + + + @foreach ($tmallHeaders as $header) + + @endforeach + + + + @foreach ($pddHeaders as $header) + + @endforeach + + + + @foreach ($taobaoHeaders as $header) + + @endforeach + @if ($records->isEmpty()) - + @else @foreach ($records as $r) - + @php + $platform = (string) $r->responsible_platform; + $platformKey = str_contains($platform, '京东') + ? 'jd' + : (str_contains($platform, '抖音') + ? 'douyin' + : (str_contains($platform, '天猫') + ? 'tmall' + : (str_contains($platform, '拼多多') + ? 'pdd' + : (str_contains($platform, '淘宝') + ? 'taobao' + : (str_contains($platform, '京喜') ? 'jingxi' : 'other'))))); + @endphp + + + + @endif + @endforeach
isEmpty()) disabled @endif - x-on:change="selected = $event.target.checked ? @js($pageIds) : []" - x-bind:checked="selected.length === {{ $pageIds->count() }} && selected.length > 0" + x-bind:disabled="platformIds[activePlatform].length === 0" + x-on:change="selected = $event.target.checked ? platformIds[activePlatform] : []" + x-bind:checked="selected.length === platformIds[activePlatform].length && selected.length > 0" class="h-4 w-4 rounded border-gray-300 text-green" /> {{ trans('store_zhongcai_reconciliations.bill_date') }}{{ trans('store_zhongcai_reconciliations.difference_data') }} {{ trans('general.actions') }}
+ isEmpty()) disabled @endif + x-bind:disabled="platformIds[activePlatform].length === 0" + x-on:change="selected = $event.target.checked ? platformIds[activePlatform] : []" + x-bind:checked="selected.length === platformIds[activePlatform].length && selected.length > 0" + class="h-4 w-4 rounded border-gray-300 text-green" /> + {{ $header }}
+ isEmpty()) disabled @endif + x-bind:disabled="platformIds[activePlatform].length === 0" + x-on:change="selected = $event.target.checked ? platformIds[activePlatform] : []" + x-bind:checked="selected.length === platformIds[activePlatform].length && selected.length > 0" + class="h-4 w-4 rounded border-gray-300 text-green" /> + {{ $header }}
+ isEmpty()) disabled @endif + x-bind:disabled="platformIds[activePlatform].length === 0" + x-on:change="selected = $event.target.checked ? platformIds[activePlatform] : []" + x-bind:checked="selected.length === platformIds[activePlatform].length && selected.length > 0" + class="h-4 w-4 rounded border-gray-300 text-green" /> + {{ $header }}
+ isEmpty()) disabled @endif + x-bind:disabled="platformIds[activePlatform].length === 0" + x-on:change="selected = $event.target.checked ? platformIds[activePlatform] : []" + x-bind:checked="selected.length === platformIds[activePlatform].length && selected.length > 0" + class="h-4 w-4 rounded border-gray-300 text-green" /> + {{ $header }}
+ isEmpty()) disabled @endif + x-bind:disabled="platformIds[activePlatform].length === 0" + x-on:change="selected = $event.target.checked ? platformIds[activePlatform] : []" + x-bind:checked="selected.length === platformIds[activePlatform].length && selected.length > 0" + class="h-4 w-4 rounded border-gray-300 text-green" /> + {{ $header }}
{{ trans('store_zhongcai_reconciliations.no_records') }}
@endforeach @endif + @foreach ($platformTabs as $key => $label) + @if (count($platformIds[$key]) === 0) +
+ 当前页暂无{{ $label }}平台数据 +
diff --git a/tests/Feature/Business/ZhongcaiReconciliationPlatformTest.php b/tests/Feature/Business/ZhongcaiReconciliationPlatformTest.php new file mode 100644 index 00000000..861e1293 --- /dev/null +++ b/tests/Feature/Business/ZhongcaiReconciliationPlatformTest.php @@ -0,0 +1,121 @@ +user->attachPermission( + Permission::where('name', 'read-admin-panel')->firstOrFail() + ); + } + + public function testReconciliationPageProvidesPlatformTabsForCurrentPageRows(): void + { + foreach ([ + ['platform' => '京东商城', 'order' => 'JD-TEST-001'], + ['platform' => '抖音小店', 'order' => 'DY-TEST-001'], + ['platform' => '天猫旗舰店', 'order' => 'TM-TEST-001'], + ['platform' => '拼多多店铺', 'order' => 'PDD-TEST-001'], + ['platform' => '淘宝店铺', 'order' => 'TB-TEST-001'], + ['platform' => '京喜店铺', 'order' => 'JX-TEST-001'], + ] as $row) { + StoreZhongcaiReconciliation::create([ + 'company_id' => $this->company->id, + 'bill_date' => '2026-08-01', + 'planting_order_no' => $row['order'], + 'responsible_platform' => $row['platform'], + ]); + } + + $response = $this->loginAs()->get(route('business.pages.show', [ + 'section' => 'store-receivables', + 'page' => 'zhongcai-reconciliation', + ])); + + $response + ->assertOk() + ->assertSee('平台筛选', false) + ->assertSee('>京东<', false) + ->assertSee('>抖音<', false) + ->assertSee('>天猫<', false) + ->assertSee('>拼多多<', false) + ->assertSee('>淘宝<', false) + ->assertSee('>京喜<', false) + ->assertDontSee('>全部<', false) + ->assertSee('data-platform="jd"', false) + ->assertSee('data-platform="douyin"', false) + ->assertSee('data-platform="tmall"', false) + ->assertSee('data-platform="pdd"', false) + ->assertSee('data-platform="taobao"', false) + ->assertSee('data-platform="jingxi"', false) + ->assertSee('data-platform-header="jd"', false) + ->assertSeeInOrder([ + 'data-platform-header="jd"', '日期', '订单编号', '财务售价', '财务运费', + '财务佣金', '财务空包费', '财务打款金额', '笔数', '备注', '正确店铺', + '负责人', '账户', '类型', '创建人', '标签', '所属利润中心', '负责平台', + 'ID', '实收', '运费', '差异', '是否退款', '备注', '问题件', + ], false) + ->assertSee('data-platform-header="douyin"', false) + ->assertSeeInOrder([ + '日期', '订单编号', '财务售价', '财务运费', '财务佣金', + '财务空包费', '财务打款金额', '笔数', '备注', '正确店铺', '负责人', + '账户', '类型', '创建人', '标签', '所属利润中心', '负责平台', 'ID', + '实收', '差异', '退款', + ], false) + ->assertSee('data-platform-header="tmall"', false) + ->assertSeeInOrder([ + 'data-platform-header="tmall"', '日期', '订单编号', '财务售价', '财务运费', + '财务佣金', '财务空包费', '财务打款金额', '笔数', '备注', + '正确店铺', '负责人', '账户', '类型', '创建人', '标签', '所属利润中心', + '负责平台', 'ID', '实收', '差异', '是否退款', '备注', '问题件', + ], false) + ->assertSee('data-platform-header="pdd"', false) + ->assertSeeInOrder([ + 'data-platform-header="pdd"', '日期', '订单编号', '财务售价', '财务运费', + '财务佣金', '财务空包费', '财务打款金额', '笔数', '备注', + '正确店铺', '负责人', '账户', '类型', '创建人', '标签', '所属利润中心', + '负责平台', 'ID', '实收', '差异', '退款', '小额打款', + ], false) + ->assertSee('data-platform-header="taobao"', false) + ->assertSeeInOrder([ + 'data-platform-header="taobao"', '日期', '订单编号', '财务售价', '财务运费', + '财务佣金', '财务空包费', '财务打款金额', '笔数', '备注', + '正确店铺', '负责人', '账户', '类型', '创建人', '标签', '所属利润中心', + '负责平台', 'ID', '实收', '差异', '是否退款', '备注', '问题件', + ], false) + ->assertSee('JD-TEST-001') + ->assertSee('DY-TEST-001') + ->assertSee('TM-TEST-001') + ->assertSee('PDD-TEST-001') + ->assertSee('TB-TEST-001') + ->assertSee('JX-TEST-001'); + } + + public function testReconciliationPageShowsPlatformSpecificEmptyState(): void + { + StoreZhongcaiReconciliation::create([ + 'company_id' => $this->company->id, + 'bill_date' => '2026-08-01', + 'planting_order_no' => 'JD-TEST-002', + 'responsible_platform' => '京东', + ]); + + $response = $this->loginAs()->get(route('business.pages.show', [ + 'section' => 'store-receivables', + 'page' => 'zhongcai-reconciliation', + ])); + + $response + ->assertOk() + ->assertSee('当前页暂无抖音平台数据', false) + ->assertSee('当前页暂无天猫平台数据', false); + } +}