From dba61e5c8e1e5be9362f229fa5a9eee997349e42 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Wed, 7 Oct 2026 17:54:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E6=98=8E=E7=BB=86=EF=BC=9A?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0/=E5=BA=97=E9=93=BA=E5=8F=AF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=A4=9A=E9=80=89=E3=80=81=E5=AF=BC=E5=87=BA=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=E7=AD=9B=E9=80=89=E4=B8=94=E7=A9=BA=E5=80=BC=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=200.00=E3=80=81=E5=88=86=E9=A1=B5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=AF=8F=E9=A1=B5=E6=9D=A1=E6=95=B0=E4=B8=8E=E8=B7=B3=E9=A1=B5?= =?UTF-8?q?=EF=BC=88=E8=A1=A8=E5=A4=B4=E5=90=B8=E9=A1=B6/=E5=BA=8F?= =?UTF-8?q?=E5=8F=B7=E5=88=97=E5=9B=BA=E5=AE=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Business/Pages.php | 103 +++++++++-- .../pages/partials/directory-table.blade.php | 163 ++++++++++++++++-- 2 files changed, 234 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 4f0a56c3..2c5f0007 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -95,6 +95,18 @@ class Pages extends Controller */ private const PAYABLES_FINAL_SECTIONS = ['supplier-payables-final', 'courier-payables-final']; + /** 业绩明细的平台筛选顺序(与店铺收款账户账单页签一致)。 */ + private const RECEIPT_PLATFORM_OPTIONS = [ + '淘系支付宝', + '淘系微信', + '拼多多', + '京东账单', + '京喜账单', + '京东网银钱包', + '抖音', + '得物', + ]; + public function __construct( private readonly EdgeBandingRepository $edgeBanding, private readonly InventoryRepository $inventory, @@ -586,7 +598,11 @@ class Pages extends Controller // 明确指定月份时严格按该月份取数(该月没同步就显示空表)。 $month = $requested !== '' ? $requested : ($months[0] ?? null); - $limit = min(max((int) setting('default.list_limit', 25), 1), 50); + // 每页条数:业绩明细页面可切 10 / 20 / 50,未指定时沿用系统默认(上限 50)。 + $requestedLimit = (int) request('per_page', 0); + $limit = in_array($requestedLimit, [10, 20, 50], true) + ? $requestedLimit + : min(max((int) setting('default.list_limit', 25), 1), 50); $page = max((int) request('page', 1), 1); $empty = new LengthAwarePaginator([], 0, $limit, $page, [ 'path' => request()->url(), @@ -596,20 +612,22 @@ class Pages extends Controller return [$empty, null]; } - $applyFilters = static function ($query): void { - $platform = trim((string) request('platform', '')); - if ($platform !== '') { - $query->where('platform', $platform); + // 平台 / 店铺与其它页面一致:可打字搜索的多选(一个都不勾=全部),同时兼容旧的单值链接。 + $platformFilter = $this->receiptOrderMatchFilterValues(request('platform')); + $storeFilter = $this->receiptOrderMatchFilterValues(request('store_name')); + $orderNo = trim((string) request('online_order_no', '')); + $status = trim((string) request('match_status', '')); + + $applyFilters = static function ($query) use ($platformFilter, $storeFilter, $orderNo, $status): void { + if ($platformFilter !== []) { + $query->whereIn('platform', $platformFilter); } - $store = trim((string) request('store_name', '')); - if ($store !== '') { - $query->where('store_name', 'like', '%' . addcslashes($store, '%_\\') . '%'); + if ($storeFilter !== []) { + $query->whereIn('store_name', $storeFilter); } - $orderNo = trim((string) request('online_order_no', '')); if ($orderNo !== '') { $query->where('online_order_no', 'like', '%' . addcslashes($orderNo, '%_\\') . '%'); } - $status = trim((string) request('match_status', '')); if ($status !== '') { // 基础状态(已匹配/未匹配)按状态列过滤,其余按异常标注过滤。 if (in_array($status, ['已匹配', '未匹配'], true)) { @@ -659,8 +677,36 @@ class Pages extends Controller 'offset_total' => round((float) ($agg->offset_total ?? 0), 2), 'goods_total' => round((float) ($agg->goods_total ?? 0), 2), 'difference_total' => round((float) ($agg->difference_total ?? 0), 2), + 'per_page' => $limit, ]; + // 筛选下拉候选:本月镜像里实际出现的平台与店铺(按 6 小时缓存,避免每次开页做去重扫描), + // 并把当前已选值并入,保证筛选项的文字不会因为换月而消失。 + $filterOptions = cache()->remember( + 'performance-details-filter-options-v1:' . $month, + now()->addHours(6), + static function () use ($connection, $month): array { + $maker = static fn () => DB::connection($connection)->table('store_receipt_order_match_rows') + ->where('report_month', $month); + + return [ + 'platforms' => $maker()->whereNotNull('platform')->distinct()->orderBy('platform')->pluck('platform')->all(), + 'stores' => $maker()->whereNotNull('store_name')->where('store_name', '!=', '') + ->distinct()->orderBy('store_name')->pluck('store_name')->all(), + ]; + }, + ); + $stats['selected_platforms'] = $platformFilter; + $stats['selected_stores'] = $storeFilter; + $stats['platform_options'] = array_values(array_unique(array_merge( + self::RECEIPT_PLATFORM_OPTIONS, + array_map('strval', $filterOptions['platforms'] ?? []), + ))); + $stats['store_options'] = array_values(array_unique(array_merge( + $storeFilter, + array_map('strval', $filterOptions['stores'] ?? []), + ))); + if ($total === 0) { return [$empty, $stats]; } @@ -680,6 +726,28 @@ class Pages extends Controller ]), $stats]; } + /** + * 业绩明细的多选筛选值:多选控件提交 name[](数组),同时兼容历史单值链接。 + * + * @return list + */ + private function receiptOrderMatchFilterValues(mixed $input): array + { + $values = is_array($input) ? $input : [$input]; + $clean = []; + foreach ($values as $value) { + if (is_array($value)) { + continue; + } + $text = trim((string) $value); + if ($text !== '') { + $clean[$text] = true; + } + } + + return array_keys($clean); + } + /** * 业绩明细 → 店铺收款匹配订单明细导出:按当前月份与筛选条件导出 CSV,列序跟随页面显示列。 */ @@ -714,13 +782,13 @@ class Pages extends Controller $query = DB::connection($connection)->table('store_receipt_order_match_rows') ->when($month !== null, static fn ($builder) => $builder->where('report_month', $month)); - $platform = trim((string) $request->query('platform', '')); - if ($platform !== '') { - $query->where('platform', $platform); + $platforms = $this->receiptOrderMatchFilterValues($request->query('platform')); + if ($platforms !== []) { + $query->whereIn('platform', $platforms); } - $store = trim((string) $request->query('store_name', '')); - if ($store !== '') { - $query->where('store_name', 'like', '%' . addcslashes($store, '%_\\') . '%'); + $stores = $this->receiptOrderMatchFilterValues($request->query('store_name')); + if ($stores !== []) { + $query->whereIn('store_name', $stores); } $orderNo = trim((string) $request->query('online_order_no', '')); if ($orderNo !== '') { @@ -765,7 +833,8 @@ class Pages extends Controller $format = $map[$key][2]; $value = $row->{$map[$key][0]} ?? ''; if ($format === 'money') { - $line[] = $value === null || $value === '' ? '' : number_format((float) $value, 2, '.', ''); + // 金额列空值导出成 0.00:Excel 里直接求和、做差额核对不用再补空。 + $line[] = number_format((float) ($value === null || $value === '' ? 0 : $value), 2, '.', ''); continue; } diff --git a/resources/views/business/pages/partials/directory-table.blade.php b/resources/views/business/pages/partials/directory-table.blade.php index 29d0f76a..90401e0a 100644 --- a/resources/views/business/pages/partials/directory-table.blade.php +++ b/resources/views/business/pages/partials/directory-table.blade.php @@ -1352,16 +1352,60 @@ @elseif (($page['slug'] ?? '') === 'performance-details') + @include('business.pages.partials.multi-select') +
-