OrderPaySuccess.php 1.2 KB

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