| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace common\models\backend;
- use common\enums\StatusEnum;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%system_version_slb}}".
- *
- * @property int $id
- * @property int|null $version_id 最新更新成功版本ID
- * @property string|null $ip 服务器ip
- * @property int $upgrade_status 更新状态[-1=更新失败,0=更新中,1=更新完成]
- * @property int $status 状态:0-更新中,1-更新完成
- * @property int $created_at
- * @property int $updated_at
- */
- class SystemVersionSlb extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%system_version_slb}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['version_id', 'upgrade_status', 'status', 'created_at', 'updated_at'], 'integer'],
- [['ip'], 'string', 'max' => 32],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'version_id' => '最新更新成功版本ID',
- 'ip' => '服务器ip',
- 'upgrade_status' => '更新状态[-1=更新失败,0=更新中,1=更新完成]',
- 'status' => '状态:0禁用,1正常',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * 初始化
- * @Author: lun
- * @DateTime: 2023/5/18 0018 10:04
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $version_id
- * @return array|bool
- */
- public static function initSetData($version_id, $upgrade_status = 0)
- {
- try {
- $model = new self();
- $model->version_id = $version_id;
- $model->ip = Yii::$app->params['network_ip'];// 服务器外网IP[注意:在qimall/common/config/params-local.php文件进行配置]
- $model->upgrade_status = $upgrade_status;
- if (!$model->save()) throw new Exception($model->getErrorMessage());
- return $model->toArray();
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- /**
- * 更新状态
- * @Author: lun
- * @DateTime: 2023/5/18 0018 10:19
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $slb_id
- * @param $upgrade_status
- * @throws Exception
- */
- public static function setStatus($slb_id, $upgrade_status)
- {
- $res = self::updateAll(['upgrade_status' => $upgrade_status, 'updated_at' => time()], ['id' => $slb_id]);
- if ($res == false) throw new Exception('更新状态失败');
- }
- }
|