IndexController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. $groupId = request()->get('group_id', 16);
  98. $config = ConfigService::make()->getConfigByGroup($groupId);
  99. return message(1005,true, $config);
  100. }
  101. /**
  102. * 会员中心菜单设置
  103. * @return array
  104. */
  105. public function menus(){
  106. $config = ConfigService::make()->getConfigByGroup(22);
  107. return message(1005,true, $config);
  108. }
  109. /**
  110. * 获取验证订单信息
  111. * @return array
  112. */
  113. public function orderInfo(){
  114. $orderSn = request()->get('order_sn');
  115. if(empty($orderSn)){
  116. return message('订单号参数错误', false);
  117. }
  118. $info = [];
  119. $prefix = substr($orderSn, 0,1);
  120. switch ($prefix){
  121. case 'G': // 供灯
  122. $info = $this->gdService->orderInfo($orderSn);
  123. break;
  124. case 'R': // 充值
  125. $info = $this->rechargeService->orderInfo($orderSn);
  126. break;
  127. case 'S': // 商城
  128. $info = $this->orderService->orderInfo($orderSn);
  129. break;
  130. }
  131. if($info){
  132. return message('获取订单信息', true, $info);
  133. }else{
  134. return message('获取订单信息失败', false);
  135. }
  136. }
  137. /**
  138. * 获取热门关键词
  139. * @return array
  140. */
  141. public function keywords(){
  142. $type = request()->get('type', 1);
  143. $keywords = ConfigService::make()->getConfigByCode("search_keyword_{$type}");
  144. $keywords = $keywords? explode(',', $keywords) : [];
  145. return message(1005, true, $keywords);
  146. }
  147. }