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, ]; } }