Эх сурвалжийг харах

feat(app): 优化赛事搜索功能

- 重构 AppGameMapper.xml 中的 SQL 查询,简化查询字段并优化关联查询
- 在 AppHomeServiceImpl 中添加赛事价格规则的处理逻辑,计算赛事类型
- 更新 SearchVO 中的 SearchRaceVO 类,增加赛事类型字段
- 优化课程信息的处理,添加销量字段并调整属性复制逻辑
SheepHy 2 долоо хоног өмнө
parent
commit
09f436ec15

+ 29 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/AppHomeServiceImpl.java

@@ -44,6 +44,8 @@ public class AppHomeServiceImpl implements IAppHomeService {
     private AppGameMapper appGameMapper;
     @Resource
     private AppSearchHotMapper appSearchHotMapper;
+    @Resource
+    private AppGamePriceRulesMapper appGamePriceRulesMapper;
 
     @Override
     public HomeVO homeInfo() {
@@ -284,9 +286,32 @@ public class AppHomeServiceImpl implements IAppHomeService {
         Page<SearchVO.SearchRaceVO> page = new Page<>(searchDTO.getCurrent(), searchDTO.getSize());
         Page<SearchVO.SearchRaceVO> searchCompetitionVOPage = appGameMapper.convertSearchCompetitionVOPage(page, searchDTO);
         searchCompetitionVOPage.getRecords().forEach(competitionVO -> {
-            AppSite appSite = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getOrgCode,competitionVO.getOrgCode()));
+            AppSite appSite = appSiteMapper.selectOne(
+                    Wrappers.<AppSite>lambdaQuery().eq(AppSite::getOrgCode, competitionVO.getOrgCode()));
+            competitionVO.setKm(PositionUtil.calculateDistance(
+                    searchDTO.getLatitude(), searchDTO.getLongitude(),
+                    appSite.getLatitude().doubleValue(), appSite.getLongitude().doubleValue()));
+            // 获取价格规则并判断 type
+            List<AppGamePriceRules> appGamePriceRules = appGamePriceRulesMapper.selectList(
+                    Wrappers.<AppGamePriceRules>lambdaQuery()
+                            .eq(AppGamePriceRules::getGameId, competitionVO.getId()));
+            int targetType = -1; // 默认无效状态
+            if (appGamePriceRules != null && !appGamePriceRules.isEmpty()) {
+                boolean hasType0 = appGamePriceRules.stream()
+                        .anyMatch(rule -> rule.getType() == 0);
+                boolean hasType1 = appGamePriceRules.stream()
+                        .anyMatch(rule -> rule.getType() == 1);
+                if (hasType0 && hasType1) {
+                    targetType = 2;
+                } else if (hasType0) {
+                    targetType = 0;
+                } else if (hasType1) {
+                    targetType = 1;
+                }
+            }
+            competitionVO.setType(targetType);
             competitionVO.setKm(PositionUtil.calculateDistance(searchDTO.getLatitude(), searchDTO.getLongitude(), appSite.getLatitude().doubleValue(), appSite.getLongitude().doubleValue()));
-
+            competitionVO.setCategory(getCategoryName(appSite.getCategoryId()));
         });
         return page;
     }
@@ -308,7 +333,8 @@ public class AppHomeServiceImpl implements IAppHomeService {
             List<SearchVO.SearchCoursesVO> courseInfoVOS = courses.stream()
                     .map(course -> {
                         SearchVO.SearchCoursesVO vo = new SearchVO.SearchCoursesVO();
-                        BeanUtils.copyProperties(vo, course);
+                        BeanUtils.copyProperties(course, vo);
+                        vo.setSales(666);
                         return vo;
                     })
                     .collect(Collectors.toList());

+ 3 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/SearchVO.java

@@ -83,16 +83,17 @@ public class SearchVO{
         private String id;
         @Schema(description = "名称")
         private String name;
-        @Schema(description = "课程原价")
-        private BigDecimal originalPrice;
         @Schema(description = "课程售价")
         private BigDecimal sellingPrice;
         @Schema(description = "图片")
         private String cover;
+        @Schema(description = "比赛类型;0个人、1团队、2混合")
+        private int type;
         @Schema(hidden = true)
         private String orgCode;
         @Schema(description = "类目")
         private String categoryId;
+        private List<String> category;
         @Schema(description = "开始时间")
         private java.util.Date startTime;
         @Schema(description = "结束时间")

+ 15 - 21
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppGameMapper.xml

@@ -3,29 +3,23 @@
 <mapper namespace="org.jeecg.modules.system.app.mapper.AppGameMapper">
     <select id="convertSearchCompetitionVOPage" resultType="org.jeecg.modules.app.vo.SearchVO$SearchRaceVO" parameterType="org.jeecg.modules.app.dto.SearchDTO">
         SELECT
-            a.id,
-            a.cover,
-            a.type,
-            COALESCE(g.min_original_price, 0) AS original_price,
-            COALESCE(g.min_selling_price, 0) AS selling_price,
-            a.address,
-            a.org_code AS orgCode
-            CASE
-                WHEN a.application_end_time >= NOW() THEN TRUE
-                ELSE FALSE
-                END AS isRegistrationOpen
+        a.id,
+        a.NAME,
+        COALESCE ( g.min_selling_price, 0 ) AS selling_price,
+        a.cover,
+        a.org_code,
+        a.start_time,
+        a.end_time,
+        CASE
+
+        WHEN a.application_end_time >= NOW() THEN
+        TRUE ELSE FALSE
+        END AS isRegistrationOpen
         FROM
-            nm_game a
-                LEFT JOIN (
-                SELECT
-                    game_id,
-                    MIN(original_price) AS min_original_price,
-                    MIN(selling_price) AS min_selling_price
-                FROM nm_game_peice_rules
-                GROUP BY game_id
-            ) g ON a.id = g.game_id
+        nm_game a
+        LEFT JOIN ( SELECT game_id, MIN( selling_price ) AS min_selling_price FROM nm_game_price_rules GROUP BY game_id ) g ON a.id = g.game_id
         WHERE
-            a.end_time > NOW()
+        a.end_time > NOW()
         <if test="searchDTO.keyword != null and searchDTO.keyword != ''">
             AND (a.name LIKE CONCAT('%',#{searchDTO.keyword},'%') OR a.address LIKE CONCAT('%',#{searchDTO.keyword},'%'))
         </if>