'ID', 'mall_id' => 'Mall ID', 'store_id' => 'Store ID', 'user_id' => 'User ID', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } public static function setData(array $params) { try { if (!empty($params['id'])) { $where = ['id'=> $params['id'],'mall_id' => $params['mall_id'],'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]; $model = self::findOne($where); if (empty($model)) throw new \Exception('服务不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }