255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'name' => 'Name', 'key_word' => 'Key Word', 'look_num' => 'Look Num', 'scan_code_num' => 'Scan Code Num', 'poster_content' => 'Poster Content', 'status' => 'Status', 'share_url' => 'Share Url', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @Author lun * @DateTime 2021-09-16 14:16:24 * @copyright: Copyright (c) 2020 广东七件事集团 * @param array $params * @return object|boolean */ public static function setData($mall_id, array $params){ try{ if(!empty($params['id'])){ $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $mall_id],['<>','status',StatusEnum::DELETE]]); if(empty($model)) throw new \Exception('海报不存在或已删除'); }else{ $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } // 将内容转为json字符串 $params['poster_content'] = Json::encode($params['poster_content']); if(!$model->load($params,'') || !$model->save()) throw new \Exception($model->getErrorMessage()); return $model; }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } }