DemoNotification.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Services\NoticeService;
  3. use App\Services\NoticeService\Channels\KfAccountChannel;
  4. use App\Services\NoticeService\Channels\MiniTemplateChannel;
  5. use App\Services\NoticeService\Channels\TemplateChannel;
  6. class DemoNotification extends Notification
  7. {
  8. protected $title = "";
  9. public function __construct($to_uid)
  10. {
  11. parent::__construct($to_uid);
  12. }
  13. /**
  14. * 是否订阅
  15. * @return bool
  16. */
  17. public function subscribe(): bool
  18. {
  19. return true;
  20. }
  21. /**
  22. * 节流阀
  23. * @return bool
  24. */
  25. public function throttle(): bool
  26. {
  27. return true;
  28. }
  29. /**
  30. * 通知渠道
  31. * @return array
  32. */
  33. public function via(): array
  34. {
  35. return [
  36. $this->toKfAccount(),
  37. $this->toTemplate(),
  38. $this->toMiniTemplate(),
  39. ];
  40. }
  41. /**
  42. * 客服通知
  43. * @return KfAccountChannel
  44. */
  45. public function toKfAccount()
  46. {
  47. $content = "";
  48. $channel = new KfAccountChannel($this->to_uid, $content);
  49. return $channel;
  50. }
  51. /**
  52. * 模版消息
  53. * @return TemplateChannel
  54. */
  55. public function toTemplate()
  56. {
  57. $templateId = "";
  58. $data = [];
  59. return new TemplateChannel($this->to_uid, $templateId, $data);
  60. }
  61. /**
  62. * 小程序模版消息
  63. * @return MiniTemplateChannel
  64. */
  65. public function toMiniTemplate()
  66. {
  67. $templateId = "";
  68. $data = [];
  69. return new MiniTemplateChannel($this->to_uid, $templateId, $data);
  70. }
  71. protected function getPagePath()
  72. {
  73. return parent::getPagePath();
  74. }
  75. }