diff --git a/app/api/logic/GoodsLogic.php b/app/api/logic/GoodsLogic.php index 38134ec6..05f3edb4 100755 --- a/app/api/logic/GoodsLogic.php +++ b/app/api/logic/GoodsLogic.php @@ -409,17 +409,12 @@ class GoodsLogic extends Logic */ public static function getGoodsListTemplate($where, $order, $get) { - if (isset($get['cate']) && $get['cate'] && isset($get['keyword']) && empty($get['keyword'])) { - return []; - } - $wh = ""; if (!empty(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)) { $category_msg = GoodsCategory::where("id",$get['platform_cate_id'])->find(); if($category_msg['pid'] == 0){ @@ -528,23 +523,29 @@ class GoodsLogic extends Logic if (isset($get['keyword'])) { $cate = GoodsCategory::where(['is_show' => 1, 'del' => 0]) ->where([['name', 'like', '%' . trim($get['keyword']) . '%']]) - ->field('id') + ->field('id, level') ->select() ->toArray(); } - if (!empty($cate)) { $where = array_filter($where, function($item) { return $item[0] !== "name"; }); $where = array_values($where); + + $con = array( + 1 => 'first_cate_id', + 2 => 'second_cate_id', + 3 => 'second_cate_id', + ); foreach ($cate as &$v) { $list = Goods::with(['shop']) ->field($field) ->where($where) - ->where([['first_cate_id|second_cate_id|third_cate_id', 'like', '%' . $v['id'] . '%']]) + ->where([ + [$con[$v['level']], 'like', '%' . $v['id'] . '%'], + ]) ->order($order) - ->page($get['page_no'], $get['page_size']) ->select(); } } else {