|
@@ -14,6 +14,7 @@ import org.jeecg.modules.app.vo.coach.AppCoachVO;
|
|
|
import org.jeecg.modules.app.vo.course.CourseRequestVo;
|
|
|
import org.jeecg.modules.app.vo.course.CourseResponseVo;
|
|
|
import org.jeecg.modules.system.app.entity.AppCategory;
|
|
|
+import org.jeecg.modules.system.app.entity.AppCourses;
|
|
|
import org.jeecg.modules.system.app.entity.AppOrder;
|
|
|
import org.jeecg.modules.system.app.entity.AppOrderProInfo;
|
|
|
import org.jeecg.modules.system.app.mapper.*;
|
|
@@ -28,6 +29,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Log4j2
|
|
@@ -98,21 +100,66 @@ public class CoachServiceImpl implements ICoachService {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- Long teachingCount=0L;
|
|
|
- Long orderNumCount=0L;
|
|
|
- List<String> byInstructorId = appCoursesMapper.findByInstructorId(appCoachDetailsVO.getUserId());
|
|
|
- //缺少授课人数和订单数,评价
|
|
|
- if (byInstructorId!=null&&!byInstructorId.isEmpty()){
|
|
|
- teachingCount= appOrderMapper.findByTeachingCount(byInstructorId);
|
|
|
- orderNumCount= appOrderMapper.findByOrderNumCount(byInstructorId);
|
|
|
- }
|
|
|
-
|
|
|
- appCoachDetailsVO.setClassesNumber(teachingCount);
|
|
|
- appCoachDetailsVO.setOrderNumber(orderNumCount);
|
|
|
+ appCoachDetailsVO.setClassesNumber((long) getInstructorTeachingNum(userId));
|
|
|
+ appCoachDetailsVO.setOrderNumber((long) getInstructorOrderNum(userId));
|
|
|
return Result.ok(appCoachDetailsVO);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @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();
|
|
|
+ }
|
|
|
/**
|
|
|
* @Author SheepHy
|
|
|
* @Description 计算当前课程年销售数
|