| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace addons\DepositPresale\common\helpers\sms;
- use Overtrue\EasySms\Contracts\GatewayInterface;
- use Overtrue\EasySms\Message;
- class OrderShipMessage extends Message
- {
- protected $content;
- protected $orderConfig;
- // protected $strategy = OrderStrategy::class; // 定义本短信的网关使用策略,覆盖全局配置中的 `default.strategy`
- // protected $gateways = ['alidayu', 'yunpian', 'juhe']; // 定义本短信的适用平台,覆盖全局配置中的 `default.gateways`
- public function __construct($content, $orderConfig)
- {
- $this->content = $content;
- $this->orderConfig = $orderConfig;
- }
- // 定义直接使用内容发送平台的内容
- public function getContent(GatewayInterface $gateway = null)
- {
- return sprintf('您的预售订单编号%s,已支付尾款成功,今天到达%s发货日期', $this->content['order_no'], $this->content['date']);
- }
- // 定义使用模板发送方式平台所需要的模板 ID
- public function getTemplate(GatewayInterface $gateway = null)
- {
- return $this->orderConfig['template_id'];
- }
- // 模板参数
- public function getData(GatewayInterface $gateway = null)
- {
- return [
- $this->orderConfig['template_variable'] => $this->content
- ];
- }
- }
|