| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace common\models\user;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%user_label_cond}}".
- *
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $label_id 对应qimall_user_label.id
- * @property string $cond_type 条件类型
- * @property string|null $condition 条件内容
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- * @property int $select_status 是否选择中 是选中条件0:未选中,1:选中
- */
- class UserLabelCond extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%user_label_cond}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'label_id', 'status', 'created_at', 'updated_at','select_status'], 'integer'],
- [['cond_type'], 'string', 'max' => 45],
- [['condition'], 'string', 'max' => 5000],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'label_id' => '对应qimall_user_label.id',
- 'cond_type' => '条件类型',
- 'condition' => '条件内容',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'select_status' => '是否选择中',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * @Author: ltm
- * @DateTime: 2022/3/10 0010 9:29
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return string
- */
- public static function setData(array $params){
- try{
- $model = self::findOne(['label_id'=>$params['label_id'],'mall_id'=>$params['mall_id'],'cond_type'=>$params['cond_type']]);
- if(empty($model)){
- $model = new self();
- $model->loadDefaultValues();
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new Exception($model->getErrorMessage());
- }
- return $model;
- }catch(\Exception $e){
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|