255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'album_id' => '画册ID', 'image' => '画册单页图片', 'goods_ids' => '商品id,多个商品逗号隔开', 'created_at' => '添加时间戳', 'updated_at' => '更新时间戳', 'status' => '-1是删除,0是禁用,1是启用', 'mall_id' => '商城ID', 'sort' => '排序', ]; } /** * @Author: ltm * @DateTime: 2022/2/15 0015 11:43 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $data * @return string */ public static function setData(array $params){ try{ if (!empty($params['id'])) { $model = self::findOne(['id'=>$params['id'],'mall_id'=>$params['mall_id']]); if($params['status'] == StatusEnum::DELETE){ $album = AddonsAlbum::findOne(['id'=>$model->album_id]); $album->page_num = $album->page_num-1; $album->save(); } $model->updated_at = time(); if (empty($model)) throw new Exception('记录不存在或已删除'); }else{ $model = new self(); $model->created_at = time(); $model->loadDefaultValues(); } $model->mall_id = $params['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; } } }