81 lines
2.2 KiB
PHP
81 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\models\wechat;
|
|
|
|
use Yii;
|
|
|
|
/**
|
|
* This is the model class for table "{{%wechat_app}}".
|
|
*
|
|
* @property int $id ID
|
|
* @property int $cx_mch_id 平台商户ID
|
|
* @property string $name 小程序名称
|
|
* @property string $app_id AppId
|
|
* @property string $app_secret AppSecret
|
|
* @property string|null $desc 描述
|
|
* @property string|null $mch_id 商户ID
|
|
* @property string|null $key ApiKeyv2
|
|
* @property string|null $cert_pem 微信支付CertPem
|
|
* @property string|null $key_pem 微信支付KeyPem
|
|
* @property int $is_delete 是否删除
|
|
* @property int $created_at 添加时间
|
|
* @property string|null $key_three ApiKeyv3
|
|
*/
|
|
class WechatApp extends \yii\db\ActiveRecord
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return '{{%wechat_app}}';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['name', 'app_id', 'app_secret', 'desc', 'mch_id', 'key','key_three'], 'trim',],
|
|
[['cx_mch_id', 'is_delete', 'created_at'], 'integer'],
|
|
[['name', 'app_id', 'app_secret'], 'required'],
|
|
[['cert_pem', 'key_pem'], 'string'],
|
|
[['name', 'app_id', 'app_secret', 'desc', 'mch_id', 'key','key_three'], 'string', 'max' => 256],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'ID',
|
|
'cx_mch_id' => '平台商户ID',
|
|
'name' => '小程序名称',
|
|
'app_id' => 'AppId',
|
|
'app_secret' => 'AppSecret',
|
|
'desc' => '描述',
|
|
'mch_id' => '商户ID',
|
|
'key' => 'ApiKeyv2',
|
|
'cert_pem' => '微信支付CertPem',
|
|
'key_pem' => '微信支付KeyPem',
|
|
'is_delete' => '是否删除',
|
|
'created_at' => '添加时间',
|
|
'key_three' => 'ApiKeyv3',
|
|
];
|
|
}
|
|
|
|
public function beforeSave($insert) {
|
|
if(parent::beforeSave($insert)){
|
|
if($this->isNewRecord){
|
|
$this->created_at = time();
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|