新增 获取患者问诊订单列表 接口
This commit is contained in:
parent
2068019145
commit
15738f0c5a
@ -236,4 +236,21 @@ class PatientOrderController extends AbstractController
|
||||
$data = $PatientOrderService->deletePatientPrescriptionOrder();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者检测订单列表
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPatientDetectionOrderList(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(PatientOrderRequest::class);
|
||||
$request->scene('getPatientDetectionOrderList')->validateResolved();
|
||||
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->getPatientDetectionOrderList();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -109,4 +109,33 @@ class OrderDetection extends Model
|
||||
{
|
||||
return self::where($params)->whereIn('detection_status',[1,2,3])->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取问诊订单分页
|
||||
* 已结束
|
||||
* @param array $params
|
||||
* @param array $detection_status_params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return array
|
||||
*/
|
||||
public static function getPatientOrderDetectionPage(array $params, array $detection_status_params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$raw = self::where($params)
|
||||
->when($detection_status_params, function ($query, $detection_status_params) {
|
||||
$query->whereIn('detection_status', $detection_status_params);
|
||||
})
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
$data['current_page'] = $raw->currentPage();// 当前页码
|
||||
$data['total'] = $raw->total();//数据总数
|
||||
$data['data'] = $raw->items();//数据
|
||||
$data['per_page'] = $raw->perPage();//每页个数
|
||||
$data['last_page'] = $raw->lastPage();//最后一页
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,10 @@ class PatientOrderRequest extends FormRequest
|
||||
],
|
||||
'getPatientPrescriptionOrderList' => [ // 获取处方订单列表
|
||||
],
|
||||
'getPatientDetectionOrderList' => [ // 获取患者检测订单列表
|
||||
'detection_status',// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
'family_id',// 家庭成员id(就诊用户)
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -75,6 +79,7 @@ class PatientOrderRequest extends FormRequest
|
||||
'order_prescription_id' => 'required',
|
||||
'address_id' => 'required',
|
||||
'product_ids' => 'required|array|min:1',
|
||||
'detection_status' => 'required|integer|min:0|max:5',
|
||||
];
|
||||
}
|
||||
|
||||
@ -127,6 +132,10 @@ class PatientOrderRequest extends FormRequest
|
||||
'product_ids.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'product_ids.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'product_ids.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'detection_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'detection_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'detection_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'detection_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,6 +1538,114 @@ class PatientOrderService extends BaseService
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者检测订单列表
|
||||
* @return array
|
||||
*/
|
||||
public function getPatientDetectionOrderList(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$detection_status = $this->request->input('detection_status', 0);
|
||||
$family_id = $this->request->input('family_id');
|
||||
$page = $this->request->input('page', 1);
|
||||
$per_page = $this->request->input('per_page', 10);
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
if (!empty($family_id)) {
|
||||
$params['family_id'] = $family_id;
|
||||
}
|
||||
|
||||
$detection_status_params = [];
|
||||
if (!empty($detection_status) && $detection_status != 0) {
|
||||
// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
$detection_status_params = [$detection_status];
|
||||
}
|
||||
|
||||
$params['is_delete'] = 0;
|
||||
|
||||
$fields = [
|
||||
'order_detection_id',
|
||||
'patient_id',
|
||||
'doctor_id',
|
||||
'family_id',
|
||||
'detection_status',
|
||||
'is_delete',
|
||||
'detection_refund_status',
|
||||
'detection_pay_channel',
|
||||
'detection_pay_status',
|
||||
'detection_no',
|
||||
'escrow_trade_no',
|
||||
'amount_total',
|
||||
'payment_amount_total',
|
||||
'patient_name',
|
||||
'patient_name_mask',
|
||||
'patient_sex',
|
||||
'patient_age',
|
||||
'created_at',
|
||||
];
|
||||
dump($params);
|
||||
dump($detection_status_params);
|
||||
dump($fields);
|
||||
$order_detection = OrderDetection::getPatientOrderDetectionPage($params, $detection_status_params, $fields, $page, $per_page);
|
||||
if (empty($order_detection['data'])) {
|
||||
return success($order_detection);
|
||||
}
|
||||
|
||||
foreach ($order_detection['data'] as &$item) {
|
||||
// 获取医生数据
|
||||
$item['user_doctor'] = [];
|
||||
if (!empty($item['doctor_id'])) {
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'user_name',
|
||||
'doctor_title',
|
||||
'hospital_id',
|
||||
"avatar"
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $item['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params, $fields);
|
||||
if (empty($user_doctor)) {
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 转换医生职称
|
||||
$user_doctor['doctor_title'] = empty($user_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($user_doctor['doctor_title']);
|
||||
|
||||
// 获取医生医院名称
|
||||
$user_doctor['hospital_name'] = "";
|
||||
$user_doctor['hospital_level_name'] = "";
|
||||
|
||||
// 医生头像
|
||||
$user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']);
|
||||
|
||||
$fields = [
|
||||
'hospital_id',
|
||||
'hospital_name',
|
||||
'hospital_level_name',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['hospital_id'] = $user_doctor['hospital_id'];
|
||||
$hospital = Hospital::getOne($params, $fields);
|
||||
if (!empty($hospital)) {
|
||||
$user_doctor['hospital_name'] = $hospital['hospital_name'];
|
||||
$user_doctor['hospital_level_name'] = $hospital['hospital_level_name'];
|
||||
}
|
||||
|
||||
$item['user_doctor'] = $user_doctor;
|
||||
unset($hospital);
|
||||
unset($user_doctor);
|
||||
}
|
||||
}
|
||||
|
||||
return success($order_detection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取患者未完成订单
|
||||
* @param string $patient_id
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user