gdService = new GongdengOrderService(); $this->rechargeService = new RechargeService(); $this->cityService = new CityService(); $this->adServices = new AdService(); $this->orderService = new OrdersService(); } /** * 获取首页广告轮播数据 * @return array */ public function banners(){ $banners = $this->adServices->geListBySort(1); $advert1 = $this->adServices->geDataBySort(2); $advert2 = $this->adServices->geListBySort(3); $data = [ 'banners'=> $banners? $banners : [], 'advert1'=> $advert1? $advert1 : [], 'advert2'=> $advert2? $advert2 : [], ]; return message(1005, true, $data); } /** * 按广告位返回广告列表 * @return array */ public function banner(){ $sortId = request()->get('id', 0); return message(1005, true, $this->adServices->geListBySort($sortId)); } /** * 获取jssdk参数 * @return array */ public function jssdk(){ $url = request()->get('url', ''); $jssdkParams = WechatService::getJssdkParams($url); RedisService::set('caches:shares:'.date('YmdHis'), ['url'=> $url,'params'=> $jssdkParams], 600); return message(1005,true, $jssdkParams); } /** * 城市列表 * @return array */ public function city(){ return $this->cityService->getPickerList(); } /** * 邀请奖励参数 * @return array */ public function inviteParams(){ $config = ConfigService::make()->getConfigByGroup(14); return message(1005,true, $config); } /** * 邀请奖励参数 * @return array */ public function vipParams(){ $config = ConfigService::make()->getConfigByGroup(15); return message(1005,true, $config); } /** * 平台参数 * @return array */ public function params(){ $type = request()->get('type', 1); $groupId = request()->get('group_id', 16); $config = ConfigService::make()->getConfigByGroup($groupId); $config = $type==2? array_values($config) : $config; return message(1005,true, $config); } /** * 会员中心菜单设置 * @return array */ public function menus(){ $config = ConfigService::make()->getConfigByGroup(22); return message(1005,true, $config); } /** * 获取验证订单信息 * @return array */ public function orderInfo(){ $orderSn = request()->get('order_sn'); if(empty($orderSn)){ return message('订单号参数错误', false); } $info = []; $prefix = substr($orderSn, 0,1); switch ($prefix){ case 'G': // 供灯 $info = $this->gdService->orderInfo($orderSn); break; case 'R': // 充值 $info = $this->rechargeService->orderInfo($orderSn); break; case 'S': // 商城 $info = $this->orderService->orderInfo($orderSn); break; } if($info){ return message('获取订单信息', true, $info); }else{ return message('获取订单信息失败', false); } } /** * 获取热门关键词 * @return array */ public function keywords(){ $type = request()->get('type', 1); $keywords = ConfigService::make()->getConfigByCode("search_keyword_{$type}"); $keywords = $keywords? explode(',', $keywords) : []; return message(1005, true, $keywords); } /** * 佛历 * @return array */ public function calendar(){ $apiUrl = env('FOLI_API'); $type = request()->get('type', 0); $cacheKey = "caches:calendar:".date('YmdH')."_{$type}"; $data = RedisService::get($cacheKey); if($data){ return message(MESSAGE_OK, true, $data); } if(empty($apiUrl)){ return message('获取失败', false); } $content = ''; $temp = ''; if($type == 0){ $content = file_get_contents($apiUrl.'/foli/'.date('Y').'/'.date('m')); $temp = substr($content,strpos($content, '
')); $temp = substr($temp, 0, strpos($temp, '
')); } // 宜忌 $content1 = file_get_contents($apiUrl.'/laohuangli/'); $temp1 = substr($content1,strpos($content1, '
')); $temp1 = substr($temp1,0, strpos($temp1, '
')); preg_match("/<\/td>\\n(.*)<\/td>\\n(.*)<\/td>/", $temp1, $ji); $ji = isset($ji[1])? $ji[1] : ''; preg_match("/(.*)<\/td>\\n/", $temp1, $yl); $yl = isset($yl[1])? $yl[1] : ''; $data = ['content'=> $content, 'result'=> $temp,'hl'=> $temp1,'date'=> date('m月d日'),'yl'=> $yl,'yl_day'=> mb_substr($yl, -2, 2,'utf-8'),'yi'=> $yi,'ji'=> $ji]; RedisService::set($cacheKey, $data, 48 *3600); return message(MESSAGE_OK, true, $data); } }