Browse Source

流拍5次删号

licailing 4 years ago
parent
commit
91bdd08ca8

+ 4 - 2
src/main/java/com/izouma/nineth/repo/AuctionPassRecordRepo.java

@@ -10,10 +10,12 @@ import javax.transaction.Transactional;
 import java.util.List;
 import java.util.List;
 
 
 public interface AuctionPassRecordRepo extends JpaRepository<AuctionPassRecord, Long>, JpaSpecificationExecutor<AuctionPassRecord> {
 public interface AuctionPassRecordRepo extends JpaRepository<AuctionPassRecord, Long>, JpaSpecificationExecutor<AuctionPassRecord> {
-    @Query("update AuctionRecord t set t.del = true where t.id = ?1")
+    @Query("update AuctionPassRecord t set t.del = true where t.id = ?1")
     @Modifying
     @Modifying
     @Transactional
     @Transactional
     void softDelete(Long id);
     void softDelete(Long id);
 
 
-    List<AuctionPassRecord> findAllByAuctionId(Long auctionId);
+    @Query(nativeQuery = true, value = "select r.user_id  from auction_pass_record r " +
+            "GROUP BY r.user_id HAVING count(*) > 5")
+    List<Long> checkUserId();
 }
 }

+ 5 - 0
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -24,6 +24,11 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     @Query("update User u set u.del = true where u.id = ?1")
     @Query("update User u set u.del = true where u.id = ?1")
     void softDelete(Long id);
     void softDelete(Long id);
 
 
+    @Transactional
+    @Modifying
+    @Query("update User u set u.del = true where u.id in ?1")
+    void softDeleteIn(Collection<Long> id);
+
     Optional<User> findByUsernameAndDelFalse(String username);
     Optional<User> findByUsernameAndDelFalse(String username);
 
 
     List<User> findAllByAuthoritiesContainsAndDelFalse(Authority authority);
     List<User> findAllByAuthoritiesContainsAndDelFalse(Authority authority);

+ 21 - 3
src/main/java/com/izouma/nineth/service/UserService.java

@@ -3,6 +3,7 @@ package com.izouma.nineth.service;
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
+import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.core.sym.NameN;
 import com.fasterxml.jackson.core.sym.NameN;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
@@ -50,6 +51,7 @@ import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -62,6 +64,8 @@ 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.LocalTime;
 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 +98,7 @@ public class UserService {
     private WeakPassRepo                  weakPassRepo;
     private WeakPassRepo                  weakPassRepo;
     private UserBalanceRepo               userBalanceRepo;
     private UserBalanceRepo               userBalanceRepo;
     private ContentAuditService           contentAuditService;
     private ContentAuditService           contentAuditService;
+    private AuctionPassRecordRepo         auctionPassRecordRepo;
 
 
     public User update(User user) {
     public User update(User user) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
@@ -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,17 @@ public class UserService {
         result.setCount(BigInteger.valueOf(invitedUserDTOS.size()));
         result.setCount(BigInteger.valueOf(invitedUserDTOS.size()));
         return result;
         return result;
     }
     }
+
+    /**
+     * 流拍5次直接删号处罚
+     */
+    @Scheduled(cron = "0 0/10 * * * ?")
+    public void delUser() {
+        List<Long> userIds = auctionPassRecordRepo.checkUserId();
+        if (CollUtil.isNotEmpty(userIds)) {
+            log.info("流拍处罚:{}", userIds);
+            userRepo.softDeleteIn(userIds);
+        }
+
+    }
 }
 }