Explorar el Código

feat(app): 优化门店详情信息查询功能

- 添加课程信息查询功能
- 增加用户是否为第一次购买的判断
- 优化数据结构,支持不同类型的门店信息展示
- 添加评论查询的接口预留
SheepHy hace 2 semanas
padre
commit
dafa614866

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/AppHomeController.java

@@ -106,7 +106,7 @@ public class AppHomeController {
      * @return PlaceInfoVO {@link PlaceInfoVO}
      **/
     @GetMapping("/getPlaceInfo")
-    @Operation(summary = "门店详情信息查询")
+    @Operation(summary = "门店详情信息查询 ")
     public Result<PlaceInfoVO> getPlaceInfo(@RequestParam @Schema(description="门店ID") String id){
         return Result.ok(detailService.getPlaceInfo(id));
     }

+ 76 - 14
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/DetailServiceImpl.java

@@ -2,6 +2,8 @@ package org.jeecg.modules.app.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.log4j.Log4j2;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.app.service.IDetailService;
 import org.jeecg.modules.app.vo.CourseInfoVO;
 import org.jeecg.modules.app.vo.PlaceInfoVO;
@@ -33,11 +35,18 @@ public class DetailServiceImpl implements IDetailService {
     private AppSitePriceRulesMapper appSitePriceRulesMapper;
     @Resource
     private AppInstructorMapper appInstructorMapper;
+    @Resource
+    private AppOrderMapper appOrderMapper;
 
     @Override
     public PlaceInfoVO getPlaceInfo(String id) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         AppSite appSite = appSiteMapper.selectById(id);
         PlaceInfoVO placeInfo = appSiteMapper.getPlaceInfo(id);
+        AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery()
+                .eq(AppSitePriceRules::getSiteId, id)
+                .eq(AppSitePriceRules::getStatus, 0)
+                .last("limit 1"));
         List<PlaceInfoVO.InstructorVO> instructorVOList = new ArrayList<>();
         List<AppInstructor> appInstructors = appInstructorMapper.selectList(Wrappers.<AppInstructor>lambdaQuery()
                 .eq(AppInstructor::getOrgCode, appSite.getOrgCode()));
@@ -48,21 +57,44 @@ public class DetailServiceImpl implements IDetailService {
                 instructorVOList.add(vo);
             }
         }
-        AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery()
-                .eq(AppSitePriceRules::getSiteId, id)
-                .eq(AppSitePriceRules::getStatus, 0)
-                .last("limit 1"));
-        PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
-        placeInfoMsgVO.setName(appSite.getName())
-                .setSales(getPlaceSales(id))
-                .setOriginalPrice(appSitePriceRules.getOriginalPrice())
-                .setSellingPrice(appSitePriceRules.getSellingPrice());
-        placeInfo.setInstructorVOList(instructorVOList)
-                .setPlaceInfoMsgVO(placeInfoMsgVO);
-        //todo 评价查询待添加
-        return placeInfo;
+        List<PlaceInfoVO.CourseInfoVO> courseInfoVOList = new ArrayList<>();
+        appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery()
+                .eq(AppCourses::getSiteId, id)
+                .eq(AppCourses::getStatus, 0)
+                .eq(AppCourses::getDelFlag, 0)).forEach(appCourses -> {
+                PlaceInfoVO.CourseInfoVO courseInfoVO = new PlaceInfoVO.CourseInfoVO();
+                    BeanUtils.copyProperties(courseInfoVO, appCourses);
+                    courseInfoVO.setSales(getCourseSalesCount(appCourses.getId()));
+                    courseInfoVO.setSalesYear(getCourseSales(appCourses.getId()));
+                    courseInfoVO.setPriceType(isFirstPurchase(user.getId()));
+            courseInfoVOList.add(courseInfoVO);
+        });
+        placeInfo.setInstructorVOList(instructorVOList);
+        placeInfo.setCourseInfoVOList(courseInfoVOList);
+        if(appSite.getType() == 0){
+            //todo 评价查询待添加
+            PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
+            placeInfoMsgVO.setName(appSite.getName())
+                    .setSales(getPlaceSales(id))
+                    .setOriginalPrice(appSitePriceRules.getOriginalPrice())
+                    .setSellingPrice(appSitePriceRules.getSellingPrice());
+            placeInfo.setPlaceInfoMsgVO(placeInfoMsgVO);
+            return placeInfo;
+        }else if(appSite.getType() == 1){
+//            //todo 评价查询待添加
+            PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
+            placeInfoMsgVO.setName(appSite.getName())
+                    .setSales(getPlaceSales(id))
+                    .setOriginalPrice(appSitePriceRules.getOriginalPrice())
+                    .setSellingPrice(appSitePriceRules.getSellingPrice());
+            placeInfo.setPlaceInfoMsgVO(placeInfoMsgVO);
+            return placeInfo;
+        }else {
+            return null;
+        }
     }
 
+
     @Override
     public CourseInfoVO getCourseInfo(String id, double latitude, double longitude) {
         CourseInfoVO courseInfoVO = appCoursesMapper.getCourseInfo(id);
@@ -88,7 +120,7 @@ public class DetailServiceImpl implements IDetailService {
      * @Date 20:02 2025/7/7
      * @Param
      **/
-    public int getPlaceSales(String id) {
+    private int getPlaceSales(String id) {
         List<String> ids = appCoursesPriceRulesMapper.selectRuleIdsByCourseId(id);
         int totalOrders = 0;
         if (!ids.isEmpty()) {
@@ -120,4 +152,34 @@ public class DetailServiceImpl implements IDetailService {
                         .lt(AppOrderProduct::getCreateTime, Date.from(endOfYear.atZone(ZoneId.systemDefault()).toInstant())) // < 2026-01-01
         ));
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 计算当前课程销售数
+     * @Date 15:47 2025/7/8
+     * @Param id 课程id
+     * @return int 课程年销售数
+     **/
+    private int getCourseSalesCount(String id) {
+        return Math.toIntExact(appOrderProductMapper.selectCount(
+                Wrappers.<AppOrderProduct>lambdaQuery()
+                        .eq(AppOrderProduct::getProductId, id)
+        ));
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 查询用户是否为第一次购买
+     * @Date 16:54 2025/7/8
+     * @Param
+     * @return
+     **/
+    private int isFirstPurchase(String userId) {
+        AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getUpdateBy, userId).last("limit 1"));
+        if(null == appOrder){
+            return 1;
+        }else {
+            return 0;
+        }
+    }
 }

+ 5 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/PlaceInfoVO.java

@@ -40,9 +40,11 @@ public class PlaceInfoVO {
     @Schema(description = "视频")
     private String video;
     @Schema(description = "场地简约返回参数")
-    private PlaceInfoMsgVO placeInfoMsgVO;
+    private Object placeInfoMsgVO;
     @Schema(description = "教练简约返回参数")
     private List<InstructorVO> instructorVOList;
+    @Schema(description="课程返回参数")
+    private List<CourseInfoVO> courseInfoVOList;
     @Data
     @Accessors(chain = true)
     @EqualsAndHashCode(callSuper = false)
@@ -68,6 +70,8 @@ public class PlaceInfoVO {
         private String id;
         @Schema(description = "场地名称")
         private String name;
+        @Schema(description = "费用类型;0 精品 1免费 仅课程")
+        private Integer priceType;
         @Schema(description = "课程原价")
         private BigDecimal originalPrice;
         @Schema(description = "课程售价")