فهرست منبع

feat(store): 新增举报分页查询功能并优化相关逻辑

- 在 LifeUserViolationDto 中新增 violationTypeName、reportContextName 和 processingName 字段
- 修改 LifeUserViolationMapper.xml 查询语句,增加 store_name 字段返回
- 新增 getAllViolationPage 方法支持按时间筛选的举报分页查询
- 优化 getViolationPage 查询条件构造逻辑,去除冗余表别名前缀
- 在 UserViolationController 中新增 /allPage 接口用于举报分页查询
- 完善违规举报相关的 VO 和 DTO 类字段定义及注释说明
zjy 6 روز پیش
والد
کامیت
c5802b487a

+ 10 - 0
alien-entity/src/main/java/shop/alien/entity/store/dto/LifeUserViolationDto.java

@@ -105,6 +105,16 @@ public class LifeUserViolationDto {
     @ApiModelProperty(value = "举报内容")
     private String LifeNotice;
 
+    //  举报类型状态名称
+    @ApiModelProperty(value = "举报类型状态名称")
+    private String violationTypeName;
 
+    // 举报类型名称
+    @ApiModelProperty(value = "举报类型名称")
+    private String reportContextName;
+
+    // 处理状态名称
+    @ApiModelProperty(value = "处理状态名称")
+    private String processingName;
 
 }

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

@@ -29,4 +29,13 @@ public class LifeUserViolationVo extends LifeUserViolation {
     private String nickName;
 
     private String image;
+
+    //  举报类型状态名称
+    private String violationTypeName;
+
+    // 举报类型名称
+    private String reportContextName;
+
+    // 处理状态名称
+    private String processingName;
 }

+ 39 - 0
alien-entity/src/main/java/shop/alien/mapper/LifeUserViolationMapper.java

@@ -113,4 +113,43 @@ public interface LifeUserViolationMapper extends BaseMapper<LifeUserViolation> {
     List<LifeUserViolationVo> getViolationList(
             @Param(Constants.WRAPPER) QueryWrapper<LifeUserViolationVo> queryWrapper
     );
+
+
+    @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 " +
+            " ) " +
+            " , violationInfo as ( " +
+            " SELECT " +
+            " luv.id, ui.nick_name, ui.phone, luv.report_context_type,  " +
+            " case when luv.violation_type = 1 then '用户违规' when luv.violation_type = 2 then '色情低俗' when luv.violation_type = 3 then '违法违规' when luv.violation_type = 4 then '谩骂嘲讽、煽动对立' when luv.violation_type = 5 then '涉嫌诈骗' " +
+            " when luv.violation_type = 6 then '人身攻击' when luv.violation_type = 7 then '种族歧视' when luv.violation_type = 8 then '政治敏感' when luv.violation_type = 9 then '虚假、不实内容' " +
+            " when luv.violation_type = 10 then '违反公德秩序' when luv.violation_type = 11 then '危害人身安全' when luv.violation_type = 12 then '网络暴力' else '其他原因' end violation_type_name,  " +
+            " case when luv.report_context_type = 0 then '商户' when luv.report_context_type = 1 then '用户' when luv.report_context_type = 2 then '动态' else '评论' end report_context_name, " +
+            " luv.processing_status, case when luv.processing_status = 0 then '待处理' when luv.processing_status = 1 then '已通过' else '已驳回' end processing_name,  " +
+            " luv.processing_time, luv.created_time, img.img_url image, luv.updated_time " +
+            " FROM life_user_violation luv " +
+            " LEFT JOIN userInfo ui ON ui.type = luv.reporting_user_type AND ui.id = luv.reporting_user_id " +
+            " left join store_img img on luv.id = img.store_id and img.delete_flag = 0 " +
+            " where luv.delete_flag = 0 and luv.report_context_type in ('1', '2', '3') " +
+            " union all " +
+            " select " +
+            " luv.id, lu.user_name nick_name, lu.user_phone phone, luv.report_context_type, sd.dict_detail,  " +
+            " case when luv.report_context_type = '4' then '商品' else '用户' end report_context_name,  " +
+            " luv.processing_status, case when luv.processing_status = 0 then '待处理' when luv.processing_status = 1 then '已通过' else '已驳回' end processing_name, " +
+            " luv.processing_time, luv.created_time, '' image, luv.updated_time " +
+            " from life_user_violation luv " +
+            " left join life_user lu on luv.reporting_user_id = lu.id and lu.delete_flag = 0 " +
+            " left join store_dictionary sd on luv.dict_type = sd.type_name and luv.dict_id = sd.dict_id and sd.delete_flag = 0 " +
+            " where luv.report_context_type in ('4', '5') and sd.delete_flag = 0 " +
+            " ) " +
+            " select * from violationInfo " +
+            " ${ew.customSqlSegment}" +
+            "</script>")
+    IPage<LifeUserViolationVo> getAllViolationPage(
+            IPage<LifeUserViolationVo> page,
+            @Param(Constants.WRAPPER) QueryWrapper<LifeUserViolationVo> queryWrapper
+    );
 }

+ 2 - 2
alien-entity/src/main/resources/mapper/LifeUserDynamicsMapper.xml

@@ -15,14 +15,14 @@
         from life_user_dynamics
         where delete_flag = 0 and draft = 0 order by created_time desc
         )
