mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 21:40:50 +00:00
fix(商品中台): 统一商品列表搜索参数契约对齐页面
list() 补收 keyword/is_show/is_del,keyword 归一为 store_name; is_show/is_del 显式筛选与通用 type tab 口径互斥,空值不过滤 (避免 is_show='' 被 MySQL 松散比较为 0),默认不再强制仅上架可见
This commit is contained in:
parent
91e12d1c5b
commit
0236577e47
@ -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', ''],
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user