64], [['media_id'], 'string', 'max' => 128], [['url', 'material_desc'], 'string', 'max' => 255], [['name'], 'string', 'max' => 45], [['media_type'], 'string', 'max' => 12], [['material_desc'], 'safe'], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'wechat_app_id' => '公众号appid', 'media_id' => 'media_id', 'url' => 'url', 'name' => 'Name', 'media_type' => '类型:image video voice text', 'material_desc' => '描述', 'status' => '状态【1启用 0禁用 -1删除】', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @Author lun * @DateTime 2021-09-17 14:16:24 * @copyright: Copyright (c) 2020 广东七件事集团 * @param array $params * @return object|boolean */ public static function setData(int $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; } if(!$model->load($params,'') || !$model->save()){ throw new \Exception($model->getErrorMessage()); } return $model; }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } }