From 854aa5b79d3906b335524f09581f3a567a7bad49 Mon Sep 17 00:00:00 2001
From: peter <14100000001@qq.com>
Date: Thu, 30 Oct 2025 18:23:34 +0800
Subject: [PATCH] 周收益、代理后台入金 充值

---
 src/main/java/com/nq/service/impl/UserServiceImpl.java |   37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index ec3756f..0693d2d 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -42,8 +42,7 @@
 import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import javax.annotation.Resource;
@@ -1200,17 +1199,45 @@
             return ServerResponse.createBySuccess(BigDecimal.ZERO);
         }
         // 计算7天前的时间
-        Date sevenDaysAgo = Date.from(LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toInstant());
+//        Date sevenDaysAgo = Date.from(LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toInstant());
+//
+//        List<UserPosition> userPositions = userPositionMapper.selectList(
+//                new QueryWrapper<UserPosition>()
+//                        .eq("user_id", userId)
+//                        .and(wrapper -> wrapper
+//                                .isNotNull("sell_order_id")
+//                                .ge("sell_order_time", sevenDaysAgo)
+//                                .or()
+//                                .isNull("sell_order_id")
+//                                .ge("buy_order_time", sevenDaysAgo)
+//                        )
+//        );
+        // 获取当前日期
+        LocalDate today = LocalDate.now();
 
+        // 获取当前周的周一和周日
+        LocalDate startOfWeek = today.with(DayOfWeek.MONDAY); // 本周周一
+        LocalDate endOfWeek = today.with(DayOfWeek.SUNDAY); // 本周周日
+
+        // 获取当前周周一和周日的开始时间和结束时间
+        LocalDateTime startOfWeekTime = startOfWeek.atStartOfDay(); // 周一 00:00:00
+        LocalDateTime endOfWeekTime = endOfWeek.atTime(LocalTime.MAX); // 周日 23:59:59.999999999
+
+        // 转换为Date类型
+        Date startOfWeekDate = Date.from(startOfWeekTime.atZone(ZoneId.systemDefault()).toInstant());
+        Date endOfWeekDate = Date.from(endOfWeekTime.atZone(ZoneId.systemDefault()).toInstant());
+        // 执行查询
         List<UserPosition> userPositions = userPositionMapper.selectList(
                 new QueryWrapper<UserPosition>()
                         .eq("user_id", userId)
                         .and(wrapper -> wrapper
                                 .isNotNull("sell_order_id")
-                                .ge("sell_order_time", sevenDaysAgo)
+                                .ge("sell_order_time", startOfWeekDate)  // 过滤sell_order_time >= 本周周一
+                                .le("sell_order_time", endOfWeekDate)  // 过滤sell_order_time <= 本周周日
                                 .or()
                                 .isNull("sell_order_id")
-                                .ge("buy_order_time", sevenDaysAgo)
+                                .ge("buy_order_time", startOfWeekDate)  // 过滤buy_order_time >= 本周周一
+                                .le("buy_order_time", endOfWeekDate)  // 过滤buy_order_time <= 本周周日
                         )
         );
         BigDecimal weeklyProfit = BigDecimal.ZERO;

--
Gitblit v1.9.3