SmsMessage.php 1011 B

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