SmsMessage.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace addons\ReservationService\common\logic;
  3. use Overtrue\EasySms\Contracts\MessageInterface;
  4. use Overtrue\EasySms\Message;
  5. use Overtrue\EasySms\Contracts\GatewayInterface;
  6. class SmsMessage extends Message
  7. {
  8. protected $data;
  9. protected $template_id;
  10. protected $mall_id;
  11. protected $mall_sms;
  12. public function __construct($content)
  13. {
  14. $this->data = $content['data'];
  15. parent::__construct();
  16. $this->template_id = $content['template'];
  17. $this->mall_sms = $content['mall_sms'];
  18. }
  19. // 定义使用模板发送方式平台所需要的模板 ID
  20. public function getTemplate(GatewayInterface $gateway = null)
  21. {
  22. return $this->template_id;
  23. }
  24. // 模板参数
  25. public function getData(GatewayInterface $gateway = null)
  26. {
  27. $data = [];
  28. foreach ($this->data as $key => $value) {
  29. $data[$key] = $value;
  30. }
  31. if ($this->mall_sms == 'submail') {
  32. $data['project'] = $this->template_id;
  33. }
  34. return $data;
  35. }
  36. }