HdNotifyClass.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace biz\common\classes;
  3. use biz\base\classes\BaseClass;
  4. use common\components\noticeUtil;
  5. use Yii;
  6. class HdNotifyClass extends BaseClass
  7. {
  8. public static function newOrderNotify($orderId)
  9. {
  10. try {
  11. $producer = Yii::$app->rabbitmq->getProducer('notifyProducer');
  12. $msg = serialize(['type' => 'hd_new_order_notify', 'orderId' => $orderId]);
  13. $producer->publish($msg, 'notifyExchange', 'notifyRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
  14. } catch (\Exception $e) {
  15. $msg = $e->getMessage();
  16. $remind = "零售,新订单通知,生产消息端报错 {$orderId} {$msg}";
  17. noticeUtil::push($remind, '15280215347');
  18. }
  19. }
  20. public static function newCgNotify($cgId)
  21. {
  22. return false;
  23. try {
  24. $producer = Yii::$app->rabbitmq->getProducer('notifyProducer');
  25. $msg = serialize(['type' => 'hd_new_cg_notify', 'cgId' => $cgId]);
  26. $producer->publish($msg, 'notifyExchange', 'notifyRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
  27. } catch (\Exception $e) {
  28. $msg = $e->getMessage();
  29. $remind = "零售,新采购单通知,生产消息端报错 {$cgId} {$msg}";
  30. noticeUtil::push($remind, '15280215347');
  31. }
  32. }
  33. public static function ptErrorNotify($orderId, $event)
  34. {
  35. try {
  36. $producer = Yii::$app->rabbitmq->getProducer('notifyProducer');
  37. $msg = serialize(['type' => 'hd_pt_error', 'orderId' => $orderId, 'event' => $event]);
  38. $producer->publish($msg, 'notifyExchange', 'notifyRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
  39. } catch (\Exception $e) {
  40. $msg = $e->getMessage();
  41. $remind = "零售,跑腿异常通知,生产消息端报错 {$orderId} {$msg}";
  42. noticeUtil::push($remind, '15280215347');
  43. }
  44. }
  45. }