| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace addons\CloudStockTwo\common\sms;
- use addons\CloudStockTwo\common\models\CloudStockTwoSms;
- use common\enums\StatusEnum;
- use Overtrue\EasySms\Contracts\GatewayInterface;
- use Overtrue\EasySms\Message;
- class RewardMessage extends Message
- {
- protected $money;
- protected $template_id;
- protected $mall_id;
- const sms_key = 'bonus';
- public function __construct($mall_id, $money)
- {
- $this->money = $money;
- $this->mall_id = $mall_id;
- parent::__construct();
- $this->getTempId();
- }
- public function getTempId()
- {
- $detail = CloudStockTwoSms::findOne(['mall_id' => $this->mall_id, 'sms_key' => self::sms_key, 'status' => StatusEnum::ENABLED]);
- if (!isset($detail['temp_id'])) throw new \Exception('bonus短信通知,temp_id为空');
- $this->template_id = $detail['temp_id'];
- }
- // 定义直接使用内容发送平台的内容
- public function getContent(GatewayInterface $gateway = null)
- {
- return sprintf("恭喜你,获得了%s元云库存收益。请注意查看", $this->money);
- }
- // 定义使用模板发送方式平台所需要的模板 ID
- public function getTemplate(GatewayInterface $gateway = null)
- {
- return $this->template_id;
- }
- // 模板参数
- public function getData(GatewayInterface $gateway = null)
- {
- return [
- 'money' => $this->money,
- ];
- }
- }
|