99 lines
2.9 KiB
PHP
99 lines
2.9 KiB
PHP
<?php
|
||
|
||
namespace app\models\sms;
|
||
|
||
use Yii;
|
||
use app\components\DbUtils;
|
||
|
||
/**
|
||
* This is the model class for table "{{%sms_setting}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property int $type 类型,0=阿里云,1=腾讯云
|
||
* @property string|null $access_key_id 阿里云AccessKeyId
|
||
* @property string|null $access_secret 阿里云AccessSecret
|
||
* @property string|null $secret_id 腾讯短信SecretId
|
||
* @property string|null $secret_key 腾讯短信SecretKey
|
||
* @property string|null $sdk_app_id 腾讯短信应用ID
|
||
* @property string|null $sign_name 签名
|
||
* @property int $expire_time 有效时长
|
||
* @property int $time_delay 获取时间间隔
|
||
* @property int $day_limit 每日获取验证码次数
|
||
* @property int $is_prod 环境,0=非正式,1=正式环境
|
||
* @property int $code_len 验证码长度
|
||
* @property string $super_code 超级验证码,默认6666
|
||
*/
|
||
class SmsSetting extends \yii\db\ActiveRecord
|
||
{
|
||
const TYPE_ALIYUN = 0;
|
||
const TYPE_TENCENT = 1;
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%sms_setting}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['cx_mch_id', 'type', 'expire_time', 'time_delay', 'day_limit', 'is_prod', 'code_len'], 'integer'],
|
||
[['access_key_id', 'access_secret', 'secret_id', 'secret_key', 'sdk_app_id', 'sign_name', 'super_code'], 'string', 'max' => 64],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'type' => '类型,0=阿里云,1=腾讯云',
|
||
'access_key_id' => '阿里云AccessKeyId',
|
||
'access_secret' => '阿里云AccessSecret',
|
||
'secret_id' => '腾讯短信SecretId',
|
||
'secret_key' => '腾讯短信SecretKey',
|
||
'sdk_app_id' => '腾讯短信应用ID',
|
||
'sign_name' => '签名',
|
||
'expire_time' => '有效时长',
|
||
'time_delay' => '获取时间间隔',
|
||
'day_limit' => '每日获取验证码次数',
|
||
'is_prod' => '环境,0=非正式,1=正式环境',
|
||
'code_len' => '验证码长度',
|
||
'super_code' => '超级验证码,默认6666',
|
||
];
|
||
}
|
||
|
||
public function beforeSave($insert) {
|
||
if(parent::beforeSave($insert)){
|
||
if($this->isNewRecord){
|
||
}
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public static function getType($type)
|
||
{
|
||
$labels = self::typeLabels();
|
||
return isset($labels[$type]) ? $labels[$type] : "未知";
|
||
}
|
||
|
||
public static function typeLabels()
|
||
{
|
||
return [
|
||
'0' => '阿里云',
|
||
'1' => '腾讯云',
|
||
];
|
||
}
|
||
}
|