修改消息推送

This commit is contained in:
wucongxing 2023-04-04 18:39:10 +08:00
parent ad119be0e8
commit 9c44f13498
11 changed files with 351 additions and 277 deletions

View File

@ -187,7 +187,7 @@ class AssignDoctorConsumer extends ConsumerMessage
return Result::ACK; return Result::ACK;
} }
// 发送问诊消息-等待医生接诊 // 发送IM消息-等待医生接诊
$imService = new ImService(); $imService = new ImService();
$imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); $imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);

View File

@ -149,8 +149,6 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息"); Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息");
try { try {
$ImService = new ImService();
// 获取订单医生数据 // 获取订单医生数据
$params = array(); $params = array();
$params['doctor_id'] = $order_inquiry['doctor_id']; $params['doctor_id'] = $order_inquiry['doctor_id'];
@ -159,28 +157,12 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息失败医生数据错误"); Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息失败医生数据错误");
} }
// 发送消息 // 发送IM消息-医生未接诊
// 自定义消息 $imService = new ImService();
$cloud_custom_data = array(); $imService->doctorUnInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容 // 发送IM消息-问诊退款
$message_content_data = array(); $imService->inquiryRefund($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
$message_content_data['message_type'] = 1;
$message_content_data['content'] = "--医生未接诊--";
$message_content_data['desc'] = "医生因工作繁忙未能接诊和您沟通希望见谅。平台在24小时内进行退款钱会退回至原账户中。";
$message_content = [
'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),
];
$ImService->sendMessage($user_doctor['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data);
Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息成功"); Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息成功");
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -159,7 +159,7 @@ class CallBackController extends AbstractController
return $server->serve(); return $server->serve();
} }
// 发送问诊消息-等待医生接诊 // 发送IM消息-等待医生接诊
$imService = new ImService(); $imService = new ImService();
$imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); $imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
@ -359,6 +359,7 @@ class CallBackController extends AbstractController
// 支付成功 // 支付成功
$data['order_product_status'] = 2; $data['order_product_status'] = 2;
$data['pay_status'] = 2;// 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) $data['pay_status'] = 2;// 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
$data['pay_time'] = date('Y-m-d H:i:s',strtotime($message['success_time']));// 支付时间
}elseif($message['trade_state'] == "CLOSED"){ }elseif($message['trade_state'] == "CLOSED"){
// 已关闭 // 已关闭

View File

@ -10,6 +10,7 @@ use App\Model\DoctorInquiryTime;
use App\Model\OrderPrescriptionProduct; use App\Model\OrderPrescriptionProduct;
use App\Model\OrderProduct; use App\Model\OrderProduct;
use App\Model\OrderProductItem; use App\Model\OrderProductItem;
use App\Model\User;
use App\Model\UserCaCert; use App\Model\UserCaCert;
use App\Model\OrderInquiry; use App\Model\OrderInquiry;
use App\Model\OrderPrescription; use App\Model\OrderPrescription;
@ -29,6 +30,8 @@ use Hyperf\Utils\ApplicationContext;
use Imagick; use Imagick;
use Intervention\Image\ImageManager; use Intervention\Image\ImageManager;
use Spatie\PdfToImage\Pdf; use Spatie\PdfToImage\Pdf;
use Swoole\Coroutine;
use Swoole\Coroutine\WaitGroup;
use TCPDF; use TCPDF;
class TestController extends AbstractController class TestController extends AbstractController
@ -578,16 +581,6 @@ class TestController extends AbstractController
} }
public function test_11(){ public function test_11(){
$PatientOrderService = new PatientOrderService();
$order_inquiry_id = $PatientOrderService->getNotFinishedOrderInquiry(4,"501764342039097344");
dump($order_inquiry_id);
dump(!empty($order_inquiry_id));
if (!empty($order_inquiry_id)) {
return 111;
return fail(HttpEnumCode::HTTP_ERROR, "当前患者存在进行中的问诊订单");
}
die;
$order_prescription_id = "501751534291394561"; $order_prescription_id = "501751534291394561";
// 获取处方数据 // 获取处方数据
@ -637,6 +630,8 @@ class TestController extends AbstractController
$order_prescription_product->toArray(), $order_prescription_product->toArray(),
$order_product->toArray() $order_product->toArray()
); );
dump($result);
} }

View File

