IndexController.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Services\Common\BalanceLogService;
  13. use App\Services\Common\GoodsService;
  14. use App\Services\Common\MemberService;
  15. use App\Services\Common\MenuService;
  16. use App\Services\Common\OrderService;
  17. use App\Services\Common\UserService;
  18. use App\Services\RedisService;
  19. use App\utils\TimeUtils;
  20. /**
  21. * 系统主页控制器
  22. * @author laravel开发员
  23. * @since 2020/11/10
  24. * Class IndexController
  25. * @package App\Http\Controllers
  26. */
  27. class IndexController extends Backend
  28. {
  29. /**
  30. * 构造函数
  31. * @author laravel开发员
  32. * @since 2020/11/10
  33. * IndexController constructor.
  34. */
  35. public function __construct()
  36. {
  37. parent::__construct();
  38. }
  39. /**
  40. * 后台主页
  41. * @author laravel开发员
  42. * @since 2020/11/10
  43. */
  44. public function getMenuList()
  45. {
  46. $menuService = new MenuService();
  47. $menuList = $menuService->getPermissionList($this->userId);
  48. return $menuList;
  49. }
  50. /**
  51. * 获取个人信息
  52. * @return array
  53. * @since 2020/11/10
  54. * @author laravel开发员
  55. */
  56. public function getUserInfo()
  57. {
  58. $userService = new UserService();
  59. $result = $userService->getUserInfo($this->userId);
  60. return $result;
  61. }
  62. /**
  63. * 更新个人资料
  64. * @return mixed
  65. * @since 2020/11/11
  66. * @author laravel开发员
  67. */
  68. public function updateUserInfo()
  69. {
  70. $userService = new UserService();
  71. $result = $userService->updateUserInfo($this->userId);
  72. return $result;
  73. }
  74. /**
  75. * 更新密码
  76. * @return mixed
  77. * @since 2020/11/11
  78. * @author laravel开发员
  79. */
  80. public function updatePwd()
  81. {
  82. $userService = new UserService();
  83. $result = $userService->updatePwd($this->userId);
  84. return $result;
  85. }
  86. /**
  87. * 清除缓存
  88. * @return array
  89. */
  90. public function clearCache()
  91. {
  92. RedisService::keyDel("caches:adm*");
  93. RedisService::keyDel("caches:index*");
  94. RedisService::keyDel("caches:good*");
  95. RedisService::keyDel("caches:advert*");
  96. RedisService::keyDel("caches:count*");
  97. RedisService::keyDel("caches:account*");
  98. RedisService::keyDel("caches:article*");
  99. RedisService::keyDel("caches:member*");
  100. RedisService::keyDel("caches:config*");
  101. RedisService::keyDel("caches:deposit*");
  102. RedisService::keyDel("caches:order*");
  103. RedisService::keyDel(env('APP_NAME')."_cache:*");
  104. //Cache::flush();
  105. return message(MESSAGE_OK, true);
  106. }
  107. /**
  108. * 获取首页数据
  109. * @return array
  110. */
  111. public function statistics()
  112. {
  113. $datas = [
  114. // 用户
  115. 'users' => [
  116. 'count' => MemberService::make()->getRegisterCount(), // 总用户数
  117. 'count_by_day' => MemberService::make()->getRegisterCount(TimeUtils::beginToday(), TimeUtils::endToday()), // 今日注册
  118. 'count_by_month' => MemberService::make()->getRegisterCount(TimeUtils::beginMonth(), TimeUtils::endMonth()), // 本月注册
  119. 'count_by_confirm' => MemberService::make()->getRegisterCount(0,0,2), // 待审核
  120. ],
  121. 'goods'=>[
  122. 'count_by_all'=> GoodsService::make()->getCounts(0),
  123. 'count_by_up'=> GoodsService::make()->getCounts(1),
  124. 'count_by_success'=> GoodsService::make()->getCounts(2),
  125. ],
  126. // 订单
  127. 'orders' => [
  128. 'count' => OrderService::make()->getCountByTime(), // 总量
  129. 'count_by_day' => OrderService::make()->getCountByTime(TimeUtils::beginToday(), TimeUtils::endToday()), // 今日
  130. 'count_by_month' => OrderService::make()->getCountByTime(TimeUtils::beginMonth(), TimeUtils::endMonth()), // 本月
  131. 'amount_by_day' => OrderService::make()->getTotalByTime(TimeUtils::beginToday(), TimeUtils::endToday()), // 日营业额
  132. 'amount_by_month' => OrderService::make()->getTotalByTime(TimeUtils::beginMonth(), TimeUtils::endMonth()), // 月营业额
  133. ],
  134. 'deposit'=>[
  135. 'total'=> DepositService::make()->getTotal(0),
  136. 'withdraw'=> DepositService::make()->getTotal(1),
  137. ],
  138. // 营收
  139. 'balance' => [
  140. 'income_by_total'=> OrderService::make()->getTotalByTime(),
  141. 'withdraw_by_total'=> BalanceLogService::make()->getTotal(),
  142. ],
  143. ];
  144. return message(1010, true, $datas);
  145. }
  146. }