新增:获取患者服务包订单列表
This commit is contained in:
parent
ead795094c
commit
5971ca7d6e
@ -329,4 +329,31 @@ class PatientOrderController extends AbstractController
|
||||
$data = $PatientOrderService->putCancelPatientOrder();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者服务包订单列表
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPatientServiceOrderList(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(PatientOrderRequest::class);
|
||||
$request->scene('getPatientServiceOrderList')->validateResolved();
|
||||
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->getPatientServiceOrderList();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者问诊订单详情
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getPatientServiceOrderInfo(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->getPatientInquiryOrderInfo();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ namespace App\Model;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@ -56,6 +57,15 @@ class OrderServicePackage extends Model
|
||||
|
||||
protected string $primaryKey = "order_service_id";
|
||||
|
||||
/**
|
||||
* 关联服务包病例表
|
||||
*/
|
||||
public function OrderServicePackageCase(): HasOne
|
||||
{
|
||||
return $this->hasOne(OrderServicePackageCase::class, 'order_service_id', 'order_service_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
@ -122,4 +132,35 @@ class OrderServicePackage extends Model
|
||||
{
|
||||
return self::where($params)->whereIn('order_service_status',$order_service_status)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单-分页
|
||||
* @param array $params
|
||||
* @param array $order_service_status
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public static function getPatientOrderServicePage(array $params, array $order_service_status_params, array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||
{
|
||||
$raw = self::with([
|
||||
'OrderServicePackageCase:order_service_case_id,order_service_id,disease_desc',
|
||||
])
|
||||
->where($params)
|
||||
->when($order_service_status_params, function ($query, $order_service_status_params) {
|
||||
$query->whereIn('order_service_status', $order_service_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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,10 @@ class PatientOrderRequest extends FormRequest
|
||||
'detection_status',// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
'family_id',// 家庭成员id(就诊用户)
|
||||
],
|
||||
'getPatientServiceOrderList' => [ // 获取患者服务包订单列表
|
||||
'order_service_status',// 订单状态(0:全部 1:待支付、2:待接诊 3:服务中 4:完成/取消)
|
||||
'family_id',// 家庭成员id(就诊用户)
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -82,6 +86,7 @@ class PatientOrderRequest extends FormRequest
|
||||
'address_id' => 'required',
|
||||
'product_ids' => 'required|array|min:1',
|
||||
'detection_status' => 'required|integer|min:0|max:5',
|
||||
'order_service_status' => 'required|integer|min:0|max:4',
|
||||
];
|
||||
}
|
||||
|
||||
@ -125,6 +130,11 @@ class PatientOrderRequest extends FormRequest
|
||||
'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
'order_service_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_service_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_service_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_service_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
'order_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
@ -2423,6 +2423,249 @@ class PatientOrderService extends BaseService
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者服务包订单列表
|
||||
* @return array
|
||||
*/
|
||||
public function getPatientServiceOrderList(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_service_status = $this->request->input('order_service_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;
|
||||
}
|
||||
|
||||
$order_service_status_params = [];
|
||||
if (!empty($order_service_status) && $order_service_status != 0) {
|
||||
// 订单状态(0:全部 1:待支付、2:待接诊 3:服务中 4:完成/取消)
|
||||
if ($order_service_status == 1) {
|
||||
$order_service_status_params = [1];
|
||||
}
|
||||
|
||||
if ($order_service_status == 2) {
|
||||
$order_service_status_params = [3];
|
||||
}
|
||||
|
||||
if ($order_service_status == 3) {
|
||||
$order_service_status_params = [3];
|
||||
}
|
||||
|
||||
if ($order_service_status == 4) {
|
||||
$order_service_status_params = [4,5];
|
||||
}
|
||||
}
|
||||
|
||||
$params['is_delete'] = 0;
|
||||
|
||||
$fields = [
|
||||
'order_service_id',
|
||||
'order_id',
|
||||
'patient_id',
|
||||
'doctor_id',
|
||||
'family_id',
|
||||
'order_service_type',
|
||||
'order_service_status',
|
||||
'is_delete',
|
||||
'refund_status',
|
||||
'pay_channel',
|
||||
'pay_status',
|
||||
'order_service_no',
|
||||
'escrow_trade_no',
|
||||
'amount_total',
|
||||
'payment_amount_total',
|
||||
'start_time',
|
||||
'finish_time',
|
||||
'patient_name',
|
||||
'patient_name_mask',
|
||||
'patient_sex',
|
||||
'patient_age',
|
||||
'created_at',
|
||||
];
|
||||
$order_service_package = OrderServicePackage::getPatientOrderServicePage($params, $order_service_status_params, $fields, $page, $per_page);
|
||||
if (empty($order_service_package['data'])) {
|
||||
return success($order_service_package);
|
||||
}
|
||||
|
||||
foreach ($order_service_package['data'] as &$item) {
|
||||
$item['disease_desc'] = $item['OrderServicePackageCase']['disease_desc'];
|
||||
unset($item['OrderServicePackageCase']);
|
||||
|
||||
// 获取医生数据
|
||||
$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_service_package);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者服务包订单详情
|
||||
* @return array
|
||||
*/
|
||||
public function getPatientServiceOrderInfo(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_inquiry_id = $this->request->route('order_inquiry_id');
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 获取病例信息
|
||||
$fields = [
|
||||
'disease_class_name',
|
||||
'disease_desc',
|
||||
];
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params, $fields);
|
||||
if (empty($order_inquiry_case)) {
|
||||
$order_inquiry['case'] = [];
|
||||
} else {
|
||||
$order_inquiry['case'] = $order_inquiry_case->toArray();
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$order_inquiry['user_doctor'] = [];
|
||||
if (!empty($order_inquiry['doctor_id'])) {
|
||||
$fields = [
|
||||
'user_id',
|
||||
'doctor_id',
|
||||
'user_name',
|
||||
'doctor_title',
|
||||
'hospital_id',
|
||||
'avatar',
|
||||
'department_custom_name',
|
||||
'multi_point_status',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['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['avatar'] = addAliyunOssWebsite($user_doctor['avatar']);
|
||||
|
||||
// 获取医生医院名称
|
||||
$user_doctor['hospital_name'] = "";
|
||||
$user_doctor['hospital_level_name'] = "";
|
||||
|
||||
$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'];
|
||||
}
|
||||
|
||||
// 获取医生关注状态
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$user_doctor['follow'] = PatientFollow::getExists($params);
|
||||
|
||||
// 获取医生问诊配置-问诊购药
|
||||
$user_doctor['multi_point_enable'] = 0;
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$params['inquiry_type'] = 4;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (!empty($doctor_inquiry_config)) {
|
||||
if ($doctor_inquiry_config['is_enable'] == 1) {
|
||||
$user_doctor['multi_point_enable'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$order_inquiry['user_doctor'] = $user_doctor;
|
||||
|
||||
unset($hospital);
|
||||
unset($user_doctor);
|
||||
}
|
||||
|
||||
// 获取退款数据
|
||||
$order_inquiry['order_inquiry_refund'] = array();
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_refund = OrderInquiryRefund::getList($params);
|
||||
if (!empty($order_inquiry_refund)){
|
||||
$order_inquiry['order_inquiry_refund'] = $order_inquiry_refund;
|
||||
}
|
||||
|
||||
return success($order_inquiry->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者未完成订单
|
||||
* @param string $patient_id
|
||||
|
||||
@ -548,6 +548,12 @@ Router::addGroup('/patient', function () {
|
||||
Router::addGroup('/service', function () {
|
||||
// 服务包订单取消支付-1未支付
|
||||
Router::put('/cancel-pay/{order_no}', [PatientOrderController::class, 'putPatientServiceOrderCancelPay']);
|
||||
|
||||
// 获取患者服务包订单列表
|
||||
Router::get('', [PatientOrderController::class, 'getPatientServiceOrderList']);
|
||||
|
||||
// 获取患者服务包订单详情
|
||||
Router::get('/{order_no}', [PatientOrderController::class, 'getPatientDetectionOrderInfo']);
|
||||
});
|
||||
|
||||
// 获取患者订单支付数据
|
||||
@ -603,9 +609,6 @@ Router::addGroup('/patient', function () {
|
||||
|
||||
// 创建服务包问诊订单
|
||||
Router::post('/inquiry/{order_no}', [OrderServicePackageController::class, 'addServiceInquiryOrder']);
|
||||
|
||||
// 服务包订单取消支付-1未支付
|
||||
Router::put('/cancel-pay/{order_no:\d+}', [OrderServicePackageController::class, 'putPatientServiceOrderCancelPay']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user