From cbf2486983b77a27af9968bbb362cb8d43789115 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 26 三月 2025 15:30:53 +0800
Subject: [PATCH] 修改统计bug和部分功能修改

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java |   56 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
index b08938b..b03e17e 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
@@ -185,8 +185,11 @@
                     changeRecord.setId(null);
                     balanceChangeRecordClient.saveBalanceChangeRecord(changeRecord);
                 }
+                if(data2.size() > 0){
+                    List<Long> ids = data2.stream().map(BalanceChangeRecordCopy::getId).collect(Collectors.toList());
+                    balanceChangeRecordClient.deleteBalanceChangeRecordCopyByIds(ids);
+                }
             }
-            balanceChangeRecordClient.deleteBalanceChangeRecordCopy(order.getId(), Arrays.asList(4));
             
             List<UserPointCopy> data3 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2,8,9,10,14)).getData();
             if(null != data3){
@@ -196,8 +199,11 @@
                     userPoint.setId(null);
                     userPointClient.saveUserPoint(userPoint);
                 }
+                if(data3.size() > 0){
+                    List<Long> ids = data3.stream().map(UserPointCopy::getId).collect(Collectors.toList());
+                    userPointClient.deleteUserPointCopyByIds(ids);
+                }
             }
-            userPointClient.deleteUserPointCopy(order.getId(), Arrays.asList(2,8,9,10,14));
             
             
             List<ShopBalanceStatementCopy> data4 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)).getData();
@@ -208,8 +214,11 @@
                     shopBalanceStatement.setId(null);
                     shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement);
                 }
+                if(data4.size() > 0){
+                    List<Long> ids = data4.stream().map(ShopBalanceStatementCopy::getId).collect(Collectors.toList());
+                    shopBalanceStatementClient.deleteShopBalanceStatementCopyByIds(ids);
+                }
             }
-            shopBalanceStatementClient.deleteShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3));
             
             List<ShopPointCopy> data5 = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1,2,3)).getData();
             if(null != data5){
@@ -219,8 +228,11 @@
                     shopPoint.setId(null);
                     shopPointClient.saveShopPoint(shopPoint);
                 }
+                if(data5.size() > 0){
+                    List<Long> ids = data5.stream().map(ShopPointCopy::getId).collect(Collectors.toList());
+                    shopPointClient.deleteShopPointCopyByIds(ids);
+                }
             }
-            shopPointClient.deleteShopPointCopy(order.getId(), Arrays.asList(1,2,3));
             order.setIsCommission(3);
             orderService.updateById(order);
     
@@ -335,24 +347,22 @@
                 balanceChangeRecordCopy.setVipId(superiorLeader.getVipId());
                 balanceChangeRecordCopy.setOrderId(order.getId());
                 balanceChangeRecordCopy.setChangeType(4);
-                balanceChangeRecordCopy.setBeforeAmount(balance);
                 balanceChangeRecordCopy.setChangeAmount(zdls_price);
-                balanceChangeRecordCopy.setAfterAmount(superiorLeader.getBalance().add(zdls_price));
                 balanceChangeRecordCopy.setDelFlag(0);
                 balanceChangeRecordCopy.setCreateTime(LocalDateTime.now());