-        select dynamice.*, user.nick_name userName, user.head_img userImage, info.id storeUserId, user.id storeOrUserId, 0 isExpert
+        select dynamice.*, user.nick_name userName, user.head_img userImage, info.id storeUserId, user.id storeOrUserId, 0 isExpert, info.store_name
         from dynamice
         left join store_user user on dynamice.phone = user.phone and user.delete_flag = 0
         left join store_info info on info.id = user.store_id and info.delete_flag = 0
         left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0
         where dynamice.userType = 'store'
         union
-        select dynamice.*, user.user_name userName, user.user_image userImage, user.id storeUserId, user.id storeOrUserId, IF(lue.expert_code IS NOT NULL , 1, 0) AS isExpert
+        select dynamice.*, user.user_name userName, user.user_image userImage, user.id storeUserId, user.id storeOrUserId, IF(lue.expert_code IS NOT NULL , 1, 0) AS isExpert, '' store_name
         from dynamice
         join life_user user on dynamice.phone = user.user_phone and user.delete_flag = 0
         left join life_user_expert  lue on lue.user_id = user.id and lue.delete_flag = 0

+ 25 - 0
alien-store/src/main/java/shop/alien/store/controller/UserViolationController.java

@@ -81,6 +81,31 @@ public class UserViolationController {
         return R.data(lifeUserViolationService.getViolationPage(pageNum, pageSize, nickname, phone, processingStatus));
     }
 
+    @ApiOperation("举报分页(带时间筛选)")
+    @ApiOperationSupport(order = 9)
+    @GetMapping("/allPage")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", paramType = "query", defaultValue = "1"),
+            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", defaultValue = "10"),
+            @ApiImplicitParam(name = "nickname", value = "昵称", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "processingStatus", value = "处理状态", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query")
+    })
+    public R<IPage<LifeUserViolationDto>> getAllViolationPage(
+            @RequestParam(defaultValue = "1") int pageNum,
+            @RequestParam(defaultValue = "10") int pageSize,
+            @RequestParam(required = false) String nickname,
+            @RequestParam(required = false) String phone,
+            @RequestParam(required = false) String processingStatus,
+            @RequestParam(required = false) String startTime,
+            @RequestParam(required = false) String endTime) {
+        log.info("UserViolationController.getAllViolationPage?pageNum={},pageSize={},nickName={},phone={},processingStatus={},startTime={},endTime={}", 
+                pageNum, pageSize, nickname, phone, processingStatus, startTime, endTime);
+        return R.data(lifeUserViolationService.getAllViolationPage(pageNum, pageSize, nickname, phone, processingStatus, startTime, endTime));
+    }
+
     @ApiOperation(value = "举报审核")
     @ApiOperationSupport(order = 5)
     @GetMapping("/approve")

+ 2 - 0
alien-store/src/main/java/shop/alien/store/service/LifeUserViolationService.java

@@ -27,6 +27,8 @@ public interface LifeUserViolationService extends IService<LifeUserViolation> {
 
     IPage<LifeUserViolationDto> getViolationPage(int page, int size, String nickName, String phone, String processingStatus);
 
+    IPage<LifeUserViolationDto> getAllViolationPage(int page, int size, String nickName, String phone, String processingStatus, String startTime, String endTime);
+
     void approve(int id, String processingStatus, String reportResult);
 
     LifeUserViolationDto byId(Integer id);

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

@@ -331,19 +331,15 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
         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);
+        queryWrapper.like(StringUtils.isNotEmpty(nickName), "nick_name", nickName)
+                .like(StringUtils.isNotEmpty(phone), "phone", phone);
 
         if (StringUtils.isNotEmpty(processingStatus)) {
-            queryWrapper.eq("luv.processing_status", processingStatus);
+            queryWrapper.eq("processing_status", processingStatus);
         }
 
-        queryWrapper.orderByDesc("luv.updated_time");
+        queryWrapper.orderByDesc("updated_time");
 
         IPage<LifeUserViolationVo> resultPage = lifeUserViolationMapper.getViolationPage(pageRequest, queryWrapper);
 
@@ -726,4 +722,34 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
         if (count >= 3) return "B";
         return "A";
     }
+
+    @Override
+    public IPage<LifeUserViolationDto> getAllViolationPage(int page, int size, String nickName, String phone, String processingStatus, String startTime, String endTime) {
+        IPage<LifeUserViolationVo> pageRequest = new Page<>(page, size);
+        QueryWrapper<LifeUserViolationVo> queryWrapper = new QueryWrapper<>();
+
+        // 动态查询条件
+        queryWrapper.like(StringUtils.isNotEmpty(nickName), "nick_name", nickName)
+                .like(StringUtils.isNotEmpty(phone), "phone", phone);
+
+        if (StringUtils.isNotEmpty(processingStatus)) {
+            queryWrapper.eq("processing_status", processingStatus);
+        }
+        // 根据开始时间和结束时间过滤
+        if (StringUtils.isNotEmpty(startTime)) {
+            queryWrapper.ge("created_time", startTime);
+        }
+        if (StringUtils.isNotEmpty(endTime)) {
+            queryWrapper.le("created_time", endTime);
+        }
+        queryWrapper.orderByDesc("updated_time");
+
+        IPage<LifeUserViolationVo> resultPage = lifeUserViolationMapper.getViolationPage(pageRequest, queryWrapper);
+
+        return resultPage.convert(e -> {
+            LifeUserViolationDto dto = new LifeUserViolationDto();
+            BeanUtils.copyProperties(e, dto);
+            return dto;
+        });
+    }
 }