Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
e4e5ad62
ShopXO
项目概览
纵之格
/
ShopXO
通知
394
Star
16
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e4e5ad62
编写于
3月 18, 2021
作者:
D
Devil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
搜索优化,url默认兼容模式
上级
c21458ec
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
31 deletion
+64
-31
application/service/BrandService.php
application/service/BrandService.php
+33
-8
application/service/SearchService.php
application/service/SearchService.php
+16
-13
config/shopxo.sql
config/shopxo.sql
+15
-10
未找到文件。
application/service/BrandService.php
浏览文件 @
e4e5ad62
...
...
@@ -59,21 +59,46 @@ class BrandService
{
if
(
!
empty
(
$data
))
{
// 分类名称
$cnames
=
[];
$cids
=
array_column
(
$data
,
'brand_category_id'
);
if
(
!
empty
(
$cids
))
// 字段列表
$keys
=
ArrayKeys
(
$data
);
// 分类信息
// 获取所有品牌关联的分类数据
$category_group
=
[];
if
(
in_array
(
'id'
,
$keys
))
{
$cnames
=
Db
::
name
(
'BrandCategory'
)
->
where
([
'id'
=>
$cids
])
->
column
(
'name'
,
'id'
);
$category
=
Db
::
name
(
'BrandCategoryJoin'
)
->
where
([
'brand_id'
=>
array_column
(
$data
,
'id'
)])
->
field
(
'brand_id,brand_category_id'
)
->
select
();
if
(
!
empty
(
$category
))
{
$ids
=
array_unique
(
array_column
(
$category
,
'brand_category_id'
));
$names
=
Db
::
name
(
'BrandCategory'
)
->
where
([
'id'
=>
$ids
])
->
column
(
'name'
,
'id'
);
foreach
(
$category
as
$c
)
{
if
(
!
array_key_exists
(
$c
[
'brand_id'
],
$category_group
))
{
$category_group
[
$c
[
'brand_id'
]][
'ids'
]
=
[];
$category_group
[
$c
[
'brand_id'
]][
'names'
]
=
[];
}
$category_group
[
$c
[
'brand_id'
]][
'ids'
][]
=
$c
[
'brand_category_id'
];
$category_group
[
$c
[
'brand_id'
]][
'names'
][]
=
$names
[
$c
[
'brand_category_id'
]];
}
}
}
// 数处理
foreach
(
$data
as
&
$v
)
{
// 分类名称
if
(
isset
(
$v
[
'id'
]))
{
$v
[
'brand_category_ids'
]
=
Db
::
name
(
'BrandCategoryJoin'
)
->
where
([
'brand_id'
=>
$v
[
'id'
]])
->
column
(
'brand_category_id'
);
$category_name
=
Db
::
name
(
'BrandCategory'
)
->
where
([
'id'
=>
$v
[
'brand_category_ids'
]])
->
column
(
'name'
);
$v
[
'brand_category_text'
]
=
implode
(
','
,
$category_name
);
if
(
array_key_exists
(
$v
[
'id'
],
$category_group
))
{
$v
[
'brand_category_ids'
]
=
$category_group
[
$v
[
'id'
]][
'ids'
];
$v
[
'brand_category_text'
]
=
implode
(
','
,
$category_group
[
$v
[
'id'
]][
'names'
]);
}
else
{
$v
[
'brand_category_ids'
]
=
[];
$v
[
'brand_category_text'
]
=
''
;
}
}
// logo
...
...
application/service/SearchService.php
浏览文件 @
e4e5ad62
...
...
@@ -45,7 +45,7 @@ class SearchService
// 搜索条件
$where
=
self
::
SearchWhereHandle
(
$params
);
$
base_wher
e
=
$where
[
'base'
];
$
where_bas
e
=
$where
[
'base'
];
$where_keywords
=
$where
[
'keywords'
];
$where_screening_price
=
$where
[
'screening_price'
];
...
...
@@ -69,7 +69,7 @@ class SearchService
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
&
$params
,
'
base_where'
=>
&
$base_wher
e
,
'
where_base'
=>
&
$where_bas
e
,
'where_keywords'
=>
&
$where_keywords
,
'where_screening_price'
=>
&
$where_screening_price
,
'field'
=>
&
$field
,
...
...
@@ -80,7 +80,7 @@ class SearchService
]);
// 获取商品总数
$result
[
'total'
]
=
(
int
)
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
where
(
$
base_wher
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$result
[
'total'
]
=
(
int
)
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
where
(
$
where_bas
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$query
->
whereOr
(
$where_keywords
);
})
->
where
(
function
(
$query
)
use
(
$where_screening_price
)
{
$query
->
whereOr
(
$where_screening_price
);
...
...
@@ -90,7 +90,7 @@ class SearchService
if
(
$result
[
'total'
]
>
0
)
{
// 查询数据
$data
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
field
(
$field
)
->
where
(
$
base_wher
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$data
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
field
(
$field
)
->
where
(
$
where_bas
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$query
->
whereOr
(
$where_keywords
);
})
->
where
(
function
(
$query
)
use
(
$where_screening_price
)
{
$query
->
whereOr
(
$where_screening_price
);
...
...
@@ -138,7 +138,7 @@ class SearchService
$keywords
=
explode
(
' '
,
$params
[
'wd'
]);
foreach
(
$keywords
as
$kv
)
{
$where_keywords
[]
=
[
'g.title|g.
model|g.simple_desc|g.seo_title|g.seo_keywords|g.seo_keywords
'
,
'like'
,
'%'
.
$kv
.
'%'
];
$where_keywords
[]
=
[
'g.title|g.
simple_desc
'
,
'like'
,
'%'
.
$kv
.
'%'
];
}
}
...
...
@@ -234,7 +234,7 @@ class SearchService
}
if
(
!
empty
(
$params
[
'goods_params_values'
]))
{
$ids
=
Db
::
name
(
'GoodsParams'
)
->
where
([
'value'
=>
$params
[
'goods_params_values'
]])
->
column
(
'goods_id'
);
$ids
=
Db
::
name
(
'GoodsParams'
)
->
where
([
'value'
=>
$params
[
'goods_params_values'
]
,
'type'
=>
2
])
->
column
(
'goods_id'
);
if
(
!
empty
(
$ids
))
{
$where_base
[]
=
[
'g.id'
,
'in'
,
$ids
];
...
...
@@ -364,14 +364,14 @@ class SearchService
// 搜索条件
$where
=
self
::
SearchWhereHandle
(
$params
);
$
base_wher
e
=
$where
[
'base'
];
$
where_bas
e
=
$where
[
'base'
];
$where_keywords
=
$where
[
'keywords'
];
$where_screening_price
=
$where
[
'screening_price'
];
// 一维数组、参数值去重
if
(
!
empty
(
$
base_wher
e
)
||
!
empty
(
$where_keywords
)
||
!
empty
(
$where_screening_price
))
if
(
!
empty
(
$
where_bas
e
)
||
!
empty
(
$where_keywords
)
||
!
empty
(
$where_screening_price
))
{
$ids
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
where
(
$
base_wher
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$ids
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
where
(
$
where_bas
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$query
->
whereOr
(
$where_keywords
);
})
->
where
(
function
(
$query
)
use
(
$where_screening_price
)
{
$query
->
whereOr
(
$where_screening_price
);
...
...
@@ -450,12 +450,15 @@ class SearchService
{
// 搜索条件
$where
=
self
::
SearchWhereHandle
(
$params
);
$
base_wher
e
=
$where
[
'base'
];
$
where_bas
e
=
$where
[
'base'
];
$where_keywords
=
$where
[
'keywords'
];
$where_screening_price
=
$where
[
'screening_price'
];
// 仅搜索基础参数
$where_base
[]
=
[
'gp.type'
,
'='
,
2
];
// 一维数组、参数值去重
$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
(
$
base_wher
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$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_bas
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$query
->
whereOr
(
$where_keywords
);
})
->
where
(
function
(
$query
)
use
(
$where_screening_price
)
{
$query
->
whereOr
(
$where_screening_price
);
...
...
@@ -480,12 +483,12 @@ class SearchService
{
// 搜索条件
$where
=
self
::
SearchWhereHandle
(
$params
);
$
base_wher
e
=
$where
[
'base'
];
$
where_bas
e
=
$where
[
'base'
];
$where_keywords
=
$where
[
'keywords'
];
$where_screening_price
=
$where
[
'screening_price'
];
// 一维数组、参数值去重
$data
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
join
([
'__GOODS_SPEC_VALUE__'
=>
'gsv'
],
'g.id=gsv.goods_id'
)
->
where
(
$
base_wher
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$data
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
join
([
'__GOODS_SPEC_VALUE__'
=>
'gsv'
],
'g.id=gsv.goods_id'
)
->
where
(
$
where_bas
e
)
->
where
(
function
(
$query
)
use
(
$where_keywords
)
{
$query
->
whereOr
(
$where_keywords
);
})
->
where
(
function
(
$query
)
use
(
$where_screening_price
)
{
$query
->
whereOr
(
$where_screening_price
);
...
...
config/shopxo.sql
浏览文件 @
e4e5ad62
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录