IndexController.php 2.2 KB

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