From b0ce8876dfd8e834656721191fdbb2949db02cb7 Mon Sep 17 00:00:00 2001 From: terrfly Date: Tue, 30 Apr 2024 13:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=A7=A3=E5=86=B3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=AE=A2=E5=8D=95=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payorder/AbstractPayOrderController.java | 17 ++++--------- .../pay/service/PayOrderProcessService.java | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/AbstractPayOrderController.java b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/AbstractPayOrderController.java index 5fcd340..da78523 100644 --- a/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/AbstractPayOrderController.java +++ b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/AbstractPayOrderController.java @@ -26,7 +26,10 @@ import com.jeequan.jeepay.core.entity.PayOrder; import com.jeequan.jeepay.core.exception.BizException; import com.jeequan.jeepay.core.model.ApiRes; import com.jeequan.jeepay.core.model.DBApplicationConfig; -import com.jeequan.jeepay.core.utils.*; +import com.jeequan.jeepay.core.utils.AmountUtil; +import com.jeequan.jeepay.core.utils.SeqKit; +import com.jeequan.jeepay.core.utils.SpringBeansUtil; +import com.jeequan.jeepay.core.utils.StringKit; import com.jeequan.jeepay.pay.channel.IPaymentService; import com.jeequan.jeepay.pay.ctrl.ApiController; import com.jeequan.jeepay.pay.exception.ChannelException; @@ -372,18 +375,8 @@ public abstract class AbstractPayOrderController extends ApiController { payOrder.setChannelUser(channelRetMsg.getChannelUserId()); } + payOrderProcessService.updateIngAndSuccessOrFailByCreatebyOrder(payOrder, channelRetMsg); - - boolean isSuccess = payOrderService.updateInit2Ing(payOrder.getPayOrderId(), payOrder); - if(!isSuccess){ - throw new BizException("更新订单异常!"); - } - - isSuccess = payOrderService.updateIng2SuccessOrFail(payOrder.getPayOrderId(), payOrder.getState(), - channelRetMsg.getChannelOrderId(), channelRetMsg.getChannelUserId(), channelRetMsg.getChannelErrCode(), channelRetMsg.getChannelErrMsg()); - if(!isSuccess){ - throw new BizException("更新订单异常!"); - } } diff --git a/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayOrderProcessService.java b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayOrderProcessService.java index c5defb0..7bf994f 100644 --- a/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayOrderProcessService.java +++ b/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayOrderProcessService.java @@ -20,10 +20,13 @@ import com.jeequan.jeepay.components.mq.model.PayOrderDivisionMQ; import com.jeequan.jeepay.components.mq.vender.IMQSender; import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.entity.PayOrder; +import com.jeequan.jeepay.core.exception.BizException; +import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg; import com.jeequan.jeepay.service.impl.PayOrderService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /*** * 订单处理通用逻辑 @@ -88,4 +91,25 @@ public class PayOrderProcessService { } + /*** + * + * 支付中 --》 支付成功或者失败 + * **/ + @Transactional + public void updateIngAndSuccessOrFailByCreatebyOrder(PayOrder payOrder, ChannelRetMsg channelRetMsg){ + + boolean isSuccess = payOrderService.updateInit2Ing(payOrder.getPayOrderId(), payOrder); + if(!isSuccess){ + log.error("updateInit2Ing更新异常 payOrderId={}", payOrder.getPayOrderId()); + throw new BizException("更新订单异常!"); + } + + isSuccess = payOrderService.updateIng2SuccessOrFail(payOrder.getPayOrderId(), payOrder.getState(), + channelRetMsg.getChannelOrderId(), channelRetMsg.getChannelUserId(), channelRetMsg.getChannelErrCode(), channelRetMsg.getChannelErrMsg()); + if(!isSuccess){ + log.error("updateIng2SuccessOrFail更新异常 payOrderId={}", payOrder.getPayOrderId()); + throw new BizException("更新订单异常!"); + } + } + }