OrderCreateMessage.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace addons\DepositPresale\common\helpers\sms;
  3. use Overtrue\EasySms\Contracts\GatewayInterface;
  4. use Overtrue\EasySms\Message;
  5. class OrderCreateMessage extends Message
  6. {
  7. protected $captcha;
  8. protected $content;
  9. protected $orderConfig;
  10. // protected $strategy = OrderStrategy::class; // 定义本短信的网关使用策略,覆盖全局配置中的 `default.strategy`
  11. // protected $gateways = ['alidayu', 'yunpian', 'juhe']; // 定义本短信的适用平台,覆盖全局配置中的 `default.gateways`
  12. public function __construct($content, $orderConfig)
  13. {
  14. $this->content = $content;
  15. $this->orderConfig = $orderConfig;
  16. }
  17. // 定义直接使用内容发送平台的内容
  18. public function getContent(GatewayInterface $gateway = null)
  19. {
  20. return sprintf('您的预售订单编号%s,已支付定金成功,今天%s到达支付尾款日期', $this->content['order_no'], $this->content['date']);
  21. }
  22. // 定义使用模板发送方式平台所需要的模板 ID
  23. public function getTemplate(GatewayInterface $gateway = null)
  24. {
  25. return $this->orderConfig['template_id'];
  26. }
  27. // 模板参数
  28. public function getData(GatewayInterface $gateway = null)
  29. {
  30. return [
  31. $this->orderConfig['template_variable'] => $this->content
  32. ];
  33. }
  34. }