From fd7b8fb7c89832c28a838b0449bbb8a392433ee2 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期二, 22 四月 2025 14:33:02 +0800
Subject: [PATCH] 将华为云短信替换成阿里云短信

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java |   69 ++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
index 52e263b..49e2728 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -456,19 +456,6 @@
         if (200 == r.getCode()) {
             this.updateById(order);
         }
-
-        R r1 = balanceChangeRecordClient.deleteBalanceChangeRecordCopy(orderId, Arrays.asList(4));
-        if (200 != r1.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致
-         throw new RuntimeException("订单取消失败");
-        }
-        R r2 = userPointClient.deleteUserPointCopy(orderId, Arrays.asList(2,8,9,10,14));
-        if (200 != r2.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致
-            throw new RuntimeException("订单取消失败");
-        }
-        R<Boolean> r3 = shopBalanceStatementClient.deleteShopBalanceStatementCopy(orderId, Arrays.asList(1,2,3));
-        if (200 != r3.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致
-            throw new RuntimeException("订单取消失败");
-        }
         return r;
     }
 
@@ -508,7 +495,7 @@
         //开始退款
         Integer payMethod = order.getPayMethod();
         BigDecimal expressAmount = order.getExpressAmount() == null ? BigDecimal.ZERO : order.getExpressAmount();
-        BigDecimal paymentAmount = order.getPaymentAmount().add(expressAmount);
+        BigDecimal paymentAmount = order.getPaymentAmount();
         AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
         if (1 == payMethod) {
             //微信退款
@@ -587,11 +574,6 @@
                 userPointClient.saveUserPoint(userPoint);
             }
             appUserClient.editAppUserById(appUser);
-
-            //降级检测
-            if (1 < appUser.getVipId() && appUser.getVipId() < 4) {
-                appUserClient.vipDemotion(appUser.getId());
-            }
             //回退优惠券状态
             if (null != order.getUserCouponId()) {
                 UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData();
@@ -699,6 +681,11 @@
         //删除用户和门店添加的汇总数据(冻结数据)
         appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId());
         shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId());
+    
+        //降级检测
+        if (1 < appUser.getVipId() && appUser.getVipId() < 4) {
+            appUserClient.vipDemotion(appUser.getId());
+        }
         return R.ok();
     }
 
@@ -754,16 +741,49 @@
         }
         appUserClient.editAppUserById(appUser);
 
-        //降级检测
-        if (1 < appUser.getVipId() && appUser.getVipId() < 4) {
-            appUserClient.vipDemotion(appUser.getId());
-        }
-
         //回退优惠券状态
         if (null != order.getUserCouponId()) {
             UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData();
             userCoupon.setUseTime(null);
             userCouponClient.editReturnUse(userCoupon);
+        }
+    
+        //生成反向冻结流水数据
+        List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData();
+        for (UserPointCopy userPointCopy : data2) {
+            userPointCopy.setId(null);
+            userPointCopy.setCreateTime(LocalDateTime.now());
+            userPointCopy.setChangeDirection(-1);
+            userPointClient.saveUserPointCopy(userPointCopy);
+        }
+        List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData();
+        for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) {
+            balanceChangeRecordCopy.setId(null);
+            balanceChangeRecordCopy.setCreateTime(LocalDateTime.now());
+            balanceChangeRecordCopy.setChangeDirection(-1);
+            balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy);
+        }
+        List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData();
+        for (ShopPointCopy datum : data) {
+            datum.setId(null);
+            datum.setCreateTime(LocalDateTime.now());
+            datum.setChangeDirection(-1);
+            shopPointClient.saveShopPointCopy(datum);
+        }
+        List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData();
+        for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) {
+            shopBalanceStatementCopy.setId(null);
+            shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
+            shopBalanceStatementCopy.setChangeDirection(-1);
+            shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
+        }
+        //删除用户和门店添加的汇总数据(冻结数据)
+        appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId());
+        shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId());
+        
+        //降级检测
+        if (1 < appUser.getVipId() && appUser.getVipId() < 4) {
+            appUserClient.vipDemotion(appUser.getId());
         }
         return R.ok();
     }
@@ -843,7 +863,6 @@
         Long days = jsonObject.getLong("days");
         order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
         this.updateById(order);
-        commissionService.calculationCommissionShop(order.getId());
         return R.ok();
     }
 

--
Gitblit v1.7.1