Notify.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace common\logic\notify;
  3. use common\models\common\PaymentTrade;
  4. use common\models\order\Order;
  5. use common\traits\ErrorTrait;
  6. use Exception;
  7. /**
  8. * Class Notify
  9. * @Author: hua
  10. * @DateTime: 2021/10/18 9:39
  11. * @Copyright: copyright (c) 2021 广东七件事集团
  12. * @package common\logic\notify
  13. */
  14. class Notify
  15. {
  16. use ErrorTrait;
  17. /**
  18. * @Author: hua
  19. * @DateTime: 2021/10/18 9:57
  20. * @Copyright: copyright (c) 2021 广东七件事集团
  21. * @param $order_info
  22. * @return bool
  23. */
  24. public function notify($order_info)
  25. {
  26. try {
  27. $payment_trade = PaymentTrade::findOne(['id' => $order_info['trade_id']]);
  28. $order = Order::findOne(['order_no' => $order_info['order_no']]);
  29. $res = Order::pay($order,$order_info['pay_type'],$payment_trade['out_trade_no']);
  30. if($res === false) throw new Exception(Order::getStaticError());
  31. return true;
  32. } catch (Exception $e) {
  33. \Yii::$app->custom->logs('notify:'.$e->getMessage());
  34. $this->setStaticError($e->getMessage());
  35. return false;
  36. }
  37. }
  38. }