IndexController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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\Models\UserModel;
  13. use App\Services\Common\MemberService;
  14. use App\Services\Common\MemberSettingService;
  15. use App\Services\Common\MenuService;
  16. use App\Services\Common\TradeOrderService;
  17. use App\Services\Common\UserService;
  18. use App\Services\RedisService;
  19. use Illuminate\Support\Facades\Cache;
  20. /**
  21. * 系统主页控制器
  22. * @author laravel开发员
  23. * @since 2020/11/10
  24. * Class IndexController
  25. * @package App\Http\Controllers\Admin
  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. $this->model = new UserModel();
  38. parent::__construct();
  39. }
  40. /**
  41. * 后台主页
  42. * @author laravel开发员
  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 laravel开发员
  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 laravel开发员
  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 laravel开发员
  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 clearCache(){
  92. RedisService::keyDel("caches:d*");
  93. RedisService::keyDel("caches:inde*");
  94. RedisService::keyDel("caches:advert*");
  95. RedisService::keyDel("caches:article*");
  96. RedisService::keyDel("caches:qrcode*");
  97. RedisService::keyDel("laravel_cache:model*");
  98. return message(MESSAGE_OK, true);
  99. }
  100. /**
  101. * 获取首页数据
  102. * @return array
  103. */
  104. public function indexData()
  105. {
  106. $this->userId;
  107. $info = $this->model->getInfo($this->userId);
  108. $userId = isset($info['user_id'])? $info['user_id'] : 0;
  109. $userInfo = MemberService::make()->getInfo($userId);
  110. if($userId<=0 || empty($userInfo)){
  111. return message(MESSAGE_FAILED, false);
  112. }
  113. // 用户交易设置参数
  114. $setting = MemberSettingService::make()->getInfo($userId);
  115. // 15分钟内的买卖比统计
  116. $counts = TradeOrderService::make()->getCountRateByTime(1, $this->userInfo['user_id'], 15);
  117. $datas = [
  118. 'counts'=> [
  119. 'usdt_num'=> isset($userInfo['usdt_num'])? moneyFormat($userInfo['usdt_num'], 2) : '0.00',
  120. 'buy_total'=> TradeOrderService::make()->getCompleteTotalByDay(1, $this->userInfo['user_id']),
  121. 'sell_total'=> TradeOrderService::make()->getCompleteTotalByDay(2, $this->userInfo['user_id']),
  122. 'day_sell_quota'=> isset($setting['day_sell_quota'])? floatval($setting['day_sell_quota']) : '0.00',
  123. 'buy_rate'=> isset($counts['buy_rate'])? $counts['buy_rate'] : '0.00',
  124. 'sell_rate'=> isset($counts['sell_rate'])? $counts['sell_rate'] : '0.00',
  125. 'rate_count'=> $counts,
  126. ],
  127. 'setting'=> $setting
  128. ];
  129. return message(MESSAGE_OK, true, $datas);
  130. }
  131. }