|  | @@ -1,16 +1,13 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.ArrayList;
 | 
	
		
			
				|  |  | -import java.util.Arrays;
 | 
	
		
			
				|  |  | -import java.util.Date;
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | -import java.util.Objects;
 | 
	
		
			
				|  |  | -import java.util.Set;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysConfigService;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
	
		
			
				|  | @@ -102,6 +99,10 @@ public class StudentManageServiceImpl implements StudentManageService {
 | 
	
		
			
				|  |  |      private SubjectChangeDao subjectChangeDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysConfigService sysConfigService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public PageInfo<StudentManageListDto> findStudentsByOrganId(StudentManageQueryInfo queryInfo) {
 | 
	
	
		
			
				|  | @@ -214,6 +215,62 @@ public class StudentManageServiceImpl implements StudentManageService {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | +    public PageInfo<StudentVipDouble11Dto> queryDouble11Students(StudentManageQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        PageInfo<StudentVipDouble11Dto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | +        Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +        MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Teacher teacher = teacherDao.get(queryInfo.getTeacherId());
 | 
	
		
			
				|  |  | +        if (Objects.isNull(teacher)) {
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Integer> organIds = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if (Objects.nonNull(teacher.getTeacherOrganId())) {
 | 
	
		
			
				|  |  | +            organIds.add(teacher.getTeacherOrganId());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotBlank(teacher.getFlowOrganRange())) {
 | 
	
		
			
				|  |  | +            List<Integer> flowOrganRangeIds = Arrays.stream(teacher.getFlowOrganRange().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            organIds.addAll(flowOrganRangeIds);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(organIds)) {
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        params.put("organIds", organIds);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<StudentVipDouble11Dto> dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        int count = studentPaymentOrderDao.countDouble11Students(params);
 | 
	
		
			
				|  |  | +        if (count > 0) {
 | 
	
		
			
				|  |  | +            pageInfo.setTotal(count);
 | 
	
		
			
				|  |  | +            params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | +            dataList = studentPaymentOrderDao.queryDouble11Students(params);
 | 
	
		
			
				|  |  | +            SysConfig vipSpecialActivityConfig = sysConfigService.findByParamName(SysConfigService.VIP_SPECIAL_ACTIVITY_IDS);
 | 
	
		
			
				|  |  | +            Map<Integer, StudentVipDouble11Dto> studentCourseTimeMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            if(Objects.nonNull(vipSpecialActivityConfig)&&StringUtils.isNotBlank(vipSpecialActivityConfig.getParanValue())){
 | 
	
		
			
				|  |  | +                Set<Integer> studentIds = dataList.stream().map(StudentVipDouble11Dto::getUserId).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | +                Set<Integer> specialActivityIds = Arrays.stream(vipSpecialActivityConfig.getParanValue().split(",")).map(Integer::valueOf).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | +                List<StudentVipDouble11Dto> studentCourseTimeList = courseScheduleStudentPaymentDao.countStudentDouble11CourseTime(new ArrayList<>(studentIds), new ArrayList<>(specialActivityIds));
 | 
	
		
			
				|  |  | +                studentCourseTimeMap = studentCourseTimeList.stream().collect(Collectors.toMap(StudentVipDouble11Dto::getUserId, s -> s));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for (StudentVipDouble11Dto studentVipDouble11Dto : dataList) {
 | 
	
		
			
				|  |  | +                StudentVipDouble11Dto studentCourseTime = studentCourseTimeMap.get(studentVipDouble11Dto.getUserId());
 | 
	
		
			
				|  |  | +                studentVipDouble11Dto.setCourseOneToOneTime(studentVipDouble11Dto.getPaymentOneToOneTime()*20-(Objects.isNull(studentCourseTime)?0:studentCourseTime.getCourseOneToOneTime()));
 | 
	
		
			
				|  |  | +                if(studentVipDouble11Dto.getCourseOneToOneTime()<0){
 | 
	
		
			
				|  |  | +                    studentVipDouble11Dto.setCourseOneToOneTime(0);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                studentVipDouble11Dto.setCourseOneToTwoTime(studentVipDouble11Dto.getPaymentOneToTwoTime()*20-(Objects.isNull(studentCourseTime)?0:studentCourseTime.getCourseOneToTwoTime()));
 | 
	
		
			
				|  |  | +                if(studentVipDouble11Dto.getCourseOneToTwoTime()<0){
 | 
	
		
			
				|  |  | +                    studentVipDouble11Dto.setCourseOneToTwoTime(0);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return pageInfo;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  |      public StudentManageListDto findStudentManageBaseInfo(Integer userId) {
 | 
	
		
			
				|  |  |          return studentManageDao.findStudentBaseInfoByUserID(userId);
 | 
	
		
			
				|  |  |      }
 |