|
@@ -3,6 +3,7 @@ package com.etotem.num.service;
|
|
|
import com.etotem.num.common.BizException;
|
|
import com.etotem.num.common.BizException;
|
|
|
import com.etotem.num.config.JwtConfig;
|
|
import com.etotem.num.config.JwtConfig;
|
|
|
import com.etotem.num.entity.User;
|
|
import com.etotem.num.entity.User;
|
|
|
|
|
+import com.etotem.num.repository.OrderRepository;
|
|
|
import com.etotem.num.repository.UserRepository;
|
|
import com.etotem.num.repository.UserRepository;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -17,11 +18,14 @@ public class UserService {
|
|
|
private final UserRepository userRepository;
|
|
private final UserRepository userRepository;
|
|
|
private final JwtConfig jwtConfig;
|
|
private final JwtConfig jwtConfig;
|
|
|
private final ConfigService configService;
|
|
private final ConfigService configService;
|
|
|
|
|
+ private final OrderRepository orderRepository;
|
|
|
|
|
|
|
|
- public UserService(UserRepository userRepository, JwtConfig jwtConfig, ConfigService configService) {
|
|
|
|
|
|
|
+ public UserService(UserRepository userRepository, JwtConfig jwtConfig, ConfigService configService,
|
|
|
|
|
+ OrderRepository orderRepository) {
|
|
|
this.userRepository = userRepository;
|
|
this.userRepository = userRepository;
|
|
|
this.jwtConfig = jwtConfig;
|
|
this.jwtConfig = jwtConfig;
|
|
|
this.configService = configService;
|
|
this.configService = configService;
|
|
|
|
|
+ this.orderRepository = orderRepository;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -192,6 +196,14 @@ public class UserService {
|
|
|
return user;
|
|
return user;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * US-4.3 §19: Check whether the user has ever purchased at seed price.
|
|
|
|
|
+ * Returns true if the user has at least one paid order with isSeedPrice=true.
|
|
|
|
|
+ */
|
|
|
|
|
+ public boolean isSeedPriceUser(Long userId) {
|
|
|
|
|
+ return orderRepository.countByUserIdAndIsSeedPriceAndStatus(userId, true, "paid") > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// US-6.1 §2: 6位大写字母+数字, 去掉易混淆 O/0/I/1
|
|
// US-6.1 §2: 6位大写字母+数字, 去掉易混淆 O/0/I/1
|
|
|
private static final String RC_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
private static final String RC_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
|
private static final int RC_LENGTH = 6;
|
|
private static final int RC_LENGTH = 6;
|