+                balanceChangeRecordCopy.setChangeDirection(1);
                 balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy);
             }
             //添加积分明细
             if(zdls_point > 0){
                 UserPointCopy userPointCopy = new UserPointCopy();
                 userPointCopy.setType(2);
-                userPointCopy.setHistoricalPoint(lavePoint);
                 userPointCopy.setVariablePoint(zdls_point);
-                userPointCopy.setBalance(superiorLeader.getLavePoint() + zdls_point);
                 userPointCopy.setCreateTime(LocalDateTime.now());
                 userPointCopy.setAppUserId(superiorLeader.getId());
                 userPointCopy.setObjectId(order.getId());
                 userPointCopy.setExtention(order.getOrderNumber());
+                userPointCopy.setChangeDirection(1);
                 userPointClient.saveUserPointCopy(userPointCopy);
                 //变更等级
 //                    appUserClient.vipUpgrade(superiorLeader.getId());
@@ -440,26 +450,24 @@
                     ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                     shopBalanceStatementCopy.setShopId(shop1.getId());
                     shopBalanceStatementCopy.setType(1);
-                    shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                     shopBalanceStatementCopy.setVariableAmount(fws_price);
-                    shopBalanceStatementCopy.setBalance(shop1.getBalance().add(fws_price));
                     shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                     shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                     shopBalanceStatementCopy.setObjectId(order.getId());
                     shopBalanceStatementCopy.setExtension(order.getOrderNumber());
+                    shopBalanceStatementCopy.setChangeDirection(1);
                     shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                 }
                 //添加积分明细
                 if(fws_point > 0){
                     UserPointCopy userPointCopy = new UserPointCopy();
                     userPointCopy.setType(9);
-                    userPointCopy.setHistoricalPoint(lavePoint);
                     userPointCopy.setVariablePoint(fws_point);
-                    userPointCopy.setBalance(bdShopAppUser.getLavePoint() + fws_point);
                     userPointCopy.setCreateTime(LocalDateTime.now());
                     userPointCopy.setAppUserId(bdShopAppUser.getId());
                     userPointCopy.setObjectId(order.getId());
                     userPointCopy.setExtention(order.getOrderNumber());
+                    userPointCopy.setChangeDirection(1);
                     userPointClient.saveUserPointCopy(userPointCopy);
                     //变更等级
 //                        appUserClient.vipUpgrade(bdShopAppUser.getId());
@@ -469,13 +477,12 @@
                     ShopPointCopy shopPointCopy = new ShopPointCopy();
                     shopPointCopy.setShopId(shop1.getId());
                     shopPointCopy.setType(2);
-                    shopPointCopy.setHistoricalPoint(shopLavePoint);
                     shopPointCopy.setVariablePoint(fws_point);
-                    shopPointCopy.setBalance(shop1.getLavePoint() + fws_point);
                     shopPointCopy.setCreateTime(LocalDateTime.now());
                     shopPointCopy.setCreateUserId(order.getAppUserId());
                     shopPointCopy.setObjectId(order.getId());
                     shopPointCopy.setOrderNum(order.getOrderNumber());
+                    shopPointCopy.setChangeDirection(1);
                     shopPointClient.saveShopPointCopy(shopPointCopy);
                 }
             }
@@ -566,26 +573,24 @@
                     ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                     shopBalanceStatementCopy.setShopId(shop2.getId());
                     shopBalanceStatementCopy.setType(2);
-                    shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                     shopBalanceStatementCopy.setVariableAmount(gjfws_price);
-                    shopBalanceStatementCopy.setBalance(shop2.getBalance().add(gjfws_price));
                     shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                     shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                     shopBalanceStatementCopy.setObjectId(order.getId());
                     shopBalanceStatementCopy.setExtension(order.getOrderNumber());
+                    shopBalanceStatementCopy.setChangeDirection(1);
                     shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                 }
                 //添加积分明细
                 if(gjfws_point > 0){
                     UserPointCopy userPointCopy = new UserPointCopy();
                     userPointCopy.setType(14);
-                    userPointCopy.setHistoricalPoint(lavePoint);
                     userPointCopy.setVariablePoint(gjfws_point);
-                    userPointCopy.setBalance(sjShopAppUser.getLavePoint() + gjfws_point);
                     userPointCopy.setCreateTime(LocalDateTime.now());
                     userPointCopy.setAppUserId(sjShopAppUser.getId());
                     userPointCopy.setObjectId(order.getId());
                     userPointCopy.setExtention(order.getOrderNumber());
+                    userPointCopy.setChangeDirection(1);
                     userPointClient.saveUserPointCopy(userPointCopy);
                     //变更等级
 //                        appUserClient.vipUpgrade(sjShopAppUser.getId());
@@ -595,13 +600,12 @@
                     ShopPointCopy shopPointCopy = new ShopPointCopy();
                     shopPointCopy.setShopId(shop2.getId());
                     shopPointCopy.setType(3);
-                    shopPointCopy.setHistoricalPoint(shopLavePoint);
                     shopPointCopy.setVariablePoint(gjfws_point);
-                    shopPointCopy.setBalance(shop2.getLavePoint() + gjfws_point);
                     shopPointCopy.setCreateTime(LocalDateTime.now());
                     shopPointCopy.setCreateUserId(order.getAppUserId());
                     shopPointCopy.setObjectId(order.getId());
                     shopPointCopy.setOrderNum(order.getOrderNumber());
+                    shopPointCopy.setChangeDirection(1);
                     shopPointClient.saveShopPointCopy(shopPointCopy);
                 }
             }
