'ID', 'album_id' => '画册ID', 'album_page_id' => '画册页ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'created_at' => '分享时间', 'date' => '日期', 'updated_at' => '更新时间', ]; } /** * @Author: ltm * @DateTime: 2022/2/15 0015 11:43 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $data * @return string */ public static function setData(array $params){ try{ $params['created_at'] = time(); $params['updated_at'] = time(); $params['date'] = date("Y-m-d"); if (!empty($params['id'])) { $model = self::findOne(['id'=>$params['id'],'mall_id'=>$params['mall_id']]); if (empty($model)) throw new Exception('记录不存在或已删除'); }else{ $model = new self(); $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; } } public function getAlbum() { return $this->hasOne(AddonsAlbum::class, ['id' => 'album_id'])->select('id,title,goods_count'); } }