修正分配医生逻辑,修改搜索医生列表新增是否参加公益图文问诊字段
This commit is contained in:
@@ -60,10 +60,10 @@ class InquiryService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "患者信息错误");
|
||||
}
|
||||
|
||||
// 检测当前家庭成员是否存在未完成的问诊订单
|
||||
$UserPatientService = new UserPatientService();
|
||||
$res = $UserPatientService->getNotFinishedOrdeInquiry($user_info['client_user_id']);
|
||||
if (!empty($res)) {
|
||||
// 检测是否存在同类型未完成的问诊订单
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$order_inquiry_id = $PatientOrderService->getNotFinishedOrdeInquiry($user_info['client_user_id']);
|
||||
if (!empty($order_inquiry_id)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "当前患者存在进行中的问诊订单");
|
||||
}
|
||||
|
||||
@@ -863,4 +863,33 @@ class InquiryService extends BaseService
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测当前医生是否和患者存在未完成问诊订单
|
||||
* @param string $patient_id
|
||||
* @param string $doctor_id
|
||||
* @return array
|
||||
*/
|
||||
public function checkPatientDoctorProgressInquiry(string $patient_id,string $doctor_id): array
|
||||
{
|
||||
$params = array();
|
||||
if (!empty($patient_id)){
|
||||
$params[] = ['patient_id','=',$patient_id];
|
||||
}
|
||||
|
||||
if (!empty($family_id)){
|
||||
$params[] = ['family_id','=',$family_id];
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params[] = ['patient_id','=',$patient_id];
|
||||
$params[] = ['doctor_id','=',$doctor_id];
|
||||
|
||||
$inquiry_status_params = [1,3,4];// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$order_inquiry = OrderInquiry::getInquiryStatusOne($params, $inquiry_status_params);
|
||||
if (empty($order_inquiry)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $order_inquiry->toArray();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ class PatientDoctorService extends BaseService
|
||||
$city_id = $this->request->input('city_id');
|
||||
$sort_order = $this->request->input('sort_order',1);
|
||||
$keyword = $this->request->input('keyword',"");
|
||||
$is_search_welfare_reception = $this->request->input('is_search_welfare_reception',0);
|
||||
$page = $this->request->input('page',1);
|
||||
$per_page = $this->request->input('per_page',10);
|
||||
|
||||
@@ -62,6 +63,10 @@ class PatientDoctorService extends BaseService
|
||||
|
||||
$doctor_params["is_img_expert_reception"] = 1;// 是否参加专家图文接诊(0:否 1:是)
|
||||
|
||||
if (!empty($is_search_welfare_reception)){
|
||||
$doctor_params["is_img_welfare_reception"] = $is_search_welfare_reception;// 是否参加公益图文问诊(0:否 1:是)
|
||||
}
|
||||
|
||||
$fields = [
|
||||
"doctor_id",
|
||||
"user_id",
|
||||
@@ -238,12 +243,11 @@ class PatientDoctorService extends BaseService
|
||||
$doctor_inquiry_config = DoctorInquiryConfigModel::getInquiryConfigList($params);
|
||||
if (!empty($doctor_inquiry_config)) {
|
||||
foreach ($doctor_inquiry_config as &$value) {
|
||||
// 获取医生当日已付款的全部订单
|
||||
// 获取医生当日的全部订单
|
||||
$params = array();
|
||||
$params[] = ['doctor_id', '=', $doctor_id];
|
||||
$params[] = ['inquiry_type', '=', $value['inquiry_type']];
|
||||
$params[] = ['inquiry_mode', '=', 1];
|
||||
$params[] = ['inquiry_status', '=', 3];
|
||||
$params[] = ['inquiry_refund_status', '=', 0];
|
||||
$value['order_inquiry_count'] = OrderInquiry::getCount($params);
|
||||
|
||||
@@ -367,16 +371,16 @@ class PatientDoctorService extends BaseService
|
||||
$doctor_id = $this->request->input('doctor_id','');
|
||||
|
||||
$result = array();
|
||||
$result['data'] = "";
|
||||
$result['data'] = [];
|
||||
$result['message'] = "可接诊";
|
||||
$result['status'] = 1;
|
||||
|
||||
// 检测是否存在未完成的问诊订单
|
||||
$UserPatientService = new UserPatientService();
|
||||
$res = $UserPatientService->getNotFinishedOrdeInquiry($user_info['client_user_id']);
|
||||
if (!empty($res)){
|
||||
// 检测是否存在同类型未完成的问诊订单
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$order_inquiry_id = $PatientOrderService->getNotFinishedOrdeInquiry($inquiry_type,$user_info['client_user_id']);
|
||||
if (!empty($order_inquiry_id)){
|
||||
$result['status'] = 2;
|
||||
$result['data'] = $res;
|
||||
$result['data']['order_inquiry_id'] = $order_inquiry_id;
|
||||
$result['message'] = "存在未完成的问诊订单";
|
||||
return success($result);
|
||||
}
|
||||
@@ -384,7 +388,7 @@ class PatientDoctorService extends BaseService
|
||||
if (!empty($doctor_id)){
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
@@ -413,14 +417,56 @@ class PatientDoctorService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "医生未开通在线问诊服务");
|
||||
}
|
||||
|
||||
// 检测医生今日接诊数量
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($user_info['client_user_id'],$doctor_id);
|
||||
if (!empty($order_inquiry)){
|
||||
$result['status'] = 2;
|
||||
$result['data']['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$result['message'] = "您和当前医生存在问诊中订单,无法再次发起问诊";
|
||||
return success($result);
|
||||
}
|
||||
|
||||
// 获取医生每日最大接诊数量
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$max_work_num_day = $UserDoctorService->getDoctorInquiryDayMaxNum($doctor_id,$inquiry_type,$inquiry_mode);
|
||||
|
||||
// 获取医生未接诊订单数量(包含未接诊、未支付、已接诊)
|
||||
$order_inquiry_count = $UserDoctorService->getDoctorUnInquiryOrderNum($doctor_id,$inquiry_type,$inquiry_mode);
|
||||
|
||||
// 计算剩余未接诊数量 = 最大数量-
|
||||
$access_inquiry_num = $max_work_num_day - $order_inquiry_count;
|
||||
if ($access_inquiry_num <= 0){
|
||||
$result['status'] = 3;
|
||||
$result['data'] = "";
|
||||
$result['message'] = "当前医生已无每日问诊次数,请选择其他医生";
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($inquiry_type == 4){
|
||||
// 公益问诊-检测当前患者问诊次数(24小时内两次公益问诊)
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
|
||||
$inquiry_status_params = [1,2,3,4];
|
||||
$inquiry_count = OrderInquiry::getInquiryStatusCount($params,$inquiry_status_params);
|
||||
if ($inquiry_count >= 2){
|
||||
$result['status'] = 3;
|
||||
$result['data'] = "";
|
||||
$result['message'] = "您还有未完成的公益问诊,完成之后才可以重新问诊";
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
|
||||
// 检测快速、购药问诊是否由可分配医生
|
||||
if ($inquiry_type == 2 || $inquiry_type == 4){
|
||||
// 获取快速、购药问诊可分配医生
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$doctor_id = $UserDoctorService->getInquiryAssignDoctor($inquiry_type);
|
||||
$doctor_id = $UserDoctorService->getInquiryAssignDoctor($inquiry_type,$user_info['client_user_id']);
|
||||
if (empty($doctor_id)){
|
||||
// 无合适医生
|
||||
$result['status'] = 3;
|
||||
$result['data'] = "";
|
||||
$result['message'] = "目前暂无可接诊医生";
|
||||
|
||||
@@ -341,10 +341,10 @@ class PatientFamilyService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "证件号码重复");
|
||||
}
|
||||
|
||||
// 检测患者关系-本人类型是否重复
|
||||
if ($request_params['relation'] == 1 && $value['relation'] == 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "患者类型重复");
|
||||
}
|
||||
// // 检测患者关系-本人类型是否重复
|
||||
// if ($request_params['relation'] == 1 && $value['relation'] == 1) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "患者类型重复");
|
||||
// }
|
||||
|
||||
// 检测是否默认字段是否重复
|
||||
if (isset($request_params['is_default'])) {
|
||||
|
||||
@@ -832,7 +832,12 @@ class PatientOrderService extends BaseService
|
||||
return success();
|
||||
}
|
||||
|
||||
// 创建药品订单
|
||||
/**
|
||||
* 创建药品订单
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addPatientProductOrder(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
@@ -1271,4 +1276,36 @@ class PatientOrderService extends BaseService
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者未完成订单
|
||||
* @param string $patient_id
|
||||
* @param string|int $inquiry_type
|
||||
* @param string $family_id
|
||||
* @return string
|
||||
*/
|
||||
public function getNotFinishedOrdeInquiry(string|int $inquiry_type,string $patient_id = '',string $family_id = ''): string
|
||||
{
|
||||
$params = array();
|
||||
if (!empty($patient_id)){
|
||||
$params[] = ['patient_id','=',$patient_id];
|
||||
}
|
||||
|
||||
if (!empty($family_id)){
|
||||
$params[] = ['family_id','=',$family_id];
|
||||
}
|
||||
|
||||
$params[] = ['inquiry_type','=',$inquiry_type];
|
||||
$params[] = ['inquiry_mode','=',1];
|
||||
$params[] = ['inquiry_refund_status','=',0];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (!empty($order_inquiry)) {
|
||||
// 1:待支付 2:待分配 3:待接诊 4:已接诊
|
||||
if (in_array($order_inquiry['inquiry_status'], [1,2, 3, 4])) {
|
||||
return $order_inquiry['order_inquiry_id'];
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1613,9 +1613,10 @@ class UserDoctorService extends BaseService
|
||||
* 获取当前时间N分钟前接诊中的医生
|
||||
* @param string|int $minute 分钟
|
||||
* @param int|string $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
* @param array $not_doctor_ids 不可选择的医生id数组
|
||||
* @return array
|
||||
*/
|
||||
public function getBeforeCurrentTimeDoctor(string|int $minute, int|string $inquiry_type): array
|
||||
public function getBeforeCurrentTimeDoctor(string|int $minute, int|string $inquiry_type,array $not_doctor_ids = []): array
|
||||
{
|
||||
// 获取当前时间n分钟前时间
|
||||
$date = date('Y-m-d H:i:s', time() - $minute * 60);
|
||||
@@ -1627,7 +1628,7 @@ class UserDoctorService extends BaseService
|
||||
|
||||
$inquiry_status_params = array();
|
||||
$inquiry_status_params = [4, 5];// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$order_inquirys = OrderInquiry::getInquiryStatusList($params, $inquiry_status_params);
|
||||
$order_inquirys = OrderInquiry::getInquiryStatusWithDoctorNotInList($params, $inquiry_status_params,$not_doctor_ids);
|
||||
if (empty($order_inquirys)) {
|
||||
return [];
|
||||
}
|
||||
@@ -1643,9 +1644,10 @@ class UserDoctorService extends BaseService
|
||||
/**
|
||||
* 获取快速、购药问诊可分配医生
|
||||
* @param string $inquiry_type
|
||||
* @param string $patient_id
|
||||
* @return string
|
||||
*/
|
||||
public function getInquiryAssignDoctor(string $inquiry_type): string
|
||||
public function getInquiryAssignDoctor(string $inquiry_type,string $patient_id): string
|
||||
{
|
||||
// 获取问诊配置
|
||||
$params = array();
|
||||
@@ -1675,110 +1677,214 @@ class UserDoctorService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_time_pass){
|
||||
// 不可选择的医生id数组
|
||||
$not_doctor_ids = [];
|
||||
|
||||
while (true){
|
||||
// 系统坐班时间
|
||||
// 获取坐班时间包含当前时间的深度合作医生
|
||||
$doctor_id = $this->getNowTimePlatDeepCooperationDoctorId($inquiry_type,time());
|
||||
if (!empty($doctor_id)){
|
||||
return $doctor_id;
|
||||
if ($is_time_pass){
|
||||
// 获取坐班时间包含当前时间的深度合作医生
|
||||
$doctor_id = $this->getNowTimePlatDeepCooperationDoctorId($inquiry_type,time(),$not_doctor_ids);
|
||||
if (!empty($doctor_id)){
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($patient_id,$doctor_id);
|
||||
if (!empty($order_inquiry)){
|
||||
// 存在未完成问诊订单,记录该医生id,重新分配
|
||||
$not_doctor_ids[] = $order_inquiry['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 不存在未完成的问诊订单
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 非坐班时间
|
||||
// 获取深度合作的在线医生
|
||||
$params = array();
|
||||
$params['status'] = 1;
|
||||
$params['idcard_status'] = 1;
|
||||
$params['iden_auth_status'] = 1;
|
||||
$params['is_bind_bank'] = 1;
|
||||
$params['is_online'] = 1;
|
||||
if ($inquiry_type == 2){
|
||||
// 快速问诊
|
||||
$params['is_img_quick_reception'] = 1;
|
||||
}elseif ($inquiry_type == 4){
|
||||
// 问诊购药
|
||||
$params['multi_point_status'] = 1;
|
||||
}
|
||||
$params['is_platform_deep_cooperation'] = 1;
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (!empty($user_doctor)){
|
||||
return $user_doctor['doctor_id'];
|
||||
}
|
||||
|
||||
// 获取在线的自由注册医生
|
||||
$params = array();
|
||||
$params['status'] = 1;
|
||||
$params['idcard_status'] = 1;
|
||||
$params['iden_auth_status'] = 1;
|
||||
$params['is_bind_bank'] = 1;
|
||||
$params['is_online'] = 1;
|
||||
if ($inquiry_type == 2){
|
||||
// 快速问诊
|
||||
$params['is_img_quick_reception'] = 1;
|
||||
}elseif ($inquiry_type == 4){
|
||||
// 问诊购药
|
||||
$params['multi_point_status'] = 1;
|
||||
}
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (!empty($user_doctor)){
|
||||
// 获取医生接诊中订单数量
|
||||
$InquiryService = new InquiryService();
|
||||
$accepting_inquiry_num = $InquiryService->getDoctorAcceptingInquiryNum($user_doctor['doctor_id'],$inquiry_type);
|
||||
|
||||
// 获取医生的最大接诊量
|
||||
// 获取深度合作的在线医生
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)){
|
||||
return ""; // 未配置最大接诊量,错误数据
|
||||
$params['status'] = 1;
|
||||
$params['idcard_status'] = 1;
|
||||
$params['iden_auth_status'] = 1;
|
||||
$params['is_bind_bank'] = 1;
|
||||
$params['is_online'] = 1;
|
||||
if ($inquiry_type == 2){
|
||||
// 快速问诊
|
||||
$params['is_img_quick_reception'] = 1;
|
||||
}elseif ($inquiry_type == 4){
|
||||
// 问诊购药
|
||||
$params['multi_point_status'] = 1;
|
||||
}
|
||||
$params['is_platform_deep_cooperation'] = 1;
|
||||
|
||||
$user_doctor = UserDoctor::getUserDoctorNotInOne($params,$not_doctor_ids);
|
||||
if (!empty($user_doctor)){
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($patient_id,$user_doctor['doctor_id']);
|
||||
if (!empty($order_inquiry)){
|
||||
// 存在未完成问诊订单,记录该医生id,重新分配
|
||||
$not_doctor_ids[] = $order_inquiry['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 不存在未完成的问诊订单
|
||||
$doctor_id = $user_doctor['doctor_id'];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($accepting_inquiry_num < $doctor_inquiry_config['work_num_day']){
|
||||
// 获取在线的自由注册医生
|
||||
$params = array();
|
||||
$params['status'] = 1;
|
||||
$params['idcard_status'] = 1;
|
||||
$params['iden_auth_status'] = 1;
|
||||
$params['is_bind_bank'] = 1;
|
||||
$params['is_online'] = 1;
|
||||
if ($inquiry_type == 2){
|
||||
// 快速问诊
|
||||
$params['is_img_quick_reception'] = 1;
|
||||
}elseif ($inquiry_type == 4){
|
||||
// 问诊购药
|
||||
$params['multi_point_status'] = 1;
|
||||
}
|
||||
$user_doctor = UserDoctor::getUserDoctorNotInOne($params,$not_doctor_ids);
|
||||
if (!empty($user_doctor)){
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($patient_id,$user_doctor['doctor_id']);
|
||||
if (!empty($order_inquiry)){
|
||||
// 存在未完成问诊订单,记录该医生id,重新分配
|
||||
$not_doctor_ids[] = $order_inquiry['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取医生每日最大接诊数量
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$max_work_num_day = $UserDoctorService->getDoctorInquiryDayMaxNum($user_doctor['doctor_id'],$inquiry_type,1);
|
||||
|
||||
// 获取医生未接诊订单数量(包含未接诊、未支付、已接诊)
|
||||
$order_inquiry_count = $UserDoctorService->getDoctorUnInquiryOrderNum($user_doctor['doctor_id'],$inquiry_type,1);
|
||||
|
||||
// 计算剩余未接诊数量 = 最大数量-
|
||||
$access_inquiry_num = $max_work_num_day - $order_inquiry_count;
|
||||
|
||||
if ($access_inquiry_num <= 0){
|
||||
// 分配的医生无问诊次数,重新分配
|
||||
$not_doctor_ids[] = $user_doctor['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 未超出最大接诊量
|
||||
return $user_doctor['doctor_id'];
|
||||
$doctor_id = $user_doctor['doctor_id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 检测当前时间5分钟后,坐班时间包含某时间的平台深度合作医生
|
||||
$doctor_id = $this->getNowTimePlatDeepCooperationDoctorId($inquiry_type,strtotime ("+5 minute"));
|
||||
if (!empty($doctor_id)){
|
||||
return $doctor_id;
|
||||
}
|
||||
// 检测当前时间5分钟后,坐班时间包含某时间的平台深度合作医生
|
||||
$doctor_id = $this->getNowTimePlatDeepCooperationDoctorId($inquiry_type,strtotime ("+5 minute"),$not_doctor_ids);
|
||||
if (!empty($doctor_id)){
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($patient_id,$doctor_id);
|
||||
if (!empty($order_inquiry)){
|
||||
// 存在未完成问诊订单,记录该医生id,重新分配
|
||||
$not_doctor_ids[] = $order_inquiry['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 当前时间10分钟内接诊中医生
|
||||
$doctors = $this->getBeforeCurrentTimeDoctor(10,$inquiry_type);
|
||||
if (!empty($doctors)){
|
||||
foreach ($doctors as $item){
|
||||
// 此处不验证接诊数量
|
||||
// 可能存在上方接诊数量不够的医生
|
||||
return $item['doctor_id'];
|
||||
// 不存在未完成的问诊订单
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前时间30分钟前接诊中的医生
|
||||
$doctors = $this->getBeforeCurrentTimeDoctor(30,$inquiry_type);
|
||||
if (!empty($doctors)){
|
||||
foreach ($doctors as $item){
|
||||
// 此处不验证接诊数量
|
||||
// 可能存在上方接诊数量不够的医生
|
||||
return $item['doctor_id'];
|
||||
// 当前时间10分钟内接诊中医生
|
||||
$doctors = $this->getBeforeCurrentTimeDoctor(10,$inquiry_type,$not_doctor_ids);
|
||||
if (!empty($doctors)){
|
||||
foreach ($doctors as $item){
|
||||
// 自由注册医生检测接诊数量
|
||||
if ($item['is_platform_deep_cooperation'] == 0){
|
||||
// 获取医生每日最大接诊数量
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$max_work_num_day = $UserDoctorService->getDoctorInquiryDayMaxNum($item['doctor_id'],$inquiry_type,1);
|
||||
|
||||
// 获取医生未接诊订单数量(包含未接诊、未支付、已接诊)
|
||||
$order_inquiry_count = $UserDoctorService->getDoctorUnInquiryOrderNum($item['doctor_id'],$inquiry_type,1);
|
||||
|
||||
// 计算剩余未接诊数量 = 最大数量-
|
||||
$access_inquiry_num = $max_work_num_day - $order_inquiry_count;
|
||||
|
||||
if ($access_inquiry_num <= 0){
|
||||
// 分配的医生无问诊次数,重新分配
|
||||
$not_doctor_ids[] = $item['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($patient_id,$item['doctor_id']);
|
||||
if (!empty($order_inquiry)){
|
||||
// 存在未完成问诊订单,记录该医生id,重新分配
|
||||
$not_doctor_ids[] = $order_inquiry['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
$doctor_id = $item['doctor_id'];
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
// 当前时间10分钟内接诊中医生
|
||||
$doctors = $this->getBeforeCurrentTimeDoctor(30,$inquiry_type,$not_doctor_ids);
|
||||
if (!empty($doctors)){
|
||||
foreach ($doctors as $item){
|
||||
// 自由注册医生检测接诊数量
|
||||
if ($item['is_platform_deep_cooperation'] == 0){
|
||||
// 获取医生每日最大接诊数量
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$max_work_num_day = $UserDoctorService->getDoctorInquiryDayMaxNum($item['doctor_id'],$inquiry_type,1);
|
||||
|
||||
// 获取医生未接诊订单数量(包含未接诊、未支付、已接诊)
|
||||
$order_inquiry_count = $UserDoctorService->getDoctorUnInquiryOrderNum($item['doctor_id'],$inquiry_type,1);
|
||||
|
||||
// 计算剩余未接诊数量 = 最大数量-
|
||||
$access_inquiry_num = $max_work_num_day - $order_inquiry_count;
|
||||
|
||||
if ($access_inquiry_num <= 0){
|
||||
// 分配的医生无问诊次数,重新分配
|
||||
$not_doctor_ids[] = $item['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($patient_id,$item['doctor_id']);
|
||||
if (!empty($order_inquiry)){
|
||||
// 存在未完成问诊订单,记录该医生id,重新分配
|
||||
$not_doctor_ids[] = $order_inquiry['doctor_id'];
|
||||
continue;
|
||||
}
|
||||
|
||||
$doctor_id = $item['doctor_id'];
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
// 医生id归为空
|
||||
$doctor_id = "";
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
return $doctor_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取坐班时间包含某时间的平台深度合作医生
|
||||
* @param string $inquiry_type
|
||||
* @param string $time 时间戳
|
||||
* @param array $not_doctor_ids 不可选择的医生id数组
|
||||
* @return string
|
||||
*/
|
||||
public function getNowTimePlatDeepCooperationDoctorId(string $inquiry_type,string $time): string
|
||||
public function getNowTimePlatDeepCooperationDoctorId(string $inquiry_type,string $time,array $not_doctor_ids = []): string
|
||||
{
|
||||
$params = array();
|
||||
$params[] = ['inquiry_type','=',$inquiry_type];
|
||||
@@ -1795,7 +1901,7 @@ class UserDoctorService extends BaseService
|
||||
// 问诊购药
|
||||
$user_doctor_params['multi_point_status'] = 1;
|
||||
}
|
||||
$doctor_inquiry_times = DoctorInquiryTime::getWithDoctorList($params,$user_doctor_params);
|
||||
$doctor_inquiry_times = DoctorInquiryTime::getWithDoctorNotInList($params,$user_doctor_params,$not_doctor_ids);
|
||||
if (!empty($doctor_inquiry_times)){
|
||||
foreach ($doctor_inquiry_times as $item){
|
||||
// 检测是否存在日期
|
||||
@@ -1815,4 +1921,56 @@ class UserDoctorService extends BaseService
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生每日最大接诊数量
|
||||
* @param string $doctor_id
|
||||
* @param string|int $inquiry_type
|
||||
* @param string|int $inquiry_mode
|
||||
* @return int
|
||||
*/
|
||||
public function getDoctorInquiryDayMaxNum(string $doctor_id,string|int $inquiry_type,string|int $inquiry_mode): int
|
||||
{
|
||||
$max_work_num_day = 0;
|
||||
if ($inquiry_type == 4){
|
||||
// 问诊购药由系统统一配置
|
||||
$params = array();
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (!empty($system_inquiry_config)){
|
||||
$max_work_num_day = $system_inquiry_config['max_work_num_day'];
|
||||
}
|
||||
}else{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (!empty($doctor_inquiry_config)){
|
||||
$max_work_num_day = $doctor_inquiry_config['work_num_day'];
|
||||
}
|
||||
}
|
||||
|
||||
return $max_work_num_day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生未接诊订单数量(包含未接诊、未支付、已接诊)
|
||||
* @param string $doctor_id
|
||||
* @param string|int $inquiry_type
|
||||
* @param string|int $inquiry_mode
|
||||
* @return int
|
||||
*/
|
||||
public function getDoctorUnInquiryOrderNum(string $doctor_id,string|int $inquiry_type,string|int $inquiry_mode): int
|
||||
{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$params['inquiry_refund_status'] = 0;
|
||||
|
||||
$inquiry_status_params = [1,3,4];
|
||||
return OrderInquiry::getInquiryStatusCount($params,$inquiry_status_params);
|
||||
}
|
||||
}
|
||||
@@ -253,6 +253,8 @@ class UserPatientService extends BaseService
|
||||
/**
|
||||
* 修改购物车药品数据
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putShoppingCart(): array
|
||||
{
|
||||
@@ -260,22 +262,22 @@ class UserPatientService extends BaseService
|
||||
$product_id = $this->request->input("product_id");
|
||||
$shopping_cart_num = $this->request->input("shopping_cart_num");
|
||||
|
||||
// if ($shopping_cart_num > 0){
|
||||
// // 验证商品数据
|
||||
// $params =array();
|
||||
// $params['product_id'] = $product_id;
|
||||
// $product = Product::getOne($params);
|
||||
// if (empty($product)){
|
||||
// return fail();
|
||||
// }
|
||||
// // 获取商品库存
|
||||
// $params =array();
|
||||
// $params['product_platform_id'] = $product['product_platform_id'];
|
||||
// $product_platform_amount = ProductPlatformAmount::getOne($params);
|
||||
// if ($product_platform_amount['stock'] <= 0){
|
||||
// return fail(HttpEnumCode::HTTP_ERROR,"商品库存不足");
|
||||
// }
|
||||
// }
|
||||
if ($shopping_cart_num > 0){
|
||||
// 验证商品数据
|
||||
$params =array();
|
||||
$params['product_id'] = $product_id;
|
||||
$product = Product::getOne($params);
|
||||
if (empty($product)){
|
||||
return fail();
|
||||
}
|
||||
// 获取商品库存
|
||||
$params =array();
|
||||
$params['product_platform_id'] = $product['product_platform_id'];
|
||||
$product_platform_amount = ProductPlatformAmount::getOne($params);
|
||||
if ($product_platform_amount['stock'] <= 0){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"商品库存不足");
|
||||
}
|
||||
}
|
||||
|
||||
// 读取缓存数据
|
||||
$redis = $this->container->get(Redis::class);
|
||||
@@ -392,34 +394,4 @@ class UserPatientService extends BaseService
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者未完成订单
|
||||
* @param string $patient_id
|
||||
* @param string $family_id
|
||||
* @return string
|
||||
*/
|
||||
public function getNotFinishedOrdeInquiry(string $patient_id = '',string $family_id = ''): string
|
||||
{
|
||||
$params = array();
|
||||
if (!empty($patient_id)){
|
||||
$params[] = ['patient_id','=',$patient_id];
|
||||
}
|
||||
|
||||
if (!empty($family_id)){
|
||||
$params[] = ['family_id','=',$family_id];
|
||||
}
|
||||
|
||||
$params[] = ['inquiry_mode','=',1];
|
||||
$params[] = ['inquiry_refund_status','=',0];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (!empty($order_inquiry)) {
|
||||
// 1:待支付 2:待分配 3:待接诊 4:已接诊
|
||||
if (in_array($order_inquiry['inquiry_status'], [2, 3, 4])) {
|
||||
return $order_inquiry['order_inquiry_id'];
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user