Browse Source

bugid-1039 【服务中台】列表页面按照举报人联系电话查询条件查询结果不正确

zhangchen 1 month ago
parent
commit
c620d5997e

+ 5 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeUserViolationVo.java

@@ -22,4 +22,9 @@ public class LifeUserViolationVo extends LifeUserViolation {
 
     //举报结果通知
     private String reportResultNotification;
+
+    
+    private String phone;
+
+    private String nickName;
 }

+ 49 - 1
alien-entity/src/main/java/shop/alien/mapper/LifeUserViolationMapper.java

@@ -1,7 +1,13 @@
 package shop.alien.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.store.LifeUserViolation;
+import shop.alien.entity.store.vo.LifeUserViolationVo;
 
 /**
  * <p>
@@ -12,5 +18,47 @@ import shop.alien.entity.store.LifeUserViolation;
  * @since 2025-04-29
  */
 public interface LifeUserViolationMapper extends BaseMapper<LifeUserViolation> {
-
+    
+    /**
+     * 分页查询用户举报信息
+     * 
+     * @param page 分页对象
+     * @param queryWrapper 查询条件包装器
+     * @return 分页结果
+     */
+    @Select("<script>" +
+            "WITH userInfo AS (" +
+            "    SELECT " +
+            "        su.phone, " +
+            "        su.id, " +
+            "        CASE su.delete_flag " +
+            "            WHEN 1 THEN CONCAT(su.nick_name, '(账号已注销)') " +
+            "            ELSE su.nick_name " +
+            "        END AS nick_name, " +
+            "        '1' AS type " +
+            "    FROM store_user su " +
+            "    UNION ALL " +
+            "    SELECT " +
+            "        lu.user_phone AS phone, " +
+            "        lu.id, " +
+            "        CASE lu.delete_flag " +
+            "            WHEN 1 THEN CONCAT(lu.user_name, '(账号已注销)') " +
+            "            ELSE lu.user_name " +
+            "        END AS nick_name, " +
+            "        '2' AS type " +
+            "    FROM life_user lu " +
+            ") " +
+            "SELECT " +
+            "    luv.*, " +
+            "    ui.nick_name AS nickname, " +
+            "    ui.phone " +
+            "FROM life_user_violation luv " +
+            "LEFT JOIN userInfo ui ON ui.type = luv.reporting_user_type " +
+            "    AND ui.id = luv.reporting_user_id " +
+            "    ${ew.customSqlSegment}" +
+            "</script>")
+    IPage<LifeUserViolationVo> getViolationPage(
+            IPage<LifeUserViolationVo> page, 
+            @Param(Constants.WRAPPER) QueryWrapper<LifeUserViolationVo> queryWrapper
+    );
 }

+ 31 - 31
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserViolationServiceImpl.java

@@ -310,43 +310,43 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
 
     @Override
     public IPage<LifeUserViolationDto> getViolationPage(int page, int size, String nickName, String phone, String processingStatus) {
-        List<String> MIDs = storeUserService.getIds(nickName, phone);
-        List<String> UIDs = lifeUserService.getIds(nickName, phone);
-        boolean flag = FunctionMagic.isListFlag(MIDs, UIDs);
-        IPage<LifeUserViolation> iPage = new Page<>(page, size);
-        QueryWrapper<LifeUserViolation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq(StringUtils.isNotEmpty(processingStatus), PROCESSING_STATUS, processingStatus).and(flag, wrapper -> wrapper.nested(wq -> wq.eq(REPORTING_USER_TYPE, "1").in(!MIDs.isEmpty(), REPORTING_USER_ID, MIDs)).or(wq -> wq.eq(REPORTING_USER_TYPE, "2").in(!UIDs.isEmpty(), REPORTING_USER_ID, UIDs))).orderByDesc("updated_time");
-        String commonReportContextType = "1,2,3";
-        List<String> commonReportContextTypeList = Arrays.asList(commonReportContextType.split(","));
-        queryWrapper.lambda().in(LifeUserViolation::getReportContextType, commonReportContextTypeList);
-        IPage<LifeUserViolation> resultPage = lifeUserViolationMapper.selectPage(iPage, queryWrapper);
+        IPage<LifeUserViolationVo> pageRequest = new Page<>(page, size);
+        QueryWrapper<LifeUserViolationVo> queryWrapper = new QueryWrapper<>();
+        
+        // 基础查询条件
+        queryWrapper.eq("luv.delete_flag", 0)
+                .in("luv.report_context_type", Arrays.asList("1", "2", "3"));
+        
+        // 动态查询条件
+        queryWrapper.like(StringUtils.isNotEmpty(nickName), "ui.nick_name", nickName)
+                .like(StringUtils.isNotEmpty(phone), "ui.phone", phone);
+        
+        if (StringUtils.isNotEmpty(processingStatus)) {
+            queryWrapper.eq("luv.processing_status", processingStatus);
+        }
+        
+        queryWrapper.orderByDesc("luv.updated_time");
+        
+        IPage<LifeUserViolationVo> resultPage = lifeUserViolationMapper.getViolationPage(pageRequest, queryWrapper);
+
         return resultPage.convert(e -> {
             LifeUserViolationDto dto = new LifeUserViolationDto();
             BeanUtils.copyProperties(e, dto);
+            
+            // 处理举报凭证图片
             if (Objects.nonNull(e.getReportEvidenceImg())) {
-                List<String> list = Arrays.stream(e.getReportEvidenceImg().split(",")).map(String::trim).collect(Collectors.toList());
-                dto.setImage(list.get(0));
-                dto.setImageList(list);
-            }
-            if (e.getReportingUserType().equals("1")) {
-                // M
-                StoreUser storeUser = storeUserService.getOne(new QueryWrapper<StoreUser>().eq("id", e.getReportingUserId()));
-                if (storeUser == null) {
-                    storeUser = storeUserMapper.getRemoveUser(e.getReportingUserId());
-                    dto.setNickname(Objects.isNull(storeUser.getName()) ? "" : storeUser.getName());
-                } else {
-                    dto.setNickname(Objects.isNull(storeUser.getNickName()) ? "" : storeUser.getNickName());
-                }
-                dto.setPhone(Objects.isNull(storeUser.getPhone()) ? "" : storeUser.getPhone());
-            } else {
-                // U
-                LifeUser lifeUser = lifeUserService.getOne(new QueryWrapper<LifeUser>().eq("id", e.getReportingUserId()));
-                if (lifeUser == null) {
-                    lifeUser = lifeUserMapper.getRemoveUser(e.getReportingUserId());
+                List<String> imageList = Arrays.stream(e.getReportEvidenceImg().split(","))
+                        .map(String::trim)
+                        .filter(StringUtils::isNotEmpty)
+                        .collect(Collectors.toList());
+                
+                if (!imageList.isEmpty()) {
+                    dto.setImage(imageList.get(0));
+                    dto.setImageList(imageList);
                 }
-                dto.setNickname(Objects.isNull(lifeUser.getUserName()) ? "" : lifeUser.getUserName());
-                dto.setPhone(Objects.isNull(lifeUser.getUserPhone()) ? "" : lifeUser.getUserPhone());
             }
+            
+            dto.setNickname(e.getNickName());
             return dto;
         });
     }