IndexController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 orderInfo(){
  70. $orderSn = request()->get('order_sn');
  71. if(empty($orderSn)){
  72. return message('订单号参数错误', false);
  73. }
  74. $info = [];
  75. $prefix = substr($orderSn, 0,1);
  76. switch ($prefix){
  77. case 'G': // 供灯
  78. $info = $this->gdService->orderInfo($orderSn);
  79. break;
  80. case 'R': // 充值
  81. $info = $this->rechargeService->orderInfo($orderSn);
  82. break;
  83. }
  84. if($info){
  85. return message('获取订单信息', true, $info);
  86. }else{
  87. return message('获取订单信息失败', false);
  88. }
  89. }
  90. }