Kaynağa Gözat

refactor(app): 优化课程数量统计逻辑

- 将 AppHomeServiceImpl 中的课程数量统计方法改为使用 appOrderMapper 的 findByOrderNumCount 方法
- 更新 AppOrderMapper.xml 中的 findByOrderNumCount SQL 查询,将 order_type 改为 type
- 在 InstructorVO.CourseInfoVO 中将 count 字段类型从 int 改为 Long
SheepHy 3 hafta önce
ebeveyn
işleme
d157ab21e8

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

@@ -18,10 +18,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static org.jeecg.common.constant.CommonConstant.INSTRUCTOR;
@@ -128,8 +125,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
                     .map(course -> {
                         InstructorVO.CourseInfoVO vo = new InstructorVO.CourseInfoVO();
                         BeanUtils.copyProperties(course,vo);
-                        vo.setCount(Math.toIntExact(appCoursesMapper.selectCount(Wrappers.<AppCourses>lambdaQuery()
-                                .eq(AppCourses::getUserId, userId))));
+                        vo.setCount(appOrderMapper.findByOrderNumCount(new ArrayList<>(Collections.singletonList(course.getId()))));
                         vo.setSellingPrice(course.getSellingPrice());
                         return vo;
                     })

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

@@ -53,7 +53,7 @@ public class InstructorVO {
         @Schema(description = "课程简介")
         private String intro;
         @Schema(description = "课程数量")
-        private int count;
+        private Long count;
     }
 
 }

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

@@ -65,7 +65,7 @@
     </select>
     <select id="findByOrderNumCount" resultType="java.lang.Long">
         select count(DISTINCT  order_id)  from nm_order_pro_info
-        where order_type = 5 and product_id in
+        where type = 5 and product_id in
         <foreach collection="productIds" item="productId" open="(" separator="," close=")">
             #{productId}
         </foreach>