|
@@ -62,6 +62,9 @@ import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
@@ -94,6 +97,7 @@ public class UserService {
|
|
|
private WeakPassRepo weakPassRepo;
|
|
private WeakPassRepo weakPassRepo;
|
|
|
private UserBalanceRepo userBalanceRepo;
|
|
private UserBalanceRepo userBalanceRepo;
|
|
|
private ContentAuditService contentAuditService;
|
|
private ContentAuditService contentAuditService;
|
|
|
|
|
+ private OrderRepo orderRepo;
|
|
|
|
|
|
|
|
public User update(User user) {
|
|
public User update(User user) {
|
|
|
if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
|
|
if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
|
|
@@ -119,6 +123,7 @@ public class UserService {
|
|
|
public User save(User user) {
|
|
public User save(User user) {
|
|
|
if (user.getId() != null) {
|
|
if (user.getId() != null) {
|
|
|
cacheService.clearUserMy(user.getId());
|
|
cacheService.clearUserMy(user.getId());
|
|
|
|
|
+ cacheService.clearUser(user.getId());
|
|
|
}
|
|
}
|
|
|
return userRepo.save(user);
|
|
return userRepo.save(user);
|
|
|
}
|
|
}
|
|
@@ -577,7 +582,7 @@ public class UserService {
|
|
|
throw new BusinessException("用户不存在或未认证");
|
|
throw new BusinessException("用户不存在或未认证");
|
|
|
}
|
|
}
|
|
|
String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
|
|
String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
|
|
|
- user.getId(), AuthStatus.SUCCESS)
|
|
|
|
|
|
|
+ user.getId(), AuthStatus.SUCCESS)
|
|
|
.map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
|
|
.map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("id", user.getId());
|
|
map.put("id", user.getId());
|
|
@@ -590,8 +595,8 @@ public class UserService {
|
|
|
|
|
|
|
|
public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
|
|
public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
|
|
|
List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
|
|
List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
|
|
|
- .replaceAll("\r\n", " ")
|
|
|
|
|
- .split(" "))
|
|
|
|
|
|
|
+ .replaceAll("\r\n", " ")
|
|
|
|
|
+ .split(" "))
|
|
|
.map(String::trim)
|
|
.map(String::trim)
|
|
|
.filter(s -> !StringUtils.isEmpty(s))
|
|
.filter(s -> !StringUtils.isEmpty(s))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
@@ -881,4 +886,29 @@ public class UserService {
|
|
|
result.setCount(BigInteger.valueOf(invitedUserDTOS.size()));
|
|
result.setCount(BigInteger.valueOf(invitedUserDTOS.size()));
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void enableWallet(Long userId) {
|
|
|
|
|
+ User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
|
|
+ if (user.isWalletEnabled()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!sysConfigService.getBoolean("enable_wallet")) {
|
|
|
|
|
+ throw new BusinessException("绿魔卡功能暂未开启");
|
|
|
|
|
+ }
|
|
|
|
|
+ IdentityAuth identityAuth = identityAuthRepo.findByUserId(userId).stream().findFirst().orElse(null);
|
|
|
|
|
+ if (identityAuth == null) {
|
|
|
|
|
+ throw new BusinessException("请先完成实名认证");
|
|
|
|
|
+ }
|
|
|
|
|
+ long age = ChronoUnit.YEARS.between(LocalDate.parse(identityAuth.getIdNo().substring(6, 14),
|
|
|
|
|
+ DateTimeFormatter.ofPattern("yyyyMMdd")), LocalDate.now());
|
|
|
|
|
+ if (!((age >= 22 && age <= 55))) {
|
|
|
|
|
+ throw new BusinessException("仅22至55周岁藏家可申请绿魔卡");
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal amount = sysConfigService.getBigDecimal("wallet_enable_amount");
|
|
|
|
|
+ if (Optional.ofNullable(orderRepo.sumUserPrice(userId)).orElse(BigDecimal.ZERO).compareTo(amount) < 0) {
|
|
|
|
|
+ throw new BusinessException("申请绿魔卡需满" + amount + "绿洲石");
|
|
|
|
|
+ }
|
|
|
|
|
+ user.setWalletEnabled(true);
|
|
|
|
|
+ save(user);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|