IndexController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Laravel框架 [ Laravel ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 Laravel研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: wesmiler <12345678@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers;
  12. use App\Models\GongdengOrderModel;
  13. use App\Models\MemberModel;
  14. use App\Models\OrdersModel;
  15. use App\Models\UserModel;
  16. use App\Models\AdminRomModel;
  17. use App\Services\AdminService;
  18. use App\Services\MenuService;
  19. use App\Services\RedisService;
  20. use App\Services\UserService;
  21. /**
  22. * 系统主页控制器
  23. * @author wesmiler
  24. * @since 2020/11/10
  25. * Class IndexController
  26. * @package App\Http\Controllers
  27. */
  28. class IndexController extends Backend
  29. {
  30. /**
  31. * 构造函数
  32. * @author wesmiler
  33. * @since 2020/11/10
  34. * IndexController constructor.
  35. */
  36. public function __construct()
  37. {
  38. parent::__construct();
  39. }
  40. /**
  41. * 后台主页
  42. * @author wesmiler
  43. * @since 2020/11/10
  44. */
  45. public function getMenuList()
  46. {
  47. $menuService = new MenuService();
  48. $menuList = $menuService->getPermissionList($this->userId);
  49. return $menuList;
  50. }
  51. /**
  52. * 获取个人信息
  53. * @return array
  54. * @since 2020/11/10
  55. * @author wesmiler
  56. */
  57. public function getUserInfo()
  58. {
  59. $userService = new UserService();
  60. $result = $userService->getUserInfo($this->userId);
  61. return $result;
  62. }
  63. /**
  64. * 更新个人资料
  65. * @return mixed
  66. * @since 2020/11/11
  67. * @author wesmiler
  68. */
  69. public function updateUserInfo()
  70. {
  71. $userService = new UserService();
  72. $result = $userService->updateUserInfo($this->userId);
  73. return $result;
  74. }
  75. /**
  76. * 更新密码
  77. * @return mixed
  78. * @since 2020/11/11
  79. * @author wesmiler
  80. */
  81. public function updatePwd()
  82. {
  83. $userService = new UserService();
  84. $result = $userService->updatePwd($this->userId);
  85. return $result;
  86. }
  87. /**
  88. * 工作台统计数据
  89. * @return array
  90. */
  91. public function counts(){
  92. $data = [
  93. 'gdCount'=> GongdengOrderModel::where(['mark'=> 1,'status'=> 2])
  94. ->count('id'),
  95. 'shopCount'=> OrdersModel::where(['mark'=> 1])
  96. ->whereIn('status',[2,3,4])
  97. ->count('id'),
  98. 'memberCount'=> MemberModel::where(['mark'=> 1,'status'=> 1])
  99. ->where('create_time','>', strtotime(date('Y-m-d')))
  100. ->count('id')
  101. ];
  102. return message(MESSAGE_OK,true, $data);
  103. }
  104. public function statistics(){
  105. }
  106. /**
  107. * 清除缓存
  108. * @return array
  109. */
  110. public function clearCache(){
  111. RedisService::keyDel("caches:config:*");
  112. RedisService::keyDel("caches:index:*");
  113. RedisService::keyDel("caches:articles:*");
  114. RedisService::keyDel("caches:qrcodes:*");
  115. return message(MESSAGE_OK, true);
  116. }
  117. }