Browse Source

新增回调路由和二维码回调方法

master
王泽彦 10 months ago
parent
commit
1e0a8d553c
  1. 21
      niucloud/app/api/controller/pay/Pay.php
  2. 5
      niucloud/app/api/route/pay.php
  3. 14
      niucloud/app/service/api/pay/PayService.php

21
niucloud/app/api/controller/pay/Pay.php

@ -16,6 +16,7 @@ use core\base\BaseApiController;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
use think\facade\Log;
use think\Response; use think\Response;
/** /**
@ -94,4 +95,24 @@ class Pay extends BaseApiController
]); ]);
return success('SUCCESS',(new PayService())->close($data['type'], $data['out_trade_no'])); return success('SUCCESS',(new PayService())->close($data['type'], $data['out_trade_no']));
} }
/**
* 获取支付二维码
*/
public function getQrcode(){
$data = $this->request->params([
['trade_type', ''],
['trade_id', ''],
['type', ''],
]);
return success('SUCCESS',(new PayService())->getQrcode($data['type'], $data['trade_type'], $data['trade_id']));
}
public function qrcodeNotify()
{
// todo
Log::debug('qrcodeNotify');
Log::debug(json_encode($this->request->param()));
return success('SUCCESS');
}
} }

5
niucloud/app/api/route/pay.php

@ -19,6 +19,11 @@ Route::any('pay/notify/:channel/:type/:action', 'pay.Pay/notify')
->middleware(ApiChannel::class) ->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class) ->middleware(ApiCheckToken::class)
->middleware(ApiLog::class); ->middleware(ApiLog::class);
Route::any('pay/qrcodenotify', 'pay.Pay/qrcodeNotify')
->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class)
->middleware(ApiLog::class);
/** /**
* 路由 * 路由
*/ */

14
niucloud/app/service/api/pay/PayService.php

@ -148,4 +148,18 @@ class PayService extends BaseApiService
public function getPayTypeByTrade(string $trade_type){ public function getPayTypeByTrade(string $trade_type){
return $this->core_pay_service->getPayTypeByTrade($trade_type, $this->channel); return $this->core_pay_service->getPayTypeByTrade($trade_type, $this->channel);
} }
public function getQrcode()
{
// todo
}
/**
* 二维码支付回调
*/
public function qrcodeNotify()
{
// todo
}
} }

Loading…
Cancel
Save