From 4aec3a2467626f406e9e240e5b5cd755e3ed7bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=AA=E5=AF=92?= <2533659732@qq.com> Date: Thu, 16 Nov 2023 16:53:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=97=AE=E9=A2=98=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WeChatPayNotifyServiceImpl.java | 11 ++++ .../impl/WeChatRefundServiceImpl.java | 59 +++++++++---------- .../impl/RefundInfoTaskServiceImpl.java | 2 +- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java index 8c61dfd..357bef3 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java @@ -399,6 +399,17 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService { log.info("微信退款通知,记录商品订单微信退款单信息失败,订单编号 =====> {}", refundNotifyVO.getOutTradeNo()); } } + //处理专家咨询订单-医生拒单退款信息 + if (RefundStatusEnum.SUCCESS.getInfo().equals(refundNotifyVO.getRefundStatus()) + && StringUtils.isNotBlank(detailsOrderInfo.getOrderStatus()) + && GooodsOrderStatusEnum.REFUNDED.getInfo().equals(detailsOrderInfo.getOrderStatus()) + && OrderTypeEnum.HEALTH_CONSULTATION.getInfo().equals(detailsOrderInfo.getOrderType())) { + RefundInfo refundInfo = buildRefundInfo(plainText, refundNotifyVO); + int refundCount = refundInfoMapper.updateRefundInfoByNo(refundInfo); + if (refundCount < 1) { + log.info("微信退款通知,记录专家咨询订单微信退款单信息失败,订单编号 =====> {}", refundNotifyVO.getOutTradeNo()); + } + } if (RefundStatusEnum.CLOSED.getInfo().equals(refundNotifyVO.getRefundStatus())) { log.info("当前商品退款单已经关闭,订单号 ====> {}, 退款单号 =====> {}", refundNotifyVO.getOutTradeNo(), refundNotifyVO.getOutRefundNo()); } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java index 4f1fe04..05c5244 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java @@ -10,14 +10,7 @@ import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatRefundInfoVO; import com.xinelu.common.config.WeChatPaymentUrlConfig; import com.xinelu.common.config.XylWeChatPaymentConfig; import com.xinelu.common.core.domain.AjaxResult; -import com.xinelu.common.enums.ConfirmRefundStatusEnum; -import com.xinelu.common.enums.GooodsOrderStatusEnum; -import com.xinelu.common.enums.IntegralChangeType; -import com.xinelu.common.enums.OrderStatusEnum; -import com.xinelu.common.enums.OrderTypeEnum; -import com.xinelu.common.enums.PaymentMerchantTypeEnum; -import com.xinelu.common.enums.RefundStatusEnum; -import com.xinelu.common.enums.RefundTypeEnum; +import com.xinelu.common.enums.*; import com.xinelu.common.exception.ServiceException; import com.xinelu.manage.domain.appointmentorder.AppointmentOrder; import com.xinelu.manage.domain.goodsOrder.GoodsOrder; @@ -34,13 +27,6 @@ import com.xinelu.manage.service.consultationInfo.IConsultationInfoService; import com.xinelu.manage.service.scheduleplandetail.ISchedulePlanDetailService; import com.xinelu.manage.vo.goodsorder.GoodsInfoRedemptionVO; import com.xinelu.manage.vo.patientinfo.PatientInfoVO; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.methods.CloseableHttpResponse; @@ -52,6 +38,14 @@ import org.apache.http.util.EntityUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + /** * @Description 微信退款业务层实现类 * @Author 纪寒 @@ -80,10 +74,10 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { private PatientIntegralChangeMapper patientIntegralChangeMapper; @Resource private PatientInfoMapper patientInfoMapper; - @Resource - private IConsultationInfoService consultationInfoService; - @Resource - private ISchedulePlanDetailService planDetailService; + @Resource + private IConsultationInfoService consultationInfoService; + @Resource + private ISchedulePlanDetailService planDetailService; /** * 成功状态码 @@ -245,24 +239,25 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { if (Objects.isNull(goodsOrderInfo.getTotalPrice()) || goodsOrderInfo.getTotalPrice().compareTo(BigDecimal.ZERO) <= 0) { return AjaxResult.error("当前订单金额异常,无法拒单!"); } + //直接将订单状态修改为已退款,因为微信支付回调有延迟导致医生APP端拒单以后订单状态无法及时刷新 + goodsOrderMapper.updateGoodsOrderStatus(OrderStatusEnum.REFUNDED.getInfo(), closeOrderDTO.getOrderNo()); Long patientId = Objects.isNull(goodsOrderInfo.getPatientId()) ? 0 : goodsOrderInfo.getPatientId(); String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime(); String refundParam = this.buildHealthConsultationRefundParam(goodsOrderInfo, outRefundNo); String refundReason = StringUtils.isBlank(closeOrderDTO.getRemark()) ? "" : closeOrderDTO.getRemark(); this.applyWeRefund(refundParam, null, goodsOrderInfo, patientId, refundReason); - // 查询是否为专家咨询订单,修改时间段的可预约状态 - GoodsOrder goodsOrder = goodsOrderMapper.getGoodsOrderByOrderNo(closeOrderDTO.getOrderNo()); - if (goodsOrder.getConsultationInfoId() != null) { - ConsultationInfoDTO consultationInfo = consultationInfoService.selectConsultationInfoById(goodsOrder.getConsultationInfoId()); - if (consultationInfo != null && consultationInfo.getSchedulePlanDetailId() != null) { - // 修改预约时间段的状态 - SchedulePlanDetail schedulePlanDetail = new SchedulePlanDetail(); - schedulePlanDetail.setId(consultationInfo.getSchedulePlanDetailId()); - schedulePlanDetail.setApplyState("0"); - planDetailService.update(schedulePlanDetail); - } - } - return AjaxResult.success(); + // 查询是否为专家咨询订单,修改时间段的可预约状态 + if (goodsOrderInfo.getConsultationInfoId() != null) { + ConsultationInfoDTO consultationInfo = consultationInfoService.selectConsultationInfoById(goodsOrderInfo.getConsultationInfoId()); + if (consultationInfo != null && consultationInfo.getSchedulePlanDetailId() != null) { + // 修改预约时间段的状态 + SchedulePlanDetail schedulePlanDetail = new SchedulePlanDetail(); + schedulePlanDetail.setId(consultationInfo.getSchedulePlanDetailId()); + schedulePlanDetail.setApplyState("0"); + planDetailService.update(schedulePlanDetail); + } + } + return AjaxResult.success(); } /** diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java index b822ce4..07c2c2b 100644 --- a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java @@ -98,7 +98,7 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService { */ @Override public void automaticProcessHealthConsultationRefund() { - List refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.WAIT_RECEIVED_GOODS.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo()); + List refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.REFUNDED.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo()); if (CollectionUtils.isEmpty(refundGoodsOrderLit)) { return; }