diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index 0f4ef42a3..0d2bdc33f 100755 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -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 diff --git a/app/admin/form/User.php b/app/admin/form/User.php index 37d2ffe05..2c97b6416 100644 --- a/app/admin/form/User.php +++ b/app/admin/form/User.php @@ -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'), + ], + ], ], ]; } diff --git a/app/admin/view/default/user/index.html b/app/admin/view/default/user/index.html index 13d0cab02..dce8ed18c 100755 --- a/app/admin/view/default/user/index.html +++ b/app/admin/view/default/user/index.html @@ -4,9 +4,6 @@ {{block name="form_operate_top"}} 新增 - {{if !IsMobile()}} - 导出Excel - {{/if}} {__block__} {{/block}} \ No newline at end of file diff --git a/app/api/controller/Cart.php b/app/api/controller/Cart.php index dde0de064..623042602 100755 --- a/app/api/controller/Cart.php +++ b/app/api/controller/Cart.php @@ -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)); } diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 69894873b..e4450bbb5 100755 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -122,11 +122,11 @@ class Goods extends Common // 数据返回 $result = [ - 'goods' => $goods, - 'common_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, + 'cart_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); } diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index ba9d831ef..6987213f1 100755 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -62,12 +62,12 @@ class Index extends Common $data_list = GoodsService::HomeFloorList(); } - // 购物车数量 - $common_cart_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]), - 'common_cart_total' => $common_cart_total, - 'common_message_total' => $common_message_total, + 'right_icon_list' => AppService::HomeRightIconList(['message_total'=>$message_total]), + 'cart_total' => $cart_total, + 'message_total' => $message_total, 'plugins_sort_list' => PluginsService::PluginsSortList(), ]; return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result)); diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 6f4269c73..d4efb5516 100755 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -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(), - 'common_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(), + 'cart_total' => GoodsCartService::UserGoodsCartTotal(['user'=>$this->user]), ); // 返回数据 diff --git a/app/service/ConstService.php b/app/service/ConstService.php index 2b7b494c8..3d2d5b6cf 100644 --- a/app/service/ConstService.php +++ b/app/service/ConstService.php @@ -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', - ], - ], ]; } } diff --git a/app/service/GoodsCartService.php b/app/service/GoodsCartService.php index c7f1853d0..259ea5e81 100644 --- a/app/service/GoodsCartService.php +++ b/app/service/GoodsCartService.php @@ -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; } /** diff --git a/app/service/NavigationService.php b/app/service/NavigationService.php index 615f2afc3..629fdcbca 100755 --- a/app/service/NavigationService.php +++ b/app/service/NavigationService.php @@ -643,17 +643,18 @@ class NavigationService */ public static function HomeHavTopRight($params = []) { - $common_cart_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' => $common_cart_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 = []) { - $common_cart_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' => $common_cart_total, + 'badge' => $cart_total, 'icon' => 'nav-icon-cart', 'only_tag' => 'cartindex', 'url' => MyUrl('index/cart/index'), diff --git a/app/service/SearchService.php b/app/service/SearchService.php index b43b83be5..4b65f2e1d 100755 --- a/app/service/SearchService.php +++ b/app/service/SearchService.php @@ -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'];