diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index 58a08f4..b7aa90b 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -175,15 +175,10 @@ class CallBackController extends AbstractController $message_content_data = array(); $message_content_data['message_type'] = 1; $message_content_data['title'] = "--等待医生接诊--"; - $message_content_data['desc'] = ""; if ($order_inquiry['inquiry_type'] == 1){ $message_content_data['desc'] = "温馨提示:当前服务为专家问诊,可以在24小时内和医生沟通20个回合。医生均为一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; - } elseif ($order_inquiry['inquiry_type'] == 2){ - $message_content_data['desc'] = "温馨提示:您可继续补充问诊内容,便于更快确认病情,医生均在临床一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; - } elseif ($order_inquiry['inquiry_type'] == 3){ - $message_content_data['desc'] = "温馨提示:当前服务为公益问诊,可以在24小时内和医生沟通10个回合。医生均为一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; - } elseif ($order_inquiry['inquiry_type'] == 4){ + }else{ $message_content_data['desc'] = "温馨提示:当前服务为公益问诊,可以在24小时内和医生沟通10个回合。医生均为一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; } diff --git a/app/Services/ImService.php b/app/Services/ImService.php index 701951d..7ac505a 100644 --- a/app/Services/ImService.php +++ b/app/Services/ImService.php @@ -234,46 +234,45 @@ class ImService extends BaseService * @param string $message_type 消息类型 具体查看(https://cloud.tencent.com/document/product/269/2720) * @param array $cloud_custom_data 自定义字段 * @return void - * @throws GuzzleException */ public function sendMessage(string $from_user_id, string $to_user_id, array $message_content, string $message_type, array $cloud_custom_data): void { - if (!empty($from_user_id)){ - // 检测并创建发送者资料 - $this->setUserProfile($from_user_id); + try { + if (!empty($from_user_id)){ + // 检测并创建发送者资料 + $this->setUserProfile($from_user_id); + } + + // 检测并创建接收者资料 + $this->setUserProfile($to_user_id); + + $message = new Message(); + + $arg = array(); + if (!empty($from_user_id)){ + $arg['From_Account'] = $from_user_id; // 发送方user_id 如系统发送,无需填写 + } + $arg['To_Account'] = $to_user_id; // 接收方user_id + $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback',"ForbidAfterSendMsgCallback"]; + $arg['SendMsgControl'] = ['NoUnread']; + + $arg['MsgBody'] = [ + [ + "MsgType" => $message_type, + "MsgContent" => $message_content, + ] + ]; + + $arg['CloudCustomData'] = ""; + if (!empty($cloud_custom_data)){ + $arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE); + } + + $message->sendMessage($arg); + }catch (\Exception $e){ + throw new BusinessException($e->getMessage()); + } catch (GuzzleException $e) { + throw new BusinessException($e->getMessage()); } - - // 检测并创建接收者资料 - $this->setUserProfile($to_user_id); - - $message = new Message(); - - $arg = array(); - if (!empty($from_user_id)){ - $arg['From_Account'] = $from_user_id; // 发送方user_id 如系统发送,无需填写 - } - $arg['To_Account'] = $to_user_id; // 接收方user_id - $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback',"ForbidAfterSendMsgCallback"]; - $arg['SendMsgControl'] = ['NoUnread']; - - $arg['MsgBody'] = [ - [ - "MsgType" => $message_type, - "MsgContent" => $message_content, - ] - ]; - - // 自定义消息 -// $cloud_custom_data = array(); -// $cloud_custom_data['order_inquiry_id'] = $order_inquiry_id; -// $cloud_custom_data['is_system'] = 1; -// $cloud_custom_data['inquiry_type'] = $inquiry_type; - - $arg['CloudCustomData'] = ""; - if (!empty($cloud_custom_data)){ - $arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE); - } - - $message->sendMessage($arg); } } \ No newline at end of file diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 9166a99..292be17 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -31,6 +31,7 @@ use App\Utils\Log; use App\Utils\Mask; use App\Utils\PcreMatch; use Extend\Wechat\WechatPay; +use GuzzleHttp\Exception\GuzzleException; use Hyperf\Amqp\Producer; use Hyperf\DbConnection\Db; use Hyperf\Redis\Redis; @@ -777,7 +778,7 @@ class InquiryService extends BaseService * @param string $order_inquiry_id * @param string $refund_reason 退款原因 * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface + * @throws NotFoundExceptionInterface|GuzzleException */ public function inquiryRefund(string $order_inquiry_id, string $refund_reason) { diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index caf5f9a..27e553d 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -25,7 +25,7 @@ class OrderPrescriptionService extends BaseService } /** - * 获取药师待审核处方-分页-存在问题,需修改 + * 获取药师待审核处方-分页 * @param string $pharmacist_id 药师id * @param int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回) * @param int $platform_audit_status diff --git a/app/Services/UserPharmacistService.php b/app/Services/UserPharmacistService.php index edc201b..485d918 100644 --- a/app/Services/UserPharmacistService.php +++ b/app/Services/UserPharmacistService.php @@ -3,7 +3,9 @@ namespace App\Services; use App\Constants\HttpEnumCode; +use App\Model\OrderInquiry; use App\Model\OrderPrescription; +use App\Model\OrderPrescriptionProduct; use App\Model\User; use App\Model\UserPharmacist; use App\Model\UserPharmacistInfo; @@ -158,11 +160,72 @@ class UserPharmacistService extends BaseService return fail(HttpEnumCode::HTTP_ERROR,"处方已审核,请勿重复审核"); } + // 获取处方订单数据 + $params = array(); + $params['order_inquiry_id'] = $order_prescription['order_inquiry_id']; + $order_inquiry = OrderInquiry::getOne($params); + if (empty($order_inquiry)){ + return fail(HttpEnumCode::SERVER_ERROR,"问诊订单数据为空"); + } + + // 获取处方商品数据 + $params = array(); + $params['order_prescription_id'] = $order_prescription['order_prescription_id']; + $order_prescription_product = OrderPrescriptionProduct::getList($params); + if (!empty($order_prescription_product)){ + $product_name = array_column($order_prescription_product->toArray(),'product_name'); + if (!empty($product_name)){ + $product_name = implode('、',$product_name); + } + } + Db::beginTransaction(); try { // 修改处方审核状态 $data = array(); + if ($pharmacist_audit_status == 1){ + // 审核成功 + $data['prescription_status'] = 3; + $data['pharmacist_audit_status'] = 1; + }else{ + $data['pharmacist_audit_status'] = 2; + $data['pharmacist_fail_reason'] = $pharmacist_fail_reason; + } + $data['pharmacist_verify_time'] = date('Y-m-d H:i:s',time()); + + $params = array(); + $params['order_prescription_id'] = $order_prescription_id; + + OrderPrescription::edit($params,$data); + + // 发送消息 + $ImService = new ImService(); + + // 发送消息 + $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'] = $order_inquiry['order_inquiry_id']; + $message_content_data['data']['order_prescription_id'] = $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_info['user_id'], $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data); Db::commit(); } catch (\Exception $e) { @@ -170,12 +233,6 @@ class UserPharmacistService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); } - // 新增商品订单表 - // 新增商品订单明细表 - // 新增未支付取消订单队列 - - - return success($order_prescription->toArray()); }