|
@@ -49,9 +49,9 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
@Resource
|
|
|
private AppGamePriceRulesMapper appGamePriceRulesMapper;
|
|
|
@Resource
|
|
|
- private AppOrderMapper appOrderMapper;
|
|
|
- @Resource
|
|
|
private EvaluateMapper evaluateMapper;
|
|
|
+ @Resource
|
|
|
+ private AppOrderProInfoMapper appOrderProInfoMapper;
|
|
|
|
|
|
@Override
|
|
|
public HomeVO homeInfo() {
|
|
@@ -101,36 +101,23 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
String str = appCategoryMapper.selectById(item).getName();
|
|
|
list.add(str);
|
|
|
});
|
|
|
- List<String> courseIds = appCoursesMapper.selectList(
|
|
|
- Wrappers.<AppCourses>lambdaQuery()
|
|
|
- .select(AppCourses::getId)
|
|
|
- .eq(AppCourses::getUserId, userId)
|
|
|
- ).stream()
|
|
|
- .map(AppCourses::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
AppSite appSite = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getOrgCode, appInstructor.getOrgCode()));
|
|
|
if(null != appSite){
|
|
|
instructorVO.setId(sysUser.getId())
|
|
|
.setAvatar(sysUser.getAvatar())
|
|
|
.setName(sysUser.getRealname()).setList(list)
|
|
|
- .setTeachingCount(appInstructor.getClassesNumber())
|
|
|
+ .setTeachingCount(getInstructorTeachingNum(userId))
|
|
|
.setOrgName(appSite.getName());
|
|
|
- if(!courseIds.isEmpty()){
|
|
|
- instructorVO.setOrderCount(appOrderMapper.findByOrderNumCount(courseIds));
|
|
|
- }else {
|
|
|
- instructorVO.setOrderCount(0L);
|
|
|
- }
|
|
|
+ instructorVO.setOrderCount((long) getInstructorOrderNum(userId));
|
|
|
}
|
|
|
-
|
|
|
// 获取该教练的课程(最多取2个)
|
|
|
List<AppCourses> courses = appCoursesMapper.selectList(
|
|
|
Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, userId).eq(AppCourses::getRackingStatus,0).last("LIMIT 2"));
|
|
|
-
|
|
|
List<InstructorVO.CourseInfoVO> courseInfoVOS = courses.stream()
|
|
|
.map(course -> {
|
|
|
InstructorVO.CourseInfoVO vo = new InstructorVO.CourseInfoVO();
|
|
|
BeanUtils.copyProperties(course,vo);
|
|
|
- vo.setCount(appOrderMapper.findByOrderNumCount(new ArrayList<>(Collections.singletonList(course.getId()))));
|
|
|
+ vo.setCount(appCoursesMapper.selectCount(Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, userId)));
|
|
|
vo.setSellingPrice(course.getSellingPrice());
|
|
|
return vo;
|
|
|
})
|
|
@@ -430,4 +417,61 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
});
|
|
|
return searchInstructorVOPage;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 根据教练ID获取教练订单数
|
|
|
+ * params
|
|
|
+ * @author SheepHy
|
|
|
+ * @date 2025/9/10
|
|
|
+ * return {@link }
|
|
|
+ **/
|
|
|
+ private int getInstructorOrderNum(String id) {
|
|
|
+ List<String> courseIds = appCoursesMapper.selectList(
|
|
|
+ Wrappers.<AppCourses>lambdaQuery()
|
|
|
+ .select(AppCourses::getId)
|
|
|
+ .eq(AppCourses::getUserId, id)
|
|
|
+ ).stream()
|
|
|
+ .map(AppCourses::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(courseIds.isEmpty()) return 0;
|
|
|
+ return Math.toIntExact(appOrderProInfoMapper.selectCount(
|
|
|
+ Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
+ .eq(AppOrderProInfo::getStatus,0)
|
|
|
+ .eq(AppOrderProInfo::getDelFlag,0)
|
|
|
+ .in(AppOrderProInfo::getProductId, courseIds)
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 根据教练ID获取授课人数(基于familyUserId去重统计)
|
|
|
+ * @param id 教练ID
|
|
|
+ * @author SheepHy
|
|
|
+ * @date 2025/9/10
|
|
|
+ * @return 去重后的授课人数
|
|
|
+ **/
|
|
|
+ private int getInstructorTeachingNum(String id) {
|
|
|
+ List<String> courseIds = appCoursesMapper.selectList(
|
|
|
+ Wrappers.<AppCourses>lambdaQuery()
|
|
|
+ .select(AppCourses::getId)
|
|
|
+ .eq(AppCourses::getUserId, id)
|
|
|
+ ).stream()
|
|
|
+ .map(AppCourses::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (courseIds.isEmpty()) return 0;
|
|
|
+ // 查询不重复的familyUserId数量
|
|
|
+ List<String> distinctFamilyUserIds = appOrderProInfoMapper.selectList(
|
|
|
+ Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
+ .select(AppOrderProInfo::getFamilyUserId)
|
|
|
+ .in(AppOrderProInfo::getProductId, courseIds)
|
|
|
+ .eq(AppOrderProInfo::getStatus, 0)
|
|
|
+ .eq(AppOrderProInfo::getDelFlag, 0)
|
|
|
+ .isNotNull(AppOrderProInfo::getFamilyUserId)
|
|
|
+ ).stream()
|
|
|
+ .map(AppOrderProInfo::getFamilyUserId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return distinctFamilyUserIds.size();
|
|
|
+ }
|
|
|
+
|
|
|
}
|