Service.php 812 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\library\message;
  3. use addons\shop\library\message\Mini;
  4. use addons\shop\library\message\Mp;
  5. use addons\shop\library\message\Email;
  6. use addons\shop\library\message\Mobile;
  7. class Service
  8. {
  9. //分发数据
  10. //根据组装的数据发送
  11. public static function send($type, $data)
  12. {
  13. switch ($type) {
  14. case 1:
  15. $obj = new Mp();
  16. break;
  17. case 2:
  18. $obj = new Mini();
  19. break;
  20. case 3:
  21. $obj = new Email();
  22. break;
  23. case 4:
  24. $obj = new Mobile();
  25. break;
  26. default:
  27. throw new \Exception('类型不存在');
  28. }
  29. //异步并发发送
  30. $obj->send($data);
  31. }
  32. }