优化商品搜索
This commit is contained in:
parent
aa2ae31d31
commit
70c2eaebdd
@ -409,17 +409,12 @@ class GoodsLogic extends Logic
|
|||||||
*/
|
*/
|
||||||
public static function getGoodsListTemplate($where, $order, $get)
|
public static function getGoodsListTemplate($where, $order, $get)
|
||||||
{
|
{
|
||||||
if (isset($get['cate']) && $get['cate'] && isset($get['keyword']) && empty($get['keyword'])) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$wh = "";
|
$wh = "";
|
||||||
if (!empty(self::filterShopsIds())) {
|
if (!empty(self::filterShopsIds())) {
|
||||||
// 过滤已删除、已冻结、已暂停营业、已到期的店铺
|
// 过滤已删除、已冻结、已暂停营业、已到期的店铺
|
||||||
$where[] = ['shop_id', 'not in', self::filterShopsIds()];
|
$where[] = ['shop_id', 'not in', self::filterShopsIds()];
|
||||||
}
|
}
|
||||||
// 平台分类
|
// 平台分类
|
||||||
$get['platform_cate_id'] = 319;
|
|
||||||
if(isset($get['platform_cate_id']) && !empty($get['platform_cate_id']) && filter_var($get['platform_cate_id'], FILTER_VALIDATE_INT)) {
|
if(isset($get['platform_cate_id']) && !empty($get['platform_cate_id']) && filter_var($get['platform_cate_id'], FILTER_VALIDATE_INT)) {
|
||||||
$category_msg = GoodsCategory::where("id",$get['platform_cate_id'])->find();
|
$category_msg = GoodsCategory::where("id",$get['platform_cate_id'])->find();
|
||||||
if($category_msg['pid'] == 0){
|
if($category_msg['pid'] == 0){
|
||||||
@ -528,23 +523,29 @@ class GoodsLogic extends Logic
|
|||||||
if (isset($get['keyword'])) {
|
if (isset($get['keyword'])) {
|
||||||
$cate = GoodsCategory::where(['is_show' => 1, 'del' => 0])
|
$cate = GoodsCategory::where(['is_show' => 1, 'del' => 0])
|
||||||
->where([['name', 'like', '%' . trim($get['keyword']) . '%']])
|
->where([['name', 'like', '%' . trim($get['keyword']) . '%']])
|
||||||
->field('id')
|
->field('id, level')
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($cate)) {
|
if (!empty($cate)) {
|
||||||
$where = array_filter($where, function($item) {
|
$where = array_filter($where, function($item) {
|
||||||
return $item[0] !== "name";
|
return $item[0] !== "name";
|
||||||
});
|
});
|
||||||
$where = array_values($where);
|
$where = array_values($where);
|
||||||
|
|
||||||
|
$con = array(
|
||||||
|
1 => 'first_cate_id',
|
||||||
|
2 => 'second_cate_id',
|
||||||
|
3 => 'second_cate_id',
|
||||||
|
);
|
||||||
foreach ($cate as &$v) {
|
foreach ($cate as &$v) {
|
||||||
$list = Goods::with(['shop'])
|
$list = Goods::with(['shop'])
|
||||||
->field($field)
|
->field($field)
|
||||||
->where($where)
|
->where($where)
|
||||||
->where([['first_cate_id|second_cate_id|third_cate_id', 'like', '%' . $v['id'] . '%']])
|
->where([
|
||||||
|
[$con[$v['level']], 'like', '%' . $v['id'] . '%'],
|
||||||
|
])
|
||||||
->order($order)
|
->order($order)
|
||||||
->page($get['page_no'], $get['page_size'])
|
|
||||||
->select();
|
->select();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user