| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\BaseController;
- use App\Services\AdService;
- use App\Services\CityService;
- use App\Services\ConfigService;
- use App\Services\GongdengOrderService;
- use App\Services\OrdersService;
- use App\Services\RechargeService;
- use App\Services\RedisService;
- use App\Services\WechatService;
- /**
- * 主控制器类
- * @author wesmiler
- * @since 2020/11/10
- * Class IndexController
- * @package App\Http\Controllers
- */
- class IndexController extends BaseController
- {
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/11
- * IndexController constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->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);
- 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, '<div class="furborder">'));
- $temp = substr($temp, 0, strpos($temp, '<div class="calendar mt">'));
- }
- // 宜忌
- $content1 = file_get_contents($apiUrl.'/laohuangli/');
- $temp1 = substr($content1,strpos($content1, '<div class="goodcalendar4">'));
- $temp1 = substr($temp1,0, strpos($temp1, '</div>'));
- preg_match("/<\/td>\\n<td>(.*)<\/td>\\n<td/", $temp1, $yi);
- $yi = isset($yi[1])? $yi[1] : '';
- preg_match("/<td colspan=\"3\">(.*)<\/td>/", $temp1, $ji);
- $ji = isset($ji[1])? $ji[1] : '';
- preg_match("/<td class>(.*)<\/td>/", $temp1, $yl);
- $yl = isset($yl[1])? $yl[1] : '';
- return message(MESSAGE_OK, true, ['content'=> $content, 'result'=> $temp,'hl'=> $temp1,'date'=> date('m月d日'),'yl'=> $yl,'yl_day'=> substr($yl, -2, 2),'yi'=> $yi,'ji'=> $ji]);
- }
- }
|