| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Http\Controllers\Admin;
- use App\Models\UserModel;
- use App\Services\Common\MemberService;
- use App\Services\Common\MemberSettingService;
- use App\Services\Common\MenuService;
- use App\Services\Common\TradeOrderService;
- use App\Services\Common\UserService;
- use App\Services\RedisService;
- use Illuminate\Support\Facades\Cache;
- /**
- * 系统主页控制器
- * @author laravel开发员
- * @since 2020/11/10
- * Class IndexController
- * @package App\Http\Controllers\Admin
- */
- class IndexController extends Backend
- {
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/10
- * IndexController constructor.
- */
- public function __construct()
- {
- $this->model = new UserModel();
- parent::__construct();
- }
- /**
- * 后台主页
- * @author laravel开发员
- * @since 2020/11/10
- */
- public function getMenuList()
- {
- $menuService = new MenuService();
- $menuList = $menuService->getPermissionList($this->userId);
- return $menuList;
- }
- /**
- * 获取个人信息
- * @return array
- * @since 2020/11/10
- * @author laravel开发员
- */
- public function getUserInfo()
- {
- $userService = new UserService();
- $result = $userService->getUserInfo($this->userId);
- return $result;
- }
- /**
- * 更新个人资料
- * @return mixed
- * @since 2020/11/11
- * @author laravel开发员
- */
- public function updateUserInfo()
- {
- $userService = new UserService();
- $result = $userService->updateUserInfo($this->userId);
- return $result;
- }
- /**
- * 更新密码
- * @return mixed
- * @since 2020/11/11
- * @author laravel开发员
- */
- public function updatePwd()
- {
- $userService = new UserService();
- $result = $userService->updatePwd($this->userId);
- return $result;
- }
- /**
- * 清除缓存
- * @return array
- */
- public function clearCache(){
- RedisService::keyDel("caches:d*");
- RedisService::keyDel("caches:inde*");
- RedisService::keyDel("caches:advert*");
- RedisService::keyDel("caches:article*");
- RedisService::keyDel("caches:qrcode*");
- RedisService::keyDel("laravel_cache:model*");
- return message(MESSAGE_OK, true);
- }
- /**
- * 获取首页数据
- * @return array
- */
- public function indexData()
- {
- $this->userId;
- $info = $this->model->getInfo($this->userId);
- $userId = isset($info['user_id'])? $info['user_id'] : 0;
- $userInfo = MemberService::make()->getInfo($userId);
- if($userId<=0 || empty($userInfo)){
- return message(MESSAGE_FAILED, false);
- }
- // 用户交易设置参数
- $setting = MemberSettingService::make()->getInfo($userId);
- // 15分钟内的买卖比统计
- $counts = TradeOrderService::make()->getCountRateByTime(1, $this->userInfo['user_id'], 15);
- $datas = [
- 'counts'=> [
- 'usdt_num'=> isset($userInfo['usdt_num'])? moneyFormat($userInfo['usdt_num'], 2) : '0.00',
- 'buy_total'=> TradeOrderService::make()->getCompleteTotalByDay(1, $this->userInfo['user_id']),
- 'sell_total'=> TradeOrderService::make()->getCompleteTotalByDay(2, $this->userInfo['user_id']),
- 'day_sell_quota'=> isset($setting['day_sell_quota'])? floatval($setting['day_sell_quota']) : '0.00',
- 'buy_rate'=> isset($counts['buy_rate'])? $counts['buy_rate'] : '0.00',
- 'sell_rate'=> isset($counts['sell_rate'])? $counts['sell_rate'] : '0.00',
- 'rate_count'=> $counts,
- ],
- 'setting'=> $setting
- ];
- return message(MESSAGE_OK, true, $datas);
- }
- }
|