Parcourir la source

feat(reward-claims): 更新领奖审核列表导出功能及字段展示

- 修改导出标题与日志描述为"领奖审核列表"
- 新增数据库查询方法 selectByCriteriaExport 支持导出数据查询
- 在服务层解析奖励 JSON 并补充赛事名称、用户信息等展示字段
- 补充 Excel 导出字段映射,优化导出内容可读性- 调整 VO 类属性顺序并增加中文注释和 Excel 列名配置
fugui001 il y a 3 mois
Parent
commit
a5570c159d

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/RewardClaimsController.java

@@ -50,11 +50,11 @@ public class RewardClaimsController extends BaseController {
      * 导出用户参赛列表
      */
     @SaCheckPermission("business:claims:export")
-    @Log(title = "用户参赛", businessType = BusinessType.EXPORT)
+    @Log(title = "领奖审核列表", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(RewardClaimsBo bo, HttpServletResponse response) {
         List<RewardClaimsVo> list = rewardClaimsService.queryList(bo);
-        ExcelUtil.exportExcel(list, "用户参赛", RewardClaimsVo.class, response);
+        ExcelUtil.exportExcel(list, "领奖审核列表", RewardClaimsVo.class, response);
     }
 
     /**

+ 35 - 18
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/RewardClaimsVo.java

@@ -29,15 +29,41 @@ public class RewardClaimsVo implements Serializable {
     /**
      *
      */
-    @ExcelProperty(value = "")
+    @ExcelProperty(value = "编号")
     private Long id;
 
     /**
      * 赛事id
      */
-    @ExcelProperty(value = "赛id")
+    @ExcelProperty(value = "赛id")
     private Long tournamentId;
 
+
+    @ExcelProperty(value = "比赛名")
+    private String tournamentName;
+
+
+    /**
+     * 实名
+     */
+    @ExcelProperty(value = "用户名")
+    private String playerName;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "手机")
+    private String phone;
+
+
+    /**
+     * 奖励
+     */
+    @ExcelProperty(value = "奖励")
+    private String rewardJsonText;
+
+
+
     /**
      * 用户id
      */
@@ -50,44 +76,35 @@ public class RewardClaimsVo implements Serializable {
     @ExcelProperty(value = "排名")
     private Long rank;
 
-    /**
-     * 实名
-     */
-    @ExcelProperty(value = "实名")
-    private String playerName;
 
-    /**
-     *
-     */
-    @ExcelProperty(value = "")
-    private String phone;
+    @ExcelProperty(value = "状态 ")
+    private String claimedText;
+
 
     /**
      * 奖励
      */
-    @ExcelProperty(value = "奖励")
+    //@ExcelProperty(value = "奖励")
     private String rewardJson;
 
     /**
      * 是否审核
      */
-    @ExcelProperty(value = "是否审核 ")
+    //@ExcelProperty(value = "是否审核 ")
     private Long claimed;
 
 
-    @ExcelProperty(value = "是否审核 ")
-    private String claimedText;
 
     /**
      *
      */
-    @ExcelProperty(value = "")
+    //@ExcelProperty(value = "")
     private Date createdAt;
 
     /**
      *
      */
-    @ExcelProperty(value = "")
+    //@ExcelProperty(value = "")
     private Date updatedAt;
 
     List<RewardVo> rewardVoList;

+ 3 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/RewardClaimsMapper.java

@@ -50,4 +50,7 @@ public interface RewardClaimsMapper extends BaseMapperPlus<RewardClaims, RewardC
     @InterceptorIgnore(tenantLine = "true")
     int selectUserRewardCount(@Param("playerId") Long playerId);
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<RewardClaimsVo> selectByCriteriaExport(@Param("ew") Wrapper<RewardClaims> wrapper);
+
 }

+ 41 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/RewardClaimsServiceImpl.java

@@ -129,7 +129,47 @@ public class RewardClaimsServiceImpl implements IRewardClaimsService {
     @Override
     public List<RewardClaimsVo> queryList(RewardClaimsBo bo) {
         LambdaQueryWrapper<RewardClaims> lqw = buildQueryWrapper(bo);
-        return baseMapper.selectVoList(lqw);
+        List<RewardClaimsVo> resultRecords = baseMapper.selectByCriteriaExport(lqw);
+        //得到比赛名称
+        TournamentsVo tournamentsVo = tournamentsService.queryById(bo.getTournamentId());
+        String tournamentName = "";
+        if(tournamentsVo!=null){
+            tournamentName = tournamentsVo.getName();
+        }
+        for (RewardClaimsVo resultRecord : resultRecords) {
+            String rewardJson = resultRecord.getRewardJson();
+            StringBuilder prizeDisplayBuilder = new StringBuilder();
+            resultRecord.setTournamentId(bo.getTournamentId());
+            resultRecord.setTournamentName(tournamentName);
+            if(StringUtils.isNotBlank(rewardJson)){
+                ObjectMapper mapper = new ObjectMapper();
+                List<RewardVo> items = null;
+                try {
+                    items = mapper.readValue(rewardJson, new TypeReference<List<RewardVo>>() {});
+                } catch (JsonProcessingException e) {
+                    throw new RuntimeException(e);
+                }
+
+                for (RewardVo item : items) {
+                    ItemsVo itemsVo = itemsService.queryById(item.getItemId());
+                    item.setItemName(itemsVo.getName());
+
+                    // 拼接 name*quantity 格式字符串
+                    if (prizeDisplayBuilder.length() > 0) {
+                        prizeDisplayBuilder.append(",");
+                    }
+                    prizeDisplayBuilder.append(item.getItemName())
+                        .append("*")
+                        .append(item.getQuantity());
+
+                }
+                resultRecord.setRewardJsonText(prizeDisplayBuilder.toString());
+                resultRecord.setRewardVoList(items);
+            }
+            Long isClaimed= resultRecord.getClaimed();
+            resultRecord.setClaimedText(RewardStatusEnum.getDescriptionByCode(String.valueOf(isClaimed)));
+        }
+        return resultRecords;
     }
 
     private LambdaQueryWrapper<RewardClaims> buildQueryWrapper(RewardClaimsBo bo) {

+ 15 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/RewardClaimsMapper.xml

@@ -21,7 +21,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             reward_claims ${ew.customSqlSegment}
     </select>
 
-
+    <select id="selectByCriteriaExport" resultType="org.dromara.business.domain.vo.RewardClaimsVo">
+        SELECT
+            id,
+            tournament_id,
+            player_id,
+            `rank`,
+            player_name,
+            phone,
+            reward_json,
+            claimed,
+            created_at,
+            updated_at
+        FROM reward_claims
+       ${ew.customSqlSegment}
+    </select>
 
     <!-- 插入数据:每个字段都做非空判断 -->
     <insert id="insert" useGeneratedKeys="true" keyProperty="id">