1
zj
2025-09-16 3a8764d068b83988fa4c5f61abc4ba359e5aeb29
src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -17,6 +17,7 @@
import com.nq.pojo.reponse.RUserAssets;
import com.nq.service.*;
import com.nq.utils.UserPointUtil;
import com.nq.utils.email.EmailValidator;
import com.nq.utils.redis.RedisKeyUtil;
import com.nq.utils.timeutil.DateTimeUtil;
import com.nq.utils.PropertiesUtil;
@@ -42,6 +43,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@@ -147,16 +149,17 @@
                StringUtils.isBlank(userPwd) || StringUtils.isBlank(yzmCode)) {
            return ServerResponse.createByErrorMsg("注册失败。该参数不能为空",request);
        }
        if(!EmailValidator.isValidEmail(phone)){
            return ServerResponse.createByErrorMsg("请输入正确的邮箱格式",request);
        }
        String keys = "AliyunSmsCode:" + phone;
        String keys = "emailCode:" + phone;
        String redis_yzm = RedisShardedPoolUtils.get(keys);
        log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode);
        if (!yzmCode.equals(redis_yzm) && !"6666".equals(yzmCode)) {
            return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。过程",request);
            return ServerResponse.createByErrorMsg("验证码不正确或已过期,注册失败",request);
        }
        AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
        if (agentUser == null) {
@@ -169,7 +172,7 @@
        User dbuser = this.userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getPhone,phone).last( " limit 1"));
        if (dbuser != null) {
            return ServerResponse.createByErrorMsg("注册失败,手机号已注册",request);
            return ServerResponse.createByErrorMsg("注册失败,用户名已注册",request);
        }
@@ -204,7 +207,7 @@
    public ServerResponse login(String phone, String userPwd, HttpServletRequest request) {
        if (StringUtils.isBlank(phone) || StringUtils.isBlank(userPwd)) {
            return ServerResponse.createByErrorMsg("手机号码和密码不能为空",request);
            return ServerResponse.createByErrorMsg("账号和密码不能为空",request);
        }
        userPwd = SymmetricCryptoUtil.encryptPassword(userPwd);
        User user = this.userMapper.login(phone, userPwd);
@@ -1196,11 +1199,19 @@
        if(ObjectUtil.isEmpty(userId)){
            return ServerResponse.createBySuccess(BigDecimal.ZERO);
        }
        // 计算7天前的时间
        Date sevenDaysAgo = Date.from(LocalDateTime.now().minusDays(7).atZone(ZoneId.systemDefault()).toInstant());
        List<UserPosition> userPositions = userPositionMapper.selectList(
                new QueryWrapper<UserPosition>()
                        .eq("user_id", userId)
                        .apply("(sell_order_id IS NOT NULL AND sell_order_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)) " +
                                "OR (sell_order_id IS NULL AND buy_order_time >= DATE_SUB(NOW(), INTERVAL 7 DAY))")
                        .and(wrapper -> wrapper
                                .isNotNull("sell_order_id")
                                .ge("sell_order_time", sevenDaysAgo)
                                .or()
                                .isNull("sell_order_id")
                                .ge("buy_order_time", sevenDaysAgo)
                        )
        );
        BigDecimal weeklyProfit = BigDecimal.ZERO;
        if (userPositions.size() > 0) {