Message.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\service;
  3. /**
  4. * 消息通知服务
  5. * Class Message
  6. * @package app\common\service
  7. */
  8. class Message extends Basics
  9. {
  10. /**
  11. * 场景列表
  12. * [场景名称] => [场景类]
  13. * @var array
  14. */
  15. private static $sceneList = [
  16. // 订单支付成功
  17. 'order.payment' => 'app\common\service\message\order\Payment',
  18. // 订单发货
  19. 'order.delivery' => 'app\common\service\message\order\Delivery',
  20. // 订单退款
  21. 'order.refund' => 'app\common\service\message\order\Refund',
  22. // 拼团进度通知
  23. 'sharing.active_status' => 'app\common\service\message\sharing\ActiveStatus',
  24. // 分销商入驻通知
  25. 'dealer.apply' => 'app\common\service\message\dealer\Apply',
  26. // 分销商提现通知
  27. 'dealer.withdraw' => 'app\common\service\message\dealer\Withdraw',
  28. ];
  29. /**
  30. * 发送消息通知
  31. * @param string $sceneName 场景名称
  32. * @param array $param 参数
  33. * @return bool
  34. */
  35. public static function send($sceneName, $param)
  36. {
  37. if (!isset(self::$sceneList[$sceneName]))
  38. return false;
  39. $className = self::$sceneList[$sceneName];
  40. return class_exists($className) ? (new $className)->send($param) : false;
  41. }
  42. }