IndexController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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\RechargeService;
  9. use App\Services\RedisService;
  10. use App\Services\WechatService;
  11. /**
  12. * 主控制器类
  13. * @author wesmiler
  14. * @since 2020/11/10
  15. * Class IndexController
  16. * @package App\Http\Controllers
  17. */
  18. class IndexController extends BaseController
  19. {
  20. /**
  21. * 构造函数
  22. * @author wesmiler
  23. * @since 2020/11/11
  24. * IndexController constructor.
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->gdService = new GongdengOrderService();
  30. $this->rechargeService = new RechargeService();
  31. $this->cityService = new CityService();
  32. $this->adServices = new AdService();
  33. }
  34. /**
  35. * 获取首页广告轮播数据
  36. * @return array
  37. */
  38. public function banners(){
  39. $banners = $this->adServices->geListBySort(1);
  40. $advert1 = $this->adServices->geDataBySort(2);
  41. $advert2 = $this->adServices->geListBySort(3);
  42. $data = [
  43. 'banners'=> $banners? $banners : [],
  44. 'advert1'=> $advert1? $advert1 : [],
  45. 'advert2'=> $advert2? $advert2 : [],
  46. ];
  47. return message(1005, true, $data);
  48. }
  49. /**
  50. * 按广告位返回广告列表
  51. * @return array
  52. */
  53. public function banner(){
  54. $sortId = request()->get('id', 0);
  55. return message(1005, true, $this->adServices->geListBySort($sortId));
  56. }
  57. /**
  58. * 获取jssdk参数
  59. * @return array
  60. */
  61. public function jssdk(){
  62. $url = request()->get('url', '');
  63. $jssdkParams = WechatService::getJssdkParams($url);
  64. RedisService::set('caches:shares:'.date('YmdHis'), ['url'=> $url,'params'=> $jssdkParams], 600);
  65. return message(1005,true, $jssdkParams);
  66. }
  67. /**
  68. * 城市列表
  69. * @return array
  70. */
  71. public function city(){
  72. return $this->cityService->getPickerList();
  73. }
  74. /**
  75. * 邀请奖励参数
  76. * @return array
  77. */
  78. public function inviteParams(){
  79. $config = ConfigService::make()->getConfigByGroup(14);
  80. return message(1005,true, $config);
  81. }
  82. /**
  83. * 邀请奖励参数
  84. * @return array
  85. */
  86. public function vipParams(){
  87. $config = ConfigService::make()->getConfigByGroup(15);
  88. return message(1005,true, $config);
  89. }
  90. /**
  91. * 平台参数
  92. * @return array
  93. */
  94. public function params(){
  95. $config = ConfigService::make()->getConfigByGroup(16);
  96. return message(1005,true, $config);
  97. }
  98. /**
  99. * 会员中心菜单设置
  100. * @return array
  101. */
  102. public function menus(){
  103. $config = ConfigService::make()->getConfigByGroup(22);
  104. return message(1005,true, $config);
  105. }
  106. /**
  107. * 获取验证订单信息
  108. * @return array
  109. */
  110. public function orderInfo(){
  111. $orderSn = request()->get('order_sn');
  112. if(empty($orderSn)){
  113. return message('订单号参数错误', false);
  114. }
  115. $info = [];
  116. $prefix = substr($orderSn, 0,1);
  117. switch ($prefix){
  118. case 'G': // 供灯
  119. $info = $this->gdService->orderInfo($orderSn);
  120. break;
  121. case 'R': // 充值
  122. $info = $this->rechargeService->orderInfo($orderSn);
  123. break;
  124. }
  125. if($info){
  126. return message('获取订单信息', true, $info);
  127. }else{
  128. return message('获取订单信息失败', false);
  129. }
  130. }
  131. /**
  132. * 获取热门关键词
  133. * @return array
  134. */
  135. public function keywords(){
  136. $type = request()->get('type', 1);
  137. $keywords = ConfigService::make()->getConfigByCode("search_keyword_{$type}");
  138. $keywords = $keywords? explode(',', $keywords) : [];
  139. return message(1005, true, $keywords);
  140. }
  141. }