From 7e2098984c26f4e648a7f335a4c37cf573d46317 Mon Sep 17 00:00:00 2001 From: Devil Date: Sun, 11 Apr 2021 23:37:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8F=82=E6=95=B0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Site.php | 8 +++++ .../view/default/site/siteset/search.html | 8 +++++ .../admin/view/default/sqlconsole/index.html | 2 +- application/service/ConfigService.php | 1 + application/service/SearchService.php | 30 +++++++++++++++++-- 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/application/admin/controller/Site.php b/application/admin/controller/Site.php index 978a0cf51..ff4bc163b 100755 --- a/application/admin/controller/Site.php +++ b/application/admin/controller/Site.php @@ -179,6 +179,9 @@ class Site extends Common // 首页楼层数据类型 $this->assign('common_site_floor_data_type_list', lang('common_site_floor_data_type_list')); + // 搜索参数类型 + $this->assign('common_goods_parameters_type_list', lang('common_goods_parameters_type_list')); + // 主导航 $this->assign('second_nav_list', [ [ @@ -334,6 +337,11 @@ class Site extends Common // 楼层左侧分类 $params['home_index_floor_left_top_category'] = empty($params['home_index_floor_left_top_category']) ? '' : json_encode($params['home_index_floor_left_top_category'], JSON_UNESCAPED_UNICODE); break; + + // 搜索 + case 'search' : + $field_list[] = 'home_search_params_type'; + break; } break; diff --git a/application/admin/view/default/site/siteset/search.html b/application/admin/view/default/site/siteset/search.html index 6185e4372..b8cdb9036 100644 --- a/application/admin/view/default/site/siteset/search.html +++ b/application/admin/view/default/site/siteset/search.html @@ -76,6 +76,14 @@ {{/foreach}} +
+ + +
+
diff --git a/application/service/ConfigService.php b/application/service/ConfigService.php index 0834ec558..ff5904ffe 100755 --- a/application/service/ConfigService.php +++ b/application/service/ConfigService.php @@ -60,6 +60,7 @@ class ConfigService 'home_user_login_type', 'home_user_reg_type', 'admin_login_type', + 'home_search_params_type', ]; /** diff --git a/application/service/SearchService.php b/application/service/SearchService.php index 1f4930a7c..ec62854fa 100755 --- a/application/service/SearchService.php +++ b/application/service/SearchService.php @@ -259,7 +259,7 @@ class SearchService } if(!empty($params['goods_params_values'])) { - $ids = Db::name('GoodsParams')->where(['value'=>$params['goods_params_values'], 'type'=>2])->column('goods_id'); + $ids = Db::name('GoodsParams')->where(['value'=>$params['goods_params_values'], 'type'=>self::SearchParamsWhereTypeValue()])->column('goods_id'); if(!empty($ids)) { $where_base[] = ['g.id', 'in', $ids]; @@ -291,6 +291,32 @@ class SearchService ]; } + /** + * 参数搜索条件类型 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-04-11 + * @desc description + */ + public static function SearchParamsWhereTypeValue() + { + // 获取配置 + $value = MyC('home_search_params_type'); + if(empty($value)) + { + $value = [2]; + } + + // 是否为数组 + if(!is_array($value)) + { + $value = explode(',', $value); + } + + return $value; + } + /** * 搜索记录添加 * @author Devil @@ -480,7 +506,7 @@ class SearchService $where_screening_price = $where['screening_price']; // 仅搜索基础参数 - $where_base[] = ['gp.type', '=', 2]; + $where_base[] = ['gp.type', 'in', self::SearchParamsWhereTypeValue()]; // 一维数组、参数值去重 $data = Db::name('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->join(['__GOODS_PARAMS__'=>'gp'], 'g.id=gp.goods_id')->where($where_base)->where(function($query) use($where_keywords) {