From 6d0b7fdb91450b9939a0ead1b421910e0c8fee70 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期日, 26 四月 2026 18:23:12 +0800
Subject: [PATCH] feat:管理后台用户管理、合作商管理、兑换码管理

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
index c077d08..71008e9 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -63,7 +63,9 @@
 import com.ruoyi.other.api.domain.*;
 import com.ruoyi.order.vo.ChargingOrderListInfoVO;
 import com.ruoyi.other.api.domain.TVip;
+import com.ruoyi.other.api.dto.ExchangeCodeConsumeDTO;
 import com.ruoyi.other.api.feignClient.*;
+import com.ruoyi.other.api.vo.ExchangeCodeConsumeResultVO;
 import com.ruoyi.payment.api.feignClient.AliPaymentClient;
 import com.ruoyi.payment.api.feignClient.H5AliPaymentClient;
 import com.ruoyi.payment.api.feignClient.WxPaymentClient;
@@ -201,6 +203,8 @@
 	
 	@Resource
 	private VipClient vipClient;
+	@Resource
+	private OtherClient otherClient;
 	
 	@Resource
 	private UserTagClient userTagClient;
@@ -2672,6 +2676,22 @@
                 }
                 chargingOrder.setCouponDiscountAmount(couponDiscount.setScale(2, RoundingMode.HALF_EVEN));
                 chargingOrder.setServiceCharge(serviceCharge_total.setScale(2, RoundingMode.HALF_EVEN));
+                BigDecimal exchangeCodeDeductAmount = BigDecimal.ZERO;
+                if (chargingOrder.getAppUserId() != null && payAmount.compareTo(BigDecimal.ZERO) > 0) {
+                    ExchangeCodeConsumeDTO exchangeCodeConsumeDTO = new ExchangeCodeConsumeDTO();
+                    exchangeCodeConsumeDTO.setUserId(chargingOrder.getAppUserId());
+                    exchangeCodeConsumeDTO.setOrderId(chargingOrder.getId());
+                    exchangeCodeConsumeDTO.setAmount(payAmount.setScale(2, RoundingMode.HALF_EVEN));
+                    R<ExchangeCodeConsumeResultVO> consumeResult = otherClient.consumeExchangeCodeBalance(exchangeCodeConsumeDTO);
+                    if (consumeResult != null && consumeResult.getData() != null
+                            && consumeResult.getData().getDeductedAmount() != null) {
+                        exchangeCodeDeductAmount = consumeResult.getData().getDeductedAmount();
+                    }
+                }
+                payAmount = payAmount.subtract(exchangeCodeDeductAmount);
+                if (payAmount.compareTo(BigDecimal.ZERO) < 0) {
+                    payAmount = BigDecimal.ZERO;
+                }
                 chargingOrder.setPaymentAmount(payAmount.setScale(2, RoundingMode.HALF_EVEN));
                 chargingOrder.setRefundAmount(refundAmount.setScale(2, RoundingMode.HALF_EVEN));
                 chargingOrder.setRefundStatus(1);

--
Gitblit v1.7.1