@ -449,4 +449,144 @@ class ImService extends BaseService
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
} }
/**
* 医生超时未接诊
* @param array|object $order_inquiry
* @param string $doctor_user_id
* @param string $patient_user_id
* @return void
*/
public function doctorUnInquiry(array|object $order_inquiry, string $doctor_user_id, string $patient_user_id): void
{
try {
// 发送消息
$cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容 - 患者-医生
$message_content_data = array();
$message_content_data['message_type'] = 8;
$message_content_data['title'] = "--医生未接诊--";
$message_content_data['desc'] = "医生因工作繁忙未能接诊和您沟通希望见谅。平台在24小时内进行退款钱会退回至原账户中。";
$message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($patient_user_id, $doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
// 消息内容 医生-患者
$message_content_data = array();
$message_content_data['message_type'] = 1;
$message_content_data['title'] = "--医生未接诊--";
$message_content_data['desc'] = "医生因工作繁忙未能接诊和您沟通希望见谅。平台在24小时内进行退款钱会退回至原账户中。";
$message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($doctor_user_id, $patient_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
} catch (\Exception $e) {
throw new BusinessException($e->getMessage());
}
}
/**
* 处方已开具
* @param array|object $order_inquiry
* @param string $doctor_user_id
* @param string $patient_user_id
* @param string $product_name
* @param string $order_prescription_id
* @param string $message_type 6/7
* @return void
*/
public function prescriptionIssued(array|object $order_inquiry, string $doctor_user_id, string $patient_user_id,string $product_name,string $order_prescription_id,string $message_type): void
{
try {
// 发送消息
$cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容
$message_content_data = array();
$message_content_data['message_type'] = $message_type;
$message_content_data['title'] = "处方已开具";
$message_content_data['desc'] = "";
$message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
$message_content_data['data']['order_prescription_id'] = $order_prescription_id;
$message_content_data['data']['product_name'] = $product_name ?? "药品";
$message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());;
$message_content = [
'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($doctor_user_id, $patient_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
} catch (\Exception $e) {
throw new BusinessException($e->getMessage());
}
}
/**
* 问诊退款
* @param array|object $order_inquiry 问诊订单数据
* @param string $doctor_user_id 医生用户id
* @param string $patient_user_id 患者用户id
* @return void
*/
public function inquiryRefund(array|object $order_inquiry, string $doctor_user_id, string $patient_user_id): void
{
try {
// 发送消息
$cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容 - 患者-医生
$message_content_data = array();
$message_content_data['message_type'] = 8;
$message_content_data['title'] = "--问诊退款--";
$message_content_data['desc'] = "平台已自动发起退款,请注意查看账户信息。";
$message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($patient_user_id, $doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
// 消息内容 医生-患者
$message_content_data = array();
$message_content_data['message_type'] = 1;
$message_content_data['title'] = "--问诊退款--";
$message_content_data['desc'] = "平台已自动发起退款,请注意查看账户信息。";
$message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($doctor_user_id, $patient_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
} catch (\Exception $e) {
throw new BusinessException($e->getMessage());
}
}
} }

View File

@ -873,42 +873,6 @@ class InquiryService extends BaseService
$params = array(); $params = array();
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
OrderInquiry::edit($params, $data); OrderInquiry::edit($params, $data);
// 存在问诊医生时,需发送退款消息
if (!empty($order_inquiry['doctor_id'])){
// 获取医生数据
$params = array();
$params['doctor_id'] = $order_inquiry['doctor_id'];
$user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)){
throw new BusinessException("医生数据错误");
}
// 发送问诊消息
$ImService = new ImService();
// 发送消息
$cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容
$message_content_data = array();
$message_content_data['message_type'] = 1;
$message_content_data['title'] = "问诊已结束";
$message_content_data['desc'] = "线上咨询不能代替问诊,医生的回复仅为建议。";
$message_content = [
'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),
];
$ImService->sendMessage($user_doctor['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data);
}
} }
/** /**

View File

@ -18,8 +18,10 @@ use App\Model\UserDoctor;
use App\Model\UserDoctorInfo; use App\Model\UserDoctorInfo;
use App\Model\UserPharmacist; use App\Model\UserPharmacist;
use App\Model\UserPharmacistInfo; use App\Model\UserPharmacistInfo;
use App\Utils\Log;
use Extend\Alibaba\Oss; use Extend\Alibaba\Oss;
use Extend\Ca\Ca; use Extend\Ca\Ca;
use Extend\Prescription\Prescription;
use Hyperf\Contract\LengthAwarePaginatorInterface; use Hyperf\Contract\LengthAwarePaginatorInterface;
use Hyperf\Utils\WaitGroup; use Hyperf\Utils\WaitGroup;
use Intervention\Image\ImageManager; use Intervention\Image\ImageManager;
@ -226,7 +228,7 @@ class OrderPrescriptionService extends BaseService
// 处理疾病数据 // 处理疾病数据
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name'); $icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
if (!empty($icd_name)) { if (!empty($icd_name)) {
if (count($icd_name > 1)) { if (count($icd_name) > 1) {
$icd_name = implode(';', $icd_name); $icd_name = implode(';', $icd_name);
} else { } else {
$icd_name = $icd_name[0]; $icd_name = $icd_name[0];
@ -562,13 +564,12 @@ class OrderPrescriptionService extends BaseService
public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product) public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product)
{ {
$wg = new WaitGroup(); $wg = new WaitGroup();
$wg->add(2); $wg->add(8);
$user = []; // 就诊患者用户数据 $user = []; // 就诊患者用户数据
$patient_family = []; // 家庭成员-基本信息 $patient_family = []; // 家庭成员-基本信息
$order_prescription_icd = []; // 处方关联疾病数据 $order_prescription_icd = []; // 处方关联疾病数据
$user_doctor = []; // 医生数据 $user_doctor = []; // 医生数据
$hospital_department_custom = []; // 医生科室
$user_doctor_info = []; // 医生详情数据 $user_doctor_info = []; // 医生详情数据
$user_pharmacist = []; // 药师数据 $user_pharmacist = []; // 药师数据
$user_pharmacist_info = []; // 药师详数据 $user_pharmacist_info = []; // 药师详数据
@ -576,18 +577,17 @@ class OrderPrescriptionService extends BaseService
// 获取就诊患者用户数据 // 获取就诊患者用户数据
$user_id = $order_inquiry['user_id']; $user_id = $order_inquiry['user_id'];
co(function () use ($wg,&$user,$user_id) { co(function () use ($wg, &$user, $user_id) {
$params = array(); $params = array();
$params['user_id'] = $user_id; $params['user_id'] = $user_id;
$user = User::getOne($params); $user = User::getOne($params)->toArray();
// 计数器减一 // 计数器减一
$wg->done(); $wg->done();
}); });
// 获取家庭成员-基本信息 // 获取家庭成员-基本信息
$family_id = $order_inquiry['family_id']; $family_id = $order_inquiry['family_id'];
co(function () use ($wg,&$patient_family,$family_id) { co(function () use ($wg, &$patient_family, $family_id) {
$params = array(); $params = array();
$params['family_id'] = $family_id; $params['family_id'] = $family_id;
$patient_family = PatientFamily::getOne($params); $patient_family = PatientFamily::getOne($params);
@ -598,7 +598,7 @@ class OrderPrescriptionService extends BaseService
// 获取处方关联疾病数据 // 获取处方关联疾病数据
$order_prescription_id = $order_prescription['order_prescription_id']; $order_prescription_id = $order_prescription['order_prescription_id'];
co(function () use ($wg,&$order_prescription_icd,$order_prescription_id) { co(function () use ($wg, &$order_prescription_icd, $order_prescription_id) {
$params = array(); $params = array();
$params['order_prescription_id'] = $order_prescription_id; $params['order_prescription_id'] = $order_prescription_id;
$order_prescription_icd = OrderPrescriptionIcd::getList($params); $order_prescription_icd = OrderPrescriptionIcd::getList($params);
@ -607,6 +607,63 @@ class OrderPrescriptionService extends BaseService
$wg->done(); $wg->done();
}); });
// 获取医生数据
$doctor_id = $order_prescription['doctor_id'];
co(function () use ($wg, &$user_doctor, $doctor_id) {
$params = array();
$params['doctor_id'] = $doctor_id;
$user_doctor = UserDoctor::getOne($params);
// 计数器减一
$wg->done();
});
// 获取医生详情数据
$doctor_id = $order_prescription['doctor_id'];
co(function () use ($wg, &$user_doctor_info, $doctor_id) {
$params = array();
$params['doctor_id'] = $doctor_id;
$user_doctor_info = UserDoctorInfo::getOne($params);
// 计数器减一
$wg->done();
});
// 获取药师数据
$pharmacist_id = $order_prescription['pharmacist_id'];
co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
$params = array();
$params['pharmacist_id'] = $pharmacist_id;
$user_pharmacist = UserPharmacist::getOne($params);
// 计数器减一
$wg->done();
});
// 获取药师详情数据
$pharmacist_id = $order_prescription['pharmacist_id'];
co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
$params = array();
$params['pharmacist_id'] = $pharmacist_id;
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
// 计数器减一
$wg->done();
});
// 获取病例数据
$order_inquiry_id = $order_inquiry['order_inquiry_id'];
co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) {
$params = array();
$params['order_inquiry_id'] = $order_inquiry_id;
$params['status'] = 1;
$order_inquiry_case = OrderInquiryCase::getOne($params);
// 计数器减一
$wg->done();
});
$wg->wait();
if (empty($user)) { if (empty($user)) {
throw new BusinessException("用户数据错误"); throw new BusinessException("用户数据错误");
@ -617,6 +674,21 @@ class OrderPrescriptionService extends BaseService
if (empty($order_prescription_icd)) { if (empty($order_prescription_icd)) {
throw new BusinessException("处方疾病数据错误"); throw new BusinessException("处方疾病数据错误");
} }
if (empty($user_doctor)) {
throw new BusinessException("医生数据错误");
}
if (empty($user_doctor_info)) {
throw new BusinessException("医生详情数据错误");
}
if (empty($user_pharmacist)) {
throw new BusinessException("药师数据错误");
}
if (empty($user_pharmacist_info)) {
throw new BusinessException("药师详情数据错误");
}
if (empty($order_inquiry_case)) {
throw new BusinessException("病例数据错误");
}
// 处理疾病数据 // 处理疾病数据
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name'); $icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
@ -630,14 +702,6 @@ class OrderPrescriptionService extends BaseService
$icd_name = ""; $icd_name = "";
} }
// 获取医生数据
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
$user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)) {
throw new BusinessException("医生数据错误");
}
// 获取医生科室 // 获取医生科室
$params = array(); $params = array();
$params['department_custom_id'] = $user_doctor['department_custom_id']; $params['department_custom_id'] = $user_doctor['department_custom_id'];
@ -646,46 +710,14 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException("医生科室数据错误"); throw new BusinessException("医生科室数据错误");
} }
// 获取医生详情数据
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
$user_doctor_info = UserDoctorInfo::getOne($params);
if (empty($user_doctor_info)) {
throw new BusinessException("医生详情数据错误");
}
// 获取药师数据
$params = array();
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
$user_pharmacist = UserPharmacist::getOne($params);
if (empty($user_pharmacist)) {
throw new BusinessException("药师数据错误");
}
// 获取药师详情数据
$params = array();
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
if (empty($user_pharmacist_info)) {
throw new BusinessException("药师详情数据错误");
}
// 获取病例数据
$params = array();
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
$params['status'] = 1;
$order_inquiry_case = OrderInquiryCase::getOne($params);
if (empty($order_inquiry_case)) {
throw new BusinessException("病例数据错误");
}
$arg = array(); $arg = array();
$arg['terminalCode'] = "JG-10009"; $arg['terminalCode'] = "ZD-10003";
$arg['orderNo'] = $order_product['order_product_no']; // 支付流水 $arg['orderNo'] = $order_product['order_product_no']; // 订单编号
$arg['transactNo'] = $order_product['escrow_trade_no']; // 支付流水号 $arg['transactNo'] = $order_product['escrow_trade_no']; // 流水单号
$arg['payDate'] = $order_product['pay_time']; // 支付时间 $arg['payDate'] = $order_product['pay_time']; // 支付时间
$arg['money'] = $order_product['payment_amount_total']; // 订单金额 $arg['money'] = $order_product['payment_amount_total']; // 订单金额
$arg['takeTypeCode'] = 2; // 取货方式 1 自提 2 快递,目 前只支持快递,传 固定值 2 $arg['freight'] = $order_product['logistics_fee']; // 运费(单位:元)
$arg['takeTypeCode'] = 2; // 取货方式 1 自提 2 快递,目前只支持快递,传固定值 2
$arg['buyerName'] = $order_product['consignee_name'];// 收货人姓名 $arg['buyerName'] = $order_product['consignee_name'];// 收货人姓名
$arg['buyerPhone'] = $order_product['consignee_tel'];// 收货人联系方式 $arg['buyerPhone'] = $order_product['consignee_tel'];// 收货人联系方式
$arg['buyerAddress'] = $order_product['address'];// 收货人地址 $arg['buyerAddress'] = $order_product['address'];// 收货人地址
@ -695,32 +727,32 @@ class OrderPrescriptionService extends BaseService
$arg['cityName'] = $order_product['city']; // 收货地址(市) 名称 $arg['cityName'] = $order_product['city']; // 收货地址(市) 名称
$arg['districtCode'] = $order_product['county_id']; // 收货地址(区 县)编码 $arg['districtCode'] = $order_product['county_id']; // 收货地址(区 县)编码
$arg['districtName'] = $order_product['county']; // 收货地址(区 县)名称 $arg['districtName'] = $order_product['county']; // 收货地址(区 县)名称
$arg['freight'] = $order_product['logistics_fee']; // 运费(单位:元)
$arg['prescriptionNo'] = $order_prescription['prescription_code']; // 处方编号 $arg['presList'][0]['prescriptionNo'] = $order_prescription['prescription_code']; // 处方编号
$arg['prescriptionSubType'] = 1; // 处方类型 0无类型 1普 通处方 2儿科处 方 $arg['presList'][0]['prescriptionSubType'] = 1; // 处方类型 0无类型 1普 通处方 2儿科处 方
$arg['patientName'] = $order_prescription['patient_name']; // 就诊人姓名 $arg['presList'][0]['patientName'] = $order_prescription['patient_name']; // 就诊人姓名
$arg['patientPhone'] = $user['mobile']; // 就诊人联系方式 $arg['presList'][0]['patientPhone'] = $user['mobile']; // 就诊人联系方式
$arg['idCard'] = $patient_family['id_number']; // 身份证号 $arg['presList'][0]['idCard'] = $patient_family['id_number']; // 身份证号
$arg['advice'] = $order_prescription['doctor_advice'] ?: ""; // 医嘱 $arg['presList'][0]['advice'] = $order_prescription['doctor_advice'] ?: ""; // 医嘱
$arg['diagnosisName'] = $icd_name ?: ""; // 诊断 $arg['presList'][0]['diagnosisName'] = $icd_name ?: ""; // 诊断
$arg['thirdDoctorName'] = $user_doctor['user_name']; // 开方医生姓名 $arg['presList'][0]['thirdDoctorName'] = $user_doctor['user_name']; // 开方医生姓名
$arg['thirdDeptName'] = $hospital_department_custom['department_name'] ?: ""; // 开方科室名称 $arg['presList'][0]['thirdDeptName'] = $hospital_department_custom['department_name'] ?: ""; // 开方科室名称
$arg['thirdDoctorNameImg'] = addAliyunOssWebsite($user_doctor_info['sign_image']); // 开方医生签名链接 $arg['presList'][0]['thirdDoctorNameImg'] = addAliyunOssWebsite($user_doctor_info['sign_image']); // 开方医生签名链接
$arg['prescriptionTime'] = $order_prescription['doctor_created_time']; // 开方时间 $arg['presList'][0]['prescriptionTime'] = $order_prescription['doctor_created_time']; // 开方时间
$arg['thirdFirstPharmacist'] = $user_pharmacist['user_name']; // 初审药师姓名 $arg['presList'][0]['thirdFirstPharmacist'] = $user_pharmacist['user_name']; // 初审药师姓名
$arg['thirdFirstPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 初审药师签名链接 $arg['presList'][0]['thirdFirstPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 初审药师签名链接
$arg['thirdFirstTime'] = $order_prescription['pharmacist_verify_time']; // 初审时间 $arg['presList'][0]['thirdFirstTime'] = $order_prescription['pharmacist_verify_time']; // 初审时间
$arg['thirdLastPharmacist'] = $user_pharmacist['user_name']; // 终审药师姓名 $arg['presList'][0]['thirdLastPharmacist'] = $user_pharmacist['user_name']; // 终审药师姓名
$arg['thirdLastPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 终审药师签名 链接 $arg['presList'][0]['thirdLastPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 终审药师签名 链接
$arg['ThirdLastTime'] = $order_prescription['pharmacist_verify_time']; // 终审时间 $arg['presList'][0]['ThirdLastTime'] = $order_prescription['pharmacist_verify_time']; // 终审时间
$arg['thirdSignImg'] = addAliyunOssWebsite("/basic/file/hospital_signature.png"); // 处方签章链接 $arg['presList'][0]['thirdSignImg'] = addAliyunOssWebsite("/basic/file/hospital_signature.png"); // 处方签章链接
$arg['referenceCharge'] = $order_product['amount_total']; // 处方费用(不包含运费) $arg['presList'][0]['referenceCharge'] = $order_product['amount_total']; // 处方费用(不包含运费)
$arg['chiefComplaint'] = $order_inquiry_case['disease_desc'] ?: ""; // 主诉 $arg['presList'][0]['chiefComplaint'] = $order_inquiry_case['disease_desc'] ?: ""; // 主诉
$arg['historyPresent'] = $order_inquiry_case['disease_class_name'] ?: ""; // 现病史 $arg['presList'][0]['historyPresent'] = $order_inquiry_case['disease_class_name'] ?: ""; // 现病史
$arg['pastHistory'] = $order_inquiry_case['family_history'] ?: ""; // 既往史 $arg['presList'][0]['pastHistory'] = $order_inquiry_case['family_history'] ?: ""; // 既往史
$arg['physicalExamination'] = ""; // 体格检查 $arg['presList'][0]['physicalExamination'] = ""; // 体格检查
$arg['supplementaryExamination'] = ""; // 辅助检查 $arg['presList'][0]['supplementaryExamination'] = ""; // 辅助检查
$arg['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: ""; // 过敏史 $arg['presList'][0]['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: ""; // 过敏史
// 药品数据 // 药品数据
foreach ($order_prescription_product as $key => $item) { foreach ($order_prescription_product as $key => $item) {
@ -732,29 +764,46 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException("药品数据错误"); throw new BusinessException("药品数据错误");
} }
$arg['drugList'][$key]['drugCode'] = $product['product_pharmacy_code']; // 药品编码 $arg['presList'][0]['drugList'][$key]['drugCode'] = $product['product_platform_code']; // 药品编码
$arg['drugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号 $arg['presList'][0]['drugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
$arg['drugList'][$key]['drugName'] = $product['product_name']; // 药品名称 $arg['presList'][0]['drugList'][$key]['drugName'] = $product['product_name']; // 药品名称
$arg['drugList'][$key]['specifications'] = $product['product_spec']; // 药品规格 $arg['presList'][0]['drugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
$arg['drugList'][$key]['price'] = $product['product_price']; // 药品单价 $arg['presList'][0]['drugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['drugList'][$key]['packingCount'] = $item['prescription_product_num']; // 药品数量 $arg['presList'][0]['drugList'][$key]['packingCount'] = $item['prescription_product_num']; // 药品数量
$arg['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量 $arg['presList'][0]['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量
$arg['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位 $arg['presList'][0]['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
$arg['drugList'][$key]['singleDosage'] = $product['single_unit']; // 单次用量 $arg['presList'][0]['drugList'][$key]['singleDosage'] = 1; // 单次用量
$arg['drugList'][$key]['singleDosageUnit'] = ""; // 单次用量单位 $arg['presList'][0]['drugList'][$key]['singleDosageUnit'] = ""; // 单次用量单位
$arg['drugList'][$key]['useName'] = $product['single_use']; // 用法名称 $arg['presList'][0]['drugList'][$key]['useName'] = $product['single_use']; // 用法名称
$arg['drugList'][$key]['frequencyName'] = $product['frequency_use']; // 频次名称 $arg['presList'][0]['drugList'][$key]['frequencyName'] = $product['frequency_use']; // 频次名称
$arg['drugList'][$key]['useDays'] = $product['available_days']; // 使用天数 $arg['presList'][0]['drugList'][$key]['useDays'] = $product['available_days']; // 使用天数
$arg['orderDrugList'][$key]['drugCode'] = $product['product_pharmacy_code']; // 药品编码 $arg['presList'][0]['orderDrugList'][$key]['drugCode'] = $product['product_platform_code']; // 药品编码
$arg['orderDrugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号 $arg['presList'][0]['orderDrugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
$arg['orderDrugList'][$key]['drugName'] = $product['product_name']; // 药品名称 $arg['presList'][0]['orderDrugList'][$key]['drugName'] = $product['product_name']; // 药品名称
$arg['orderDrugList'][$key]['specifications'] = $product['product_spec']; // 药品规格 $arg['presList'][0]['orderDrugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
$arg['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价 $arg['presList'][0]['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['orderDrugList'][$key]['drugCount'] = $item['prescription_product_num']; // 药品数量 $arg['presList'][0]['orderDrugList'][$key]['drugCount'] = $item['prescription_product_num']; // 药品数量
$arg['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位 $arg['presList'][0]['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
} }
Log::getInstance()->info(json_encode($arg,JSON_UNESCAPED_UNICODE));
dump($arg);
$Prescription = new Prescription();
$result = $Prescription->reportPrescription($arg);
dump($result);
if ($result['resultCode'] != "1000"){
if ($result['resultCode'] == "1008"){
// 没有相关药品或库存不足
}
if(!empty($result['resultDesc'])){
throw new BusinessException($result['resultDesc']);
}
throw new BusinessException("上报处方平台失败");
}
return $arg; return $arg;
} }

View File

@ -801,8 +801,6 @@ class PatientOrderService extends BaseService
} }
}elseif ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){ }elseif ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){
// 专家-公益发送im消息 // 专家-公益发送im消息
$ImService = new ImService();
// 获取订单医生数据 // 获取订单医生数据
$params = array(); $params = array();
$params['doctor_id'] = $order_inquiry['doctor_id']; $params['doctor_id'] = $order_inquiry['doctor_id'];
@ -812,32 +810,9 @@ class PatientOrderService extends BaseService
return fail(HttpEnumCode::HTTP_ERROR, "医生数据错误"); return fail(HttpEnumCode::HTTP_ERROR, "医生数据错误");
} }
// 自定义消息 // 发送IM消息-等待医生接诊
$cloud_custom_data = array(); $imService = new ImService();
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $imService->waitDoctorInquiry($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']);
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容
$message_content_data = array();
$message_content_data['message_type'] = 1;
$message_content_data['title'] = "--等待医生接诊--";
if ($order_inquiry['inquiry_type'] == 1){
$message_content_data['desc'] = "温馨提示当前服务为专家问诊可以在24小时内和医生沟通20个回合。医生均为一线工作还请耐心等待医生接诊会第一时间短信通知您。";
}else{
$message_content_data['desc'] = "温馨提示当前服务为公益问诊可以在24小时内和医生沟通10个回合。医生均为一线工作还请耐心等待医生接诊会第一时间短信通知您。";
}
$message_content = [
'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),
];
$ImService->sendMessage($user_doctor['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data);
} }

View File

@ -1143,32 +1143,9 @@ class UserDoctorService extends BaseService
$params['order_prescription_id'] = $order_prescription['order_prescription_id']; $params['order_prescription_id'] = $order_prescription['order_prescription_id'];
OrderPrescription::edit($params,$data); OrderPrescription::edit($params,$data);
// 发送消息 // 发送IM消息-处方已开具
$ImService = new ImService(); $imService = new ImService();
$imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],"6");
$cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容
$message_content_data = array();
$message_content_data['message_type'] = 6;
$message_content_data['title'] = "处方已开具";
$message_content_data['desc'] = "";
$message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
$message_content_data['data']['order_prescription_id'] = (string)$order_prescription['order_prescription_id'];
$message_content_data['data']['product_name'] = $product_name ?: "药品";
$message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());;
$message_content = [
'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),
];
$ImService->sendMessage($user_doctor['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data);
// 加入分配药师队列 // 加入分配药师队列
$data = array(); $data = array();
@ -1641,7 +1618,7 @@ class UserDoctorService extends BaseService
$params['order_inquiry_id'] = $order_inquiry_id; $params['order_inquiry_id'] = $order_inquiry_id;
OrderInquiry::edit($params,$data); OrderInquiry::edit($params,$data);
// 发送问诊消息-医生接诊 // 发送IM消息-医生接诊
$imService = new ImService(); $imService = new ImService();
$imService->doctorInquiry($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']); $imService->doctorInquiry($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']);
@ -1728,7 +1705,7 @@ class UserDoctorService extends BaseService
return fail(HttpEnumCode::SERVER_ERROR, "添加患者历史问诊表失败"); return fail(HttpEnumCode::SERVER_ERROR, "添加患者历史问诊表失败");
} }
// 发送问诊消息-问诊已结束 // 发送IM消息-问诊已结束
$imService = new ImService(); $imService = new ImService();
$imService->inquiryEnd($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']); $imService->inquiryEnd($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']);

View File

@ -231,34 +231,9 @@ class UserPharmacistService extends BaseService
// 上报处方平台 // 上报处方平台
// 发送IM消息-处方已开具
// 发送消息 $imService = new ImService();
$ImService = new ImService(); $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],"7");
// 发送消息
$cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
// 消息内容
$message_content_data = array();
$message_content_data['message_type'] = 7;
$message_content_data['title'] = "处方已开具";
$message_content_data['desc'] = "";
$message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
$message_content_data['data']['order_prescription_id'] = (string)$order_prescription['order_prescription_id'];
$message_content_data['data']['product_name'] = $product_name ?? "药品";
$message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());;
$message_content = [
'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),
];
$ImService->sendMessage($user_doctor['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data);
Db::commit(); Db::commit();
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -54,13 +54,20 @@ class Prescription
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/user_thrid/token', $option); $response = $this->httpRequest($this->api_url . $this->version . '/user_thrid/token', $option);
if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($response['result'])){ if (empty($response['data']['result'])){
// 返回值为空 // 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
if (empty($response['result']['token'])){ if (empty($response['data']['result']['token'])){
// 返回值为空 // 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
@ -70,11 +77,11 @@ class Prescription
} }
$this->header = [ $this->header = [
"Authorization" => "Bearer " . $response['result']['token'] "Authorization" => "Bearer " . $response['data']['result']['token']
]; ];
$this->redis->set("prescription_token",$response['result']['token'],60 * 60 * 1.5); $this->redis->set("prescription_token",$response['data']['result']['token'],60 * 60 * 1.5);
return $response['result']['token']; return $response['data']['result']['token'];
} }
/** /**
@ -83,7 +90,8 @@ class Prescription
* @param int $pageSize * @param int $pageSize
* @return mixed * @return mixed
*/ */
public function getProd(int $page = 1,int $pageSize = 10){ public function getProd(int $page = 1,int $pageSize = 10): mixed
{
$option = [ $option = [
"json" => array( "json" => array(
"page" => $page, "page" => $page,
@ -93,12 +101,20 @@ class Prescription
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/drug/syncDrugCatalogue', $option); $response = $this->httpRequest($this->api_url . $this->version . '/drug/syncDrugCatalogue', $option);
if (empty($response['result'])){ if (empty($response['data'])){
// 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
if (empty($response['data']['result'])){
// 返回值为空 // 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
return $response['result']; return $response['data']['result'];
} catch (GuzzleException $e) { } catch (GuzzleException $e) {
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
@ -113,18 +129,22 @@ class Prescription
{ {
$option = [ $option = [
"json" => array( "json" => array(
"pharmacyCode" => "JG-10009", "pharmacyCode" => "ZD-10003",
"drugCode" => $product_platform_code, "drugCode" => $product_platform_code,
), ),
]; ];
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/pharmacyInventory', $option); $response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/pharmacyInventory', $option);
if (empty($response)){ if (empty($response['data'])){
// 返回值为空 // 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
return $response;
return $response['data'];
} catch (GuzzleException $e) { } catch (GuzzleException $e) {
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
@ -144,12 +164,15 @@ class Prescription
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/transportationExpenses', $option); $response = $this->httpRequest($this->api_url . $this->version . '/pharmacy/transportationExpenses', $option);
if (empty($response)){ if (empty($response['data'])){
// 返回值为空 // 返回值为空
if (!empty($response['message'])){
throw new BusinessException($response['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
return $response; return $response['data'];
} catch (GuzzleException $e) { } catch (GuzzleException $e) {
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
@ -169,7 +192,7 @@ class Prescription
try { try {
$response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option); $response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option);
if (empty($response)){ if (empty($response)){
// 返回值为空 // 返回值错误为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
@ -210,6 +233,7 @@ class Prescription
} }
$response = $this->client->post($path, $arg); $response = $this->client->post($path, $arg);
if ($response->getStatusCode() != '200'){ if ($response->getStatusCode() != '200'){
// 请求失败 // 请求失败
throw new BusinessException($response->getBody()->getContents()); throw new BusinessException($response->getBody()->getContents());
@ -221,14 +245,6 @@ class Prescription
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
} }
if (empty($body['data'])){ return $body;
// 返回值为空
if (!empty($body['message'])){
throw new BusinessException($body['message']);
}
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
}
return $body['data'];
} }
} }