| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace addons\Store\common\sms;
- use addons\Store\common\enums\StoreEnum;
- use Overtrue\EasySms\Contracts\GatewayInterface;
- use Overtrue\EasySms\Message;
- class PayRemindMessage extends Message
- {
- protected $order_no;
- protected $template_id;
- protected $shipping_type;
- protected $mall_id;
- public function __construct($mall_id, $order_no, $shipping_type)
- {
- $this->order_no = $order_no;
- $this->shipping_type = $shipping_type;
- $this->mall_id = $mall_id;
- parent::__construct();
- $this->getTempId();
- }
- public function getTempId()
- {
- $sms_setting = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'sms_setting');
- if (empty($sms_setting['is_pay_remind'])) throw new \Exception('o2o门店订单支付提醒未开启');
- if (empty($sms_setting['pay_template_id'])) throw new \Exception('o2o门店订单支付提醒,模板ID为空');
- $this->template_id = $sms_setting['pay_template_id'];
- }
- // 定义直接使用内容发送平台的内容
- public function getContent(GatewayInterface $gateway = null)
- {
- return sprintf("您有一笔新的订单,订单号:%s,配送方式为%s,请及时处理", $this->order_no, $this->shipping_type);
- }
- // 定义使用模板发送方式平台所需要的模板 ID
- public function getTemplate(GatewayInterface $gateway = null)
- {
- return $this->template_id;
- }
- // 模板参数
- public function getData(GatewayInterface $gateway = null)
- {
- return [
- 'order_no' => $this->order_no,
- 'shipping_type' => $this->shipping_type,
- 'project' => $this->template_id,
- ];
- }
- }
|