IndexController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\BaseController;
  4. use App\Services\AdService;
  5. use App\Services\CityService;
  6. use App\Services\ConfigService;
  7. use App\Services\GongdengOrderService;
  8. use App\Services\OrdersService;
  9. use App\Services\RechargeService;
  10. use App\Services\RedisService;
  11. use App\Services\WechatService;
  12. /**
  13. * 主控制器类
  14. * @author wesmiler
  15. * @since 2020/11/10
  16. * Class IndexController
  17. * @package App\Http\Controllers
  18. */
  19. class IndexController extends BaseController
  20. {
  21. /**
  22. * 构造函数
  23. * @author wesmiler
  24. * @since 2020/11/11
  25. * IndexController constructor.
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. $this->gdService = new GongdengOrderService();
  31. $this->rechargeService = new RechargeService();
  32. $this->cityService = new CityService();
  33. $this->adServices = new AdService();
  34. $this->orderService = new OrdersService();
  35. }
  36. /**
  37. * 获取首页广告轮播数据
  38. * @return array
  39. */
  40. public function banners(){
  41. $banners = $this->adServices->geListBySort(1);
  42. $advert1 = $this->adServices->geDataBySort(2);
  43. $advert2 = $this->adServices->geListBySort(3);
  44. $data = [
  45. 'banners'=> $banners? $banners : [],
  46. 'advert1'=> $advert1? $advert1 : [],
  47. 'advert2'=> $advert2? $advert2 : [],
  48. ];
  49. return message(1005, true, $data);
  50. }
  51. /**
  52. * 按广告位返回广告列表
  53. * @return array
  54. */
  55. public function banner(){
  56. $sortId = request()->get('id', 0);
  57. return message(1005, true, $this->adServices->geListBySort($sortId));
  58. }
  59. /**
  60. * 获取jssdk参数
  61. * @return array
  62. */
  63. public function jssdk(){
  64. $url = request()->get('url', '');
  65. $jssdkParams = WechatService::getJssdkParams($url);
  66. RedisService::set('caches:shares:'.date('YmdHis'), ['url'=> $url,'params'=> $jssdkParams], 600);
  67. return message(1005,true, $jssdkParams);
  68. }
  69. /**
  70. * 城市列表
  71. * @return array
  72. */
  73. public function city(){
  74. return $this->cityService->getPickerList();
  75. }
  76. /**
  77. * 邀请奖励参数
  78. * @return array
  79. */
  80. public function inviteParams(){
  81. $config = ConfigService::make()->getConfigByGroup(14);
  82. return message(1005,true, $config);
  83. }
  84. /**
  85. * 邀请奖励参数
  86. * @return array
  87. */
  88. public function vipParams(){
  89. $config = ConfigService::make()->getConfigByGroup(15);
  90. return message(1005,true, $config);
  91. }
  92. /**
  93. * 平台参数
  94. * @return array
  95. */
  96. public function params(){
  97. $type = request()->get('type', 1);
  98. $groupId = request()->get('group_id', 16);
  99. $config = ConfigService::make()->getConfigByGroup($groupId);
  100. $config = $type==2? array_values($config) : $config;
  101. return message(1005,true, $config);
  102. }
  103. /**
  104. * 会员中心菜单设置
  105. * @return array
  106. */
  107. public function menus(){
  108. $config = ConfigService::make()->getConfigByGroup(22);
  109. return message(1005,true, $config);
  110. }
  111. /**
  112. * 获取验证订单信息
  113. * @return array
  114. */
  115. public function orderInfo(){
  116. $orderSn = request()->get('order_sn');
  117. if(empty($orderSn)){
  118. return message('订单号参数错误', false);
  119. }
  120. $info = [];
  121. $prefix = substr($orderSn, 0,1);
  122. switch ($prefix){
  123. case 'G': // 供灯
  124. $info = $this->gdService->orderInfo($orderSn);
  125. break;
  126. case 'R': // 充值
  127. $info = $this->rechargeService->orderInfo($orderSn);
  128. break;
  129. case 'S': // 商城
  130. $info = $this->orderService->orderInfo($orderSn);
  131. break;
  132. }
  133. if($info){
  134. return message('获取订单信息', true, $info);
  135. }else{
  136. return message('获取订单信息失败', false);
  137. }
  138. }
  139. /**
  140. * 获取热门关键词
  141. * @return array
  142. */
  143. public function keywords(){
  144. $type = request()->get('type', 1);
  145. $keywords = ConfigService::make()->getConfigByCode("search_keyword_{$type}");
  146. $keywords = $keywords? explode(',', $keywords) : [];
  147. return message(1005, true, $keywords);
  148. }
  149. /**
  150. * 佛历
  151. * @return array
  152. */
  153. public function calendar(){
  154. $apiUrl = env('FOLI_API');
  155. $type = request()->get('type', 0);
  156. if(empty($apiUrl)){
  157. return message('获取失败', false);
  158. }
  159. $content = '';
  160. $temp = '';
  161. if($type == 0){
  162. $content = file_get_contents($apiUrl.'/foli/'.date('Y').'/'.date('m'));
  163. $temp = substr($content,strpos($content, '<div class="furborder">'));
  164. $temp = substr($temp, 0, strpos($temp, '<div class="calendar mt">'));
  165. }
  166. // 宜忌
  167. $content1 = file_get_contents($apiUrl.'/laohuangli/');
  168. $temp1 = substr($content1,strpos($content1, '<div class="goodcalendar4">'));
  169. $temp1 = substr($temp1,0, strpos($temp1, '</div>'));
  170. preg_match("/<\/td>\\n<td>(.*)<\/td>\\n<td/", $temp1, $yi);
  171. $yi = isset($yi[1])? $yi[1] : '';
  172. preg_match("/<td colspan=\"3\">(.*)<\/td>/", $temp1, $ji);
  173. $ji = isset($ji[1])? $ji[1] : '';
  174. preg_match("/<td class>(.*)<\/td>/", $temp1, $yl);
  175. $yl = isset($yl[1])? $yl[1] : '';
  176. 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]);
  177. }
  178. }