request->getBodyParam('consignee'); $data['phone'] = Yii::$app->request->getBodyParam('phone'); $data['province'] = Yii::$app->request->getBodyParam('province'); $data['city'] = Yii::$app->request->getBodyParam('city'); $data['district'] = Yii::$app->request->getBodyParam('district'); $data['address'] = Yii::$app->request->getBodyParam('address'); if (empty($data['consignee']) || empty($data['phone']) || empty($data['province']) || empty($data['city']) || empty($data['district']) || empty($data['address'])) { throw new BadRequestHttpException(Helper::REQUEST_BAD_PARAMS); } $address = new Address(); $address->user_id = Yii::$app->user->getId(); $address->load($data, ''); if (!$address->save()) { throw new ServerErrorHttpException('地址添加失败'); } Helper::createdResponse($address, $this->viewAction); return $address; } private function setDefaultAddress($address) { } private function findAddress() { $id = Yii::$app->request->getQueryParam('id'); $address = Address::find() ->where(['id' => $id]) ->andWhere(['user_id' => Yii::$app->user->getId()]) ->one(); if (!$address) { throw new NotFoundHttpException('地址未找到'); } } }