IndexController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\BaseController;
  4. use App\Services\CityService;
  5. use App\Services\ConfigService;
  6. use App\Services\GongdengOrderService;
  7. use App\Services\RechargeService;
  8. use App\Services\RedisService;
  9. use App\Services\WechatService;
  10. /**
  11. * 主控制器类
  12. * @author wesmiler
  13. * @since 2020/11/10
  14. * Class IndexController
  15. * @package App\Http\Controllers
  16. */
  17. class IndexController extends BaseController
  18. {
  19. /**
  20. * 构造函数
  21. * @author wesmiler
  22. * @since 2020/11/11
  23. * IndexController constructor.
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. $this->gdService = new GongdengOrderService();
  29. $this->rechargeService = new RechargeService();
  30. $this->cityService = new CityService();
  31. }
  32. /**
  33. * 获取jssdk参数
  34. * @return array
  35. */
  36. public function jssdk(){
  37. $url = request()->get('url', '');
  38. $jssdkParams = WechatService::getJssdkParams($url);
  39. RedisService::set('caches:shares:'.date('YmdHis'), ['url'=> $url,'params'=> $jssdkParams], 600);
  40. return message(1005,true, $jssdkParams);
  41. }
  42. /**
  43. * 城市列表
  44. * @return array
  45. */
  46. public function city(){
  47. return $this->cityService->getPickerList();
  48. }
  49. /**
  50. * 邀请奖励参数
  51. * @return array
  52. */
  53. public function inviteParams(){
  54. $config = ConfigService::make()->getConfigByGroup(14);
  55. return message(1005,true, $config);
  56. }
  57. /**
  58. * 邀请奖励参数
  59. * @return array
  60. */
  61. public function vipParams(){
  62. $config = ConfigService::make()->getConfigByGroup(15);
  63. return message(1005,true, $config);
  64. }
  65. /**
  66. * 平台参数
  67. * @return array
  68. */
  69. public function params(){
  70. $config = ConfigService::make()->getConfigByGroup(16);
  71. return message(1005,true, $config);
  72. }
  73. /**
  74. * 获取验证订单信息
  75. * @return array
  76. */
  77. public function orderInfo(){
  78. $orderSn = request()->get('order_sn');
  79. if(empty($orderSn)){
  80. return message('订单号参数错误', false);
  81. }
  82. $info = [];
  83. $prefix = substr($orderSn, 0,1);
  84. switch ($prefix){
  85. case 'G': // 供灯
  86. $info = $this->gdService->orderInfo($orderSn);
  87. break;
  88. case 'R': // 充值
  89. $info = $this->rechargeService->orderInfo($orderSn);
  90. break;
  91. }
  92. if($info){
  93. return message('获取订单信息', true, $info);
  94. }else{
  95. return message('获取订单信息失败', false);
  96. }
  97. }
  98. }