DiyTemplatePayNotify.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace common\logic\notify;
  3. use backend\modules\mall\services\TemplateService;
  4. use common\models\diy\DiyTemplateOrder;
  5. use Exception;
  6. use Yii;
  7. /**
  8. * 自定义模板订单支付回调
  9. * @package common\logic\notify
  10. */
  11. class DiyTemplatePayNotify
  12. {
  13. /**
  14. * @param array $order_info
  15. * @return boolean
  16. */
  17. public function notify($order_info)
  18. {
  19. try {
  20. /**
  21. * @var DiyTemplateOrder|null
  22. */
  23. $order = DiyTemplateOrder::getOrderByOrderNo($order_info['order_no']);
  24. if (empty($order)) {
  25. throw new Exception('订单不存在');
  26. }
  27. // 订单支付
  28. $order->paid($order_info['pay_type']);
  29. // 续费模板
  30. $service = new TemplateService(['mall_id' => $order->mall_id]);
  31. $service->renewTemplate($order->template_id, $order->duration);
  32. return true;
  33. } catch (Exception $e) {
  34. Yii::error('模板订单支付回调失败错误: ' . json_encode([
  35. 'line' => $e->getLine(),
  36. 'msg' => $e->getMessage(),
  37. ]));
  38. Yii::error('模板订单支付回调失败参数: ' . json_encode($order_info));
  39. return false;
  40. }
  41. }
  42. }