新增获取用户地址。修改获取检测机构合作医生列表接口,拆分为两个接口
This commit is contained in:
parent
e56e4c2606
commit
fac54d3287
@ -3,6 +3,7 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Request\DetectionRequest;
|
use App\Request\DetectionRequest;
|
||||||
|
use App\Request\UserRequest;
|
||||||
use App\Services\DetectionService;
|
use App\Services\DetectionService;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@ -35,9 +36,14 @@ class DetectionController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* 获取检测机构合作医生列表
|
* 获取检测机构合作医生列表
|
||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function getDetectionDoctorList(): ResponseInterface
|
public function getDetectionDoctorList(): ResponseInterface
|
||||||
{
|
{
|
||||||
|
$request = $this->container->get(DetectionRequest::class);
|
||||||
|
$request->scene('getDetectionDoctorList')->validateResolved();
|
||||||
|
|
||||||
$detectionService = new DetectionService();
|
$detectionService = new DetectionService();
|
||||||
$data = $detectionService->getDetectionDoctorList();
|
$data = $detectionService->getDetectionDoctorList();
|
||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
|
|||||||
@ -178,4 +178,15 @@ class UserController extends AbstractController
|
|||||||
$data = $UserService->postLocation();
|
$data = $UserService->postLocation();
|
||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户地址
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function getLocation(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserService = new UserService();
|
||||||
|
$data = $UserService->getLocation();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -29,6 +29,12 @@ class DetectionRequest extends FormRequest
|
|||||||
'detection_bar_code',
|
'detection_bar_code',
|
||||||
'detection_pic',
|
'detection_pic',
|
||||||
],
|
],
|
||||||
|
'getDetectionDoctorList' => [ // 绑定检测管
|
||||||
|
'province_id',
|
||||||
|
'city_id',
|
||||||
|
'county_id',
|
||||||
|
'company_id'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +59,8 @@ class DetectionRequest extends FormRequest
|
|||||||
'doctor_id' => 'required',
|
'doctor_id' => 'required',
|
||||||
'client_type' => 'required|integer|min:1|max:2',
|
'client_type' => 'required|integer|min:1|max:2',
|
||||||
'detection_bar_code' => 'required',
|
'detection_bar_code' => 'required',
|
||||||
|
'province_id' => 'required_with:city_id,county_id',
|
||||||
|
'city_id' => 'required_with:county_id',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +81,8 @@ class DetectionRequest extends FormRequest
|
|||||||
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'detection_bar_code.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'detection_bar_code.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'province_id.required_with' => "请选择省份",
|
||||||
|
'city_id.required_with' => "请选择城市",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,116 +112,41 @@ class DetectionService extends BaseService
|
|||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回数据
|
|
||||||
$response_data = array(
|
|
||||||
"area" => [
|
|
||||||
"province_id" => "",
|
|
||||||
"province" => "",
|
|
||||||
"city_id" => "",
|
|
||||||
"city" => "",
|
|
||||||
"county_id" => "",
|
|
||||||
"county" => "",
|
|
||||||
],
|
|
||||||
"doctors" => [],
|
|
||||||
);
|
|
||||||
|
|
||||||
// 搜索数据
|
// 搜索数据
|
||||||
$hospital_params = array();
|
$hospital_params = array();
|
||||||
|
|
||||||
if (empty($province_id) && empty($city_id) && empty($county_id)){
|
if (!empty($province_id)){
|
||||||
// 获取用户定位地址数据
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['user_id'] = $user_info['user_id'];
|
$params['area_id'] = $province_id;
|
||||||
$user_location = UserLocation::getOne($params);
|
$params['area_type'] = 2;
|
||||||
if (!empty($user_location)){
|
$area_province = Area::getOne($params);
|
||||||
// 处理省市区对应
|
if (!empty($area_province)){
|
||||||
if (!empty($user_location['province']) && !empty($user_location['city'])){
|
// 搜索条件
|
||||||
$params = array();
|
$hospital_params['province_id'] = $area_province['area_id'];
|
||||||
$params['area_name'] = $user_location['province'];
|
|
||||||
$params['area_type'] = 2;
|
|
||||||
$area_province = Area::getOne($params);
|
|
||||||
if (!empty($area_province)){
|
|
||||||
$response_data['area']['province_id'] = $area_province['area_id'];
|
|
||||||
$response_data['area']['province'] = $area_province['area_name'];
|
|
||||||
|
|
||||||
// 搜索条件
|
|
||||||
$hospital_params['province_id'] = $area_province['area_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($response_data['area']['province_id'])){
|
|
||||||
$params = array();
|
|
||||||
$params['area_name'] = $user_location['city'];
|
|
||||||
$params['parent_id'] = $response_data['area']['province_id'];
|
|
||||||
$params['area_type'] = 3;
|
|
||||||
$area_city = Area::getOne($params);
|
|
||||||
if (!empty($area_city)){
|
|
||||||
$response_data['area']['city_id'] = $area_city['area_id'];
|
|
||||||
$response_data['area']['city'] = $area_city['area_name'];
|
|
||||||
|
|
||||||
// 搜索条件
|
|
||||||
$hospital_params['city_id'] = $area_city['area_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($response_data['area']['city_id']) && !empty($user_location['county'])){
|
|
||||||
$params = array();
|
|
||||||
$params['area_name'] = $user_location['county'];
|
|
||||||
$params['parent_id'] = $response_data['area']['city_id'];
|
|
||||||
$params['area_type'] = 4;
|
|
||||||
$area_county = Area::getOne($params);
|
|
||||||
if (!empty($area_county)){
|
|
||||||
$response_data['area']['county_id'] = $area_county['area_id'];
|
|
||||||
$response_data['area']['county'] = $area_county['area_name'];
|
|
||||||
|
|
||||||
// 搜索条件
|
|
||||||
$hospital_params['county_id'] = $area_county['area_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else{
|
}
|
||||||
if (!empty($province_id)){
|
|
||||||
$params = array();
|
|
||||||
$params['area_id'] = $province_id;
|
|
||||||
$params['area_type'] = 2;
|
|
||||||
$area_province = Area::getOne($params);
|
|
||||||
if (!empty($area_province)){
|
|
||||||
$response_data['area']['province_id'] = $area_province['area_id'];
|
|
||||||
$response_data['area']['province'] = $area_province['area_name'];
|
|
||||||
|
|
||||||
// 搜索条件
|
if (!empty($city_id)){
|
||||||
$hospital_params['province_id'] = $area_province['area_id'];
|
$params = array();
|
||||||
}
|
$params['area_id'] = $city_id;
|
||||||
|
$params['parent_id'] = $province_id;
|
||||||
|
$params['area_type'] = 3;
|
||||||
|
$area_city = Area::getOne($params);
|
||||||
|
if (!empty($area_city)){
|
||||||
|
// 搜索条件
|
||||||
|
$hospital_params['city_id'] = $area_city['area_id'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($response_data['area']['province_id']) && !empty($city_id)){
|
if (!empty($county_id)){
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['area_id'] = $city_id;
|
$params['area_id'] = $county_id;
|
||||||
$params['parent_id'] = $response_data['area']['province_id'];
|
$params['parent_id'] = $city_id;
|
||||||
$params['area_type'] = 3;
|
$params['area_type'] = 4;
|
||||||
$area_city = Area::getOne($params);
|
$area_county = Area::getOne($params);
|
||||||
if (!empty($area_city)){
|
if (!empty($area_county)){
|
||||||
$response_data['area']['city_id'] = $area_city['area_id'];
|
// 搜索条件
|
||||||
$response_data['area']['city'] = $area_city['area_name'];
|
$hospital_params['county_id'] = $area_county['area_id'];
|
||||||
|
|
||||||
// 搜索条件
|
|
||||||
$hospital_params['city_id'] = $area_city['area_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($response_data['area']['city_id']) && !empty($county_id)){
|
|
||||||
$params = array();
|
|
||||||
$params['area_id'] = $county_id;
|
|
||||||
$params['parent_id'] = $response_data['area']['city_id'];
|
|
||||||
$params['area_type'] = 4;
|
|
||||||
$area_county = Area::getOne($params);
|
|
||||||
if (!empty($area_county)){
|
|
||||||
$response_data['area']['county_id'] = $area_county['area_id'];
|
|
||||||
$response_data['area']['county'] = $area_county['area_name'];
|
|
||||||
|
|
||||||
// 搜索条件
|
|
||||||
$hospital_params['county_id'] = $area_county['area_id'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,11 +176,9 @@ class DetectionService extends BaseService
|
|||||||
|
|
||||||
$value['avatar'] = addAliyunOssWebsite($value['avatar']);
|
$value['avatar'] = addAliyunOssWebsite($value['avatar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response_data['doctors'] = $user_doctors->toArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success($response_data);
|
return success($user_doctors->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Constants\HttpEnumCode;
|
use App\Constants\HttpEnumCode;
|
||||||
|
use App\Model\Area;
|
||||||
use App\Model\Popup;
|
use App\Model\Popup;
|
||||||
use App\Model\SubTemplate;
|
use App\Model\SubTemplate;
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
@ -621,6 +622,70 @@ class UserService extends BaseService
|
|||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户地址
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLocation(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
// 定义返回数据
|
||||||
|
$area = [
|
||||||
|
"province_id" => "",
|
||||||
|
"province" => "",
|
||||||
|
"city_id" => "",
|
||||||
|
"city" => "",
|
||||||
|
"county_id" => "",
|
||||||
|
"county" => "",
|
||||||
|
];
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_info['user_id'];
|
||||||
|
$user_location = UserLocation::getOne($params);
|
||||||
|
if (empty($user_location)){
|
||||||
|
return success($area);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理省市区对应
|
||||||
|
if (!empty($user_location['province']) && !empty($user_location['city'])){
|
||||||
|
$params = array();
|
||||||
|
$params['area_name'] = $user_location['province'];
|
||||||
|
$params['area_type'] = 2;
|
||||||
|
$area_province = Area::getOne($params);
|
||||||
|
if (!empty($area_province)){
|
||||||
|
$area['province_id'] = $area_province['area_id'];
|
||||||
|
$area['province'] = $area_province['area_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($area['province_id'])){
|
||||||
|
$params = array();
|
||||||
|
$params['area_name'] = $user_location['city'];
|
||||||
|
$params['parent_id'] = $area['province_id'];
|
||||||
|
$params['area_type'] = 3;
|
||||||
|
$area_city = Area::getOne($params);
|
||||||
|
if (!empty($area_city)){
|
||||||
|
$area['city_id'] = $area_city['area_id'];
|
||||||
|
$area['city'] = $area_city['area_name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($area['city_id']) && !empty($user_location['county'])){
|
||||||
|
$params = array();
|
||||||
|
$params['area_name'] = $user_location['county'];
|
||||||
|
$params['parent_id'] = $area['city_id'];
|
||||||
|
$params['area_type'] = 4;
|
||||||
|
$area_county = Area::getOne($params);
|
||||||
|
if (!empty($area_county)){
|
||||||
|
$area['county_id'] = $area_county['area_id'];
|
||||||
|
$area['county'] = $area_county['area_name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success($area);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过user_id获取用户openid
|
* 通过user_id获取用户openid
|
||||||
* @param string|int $user_id
|
* @param string|int $user_id
|
||||||
|
|||||||
@ -686,9 +686,9 @@ Router::addGroup('/user', function () {
|
|||||||
|
|
||||||
// 上报用户地址
|
// 上报用户地址
|
||||||
Router::post('/location', [UserController::class, 'postLocation']);
|
Router::post('/location', [UserController::class, 'postLocation']);
|
||||||
//
|
|
||||||
// // 获取用户地址
|
// 获取用户地址
|
||||||
// Router::get('/location', [UserController::class, 'getLocation']);
|
Router::get('/location', [UserController::class, 'getLocation']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取患者问诊病例
|
// 获取患者问诊病例
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user