| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\BaseController;
- use App\Services\RedisService;
- use App\Services\WechatService;
- /**
- * 主控制器类
- * @author wesmiler
- * @since 2020/11/10
- * Class IndexController
- * @package App\Http\Controllers
- */
- class IndexController extends BaseController
- {
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/11
- * IndexController constructor.
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * 获取jssdk参数
- * @return array
- */
- public function jssdk(){
- $url = request()->get('url', '');
- $jssdkParams = WechatService::getJssdkParams($url);
- RedisService::set('caches:shares:'.date('YmdHis'), ['url'=> $url,'params'=> $jssdkParams], 600);
- return message(1005,true, $jssdkParams);
- }
- /**
- * 获取验证订单信息
- * @return array
- */
- public function orderInfo(){
- $orderSn = request()->get('out_trade_no');
- if(empty($orderSn)){
- return message('订单号参数错误', false);
- }
- $info = [];
- $prefix = substr($orderSn, 0,1);
- switch ($prefix){
- case 'G': // 供灯
- $info = $this->service->orderInfo($orderSn);
- break;
- case 'R': // 充值
- $info = $this->service->orderInfo($orderSn);
- break;
- }
- if($info){
- return message('获取订单信息失败', false);
- }else{
- return message('获取订单信息', true, $info);
- }
- }
- }
|