Message.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\common\service;
  13. /**
  14. * 消息通知服务
  15. * Class Message
  16. * @package app\common\service
  17. */
  18. class Message extends BaseService
  19. {
  20. /**
  21. * 场景列表
  22. * [场景名称] => [场景类]
  23. * @var array
  24. */
  25. private static array $sceneList = [
  26. // 短信验证码
  27. 'passport.captcha' => \app\common\service\message\passport\Captcha::class,
  28. // 订单支付成功
  29. 'order.payment' => \app\common\service\message\order\Payment::class,
  30. // 订单发货
  31. 'order.delivery' => \app\common\service\message\order\Delivery::class,
  32. // 订单退款
  33. 'order.refund' => \app\common\service\message\order\Refund::class,
  34. ];
  35. /**
  36. * 发送消息通知
  37. * @param string $sceneName 场景名称
  38. * @param array $param 参数
  39. * @param int $storeId 商城ID
  40. * @return mixed
  41. */
  42. public static function send(string $sceneName, array $param, int $storeId)
  43. {
  44. if (!isset(self::$sceneList[$sceneName])) return false;
  45. $class = self::$sceneList[$sceneName];
  46. return (new $class($storeId))->send($param);
  47. }
  48. }