| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
- // +----------------------------------------------------------------------
- // | Laravel框架 [ Laravel ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 Laravel研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: wesmiler <12345678@qq.com>
- // +----------------------------------------------------------------------
- namespace App\Http\Controllers;
- use App\Models\EnshrineOrdersModel;
- use App\Models\GongdengOrderModel;
- use App\Models\MemberModel;
- use App\Models\OrdersModel;
- use App\Models\UserModel;
- use App\Models\AdminRomModel;
- use App\Services\AdminService;
- use App\Services\MenuService;
- use App\Services\RedisService;
- use App\Services\UserService;
- /**
- * 系统主页控制器
- * @author wesmiler
- * @since 2020/11/10
- * Class IndexController
- * @package App\Http\Controllers
- */
- class IndexController extends Backend
- {
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/10
- * IndexController constructor.
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * 后台主页
- * @author wesmiler
- * @since 2020/11/10
- */
- public function getMenuList()
- {
- $menuService = new MenuService();
- $menuList = $menuService->getPermissionList($this->userId);
- return $menuList;
- }
- /**
- * 获取个人信息
- * @return array
- * @since 2020/11/10
- * @author wesmiler
- */
- public function getUserInfo()
- {
- $userService = new UserService();
- $result = $userService->getUserInfo($this->userId);
- return $result;
- }
- /**
- * 更新个人资料
- * @return mixed
- * @since 2020/11/11
- * @author wesmiler
- */
- public function updateUserInfo()
- {
- $userService = new UserService();
- $result = $userService->updateUserInfo($this->userId);
- return $result;
- }
- /**
- * 更新密码
- * @return mixed
- * @since 2020/11/11
- * @author wesmiler
- */
- public function updatePwd()
- {
- $userService = new UserService();
- $result = $userService->updatePwd($this->userId);
- return $result;
- }
- /**
- * 工作台统计数据
- * @return array
- */
- public function counts(){
- $data = [
- 'gdCount'=> GongdengOrderModel::where(['mark'=> 1,'status'=> 2])
- ->count('id'),
- 'shopCount'=> OrdersModel::where(['mark'=> 1])
- ->whereIn('status',[2,3,4])
- ->count('id'),
- 'memberCount'=> MemberModel::where(['mark'=> 1,'status'=> 1])
- ->where('create_time','>', strtotime(date('Y-m-d')))
- ->count('id')
- ];
- return message(MESSAGE_OK,true, $data);
- }
- /**
- * 数据分析统计
- * @return array
- */
- public function statistics(){
- $cacheKey = "caches:statistics:counts";
- $datas = RedisService::get($cacheKey);
- $datas = $datas? json_decode($datas, true) : [];
- if($datas){
- return message(MESSAGE_OK, true, $datas);
- }
- $datas = [
- 'gdCount'=> GongdengOrderModel::where(['mark'=> 1,'status'=> 2])
- ->count('id'),
- 'gdDayCount'=> GongdengOrderModel::where(['mark'=> 1,'status'=> 2])
- ->where('pay_at','>=', date('Y-m-d'))
- ->count('id'),
- 'shopCount'=> OrdersModel::where(['mark'=> 1])
- ->whereIn('status',[2,3,4])
- ->count('id'),
- 'shopDayCount'=> OrdersModel::where(['mark'=> 1])
- ->whereIn('status',[2,3,4])
- ->where('pay_at','>=', date('Y-m-d'))
- ->count('id'),
- 'memberCount'=> MemberModel::where(['mark'=> 1,'status'=> 1])
- ->count('id'),
- 'memberDayCount'=> MemberModel::where(['mark'=> 1,'status'=> 1])
- ->where('create_time','>=', strtotime(date('Y-m-d')))
- ->count('id'),
- 'enshrineCount'=> EnshrineOrdersModel::where(['mark'=> 1,'status'=> 2])
- ->sum('total'),
- 'enshrineDayCount'=> EnshrineOrdersModel::where(['mark'=> 1,'status'=> 2])
- ->where('pay_at','>=', date('Y-m-d'))
- ->sum('total'),
- ];
- RedisService::set($cacheKey, json_encode($datas, 256), rand(5, 10));
- return message(MESSAGE_OK,true, $datas);
- }
- public function statisticsTable(){
- $type = request()->get('type', 'trade');
- $dateType = request()->get('dateType', 0);
- $datas = [];
- switch($type){
- case 'trade': // 消费
- break;
- case 'gd': // 供灯交易量
- break;
- case 'member': // 用户注册
- break;
- case 'shop': // 商城交易量
- break;
- case 'enshrine': // 供奉订单交易额
- break;
- }
- return message(MESSAGE_OK,true, $datas);
- }
- /**
- * 清除缓存
- * @return array
- */
- public function clearCache(){
- RedisService::keyDel("caches:config:*");
- RedisService::keyDel("caches:index:*");
- RedisService::keyDel("caches:articles:*");
- RedisService::keyDel("caches:qrcodes:*");
- RedisService::keyDel("caches:statistics:*");
- return message(MESSAGE_OK, true);
- }
- }
|