From e7a4c604b4703caf135ec3d360106e7cf028cc89 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 27 三月 2025 00:45:08 +0800
Subject: [PATCH] 修改统计bug和部分功能修改

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java
index 8fb928f..83fee5f 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java
@@ -31,6 +31,7 @@
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.beans.BeanUtils;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
@@ -106,10 +107,8 @@
         R<SysUser> sysUserR = sysUserClient.getSysUser(userid);
         SysUser sysUser = sysUserR.getData();
         Integer objectId = sysUser.getObjectId();
-        Page<ShopBalanceStatement> page = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(shopBalanceStatement.getType() != null, ShopBalanceStatement::getType, shopBalanceStatement.getType())
-                .orderByDesc(ShopBalanceStatement::getCreateTime)
-                .page(Page.of(pageNum, pageSize));
-
+        Page<ShopBalanceStatement> page = shopBalanceStatementService.shopCommissionStatisticslist(objectId, shopBalanceStatement.getType(), pageNum, pageSize);
+        page.getRecords().forEach(s->s.setVariableAmount(s.getVariableAmount().multiply(new BigDecimal(s.getChangeDirection()))));
         return R.ok(page);
 
 
@@ -276,6 +275,30 @@
             }
         }
         List<ShopBalanceStatement> list = shopBalanceStatementService.list(queryWrapper);
+        for (ShopBalanceStatement shopBalanceStatement : list) {
+            shopBalanceStatement.setVariableAmount(shopBalanceStatement.getVariableAmount().multiply(new BigDecimal(shopBalanceStatement.getChangeDirection())));
+        }
+    
+        LambdaQueryWrapper<ShopBalanceStatementCopy> queryWrapper1 = new LambdaQueryWrapper<ShopBalanceStatementCopy>()
+                .eq(ShopBalanceStatementCopy::getType, type)
+                .between(ShopBalanceStatementCopy::getCreateTime, date.with(LocalTime.MIN), date.with(LocalTime.MAX));
+        if (null != shopId && 0 != shopId) {
+            queryWrapper1.eq(ShopBalanceStatementCopy::getShopId, shopId);
+        }else{
+            List<Integer> shipIds = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0)).stream().map(Shop::getId).collect(Collectors.toList());
+            if(shipIds.size() > 0){
+                queryWrapper1.in(ShopBalanceStatementCopy::getShopId, shipIds);
+            }else{
+                queryWrapper1.eq(ShopBalanceStatementCopy::getShopId, -1);
+            }
+        }
+        List<ShopBalanceStatementCopy> list1 = shopBalanceStatementCopyMapper.selectList(queryWrapper1);
+        for (ShopBalanceStatementCopy shopBalanceStatementCopy  : list1) {
+            ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
+            BeanUtils.copyProperties(shopBalanceStatementCopy, shopBalanceStatement);
+            shopBalanceStatement.setVariableAmount(shopBalanceStatement.getVariableAmount().multiply(new BigDecimal(shopBalanceStatement.getChangeDirection())));
+            list.add(shopBalanceStatement);
+        }
         return R.ok(list);
     }
 
@@ -301,8 +324,8 @@
 
         // 合并计算
         Map<Integer, BigDecimal> result = Stream.concat(
-                copies.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount())),
-                statements.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount()))
+                copies.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount().multiply(new BigDecimal(e.getChangeDirection())))),
+                statements.stream().map(e -> Pair.of(e.getType(), e.getVariableAmount().multiply(new BigDecimal(e.getChangeDirection()))))
         ).collect(Collectors.groupingBy(
                 Pair::getKey,
                 Collectors.mapping(Pair::getValue, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
@@ -323,7 +346,6 @@
         }
 
         // 构建结果
-
         List<ShopWithdraw> list = shopWithdrawService.lambdaQuery().eq(ShopWithdraw::getShopId, shopId)
                 .eq(ShopWithdraw::getAuditStatus, 0).list();
         BigDecimal withdrawAuditMoney = list.stream().map(ShopWithdraw::getMoney).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
@@ -338,7 +360,6 @@
                         ));
         commission.setWaitingAuditCommission(waitingAudit);
         commission.setTotalAmount(commission.getCommissionAmount());
-
         return R.ok(commission);
     }
 

--
Gitblit v1.7.1