Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
______--______
ShopXO
提交
5fa361de
ShopXO
项目概览
______--______
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5fa361de
编写于
4月 05, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
商品分类优化
上级
65046166
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
14 deletion
+33
-14
application/admin/controller/Goods.php
application/admin/controller/Goods.php
+1
-1
application/admin/controller/Goodscategory.php
application/admin/controller/Goodscategory.php
+1
-1
application/admin/controller/Navigation.php
application/admin/controller/Navigation.php
+1
-1
application/index/controller/Common.php
application/index/controller/Common.php
+1
-1
application/plugins/answers/Admin.php
application/plugins/answers/Admin.php
+1
-1
application/service/GoodsService.php
application/service/GoodsService.php
+28
-9
未找到文件。
application/admin/controller/Goods.php
浏览文件 @
5fa361de
...
...
@@ -135,7 +135,7 @@ class Goods extends Common
$this
->
assign
(
'region_province_list'
,
RegionService
::
RegionItems
([
'pid'
=>
0
]));
// 商品分类
$this
->
assign
(
'category_list'
,
GoodsService
::
GoodsCategory
());
$this
->
assign
(
'category_list'
,
GoodsService
::
GoodsCategory
All
());
// 品牌分类
$this
->
assign
(
'brand_list'
,
BrandService
::
CategoryBrand
());
...
...
application/admin/controller/Goodscategory.php
浏览文件 @
5fa361de
...
...
@@ -56,7 +56,7 @@ class GoodsCategory extends Common
$this
->
assign
(
'common_is_text_list'
,
lang
(
'common_is_text_list'
));
// 商品分类
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
());
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
All
());
// 编辑器文件存放地址
$this
->
assign
(
'editor_path_type'
,
'goods_category'
);
...
...
application/admin/controller/Navigation.php
浏览文件 @
5fa361de
...
...
@@ -67,7 +67,7 @@ class Navigation extends Common
$this
->
assign
(
'article_list'
,
$article_category_content
[
'data'
]);
// 商品分类
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
());
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
All
());
// 自定义页面
$this
->
assign
(
'customview_list'
,
db
(
'CustomView'
)
->
field
(
array
(
'id'
,
'title'
))
->
where
(
array
(
'is_enable'
=>
1
))
->
select
());
...
...
application/index/controller/Common.php
浏览文件 @
5fa361de
...
...
@@ -247,7 +247,7 @@ class Common extends Controller
$this
->
assign
(
'user_left_menu'
,
NavigationService
::
UsersCenterLeftList
());
// 商品大分类
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
());
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
All
());
// 搜索框下热门关键字
$home_search_keywords
=
[];
...
...
application/plugins/answers/Admin.php
浏览文件 @
5fa361de
...
...
@@ -223,7 +223,7 @@ class Admin extends Controller
$this
->
assign
(
'goods'
,
$goods
[
'data'
]);
// 商品分类
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
());
$this
->
assign
(
'goods_category_list'
,
GoodsService
::
GoodsCategory
All
());
return
$this
->
fetch
(
'../../../plugins/view/answers/admin/goodsinfo'
);
}
...
...
application/service/GoodsService.php
浏览文件 @
5fa361de
...
...
@@ -46,7 +46,7 @@ class GoodsService
}
/**
* 获取
大
分类
* 获取
所有
分类
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
...
...
@@ -54,7 +54,7 @@ class GoodsService
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
GoodsCategory
(
$params
=
[])
public
static
function
GoodsCategory
All
(
$params
=
[])
{
// 从缓存获取
$key
=
config
(
'shopxo.cache_goods_category_key'
);
...
...
@@ -64,6 +64,27 @@ class GoodsService
return
$data
;
}
// 获取分类
$params
[
'where'
]
=
[
'pid'
=>
0
,
'is_enable'
=>
1
];
$data
=
self
::
GoodsCategory
(
$params
);
// 存储缓存
cache
(
$key
,
$data
);
return
$data
;
}
/**
* 获取分类
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-08-29
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
GoodsCategory
(
$params
=
[])
{
// 获取分类
$where
=
empty
(
$params
[
'where'
])
?
[
'pid'
=>
0
,
'is_enable'
=>
1
]
:
$params
[
'where'
];
$data
=
self
::
GoodsCategoryList
(
$where
);
...
...
@@ -71,11 +92,13 @@ class GoodsService
{
foreach
(
$data
as
&
$v
)
{
$v
[
'items'
]
=
self
::
GoodsCategoryList
([
'pid'
=>
$v
[
'id'
],
'is_enable'
=>
1
]);
$where
[
'pid'
]
=
$v
[
'id'
];
$v
[
'items'
]
=
self
::
GoodsCategoryList
(
$where
);
if
(
!
empty
(
$v
[
'items'
]))
{
// 一次性查出所有二级下的三级、再做归类、避免sql连接超多
$items
=
self
::
GoodsCategoryList
([
'pid'
=>
array_column
(
$v
[
'items'
],
'id'
),
'is_enable'
=>
1
]);
$where
[
'pid'
]
=
array_column
(
$v
[
'items'
],
'id'
);
$items
=
self
::
GoodsCategoryList
(
$where
);
if
(
!
empty
(
$items
))
{
foreach
(
$v
[
'items'
]
as
&
$vs
)
...
...
@@ -92,10 +115,6 @@ class GoodsService
}
}
}
// 存储缓存
cache
(
$key
,
$data
);
return
$data
;
}
...
...
@@ -160,7 +179,7 @@ class GoodsService
public
static
function
HomeFloorList
(
$params
=
[])
{
// 商品大分类
$params
[
'where'
]
=
[
'pid'
=>
0
,
'is_home_recommended'
=>
1
];
$params
[
'where'
]
=
[
'pid'
=>
0
,
'is_home_recommended'
=>
1
,
'is_enable'
=>
1
];
$goods_category
=
self
::
GoodsCategory
(
$params
);
if
(
!
empty
(
$goods_category
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录