Browse Source

feat(app): 优化首页教练好评率展示逻辑

- 在 AppHomeController 中添加教练好评率查询逻辑- 修改 AppHomeServiceImpl 中的 coachList 查询条件,增加上架状态限制
- 更新 AppOrderMapper.xml 中的订单统计查询,增加订单状态限制
- 调整 InstructorVO 中的 goodRate 字段类型,从 BigDecimal 改为 Long
SheepHy 2 weeks ago
parent
commit
0ff625fee1

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

@@ -8,13 +8,17 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.app.dto.GetPlaceListDTO;
 import org.jeecg.modules.app.dto.SearchDTO;
+import org.jeecg.modules.app.dto.evaluate.FindEvaluateDTO;
+import org.jeecg.modules.app.dto.evaluate.FindEvaluatePage;
 import org.jeecg.modules.app.service.IAppHomeService;
 import org.jeecg.modules.app.service.IUserService;
 import org.jeecg.modules.app.vo.HomeVO;
 import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
 import org.jeecg.modules.app.vo.PlaceVO;
+import org.jeecg.modules.system.app.dto.evaluate.FindEvaluateResponseDTO;
 import org.jeecg.modules.system.app.entity.AppSearchHot;
+import org.jeecg.modules.system.app.service.IEvaluateService;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -29,11 +33,18 @@ public class AppHomeController {
     private IAppHomeService appHomeService;
     @Resource
     private IUserService userService;
+    @Resource
+    private IEvaluateService evaluateService;
 
     @GetMapping("/homeInfo")
     @Operation(summary = "首页基础数据查询")
     public Result<HomeVO> homeInfo() {
-        return Result.ok(appHomeService.homeInfo());
+        HomeVO homeVO = appHomeService.homeInfo();
+        homeVO.getInstructorList().forEach(instructorVO -> {
+            FindEvaluatePage<FindEvaluateResponseDTO> byOrderPage = evaluateService.findByOrderPage(new FindEvaluateDTO().setInstructorId(instructorVO.getId()));
+            instructorVO.setGoodRate(byOrderPage.getApplauseRate());
+        });
+        return Result.ok(homeVO);
     }
     /**
      * @Author SheepHy

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

@@ -124,7 +124,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
 
             // 获取该教练的课程(最多取2个)
             List<AppCourses> courses = appCoursesMapper.selectList(
-                    Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, userId).last("LIMIT 2"));
+                    Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, userId).eq(AppCourses::getRackingStatus,0).last("LIMIT 2"));
 
             List<InstructorVO.CourseInfoVO> courseInfoVOS = courses.stream()
                     .map(course -> {

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

@@ -24,7 +24,7 @@ public class InstructorVO {
     @Schema(description = "教学理念")
     private String teachingPhilosophy;
     @Schema(description = "好评率")
-    private BigDecimal goodRate;
+    private Long goodRate;
     @Schema(description = "订单数")
     private Long orderCount;
     @Schema(description = "授课人数")

+ 1 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppOrderMapper.xml

@@ -75,6 +75,7 @@
         SELECT COUNT(DISTINCT order_id)
         FROM nm_order_pro_info
         WHERE type = 5
+        AND order_status IN (1, 2)
         <if test="productIds != null and !productIds.isEmpty()">
             AND product_id IN
             <foreach collection="productIds" item="productId" open="(" separator="," close=")">