Payment.php 872 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. use app\common\service\OrderPaySuccService;
  5. use app\common\service\PayReturnService;
  6. use think\Db;
  7. /**
  8. * 第三方登录控制器
  9. */
  10. class Payment extends Frontend
  11. {
  12. protected $noNeedLogin='*';
  13. /**
  14. * 支付成功回调
  15. */
  16. public function notify($order_no)
  17. {
  18. Db::startTrans();
  19. $payment=\app\common\model\Payment::where('order_no',$order_no)
  20. ->lock(true)
  21. ->find();
  22. if(!$payment){
  23. Db::rollback();
  24. $this->result([],400);
  25. }
  26. $service=new PayReturnService();
  27. $service->setPayment($payment);
  28. list($isPay,$succ)=$service->process();
  29. if(!$payment['pay_time'] && $isPay){
  30. $payment->payed();
  31. }
  32. Db::commit();
  33. return $succ;
  34. }
  35. }