@@ -723,26 +727,24 @@
                 ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                 shopBalanceStatementCopy.setShopId(shop.getId());
                 shopBalanceStatementCopy.setType(3);
-                shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                 shopBalanceStatementCopy.setVariableAmount(hxmd_price);
-                shopBalanceStatementCopy.setBalance(shop.getBalance().add(hxmd_price));
                 shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                 shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                 shopBalanceStatementCopy.setObjectId(order.getId());
                 shopBalanceStatementCopy.setExtension(order.getOrderNumber());
+                shopBalanceStatementCopy.setChangeDirection(1);
                 shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
             }
             //添加积分明细
             if(hxmd_point > 0){
                 UserPointCopy userPointCopy = new UserPointCopy();
                 userPointCopy.setType(8);
-                userPointCopy.setHistoricalPoint(lavePoint);
                 userPointCopy.setVariablePoint(hxmd_point);
-                userPointCopy.setBalance(shopAppUser.getLavePoint() + hxmd_point);
                 userPointCopy.setCreateTime(LocalDateTime.now());
                 userPointCopy.setAppUserId(shopAppUser.getId());
                 userPointCopy.setObjectId(order.getId());
                 userPointCopy.setExtention(order.getOrderNumber());
+                userPointCopy.setChangeDirection(1);
                 userPointClient.saveUserPointCopy(userPointCopy);
                 //变更等级
 //                    appUserClient.vipUpgrade(shopAppUser.getId());
@@ -752,13 +754,12 @@
                 ShopPointCopy shopPointCopy = new ShopPointCopy();
                 shopPointCopy.setShopId(shop.getId());
                 shopPointCopy.setType(1);
-                shopPointCopy.setHistoricalPoint(shopLavePoint);
                 shopPointCopy.setVariablePoint(hxmd_point);
-                shopPointCopy.setBalance(shop.getLavePoint() + hxmd_point);
                 shopPointCopy.setCreateTime(LocalDateTime.now());
                 shopPointCopy.setCreateUserId(order.getAppUserId());
                 shopPointCopy.setObjectId(order.getId());
                 shopPointCopy.setOrderNum(order.getOrderNumber());
+                shopPointCopy.setChangeDirection(1);
                 shopPointClient.saveShopPointCopy(shopPointCopy);
             }
         }
@@ -809,13 +810,12 @@
                     if(js_point > 0){
                         UserPointCopy userPointCopy = new UserPointCopy();
                         userPointCopy.setType(10);
-                        userPointCopy.setHistoricalPoint(lavePoint);
                         userPointCopy.setVariablePoint(js_point);
-                        userPointCopy.setBalance(technicianAppUser.getLavePoint() + js_point);
                         userPointCopy.setCreateTime(LocalDateTime.now());
                         userPointCopy.setAppUserId(technicianAppUser.getId());
                         userPointCopy.setObjectId(order.getId());
                         userPointCopy.setExtention(order.getOrderNumber());
+                        userPointCopy.setChangeDirection(1);
                         userPointClient.saveUserPointCopy(userPointCopy);
                         //变更等级
 //                            appUserClient.vipUpgrade(technicianAppUser.getId());

--
Gitblit v1.7.1