12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\index\controller;
- use app\common\controller\Frontend;
- use app\common\service\PayReturnService;
- use think\Db;
- /**
- * 第三方登录控制器
- */
- class Payment extends Frontend
- {
- protected $noNeedLogin='*';
- /**
- * 支付成功回调
- */
- public function notify($order_no)
- {
- Db::startTrans();
- $payment=\app\common\model\Payment::where('order_no',$order_no)
- ->lock(true)
- ->find();
- if(!$payment){
- Db::rollback();
- $this->result([],400);
- }
- user_log("payment/{$payment['order_no']}",[
- 'input'=>input(),
- '$_post'=>$_POST
- ]);
- $service=new PayReturnService();
- $service->setPayment($payment);
- list($isPay,$succ)=$service->process();
- user_log("payment/{$payment['order_no']}",compact('isPay','succ'));
- if(!$payment['pay_time'] && $isPay){
- $payment->payed();
- }
- Db::commit();
- if(!$isPay){
- $this->result($succ,400);
- }
- return $succ;
- }
- }
|