diff --git a/app/Amqp/Consumer/CouponExpiredDelayDirectConsumer.php b/app/Amqp/Consumer/CouponExpiredDelayDirectConsumer.php new file mode 100644 index 0000000..9f48ba7 --- /dev/null +++ b/app/Amqp/Consumer/CouponExpiredDelayDirectConsumer.php @@ -0,0 +1,50 @@ +error("开始执行 取消过期优惠卷 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE)); + + Db::beginTransaction(); + try { + + Db::commit(); + Log::getInstance()->info("取消过期优惠卷 队列执行成功"); + return Result::ACK; + } catch (\Exception $e) { + Db::rollBack(); + Log::getInstance()->error("取消过期优惠卷 队列执行失败:" . $e->getMessage()); + return Result::ACK; // 重回队列 + } + } +} diff --git a/app/Amqp/Producer/CouponExpiredDelayDirectProducer.php b/app/Amqp/Producer/CouponExpiredDelayDirectProducer.php new file mode 100644 index 0000000..ad0ab0d --- /dev/null +++ b/app/Amqp/Producer/CouponExpiredDelayDirectProducer.php @@ -0,0 +1,30 @@ +payload = $data; + } +} diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index c9eb596..1e62318 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -339,9 +339,6 @@ class CallBackController extends AbstractController Log::getInstance()->info("药品微信支付回调数据处理失败,缺少外部订单号"); return $server->serve(); } - - - }catch (\Exception $e) { // 验证失败 Log::getInstance()->error("药品微信支付回调数据处理失败:" . $e->getMessage()); diff --git a/app/Controller/InquiryController.php b/app/Controller/InquiryController.php index 5a32e21..8966893 100644 --- a/app/Controller/InquiryController.php +++ b/app/Controller/InquiryController.php @@ -107,4 +107,14 @@ class InquiryController extends AbstractController return $this->response->json($data); } + /** + * 结束问诊会话列表 + * @return ResponseInterface + */ + public function getDoctorFinishMessageList(): ResponseInterface + { + $InquiryService = new InquiryService(); + $data = $InquiryService->getDoctorFinishMessageList(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/MessageIm.php b/app/Model/MessageIm.php index 3a07980..9c24d68 100644 --- a/app/Model/MessageIm.php +++ b/app/Model/MessageIm.php @@ -83,4 +83,15 @@ class MessageIm extends Model { return self::create($data); } + + /* + * 获取信息-最后一条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getLastOne(array $params, array $fields = ['*']): object|null + { + return self::where($params)->latest("created_at")->first($fields); + } } diff --git a/app/Model/OrderInquiry.php b/app/Model/OrderInquiry.php index 23155fe..dd0ca8c 100644 --- a/app/Model/OrderInquiry.php +++ b/app/Model/OrderInquiry.php @@ -338,4 +338,30 @@ class OrderInquiry extends Model return self::where($params)->whereIn("inquiry_status",$inquiry_status_params)->count(); } + /** + * 获取某种状态的所有订单 + * @param array $params + * @param array $inquiry_status_params + * @param array $fields + * @param int|null $page + * @param int|null $per_page + * @return array + */ + public static function getInquiryStatusWithDoctorPage(array $params, array $inquiry_status_params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array + { + $raw = self::where($params) + ->whereIn('inquiry_status',$inquiry_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; + } + } diff --git a/app/Services/ImService.php b/app/Services/ImService.php index 9b561e2..ddf353b 100644 --- a/app/Services/ImService.php +++ b/app/Services/ImService.php @@ -243,7 +243,7 @@ class ImService extends BaseService $arg['From_Account'] = $from_user_id; // 发送方user_id 如系统发送,无需填写 } $arg['To_Account'] = $to_user_id; // 接收方user_id - $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback', "ForbidAfterSendMsgCallback"]; + $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback']; $arg['SendMsgControl'] = []; $arg['MsgBody'] = [ diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index fe09465..78b8a04 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -12,6 +12,7 @@ use App\Model\DiseaseClass; use App\Model\DoctorInquiryConfig; use App\Model\Hospital; use App\Model\InquiryCaseProduct; +use App\Model\MessageIm; use App\Model\OrderEvaluation; use App\Model\OrderInquiry; use App\Model\OrderInquiryCase; @@ -718,6 +719,57 @@ class InquiryService extends BaseService return success($result); } + /** + * 结束问诊会话列表 + * @return array + */ + public function getDoctorFinishMessageList(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $page = $this->request->input('page', 1); + $per_page = $this->request->input('per_page', 10); + + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + + $inquiry_status_params = ["5","6"]; + + $fields = [ + 'order_inquiry_id', + 'user_id', + 'patient_id', + 'doctor_id', + 'family_id', + 'inquiry_type', + 'inquiry_mode', + 'inquiry_status', + 'inquiry_no', + 'reception_time', + 'complete_time', + 'finish_time', + 'cancel_time', + 'cancel_reason', + 'cancel_remarks', + 'patient_name', + 'patient_sex', + 'patient_age', + 'created_at', + ]; + + $result = OrderInquiry::getInquiryStatusWithDoctorPage($params,$inquiry_status_params,$fields,$page,$per_page); + + if (!empty($result['data'])){ + foreach ($result['data'] as &$item){ + $params = array(); + $params['message_send_result'] = 1; + $params['order_inquiry_id'] = $item['order_inquiry_id']; + $item['message_im'] = MessageIm::getOne($params); + } + } + return success($result); + } + /** * 获取医生未接诊订单数量 * @param string $doctor_id 医生id diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index fedec4a..0ac2db3 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -284,15 +284,21 @@ class PatientOrderService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "订单无法取消"); } - if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) { + if ($order_inquiry['inquiry_refund_status'] == 1) { // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) - return fail(HttpEnumCode::HTTP_ERROR, "订单正在退款中"); + return fail(HttpEnumCode::HTTP_ERROR, "订单申请退款中,请您稍后取消"); + } + + if ($order_inquiry['inquiry_refund_status'] == 2) { + // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) + return fail(HttpEnumCode::HTTP_ERROR, "订单正在退款中,请您稍后取消"); } // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) Db::beginTransaction(); try { + // 退款成功 // 修改问诊订单为取消 $data = array(); $data['inquiry_status'] = 7; @@ -305,7 +311,7 @@ class PatientOrderService extends BaseService OrderInquiry::edit($params, $data); // 检测支付状态,判断是否需要退款处理 - if ($order_inquiry['inquiry_pay_status'] == 2) { + if ($order_inquiry['inquiry_pay_status'] == 2 && $order_inquiry['inquiry_refund_status'] != 3) { // 需退款 $inquiryService = new InquiryService(); $inquiryService->inquiryRefund($order_inquiry['order_inquiry_id'], "取消问诊"); diff --git a/config/routes.php b/config/routes.php index e3d0e03..207ec4e 100644 --- a/config/routes.php +++ b/config/routes.php @@ -90,6 +90,9 @@ Router::addGroup('/doctor', function () { // 结束问诊 Router::put('/finish/{order_inquiry_id:\d+}', [UserDoctorController::class, 'putDoctorFinishInquiry']); + + // 结束问诊会话列表 + Router::get('/finish/message', [InquiryController::class, 'getDoctorFinishMessageList']); }); //银行卡