From 670a35c9a14679376144d73e01d0bd604ed787a4 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Wed, 26 Mar 2025 19:58:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=99=E9=A2=9D=E6=94=AF=E4=BB=98,=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E6=B6=88=E8=B4=B9=E9=87=91=E9=A2=9D=20-=20?= =?UTF-8?q?=E6=8A=98=E6=89=A3=E9=87=91=E9=A2=9D=20+=20=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E9=87=91=E9=A2=9D=20=3D=20=E6=94=AF=E4=BB=98=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jsowell/service/TempService.java | 34 +++++++++++++++++++ .../impl/OrderBasicInfoServiceImpl.java | 8 +++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java index ca8b1ee25..f1f1c1200 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java @@ -16,6 +16,7 @@ import com.jsowell.adapay.service.AdapayService; import com.jsowell.adapay.vo.OrderSplitResult; import com.jsowell.adapay.vo.PaymentInfo; import com.jsowell.common.annotation.CostTime; +import com.jsowell.common.constant.RabbitConstants; import com.jsowell.common.core.domain.ykc.TransactionRecordsData; import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.adapay.AdapayStatusEnum; @@ -24,6 +25,7 @@ import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.*; +import com.jsowell.pile.dto.AfterSettleOrderDTO; import com.jsowell.pile.dto.ApplyRefundDTO; import com.jsowell.pile.dto.QueryOrderDTO; import com.jsowell.pile.dto.SettleOrderReportDTO; @@ -32,10 +34,13 @@ import com.jsowell.pile.mapper.PileMsgRecordMapper; import com.jsowell.pile.service.*; import com.jsowell.pile.service.programlogic.AbstractProgramLogic; import com.jsowell.pile.service.programlogic.ProgramLogicFactory; +import com.jsowell.pile.transaction.dto.OrderTransactionDTO; +import com.jsowell.pile.transaction.service.TransactionService; import com.jsowell.pile.vo.web.*; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -69,6 +74,12 @@ public class TempService { @Autowired private AdapayCallbackRecordService adapayCallbackRecordService; + @Autowired + protected TransactionService transactionService; + + @Autowired + protected RabbitTemplate rabbitTemplate; + @Autowired protected MemberGroupService memberGroupService; @@ -901,6 +912,29 @@ public class TempService { logger.info("testSettleOrderLogic, orderCode:{}, 支付金额:{}, 消费金额:{}, 折扣金额:{}, 退款金额:{}, 结算金额:{}", orderBasicInfo.getOrderCode(), orderBasicInfo.getPayAmount(), orderBasicInfo.getOrderAmount(), orderBasicInfo.getDiscountAmount(), orderBasicInfo.getRefundAmount(), orderBasicInfo.getSettleAmount()); + + // 更新数据库 + OrderTransactionDTO dto = new OrderTransactionDTO(); + dto.setOrderBasicInfo(orderBasicInfo); + dto.setOrderDetail(orderDetail); + transactionService.doUpdateOrder(dto); + + // 组装after参数 + AfterSettleOrderDTO afterSettleOrderDTO = AfterSettleOrderDTO.builder() + .orderCode(orderBasicInfo.getOrderCode()) + .merchantId(orderBasicInfo.getMerchantId()) + .stationId(orderBasicInfo.getStationId()) + .orderPayAmount(orderBasicInfo.getPayAmount()) // 支付金额 + .orderConsumeAmount(orderBasicInfo.getOrderAmount()) // 消费金额 + .orderSettleAmount(orderBasicInfo.getSettleAmount()) // 结算金额 + .orderElectricityAmount(orderDetail.getTotalElectricityAmount()) // 电费金额 + .orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount()) // 电费折扣金额 + .orderServiceAmount(orderDetail.getTotalServiceAmount()) // 服务费金额 + .orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount()) // 服务费折扣金额 + .orderRefundAmount(orderBasicInfo.getRefundAmount()) // 退款金额 + .build(); + rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO); } + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index ea94bcac4..d97d81857 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -1911,10 +1911,12 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { return null; } - // 如果是余额支付, 校验消费金额+ 退款金额 = 支付金额 + // 如果是余额支付, 校验消费金额 - 折扣金额 + 退款金额 = 支付金额 if (StringUtils.equals(orderBasicInfo.getPayMode(), "1")) { - if (orderConsumeAmount.add(orderRefundAmount).compareTo(orderPayAmount) != 0) { - logger.info("realTimeOrderSplit-订单:{}, payMode:{}, 支付金额与消费金额+退款金额不相等", afterSettleOrderDTO.getOrderCode(), orderBasicInfo.getPayMode()); + // 订单折扣金额 = 电费折扣金额 + 服务费折扣金额 + BigDecimal orderDiscountAmount = afterSettleOrderDTO.getOrderElectricityDiscountAmount().add(afterSettleOrderDTO.getOrderServiceDiscountAmount()); + if (orderConsumeAmount.subtract(orderDiscountAmount).add(orderRefundAmount).compareTo(orderPayAmount) != 0) { + logger.info("realTimeOrderSplit-订单:{}, payMode:{}, 支付金额与消费金额-折扣金额+退款金额不相等", afterSettleOrderDTO.getOrderCode(), orderBasicInfo.getPayMode()); return null; } }