| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace addons\CloudStock\common\sms;
- use common\models\common\MallSetting;
- class SmsConfig
- {
- private $config;
- /**
- * SmsConfig constructor.
- */
- public function __construct($mall_id = 5, $group = 'notice_sms')
- {
- $this->config = [
- // HTTP 请求的超时时间(秒)
- 'timeout' => 5.0,
- // 默认发送配置
- 'default' => [
- // 网关调用策略,默认:顺序调用
- 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
- // 默认可用的发送网关
- 'gateways' => [
- 'aliyun',
- ],
- ],
- // 可用的网关配置
- 'gateways' => [
- 'errorlog' => [
- 'file' => '/runtime/easy-sms.log',
- ],
- //...
- ],
- ];
- $smsConfig = MallSetting::getConfByGroup($mall_id, $group, true);
- // 阿里云短信配置
- if ($smsConfig['platform']['value'] == 'aliyun') {
- $this->config['gateways']['aliyun'] = [
- 'access_key_id' => $smsConfig['access_key_id']['value'] ?? '',
- 'access_key_secret' => $smsConfig['access_key_secret']['value'] ?? '',
- 'sign_name' => $smsConfig['template_name']['value'] ?? '',
- ];
- }
- }
- /**
- * @return array
- */
- public function getConfig()
- {
- return $this->config;
- }
- }
|