OrderShipMessage.php 1.3 KB

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