OrderPaySuccess.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Modules\Trade\Pay;
  3. use App\Modules\Subscribe\Models\Order;
  4. /**
  5. *
  6. */
  7. class OrderPaySuccess
  8. {
  9. /**
  10. * 支付成功回调处理订单
  11. * @param string $trade_no 订单号
  12. * @param string $transaction_id 微信商户号
  13. * @return bool
  14. */
  15. public static function handle(string $trade_no, string $transaction_id)
  16. {
  17. $order = Order::where('trade_no', $trade_no)->first();
  18. $order->transaction_id = $transaction_id;
  19. if ($order) {
  20. if ($order->status == 'PAID') {
  21. myLog('pay_notify')->info('has_pay:' . $trade_no);
  22. return true;
  23. }
  24. if ($order->order_type == 'YEAR') {
  25. $app = new YearOrderPaySuccess($order);
  26. } elseif ($order->order_type == 'BOOK') {
  27. $app = new BookOrderPaySuccess($order);
  28. } elseif ($order->order_type == 'RECHARGE') {
  29. $app = new RechargeOrderPaySuccess($order);
  30. }
  31. return $app->success();
  32. } else {
  33. return false;
  34. }
  35. }
  36. }