| | |
| | | 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; |
| | |
| | | return ServerResponse.createByErrorMsg("Operation failed. View logs"); |
| | | } |
| | | |
| | | public ServerResponse agentDelete(Integer userId, HttpServletRequest request) { |
| | | String loginToken = CookieUtils.readLoginToken(request, PropertiesUtil.getProperty("agent.cookie.name")); |
| | | String agentJson = RedisShardedPoolUtils.get(loginToken); |
| | | AgentUser agentUser = (AgentUser) JsonUtil.string2Obj(agentJson, AgentUser.class); |
| | | log.info("管理员 {} 删除用户 {}", StringUtils.isBlank(agentUser.getAgentName())?agentUser.getAgentPhone():agentUser.getAgentName(), userId); |
| | | |
| | | |
| | | int delChargeCount = this.iUserRechargeService.deleteByUserId(userId); |
| | | if (delChargeCount > 0) { |
| | | log.info("删除 充值 记录成功"); |
| | | } else { |
| | | log.info("删除 充值 记录失败"); |
| | | } |
| | | |
| | | |
| | | int delWithdrawCount = this.iUserWithdrawService.deleteByUserId(userId); |
| | | if (delWithdrawCount > 0) { |
| | | log.info("删除 提现 记录成功"); |
| | | } else { |
| | | log.info("删除 提现 记录失败"); |
| | | } |
| | | |
| | | |
| | | int delCashCount = this.iUserCashDetailService.deleteByUserId(userId); |
| | | if (delCashCount > 0) { |
| | | log.info("删除 资金 记录成功"); |
| | | } else { |
| | | log.info("删除 资金 记录成功"); |
| | | } |
| | | |
| | | |
| | | int delPositionCount = this.iUserPositionService.deleteByUserId(userId); |
| | | if (delPositionCount > 0) { |
| | | log.info("删除 持仓 记录成功"); |
| | | } else { |
| | | log.info("删除 持仓 记录失败"); |
| | | } |
| | | |
| | | |
| | | int delLogCount = this.iSiteLoginLogService.deleteByUserId(userId); |
| | | if (delLogCount > 0) { |
| | | log.info("删除 登录 记录成功"); |
| | | } else { |
| | | log.info("删除 登录 记录失败"); |
| | | } |
| | | |
| | | |
| | | int delUserCount = this.userMapper.deleteById(userId); |
| | | if (delUserCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("Successful operation"); |
| | | } |
| | | return ServerResponse.createByErrorMsg("Operation failed. View logs"); |
| | | } |
| | | |
| | | |
| | | public int CountUserSize(Integer accountType) { |
| | | return this.userMapper.CountUserSize(accountType); |
| | |
| | | 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; |