From 0236577e4766eb86797df14826ba304e98cf2150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Tue, 29 Sep 2026 13:27:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=95=86=E5=93=81=E4=B8=AD=E5=8F=B0):=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8F=82=E6=95=B0=E5=A5=91=E7=BA=A6=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit list() 补收 keyword/is_show/is_del,keyword 归一为 store_name; is_show/is_del 显式筛选与通用 type tab 口径互斥,空值不过滤 (避免 is_show='' 被 MySQL 松散比较为 0),默认不再强制仅上架可见 --- .../product/CenterProductController.php | 6 +++++- .../services/product/CenterProductServices.php | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/app/adminapi/controller/product/CenterProductController.php b/backend/app/adminapi/controller/product/CenterProductController.php index 4c1b32b9f..448d9f823 100644 --- a/backend/app/adminapi/controller/product/CenterProductController.php +++ b/backend/app/adminapi/controller/product/CenterProductController.php @@ -539,14 +539,18 @@ class CenterProductController extends AuthController /** * 统一商品列表(中台路由) + * 页面契约:keyword 搜索、product_type、is_show 上架状态、is_del 数据状态('' 均表示全部) * @return \think\Response */ public function list() { $where = $this->request->getMore([ ['store_name', ''], + ['keyword', ''], ['cate_id', ''], - ['type', 1], + ['is_show', ''], + ['is_del', ''], + ['type', ''], ['sales', 'normal'], ['spec_type', ''], ['is_gift', ''], diff --git a/backend/app/services/product/CenterProductServices.php b/backend/app/services/product/CenterProductServices.php index 2ea0034f6..93f20a81b 100644 --- a/backend/app/services/product/CenterProductServices.php +++ b/backend/app/services/product/CenterProductServices.php @@ -110,6 +110,24 @@ class CenterProductServices extends BaseService */ public function getList(array $where, int $page = 0, int $limit = 0) { + // 中台统一列表契约:keyword 等价 store_name;is_show/is_del 为页面显式状态筛选, + // 与通用 type tab 口径互斥(type 会强制 is_show=1/is_del=0);'' 表示全部不过滤, + // 空值必须移除,避免搜索器对空值做松散比较(如 is_show='' 在 MySQL 中等值 0) + if (($where['store_name'] ?? '') === '' && ($where['keyword'] ?? '') !== '') { + $where['store_name'] = $where['keyword']; + } + unset($where['keyword']); + $hasStatusFilter = false; + foreach (['is_show', 'is_del'] as $statusKey) { + if (($where[$statusKey] ?? '') === '') { + unset($where[$statusKey]); + } else { + $hasStatusFilter = true; + } + } + if ($hasStatusFilter || (string)($where['type'] ?? '') === '') { + unset($where['type']); + } $where['store_stock'] = sys_config('store_stock') > 0 ? sys_config('store_stock') : 2; if ($page <= 0 || $limit <= 0) { [$page, $limit] = $this->getPageValue();