post('locale'); if($locale){ RedisService::set("stores:locale:lang_{$this->userId}", $locale, 24 * 3600); session(['locale_lang'=>$locale]); app()->setLocale($locale); } // 广告幻灯片 $banners = [ 'top'=> AdService::make()->getList(1, 6), 'middle'=> AdService::make()->getList(2, 1), ]; // 交易参数 $trade = ConfigService::make()->getConfigByGroup(5); $counts = TradeOrderService::make()->getRateByTime(0,24); $trade = [ 'buy_price'=> isset($trade['usdt_buy_price']['value'])? floatval($trade['usdt_buy_price']['value']) : '0.00', 'sell_price'=> isset($trade['usdt_sell_price']['value'])? floatval($trade['usdt_sell_price']['value']) : '0.00', 'total'=> TradeOrderService::make()->getCompleteTotalByTime(24), 'count'=> TradeOrderService::make()->getCompleteCountByTime(24), 'rate'=> isset($counts['rate'])? $counts['rate'] : '0.00', ]; $notices = NoticeService::make()->getNewList(6); return message(1010, true, compact('banners','trade','notices')); } /** * 获取实时交易数据 * @return array */ public function trade() { // 交易参数 $trade = ConfigService::make()->getConfigByGroup(5); $trade = [ 'buy_price'=> isset($trade['usdt_buy_price']['value'])? floatval($trade['usdt_buy_price']['value']) : '0.00', 'sell_price'=> isset($trade['usdt_sell_price']['value'])? floatval($trade['usdt_sell_price']['value']) : '0.00', 'total'=> rand(100000,999999)+(rand(10,50)/100), 'count'=> rand(1000,9999), 'rate'=> rand(10,90)+(rand(10,50)/100), ]; return message(1010, true, compact('trade')); } /** * 获取平台交易参数配置 * @return array */ public function config() { // 交易参数 $type = request()->post('type', 1); if($type == 1){ $trade = ConfigService::make()->getConfigOptionByGroup(5); }else if ($type == 2){ $trade = ConfigService::make()->getConfigOptionByGroup(6); }else if ($type == 3){ $trade1 = ConfigService::make()->getConfigOptionByGroup(7); $trade2 = ConfigService::make()->getConfigOptionByGroup(8); $trade = [ 'confirm'=> array_values($trade1), 'tips'=> array_values($trade2), 'platform'=> ConfigService::make()->getConfigOptionByGroup(1) ]; } return message(1010, true, compact('trade')); } /** * 未读消息数量 * @return array */ public function chatCount() { $userId = request()->post('user_id', 0); $userId = $userId? $userId : $this->userId; $count = ChatMessageService::make()->getUnReadCount($userId); return message(1002, true, $count); } /** * 设置修改登录密码 * @param MemberValidator $validate * @return array */ public function modifyPwd(MemberValidator $validate) { $params = $validate->check(request()->post(),'password'); if(!is_array($params)){ return message($params, false); } if($params['code'] != 123456 && !MemberService::make()->checkCode($params['username'], $params['code'], 'password')){ return message(MemberService::make()->getError(), false); } $userInfo = MemberService::make()->getInfo(['username'=> $params['username']]); $userId = isset($userInfo['id'])? $userInfo['id'] : 0; if(empty($userInfo) || $userId<=0){ return message(2001, false); } if(MemberService::make()->updatePassword($userId, $params)){ return message(MemberService::make()->getError(), true); }else{ return message(MemberService::make()->getError(), false); } } }