| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace addons\Store\common\sms;
- use addons\Store\common\enums\StoreEnum;
- use Overtrue\EasySms\Contracts\GatewayInterface;
- use Overtrue\EasySms\Message;
- class ShopExpireMessage extends Message
- {
- protected $day;
- protected $template_id;
- protected $store_name;
- protected $mall_id;
- public function __construct($mall_id, $day, $store_name)
- {
- $this->day = $day;
- $this->store_name = $store_name;
- $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_alert_expire'])) throw new \Exception('o2o门店到期提醒未开启');
- if (empty($sms_setting['expire_template_id'])) throw new \Exception('o2o门店到期提醒,模板ID为空');
- $this->template_id = $sms_setting['expire_template_id'];
- }
- // 定义直接使用内容发送平台的内容
- public function getContent(GatewayInterface $gateway = null)
- {
- return sprintf("您的门店还有%s天到期,门店名:%s,请及时处理", $this->day, $this->store_name);
- }
- // 定义使用模板发送方式平台所需要的模板 ID
- public function getTemplate(GatewayInterface $gateway = null)
- {
- return $this->template_id;
- }
- // 模板参数
- public function getData(GatewayInterface $gateway = null)
- {
- return [
- 'day' => $this->day,
- 'store_name' => $this->store_name,
- 'project' => $this->template_id,
- ];
- }
- }
|