Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
8d16b0f7
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 搜索 >>
提交
8d16b0f7
编写于
11月 22, 2022
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
购物车总数优化、用户导出采用统一组件
上级
898aa0ac
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
92 addition
and
142 deletion
+92
-142
app/admin/controller/User.php
app/admin/controller/User.php
+0
-24
app/admin/form/User.php
app/admin/form/User.php
+25
-17
app/admin/view/default/user/index.html
app/admin/view/default/user/index.html
+0
-3
app/api/controller/Cart.php
app/api/controller/Cart.php
+7
-7
app/api/controller/Goods.php
app/api/controller/Goods.php
+5
-5
app/api/controller/Index.php
app/api/controller/Index.php
+6
-6
app/api/controller/User.php
app/api/controller/User.php
+13
-13
app/service/ConstService.php
app/service/ConstService.php
+0
-48
app/service/GoodsCartService.php
app/service/GoodsCartService.php
+20
-6
app/service/NavigationService.php
app/service/NavigationService.php
+14
-12
app/service/SearchService.php
app/service/SearchService.php
+2
-1
未找到文件。
app/admin/controller/User.php
浏览文件 @
8d16b0f7
...
...
@@ -32,8 +32,6 @@ class User extends Base
*/
public
function
Index
()
{
// Excel地址
MyViewAssign
(
'excel_url'
,
MyUrl
(
'admin/user/excelexport'
,
$this
->
data_request
));
return
MyView
();
}
...
...
@@ -49,28 +47,6 @@ class User extends Base
return
MyView
();
}
/**
* excel文件导出
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-01-10T15:46:00+0800
*/
public
function
ExcelExport
()
{
// 获取数据列表
$data_params
=
[
'where'
=>
$this
->
form_where
,
'm'
=>
0
,
'n'
=>
0
,
];
$data
=
UserService
::
UserList
(
$data_params
);
// Excel驱动导出数据
$excel
=
new
\
base\Excel
(
array
(
'filename'
=>
'user'
,
'title'
=>
MyConst
(
'excel_user_title_list'
),
'data'
=>
$data
[
'data'
],
'msg'
=>
'没有相关数据'
));
$excel
->
Export
();
}
/**
* 添加/编辑页面
* @author Devil
...
...
app/admin/form/User.php
浏览文件 @
8d16b0f7
...
...
@@ -39,12 +39,11 @@ class User
return
[
// 基础配置
'base'
=>
[
'key_field'
=>
'id'
,
'is_search'
=>
1
,
'is_delete'
=>
1
,
'delete_url'
=>
MyUrl
(
'admin/user/delete'
),
'delete_key'
=>
'ids'
,
'is_middle'
=>
0
,
'key_field'
=>
'id'
,
'is_search'
=>
1
,
'is_delete'
=>
1
,
'is_data_export_excel'
=>
1
,
'is_middle'
=>
0
,
],
// 表单配置
'form'
=>
[
...
...
@@ -82,8 +81,11 @@ class User
],
[
'label'
=>
'头像'
,
'view_type'
=>
'module'
,
'view_key'
=>
'user/module/avatar'
,
'view_type'
=>
'images'
,
'view_key'
=>
'avatar'
,
'images_width'
=>
40
,
'images_height'
=>
40
,
'width'
=>
65
,
],
[
'label'
=>
'用户名'
,
...
...
@@ -128,12 +130,11 @@ class User
[
'label'
=>
'性别'
,
'view_type'
=>
'field'
,
'view_key'
=>
'gender'
,
'view_data_key'
=>
'name'
,
'view_data'
=>
MyConst
(
'common_gender_list'
),
'view_key'
=>
'gender_name'
,
'is_sort'
=>
1
,
'search_config'
=>
[
'form_type'
=>
'select'
,
'form_name'
=>
'gender'
,
'where_type'
=>
'in'
,
'data'
=>
MyConst
(
'common_gender_list'
),
'data_key'
=>
'id'
,
...
...
@@ -144,12 +145,11 @@ class User
[
'label'
=>
'状态'
,
'view_type'
=>
'field'
,
'view_key'
=>
'status'
,
'view_data_key'
=>
'name'
,
'view_data'
=>
MyConst
(
'common_user_status_list'
),
'view_key'
=>
'status_name'
,
'is_sort'
=>
1
,
'search_config'
=>
[
'form_type'
=>
'select'
,
'form_name'
=>
'status'
,
'where_type'
=>
'in'
,
'data'
=>
MyConst
(
'common_user_status_list'
),
'data_key'
=>
'id'
,
...
...
@@ -267,9 +267,17 @@ class User
],
// 数据配置
'data'
=>
[
'table_name'
=>
'User'
,
'data_handle'
=>
'UserService::UserListHandle'
,
'is_page'
=>
1
,
'table_name'
=>
'User'
,
'data_handle'
=>
'UserService::UserListHandle'
,
'is_fixed_name_field'
=>
1
,
'fixed_name_data'
=>
[
'status'
=>
[
'data'
=>
MyConst
(
'common_user_status_list'
),
],
'gender'
=>
[
'data'
=>
MyConst
(
'common_gender_list'
),
],
],
],
];
}
...
...
app/admin/view/default/user/index.html
浏览文件 @
8d16b0f7
...
...
@@ -4,9 +4,6 @@
<!-- 表单顶部操作栏 -->
{{block name="form_operate_top"}}
<a
href=
"{{:MyUrl('admin/user/saveinfo')}}"
class=
"am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"
>
新增
</a>
{{if !IsMobile()}}
<a
href=
"{{$excel_url}}"
class=
"am-btn am-btn-success am-btn-xs am-icon-file-excel-o am-radius"
target=
"_blank"
>
导出Excel
</a>
{{/if}}
<!-- 父级内容 -->
{__block__}
{{/block}}
\ No newline at end of file
app/api/controller/Cart.php
浏览文件 @
8d16b0f7
...
...
@@ -38,9 +38,9 @@ class Cart extends Common
// 是否登录
$this
->
IsLogin
();
}
/**
*
[Index 首页]
*
首页
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
...
...
@@ -48,12 +48,12 @@ class Cart extends Common
*/
public
function
Index
()
{
$ret
=
GoodsCartService
::
GoodsCartList
([
'user'
=>
$this
->
user
]);
$result
=
[
'data'
=>
$ret
[
'data'
],
'common_cart_total'
=>
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]),
];
// 汇总
$result
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]);
// 列表
$list
=
GoodsCartService
::
GoodsCartList
([
'user'
=>
$this
->
user
]);
$result
[
'data'
]
=
$list
[
'data'
];
return
ApiService
::
ApiDataReturn
(
SystemBaseService
::
DataReturn
(
$result
));
}
...
...
app/api/controller/Goods.php
浏览文件 @
8d16b0f7
...
...
@@ -122,11 +122,11 @@ class Goods extends Common
// 数据返回
$result
=
[
'goods'
=>
$goods
,
'c
ommon_cart_total'
=>
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]),
'buy_button'
=>
$buy_button
,
'middle_tabs_nav'
=>
$middle_tabs_nav
,
'nav_more_list'
=>
$nav_more_list
,
'goods'
=>
$goods
,
'c
art_total'
=>
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]),
'buy_button'
=>
$buy_button
,
'middle_tabs_nav'
=>
$middle_tabs_nav
,
'nav_more_list'
=>
$nav_more_list
,
];
$ret
=
SystemBaseService
::
DataReturn
(
$result
);
}
...
...
app/api/controller/Index.php
浏览文件 @
8d16b0f7
...
...
@@ -62,12 +62,12 @@ class Index extends Common
$data_list
=
GoodsService
::
HomeFloorList
();
}
// 购物车
数量
$c
ommon_c
art_total
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]);
// 购物车
汇总
$cart_total
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]);
// 未读消息总数
$params
=
[
'user'
=>
$this
->
user
,
'is_more'
=>
1
,
'is_read'
=>
0
];
$
common_
message_total
=
MessageService
::
UserMessageTotal
(
$params
);
$message_total
=
MessageService
::
UserMessageTotal
(
$params
);
// 返回数据
$result
=
[
...
...
@@ -75,9 +75,9 @@ class Index extends Common
'banner_list'
=>
BannerService
::
Banner
(),
'data_list'
=>
$data_list
,
'article_list'
=>
ArticleService
::
HomeArticleList
(),
'right_icon_list'
=>
AppService
::
HomeRightIconList
([
'message_total'
=>
$
common_
message_total
]),
'c
ommon_cart_total'
=>
$common_
cart_total
,
'
common_message_total'
=>
$common_
message_total
,
'right_icon_list'
=>
AppService
::
HomeRightIconList
([
'message_total'
=>
$message_total
]),
'c
art_total'
=>
$
cart_total
,
'
message_total'
=>
$
message_total
,
'plugins_sort_list'
=>
PluginsService
::
PluginsSortList
(),
];
return
ApiService
::
ApiDataReturn
(
SystemBaseService
::
DataReturn
(
$result
));
...
...
app/api/controller/User.php
浏览文件 @
8d16b0f7
...
...
@@ -250,7 +250,7 @@ class User extends Common
// 未读消息总数
$params
=
[
'user'
=>
$this
->
user
,
'is_more'
=>
1
,
'is_read'
=>
0
];
$
common_
message_total
=
MessageService
::
UserMessageTotal
(
$params
);
$message_total
=
MessageService
::
UserMessageTotal
(
$params
);
// 用户订单状态
$user_order_status
=
OrderService
::
OrderStatusStepTotal
([
'user_type'
=>
'user'
,
'user'
=>
$this
->
user
,
'is_comments'
=>
1
,
'is_aftersale'
=>
1
]);
...
...
@@ -261,18 +261,18 @@ class User extends Common
// 初始化数据
$result
=
array
(
'integral'
=>
$user_integral
,
'avatar'
=>
$this
->
user
[
'avatar'
],
'nickname'
=>
$this
->
user
[
'nickname'
],
'username'
=>
$this
->
user
[
'username'
],
'user_name_view'
=>
$this
->
user
[
'user_name_view'
],
'user_order_status'
=>
$user_order_status
[
'data'
],
'user_order_count'
=>
$user_order_count
,
'user_goods_favor_count'
=>
$user_goods_favor_count
,
'user_goods_browse_count'
=>
$user_goods_browse_count
,
'
common_message_total'
=>
$common_
message_total
,
'navigation'
=>
AppCenterNavService
::
AppCenterNav
(),
'c
ommon_cart_total'
=>
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]),
'integral'
=>
$user_integral
,
'avatar'
=>
$this
->
user
[
'avatar'
],
'nickname'
=>
$this
->
user
[
'nickname'
],
'username'
=>
$this
->
user
[
'username'
],
'user_name_view'
=>
$this
->
user
[
'user_name_view'
],
'user_order_status'
=>
$user_order_status
[
'data'
],
'user_order_count'
=>
$user_order_count
,
'user_goods_favor_count'
=>
$user_goods_favor_count
,
'user_goods_browse_count'
=>
$user_goods_browse_count
,
'
message_total'
=>
$
message_total
,
'navigation'
=>
AppCenterNavService
::
AppCenterNav
(),
'c
art_total'
=>
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$this
->
user
]),
);
// 返回数据
...
...
app/service/ConstService.php
浏览文件 @
8d16b0f7
...
...
@@ -534,54 +534,6 @@ class ConstService
1
=>
[
'value'
=>
1
,
'name'
=>
'PATHINFO模式'
],
2
=>
[
'value'
=>
2
,
'name'
=>
'PATHINFO模式+短地址'
],
],
// 用户excel导出标题列表
'excel_user_title_list'
=>
[
'username'
=>
[
'name'
=>
'用户名'
,
'type'
=>
'string'
,
],
'nickname'
=>
[
'name'
=>
'昵称'
,
'type'
=>
'int'
,
],
'gender_text'
=>
[
'name'
=>
'性别'
,
'type'
=>
'string'
,
],
'birthday'
=>
[
'name'
=>
'生日'
,
'type'
=>
'string'
,
],
'status_text'
=>
[
'name'
=>
'状态'
,
'type'
=>
'string'
,
],
'mobile'
=>
[
'name'
=>
'手机号码'
,
'type'
=>
'int'
,
],
'email'
=>
[
'name'
=>
'电子邮箱'
,
'type'
=>
'string'
,
],
'province'
=>
[
'name'
=>
'所在省'
,
'type'
=>
'string'
,
],
'city'
=>
[
'name'
=>
'所在市'
,
'type'
=>
'string'
,
],
'address'
=>
[
'name'
=>
'详细地址'
,
'type'
=>
'string'
,
],
'add_time'
=>
[
'name'
=>
'注册时间'
,
'type'
=>
'string'
,
],
],
];
}
}
...
...
app/service/GoodsCartService.php
浏览文件 @
8d16b0f7
...
...
@@ -470,7 +470,7 @@ class GoodsCartService
}
/**
* 购物车
总数
* 购物车
汇总
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
...
...
@@ -480,7 +480,16 @@ class GoodsCartService
*/
public
static
function
GoodsCartTotal
(
$where
=
[])
{
return
(
int
)
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
count
();
$data
=
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
field
(
'SUM(`stock`*`price`) AS total_price, SUM(`stock`) AS buy_number'
)
->
find
();
if
(
empty
(
$data
[
'buy_number'
]))
{
$data
[
'buy_number'
]
=
0
;
}
if
(
empty
(
$data
[
'total_price'
]))
{
$data
[
'total_price'
]
=
0.00
;
}
return
$data
;
}
/**
...
...
@@ -491,7 +500,7 @@ class GoodsCartService
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
* @return [
int|string] [
超过99则返回 99+]
* @return [
array] [总数
超过99则返回 99+]
*/
public
static
function
UserGoodsCartTotal
(
$params
=
[])
{
...
...
@@ -506,7 +515,7 @@ class GoodsCartService
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
0
;
return
[
'buy_number'
=>
0
,
'total_price'
=>
0.00
]
;
}
// 条件
...
...
@@ -523,8 +532,13 @@ class GoodsCartService
'where'
=>
&
$where
,
]);
$total
=
self
::
GoodsCartTotal
(
$where
);
return
(
$total
>
99
)
?
'99+'
:
$total
;
// 获取汇总
$data
=
self
::
GoodsCartTotal
(
$where
);
if
(
$data
[
'buy_number'
]
>
99
)
{
$data
[
'buy_number'
]
=
'99+'
;
}
return
$data
;
}
/**
...
...
app/service/NavigationService.php
浏览文件 @
8d16b0f7
...
...
@@ -643,17 +643,18 @@ class NavigationService
*/
public
static
function
HomeHavTopRight
(
$params
=
[])
{
$c
ommon_c
art_total
=
0
;
$
common_
message_total
=
-
1
;
$cart_total
=
0
;
$message_total
=
-
1
;
if
(
!
empty
(
$params
[
'user'
]))
{
// 购物车商品总数
$common_cart_total
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$params
[
'user'
]]);
// 购物车商品汇总
$cart_res
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$params
[
'user'
]]);
$cart_total
=
$cart_res
[
'buy_number'
];
// 未读消息总数
$message_params
=
[
'user'
=>
$params
[
'user'
],
'is_more'
=>
1
,
'is_read'
=>
0
,
'user_type'
=>
'user'
];
$
common_
message_total
=
MessageService
::
UserMessageTotal
(
$message_params
);
$
common_message_total
=
(
$common_message_total
<=
0
)
?
-
1
:
$common_
message_total
;
$message_total
=
MessageService
::
UserMessageTotal
(
$message_params
);
$
message_total
=
(
$message_total
<=
0
)
?
-
1
:
$
message_total
;
}
// 列表
...
...
@@ -699,7 +700,7 @@ class NavigationService
'name'
=>
'购物车'
,
'type'
=>
'cart'
,
'is_login'
=>
1
,
'badge'
=>
$c
ommon_c
art_total
,
'badge'
=>
$cart_total
,
'icon'
=>
'am-icon-shopping-cart'
,
'url'
=>
MyUrl
(
'index/cart/index'
),
'items'
=>
[],
...
...
@@ -708,7 +709,7 @@ class NavigationService
'name'
=>
'消息'
,
'type'
=>
'message'
,
'is_login'
=>
1
,
'badge'
=>
$
common_
message_total
,
'badge'
=>
$message_total
,
'icon'
=>
'am-icon-bell'
,
'url'
=>
MyUrl
(
'index/message/index'
),
'items'
=>
[],
...
...
@@ -1008,11 +1009,12 @@ class NavigationService
*/
public
static
function
BottomNavigation
(
$params
=
[])
{
$c
ommon_c
art_total
=
0
;
$cart_total
=
0
;
if
(
!
empty
(
$params
[
'user'
]))
{
// 购物车商品总数
$common_cart_total
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$params
[
'user'
]]);
// 购物车商品汇总
$cart_res
=
GoodsCartService
::
UserGoodsCartTotal
([
'user'
=>
$params
[
'user'
]]);
$cart_total
=
$cart_res
[
'buy_number'
];
}
// 列表
...
...
@@ -1036,7 +1038,7 @@ class NavigationService
[
'name'
=>
'购物车'
,
'is_login'
=>
1
,
'badge'
=>
$c
ommon_c
art_total
,
'badge'
=>
$cart_total
,
'icon'
=>
'nav-icon-cart'
,
'only_tag'
=>
'cartindex'
,
'url'
=>
MyUrl
(
'index/cart/index'
),
...
...
app/service/SearchService.php
浏览文件 @
8d16b0f7
...
...
@@ -211,7 +211,8 @@ class SearchService
})
->
group
(
'g.id'
)
->
order
(
$order_by
)
->
limit
(
$result
[
'page_start'
],
$result
[
'page_size'
])
->
select
()
->
toArray
();
// 数据处理
$goods
=
GoodsService
::
GoodsDataHandle
(
$data
);
$params
[
'is_spec'
]
=
1
;
$goods
=
GoodsService
::
GoodsDataHandle
(
$data
,
$params
);
// 返回数据
$result
[
'data'
]
=
$goods
[
'data'
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录