| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  | package com.upchina.common.service;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | import cn.hutool.core.util.StrUtil;
 | 
					
						
							|  |  |  |  | import com.alibaba.fastjson.JSONObject;
 | 
					
						
							|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
					
						
							|  |  |  |  | import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
					
						
							|  |  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
					
						
							|  |  |  |  | import com.google.common.collect.Table;
 | 
					
						
							|  |  |  |  | import com.hazelcast.core.HazelcastInstance;
 | 
					
						
							|  |  |  |  | import com.hazelcast.map.IMap;
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  | import com.upchina.common.constant.CommentBlackScope;
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  | import com.upchina.common.constant.CommentBlackStatus;
 | 
					
						
							|  |  |  |  | import com.upchina.common.constant.CommentBlackType;
 | 
					
						
							|  |  |  |  | import com.upchina.common.entity.CommentBlack;
 | 
					
						
							|  |  |  |  | import com.upchina.common.handler.BizException;
 | 
					
						
							|  |  |  |  | import com.upchina.common.mapper.CommentBlackMapper;
 | 
					
						
							|  |  |  |  | import com.upchina.common.query.AddCommentBlackQuery;
 | 
					
						
							|  |  |  |  | import com.upchina.common.query.BaseProductQuery;
 | 
					
						
							|  |  |  |  | import com.upchina.common.query.CommentBlackQuery;
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  | import com.upchina.common.query.RemoveCommentBlackQuery;
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  | import com.upchina.common.result.Pager;
 | 
					
						
							|  |  |  |  | import com.upchina.common.result.ResponseStatus;
 | 
					
						
							|  |  |  |  | import com.upchina.common.util.HideUtils;
 | 
					
						
							|  |  |  |  | import com.upchina.common.util.LoggerUtil;
 | 
					
						
							|  |  |  |  | import com.upchina.common.vo.BackendUserVO;
 | 
					
						
							|  |  |  |  | import com.upchina.common.vo.CommentBlackVO;
 | 
					
						
							|  |  |  |  | import com.upchina.common.vo.MergeProductInfoVO;
 | 
					
						
							|  |  |  |  | import com.upchina.rbac.entity.Dept;
 | 
					
						
							|  |  |  |  | import com.upchina.rbac.entity.UserDept;
 | 
					
						
							|  |  |  |  | import com.upchina.rbac.service.DeptService;
 | 
					
						
							|  |  |  |  | import com.upchina.rbac.service.UserService;
 | 
					
						
							|  |  |  |  | import ma.glasnost.orika.MapperFacade;
 | 
					
						
							|  |  |  |  | import org.springframework.stereotype.Service;
 | 
					
						
							|  |  |  |  | import org.springframework.transaction.annotation.Transactional;
 | 
					
						
							|  |  |  |  | import org.springframework.util.CollectionUtils;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | import javax.annotation.Resource;
 | 
					
						
							|  |  |  |  | import java.time.LocalDateTime;
 | 
					
						
							|  |  |  |  | import java.time.format.DateTimeFormatter;
 | 
					
						
							|  |  |  |  | import java.util.*;
 | 
					
						
							|  |  |  |  | import java.util.stream.Collectors;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | import static com.upchina.common.config.cache.CacheKey.COMMENT_BLACK;
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  | import static com.upchina.common.config.cache.CacheKey.CommentBlackKey.ALL_BLACK_COMMENT;
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  | import static com.upchina.common.config.cache.CacheKey.CommentBlackKey.ALL_BLACK_USER;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | @Service
 | 
					
						
							|  |  |  |  | public class CommentBlackService {
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private MapperFacade mapperFacade;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private CommentBlackMapper commentBlackMapper;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private UserService userService;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private MergeProductService mergeProductService;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private HazelcastInstance hazelcastInstance;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private CacheService cacheService;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Resource
 | 
					
						
							|  |  |  |  |     private DeptService deptService;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Transactional(rollbackFor = Exception.class)
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |     public Integer addCommentBlack(BackendUserVO backendUserVO, AddCommentBlackQuery query) {
 | 
					
						
							|  |  |  |  |         String userPhone = query.getUserPhone();
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         LocalDateTime now = LocalDateTime.now();
 | 
					
						
							|  |  |  |  |         //禁言开始时间-1s
 | 
					
						
							|  |  |  |  |         now = now.minusSeconds(1L);
 | 
					
						
							|  |  |  |  |         QueryWrapper<CommentBlack> wrapper = Wrappers.query();
 | 
					
						
							|  |  |  |  |         wrapper.eq("phone", userPhone)
 | 
					
						
							|  |  |  |  |                 .in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value))
 | 
					
						
							|  |  |  |  |                 .lt("start_time", now)
 | 
					
						
							|  |  |  |  |                 .ge("end_time", now);
 | 
					
						
							|  |  |  |  |         long validSize = commentBlackMapper.selectCount(wrapper);
 | 
					
						
							|  |  |  |  |         if (validSize > 0) {
 | 
					
						
							|  |  |  |  |             throw new BizException(ResponseStatus.REPETITIVE_ERROR);
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         CommentBlack commentBlack = mapperFacade.map(query, CommentBlack.class);
 | 
					
						
							|  |  |  |  |         commentBlack.setUserName(query.getUserName());
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         commentBlack.setPhone(userPhone);
 | 
					
						
							|  |  |  |  |         commentBlack.setStartTime(now);
 | 
					
						
							|  |  |  |  |         commentBlack.setStatus(CommentBlackStatus.EFFECT.value);
 | 
					
						
							|  |  |  |  |         commentBlack.setOperatorId(backendUserVO.getUserId());
 | 
					
						
							|  |  |  |  |         commentBlack.setUpdateTime(now);
 | 
					
						
							|  |  |  |  |         commentBlack.setAdvisorId(backendUserVO.getAdvisorId());
 | 
					
						
							|  |  |  |  |         if (CommentBlackType.DAY.value.equals(commentBlack.getType())) {
 | 
					
						
							|  |  |  |  |             commentBlack.setEndTime(now.plusDays(1));
 | 
					
						
							|  |  |  |  |         } else if (CommentBlackType.MONTH.value.equals(commentBlack.getType())) {
 | 
					
						
							|  |  |  |  |             commentBlack.setEndTime(now.plusMonths(1));
 | 
					
						
							|  |  |  |  |         } else {
 | 
					
						
							|  |  |  |  |             commentBlack.setEndTime(now.plusYears(100));
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |         int count = commentBlackMapper.insert(commentBlack);
 | 
					
						
							|  |  |  |  |         if (count < 1) {
 | 
					
						
							|  |  |  |  |             throw new BizException(ResponseStatus.DB_SAVE_ERROR);
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         this.clearCache(ALL_BLACK_USER, ALL_BLACK_COMMENT);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         return commentBlack.getId();
 | 
					
						
							|  |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @Transactional(rollbackFor = Exception.class)
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |     public void removeCommentBlack(BackendUserVO backendUserVO, RemoveCommentBlackQuery query) {
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         LocalDateTime now = LocalDateTime.now();
 | 
					
						
							|  |  |  |  |         QueryWrapper<CommentBlack> wrapper = Wrappers.query();
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         wrapper.eq("phone", query.getUserPhone())
 | 
					
						
							|  |  |  |  |                 .eq("product_id", query.getProductId())
 | 
					
						
							|  |  |  |  |                 .eq("product_type", query.getProductType())
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |                 .in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value))
 | 
					
						
							|  |  |  |  |                 .lt("start_time", now)
 | 
					
						
							|  |  |  |  |                 .ge("end_time", now);
 | 
					
						
							|  |  |  |  |         List<CommentBlack> commentBlackList = commentBlackMapper.selectList(wrapper);
 | 
					
						
							|  |  |  |  |         if (CollectionUtils.isEmpty(commentBlackList)) {
 | 
					
						
							|  |  |  |  |             throw new BizException(ResponseStatus.REMOVE_BLACK_USER_ERROR);
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |         for (CommentBlack commentBlack : commentBlackList) {
 | 
					
						
							|  |  |  |  |             CommentBlack updateObj = new CommentBlack();
 | 
					
						
							|  |  |  |  |             updateObj.setId(commentBlack.getId());
 | 
					
						
							|  |  |  |  |             updateObj.setStatus(CommentBlackStatus.REMOVED.value);
 | 
					
						
							|  |  |  |  |             updateObj.setUpdateTime(now);
 | 
					
						
							|  |  |  |  |             updateObj.setEndTime(now);
 | 
					
						
							|  |  |  |  |             int count = commentBlackMapper.updateById(updateObj);
 | 
					
						
							|  |  |  |  |             if (count < 1) {
 | 
					
						
							|  |  |  |  |                 throw new BizException(ResponseStatus.DB_SAVE_ERROR);
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         this.clearCache(ALL_BLACK_USER, ALL_BLACK_COMMENT);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |     public Pager<CommentBlackVO> queryCommentBlackList(BackendUserVO backendUserVO, CommentBlackQuery query) {
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         LocalDateTime startTime = null;
 | 
					
						
							|  |  |  |  |         LocalDateTime endTime = null;
 | 
					
						
							|  |  |  |  |         LocalDateTime startOpTime = null;
 | 
					
						
							|  |  |  |  |         LocalDateTime endOpTime = null;
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         if (StrUtil.isNotEmpty(query.getStartTime())) {
 | 
					
						
							|  |  |  |  |             startTime = LocalDateTime.parse(query.getStartTime(), formatter);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         if (StrUtil.isNotEmpty(query.getEndTime())) {
 | 
					
						
							|  |  |  |  |             endTime = LocalDateTime.parse(query.getEndTime(), formatter);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         if (StrUtil.isNotEmpty(query.getStartOpTime())) {
 | 
					
						
							|  |  |  |  |             startOpTime = LocalDateTime.parse(query.getStartOpTime(), formatter);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         if (StrUtil.isNotEmpty(query.getEndOpTime())) {
 | 
					
						
							|  |  |  |  |             endOpTime = LocalDateTime.parse(query.getEndOpTime(), formatter);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         }
 | 
					
						
							|  |  |  |  |         QueryWrapper<CommentBlack> wrapper = Wrappers.query();
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         wrapper.like(StrUtil.isNotEmpty(query.getUserName()), "user_name", query.getUserName())
 | 
					
						
							|  |  |  |  |                 .eq(StrUtil.isNotEmpty(query.getPhone()), "phone", query.getPhone())
 | 
					
						
							|  |  |  |  |                 .eq(query.getType() != null, "type", query.getType())
 | 
					
						
							|  |  |  |  |                 .eq(query.getProductType() != null, "product_type", query.getProductType())
 | 
					
						
							|  |  |  |  |                 .eq(query.getProductType() != null && query.getProductId() != null, "product_id", query.getProductId())
 | 
					
						
							|  |  |  |  |                 .like(StrUtil.isNotBlank(query.getContent()), "content", query.getContent())
 | 
					
						
							|  |  |  |  |                 .like(StrUtil.isNotEmpty(query.getReason()), "reason", query.getReason())
 | 
					
						
							|  |  |  |  |                 .eq(query.getOperatorId() != null, "operator_id", query.getOperatorId())
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |                 .ge(startTime != null, "start_time", startTime)
 | 
					
						
							|  |  |  |  |                 .lt(endTime != null, "start_time", endTime)
 | 
					
						
							|  |  |  |  |                 .ge(startOpTime != null, "end_time", startOpTime)
 | 
					
						
							|  |  |  |  |                 .lt(endOpTime != null, "end_time", endOpTime);
 | 
					
						
							|  |  |  |  |         wrapper.orderByDesc("start_time");
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         Page<CommentBlack> page = commentBlackMapper.selectPage(query.toPage(), wrapper);
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         List<CommentBlack> list = page.getRecords();
 | 
					
						
							|  |  |  |  |         if (CollectionUtils.isEmpty(list)) {
 | 
					
						
							|  |  |  |  |             return Pager.emptyPager();
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |         List<BaseProductQuery> baseProductQueryList = list.stream().map(commentBlack -> {
 | 
					
						
							|  |  |  |  |             if (commentBlack.getProductId() != null && commentBlack.getProductType() != null) {
 | 
					
						
							|  |  |  |  |                 return new BaseProductQuery(commentBlack.getProductId(), commentBlack.getProductType());
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |             return null;
 | 
					
						
							|  |  |  |  |         }).filter(Objects::nonNull).collect(Collectors.toList());
 | 
					
						
							|  |  |  |  |         Table<Integer, Integer, MergeProductInfoVO> productTable = mergeProductService.queryMergeProductInfo(baseProductQueryList);
 | 
					
						
							|  |  |  |  |         Map<Integer, UserDept> userMap = userService.getUserMap();
 | 
					
						
							|  |  |  |  |         Map<String, Dept> deptMap = deptService.getDeptMap();
 | 
					
						
							|  |  |  |  |         List<CommentBlackVO> voList = list.stream().map(commentBlack -> mapperFacade.map(commentBlack, CommentBlackVO.class)).collect(Collectors.toList());
 | 
					
						
							|  |  |  |  |         for (CommentBlackVO commentBlackVO : voList) {
 | 
					
						
							|  |  |  |  |             // 查询产品信息
 | 
					
						
							|  |  |  |  |             if (commentBlackVO.getProductId() != null && commentBlackVO.getProductType() != null) {
 | 
					
						
							|  |  |  |  |                 MergeProductInfoVO mergeProductInfoVO = productTable.get(commentBlackVO.getProductType(), commentBlackVO.getProductId());
 | 
					
						
							|  |  |  |  |                 if (mergeProductInfoVO != null) {
 | 
					
						
							|  |  |  |  |                     commentBlackVO.setProductName(mergeProductInfoVO.getProductName());
 | 
					
						
							|  |  |  |  |                 }
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |             LocalDateTime now = LocalDateTime.now();
 | 
					
						
							|  |  |  |  |             if (CommentBlackStatus.EFFECT.value.equals(commentBlackVO.getStatus()) && now.isAfter(commentBlackVO.getEndTime())) {
 | 
					
						
							|  |  |  |  |                 commentBlackVO.setStatus(CommentBlackStatus.EXPIRED.value);
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |             UserDept user = userMap.get(commentBlackVO.getOperatorId());
 | 
					
						
							|  |  |  |  |             if (user != null) {
 | 
					
						
							|  |  |  |  |                 commentBlackVO.setOperatorName(user.getName());
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |             if (StrUtil.isNotEmpty(commentBlackVO.getUserOrgNo())) {
 | 
					
						
							|  |  |  |  |                 Dept dept = deptMap.get(commentBlackVO.getUserOrgNo());
 | 
					
						
							|  |  |  |  |                 if (dept != null) {
 | 
					
						
							|  |  |  |  |                     commentBlackVO.setUserOrgName(dept.getName());
 | 
					
						
							|  |  |  |  |                 }
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |             commentBlackVO.setPhone(HideUtils.hidePhoneNo(commentBlackVO.getPhone()));
 | 
					
						
							|  |  |  |  |             commentBlackVO.setHidePhone(commentBlackVO.getPhone());
 | 
					
						
							|  |  |  |  |             commentBlackVO.setUserName(HideUtils.maskLastName(commentBlackVO.getUserName()));
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |         return new Pager<>(voList, page.getTotal());
 | 
					
						
							|  |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |     private void clearCache(String... cacheKeys) {
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         IMap<String, Object> cacheMap = hazelcastInstance.getMap(COMMENT_BLACK);
 | 
					
						
							|  |  |  |  |         for (String key : cacheKeys) {
 | 
					
						
							|  |  |  |  |             cacheMap.remove(key);
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /**
 | 
					
						
							|  |  |  |  |      * 校验是否禁言
 | 
					
						
							|  |  |  |  |      */
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |     public boolean checkIsBlack(String phone, Integer productId, Integer productType) {
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         // 判断是否禁言用户
 | 
					
						
							|  |  |  |  |         Set<String> blackUsers = getAllBlackUser();
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         if (!blackUsers.contains(phone)) {
 | 
					
						
							|  |  |  |  |             return false;
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |         List<CommentBlack> blackComments = getAllBlackComment();
 | 
					
						
							|  |  |  |  |         if (CollectionUtils.isEmpty(blackComments)) {
 | 
					
						
							|  |  |  |  |             return false;
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2025-02-10 14:47:05 +08:00
										 |  |  |  |         for (CommentBlack commentBlack : blackComments) {
 | 
					
						
							|  |  |  |  |             if (commentBlack.getPhone().equals(phone)) {
 | 
					
						
							|  |  |  |  |                 if (CommentBlackScope.PRODUCT.value.equals(commentBlack.getScope())) {
 | 
					
						
							|  |  |  |  |                     if (commentBlack.getProductId().equals(productId) && commentBlack.getProductType().equals(productType)) {
 | 
					
						
							|  |  |  |  |                         return true;
 | 
					
						
							|  |  |  |  |                     }
 | 
					
						
							|  |  |  |  |                 } else if (CommentBlackScope.PRODUCT_TYPE.value.equals(commentBlack.getScope())) {
 | 
					
						
							|  |  |  |  |                     if (commentBlack.getProductType().equals(productType)) {
 | 
					
						
							|  |  |  |  |                         return true;
 | 
					
						
							|  |  |  |  |                     }
 | 
					
						
							|  |  |  |  |                 } else if (CommentBlackScope.GLOBAL.value.equals(commentBlack.getScope())) {
 | 
					
						
							|  |  |  |  |                     return true;
 | 
					
						
							|  |  |  |  |                 }
 | 
					
						
							|  |  |  |  |             }
 | 
					
						
							|  |  |  |  |         }
 | 
					
						
							|  |  |  |  |         return false;
 | 
					
						
							|  |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private Set<String> getAllBlackUser() {
 | 
					
						
							|  |  |  |  |         return cacheService.get(COMMENT_BLACK, ALL_BLACK_USER, () ->
 | 
					
						
							|  |  |  |  |                 getAllBlackComment().stream().map(CommentBlack::getPhone).collect(Collectors.toSet()));
 | 
					
						
							|  |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private List<CommentBlack> getAllBlackComment() {
 | 
					
						
							|  |  |  |  |         LocalDateTime now = LocalDateTime.now();
 | 
					
						
							|  |  |  |  |         return cacheService.get(COMMENT_BLACK, ALL_BLACK_COMMENT, () -> {
 | 
					
						
							|  |  |  |  |             QueryWrapper<CommentBlack> wrapper = Wrappers.<CommentBlack>query()
 | 
					
						
							|  |  |  |  |                     .in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value))
 | 
					
						
							|  |  |  |  |                     .lt("start_time", now)
 | 
					
						
							|  |  |  |  |                     .gt("end_time", now);
 | 
					
						
							|  |  |  |  |             List<CommentBlack> commentBlackList = commentBlackMapper.selectList(wrapper);
 | 
					
						
							|  |  |  |  |             LoggerUtil.info("db当前黑名单用户:" + JSONObject.toJSONString(commentBlackList));
 | 
					
						
							|  |  |  |  |             return commentBlackList;
 | 
					
						
							|  |  |  |  |         });
 | 
					
						
							| 
									
										
										
										
											2025-01-27 21:47:33 +08:00
										 |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | }
 |