| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace addons\SmartForm\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_smart_form_setting".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $is_export 是否开启一键导入功能:0:否;1是
- * @property int $agree_on 是否开启协议:0:否;1是
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class AddonsSmartFormSetting extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_smart_form_setting}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'is_export', 'agree_on', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'is_export' => '是否开启一键导入功能:0:否;1是',
- 'agree_on' => '是否开启协议:0:否;1是',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * @method setData
- * desc
- * @author zqh
- * @datetime 2022-05-31T14:41:23+0800
- */
- public static function setData($params)
- {
- $where['mall_id'] = $params['mall_id'];
- $where['status'] = StatusEnum::ENABLED;
- # 判断当前标题是否已经存在
- $find = self::findOne($where,true);
- if($find){
- $find->updated_at = time();
- $find->is_export = $params['is_export'];
- $find->agree_on = $params['agree_on'];
- $s = $find->save();
- }else {
- $tplModel = new self();
- $tplModel->loadDefaultValues();
- $tplModel->mall_id = $params['mall_id'];
- $create['mall_id'] = $params['mall_id'];# 商城id
- $create['is_export'] = $params['is_export'];
- $create['agree_on'] = $params['agree_on'];
- $create['updated_at'] = time();
- if(!$tplModel->load($create,'') || !$tplModel->save()){
- self::$static_error = $tplModel->getErrorMessage();
- return false;
- }
- }
- return true;
- }
- }
|