Browse Source

管乐迷需求迭代

zouxuan 2 năm trước cách đây
mục cha
commit
ad0e7c4d19

+ 8 - 7
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -211,15 +211,10 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
     int getOrganTotalCloudStudyLivelyStudentNum(@Param("organIds") List<Integer> organIds, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
     List<Map<Integer, Integer>> getOrganCloudStudyLivelyStudentNum(@Param("organIds") List<Integer> organIds);
     
-    List<IndexCloudStudyListDto> getCloudStudyStudentOverViewList(@Param("organIds") List<Integer> organIds);
-
-    List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList1(@Param("organIds") List<Integer> organIds);
+    List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList(@Param("organIds") List<Integer> organIds);
     
-    List<Mapper> getOrganActiveCloudStudyStudentNum(@Param("organIds") List<Integer> organIds, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
-    List<Map<Integer,Long>> getOrganActiveCloudStudyStudentNum1(@Param("organIds") List<Integer> organIds, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+    List<Map<Integer,Long>> getOrganActiveCloudStudyStudentNum(@Param("organIds") List<Integer> organIds, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
     
-    List<Mapper> getOrganCloudTeacherStudentNum(@Param("organIds") List<Integer> organIds);
-
     /**
      * @describe 查询云教练学员列表数据
      * @author Joburgess
@@ -350,6 +345,12 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
     List<CloudTeacherSumDto> cloudTeacherSum(@Param("queryInfo") StudentCourseConsumerQueryInfo queryInfo);
 
     //统计训练时长
+    int countCloudTeacherSumDetail(Map<String, Object> params);
+
+    //统计训练时长
+    List<CloudTeacherSumDto> queryCloudTeacherSumDetail(Map<String, Object> params);
+
+    //统计训练时长
     int countTeacherSum(@Param("queryInfo") StudentCourseConsumerQueryInfo queryInfo);
 
     //统计重复购买人数

+ 5 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CloudStudyStudentDataDto.java

@@ -30,7 +30,7 @@ public class CloudStudyStudentDataDto {
     private int eVipStudentNum;
 
     @ApiModelProperty("付费会员占比")
-    private float vipStudentDuty;
+    private double vipStudentRate;
 
     @ApiModelProperty("云教练使用人数")
     private int cloudStudyUseStudentNum;
@@ -120,12 +120,12 @@ public class CloudStudyStudentDataDto {
         this.eVipStudentNum = eVipStudentNum;
     }
 
-    public float getVipStudentDuty() {
-        return vipStudentDuty;
+    public double getVipStudentRate() {
+        return vipStudentRate;
     }
 
-    public void setVipStudentDuty(float vipStudentDuty) {
-        this.vipStudentDuty = vipStudentDuty;
+    public void setVipStudentRate(double vipStudentRate) {
+        this.vipStudentRate = vipStudentRate;
     }
 
     public int getCloudStudyUseStudentNum() {

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexCloudStudySumDto.java

@@ -27,6 +27,28 @@ public class IndexCloudStudySumDto {
 	//重复购买人数
 	private Integer againBuyNum = 0;
 
+	//重复购买率
+	private double againBuyRate;
+
+	//购买率
+	private double buyRate;
+
+	public double getAgainBuyRate() {
+		return againBuyRate;
+	}
+
+	public void setAgainBuyRate(double againBuyRate) {
+		this.againBuyRate = againBuyRate;
+	}
+
+	public double getBuyRate() {
+		return buyRate;
+	}
+
+	public void setBuyRate(double buyRate) {
+		this.buyRate = buyRate;
+	}
+
 	public Integer getOrganId() {
 		return organId;
 	}

+ 20 - 12
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/DegreeRegistration.java

@@ -86,12 +86,6 @@ public class DegreeRegistration extends BaseEntity {
     @ApiModelProperty(value = "1乐器考级、2乐理考级",required = true)
     private Integer type;
 
-    /**
-     * 乐理级别
-     */
-//    @ApiModelProperty(value = "乐理级别",required = true)
-//    private String theoryLevel;
-
 
     /**
      * 乐理级别证书
@@ -118,12 +112,6 @@ public class DegreeRegistration extends BaseEntity {
     private String memo;
 
     /**
-     * 乐理费用
-     */
-//    @ApiModelProperty(value = "乐理费用",required = true)
-//    private BigDecimal theoryMoney;
-
-    /**
      * 报名时间
      */
     private Date createTime;
@@ -154,6 +142,26 @@ public class DegreeRegistration extends BaseEntity {
 
     private String activityTag;
 
+    private String vipTeacherName;
+
+    private String normalTeacherName;
+
+    public String getVipTeacherName() {
+        return vipTeacherName;
+    }
+
+    public void setVipTeacherName(String vipTeacherName) {
+        this.vipTeacherName = vipTeacherName;
+    }
+
+    public String getNormalTeacherName() {
+        return normalTeacherName;
+    }
+
+    public void setNormalTeacherName(String normalTeacherName) {
+        this.normalTeacherName = normalTeacherName;
+    }
+
     public Integer getType() {
         return type;
     }

+ 0 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/DegreeRegistrationService.java

@@ -18,14 +18,8 @@ public interface DegreeRegistrationService extends BaseService<Integer, DegreeRe
 
     String ACTIVITY_TAG = "DEGREE_REGISTRATION_2020_12";
 
-    Set<String> FREE_PRICE_LEVEL = new HashSet<>(Arrays.asList(new String[]{"一级", "二级", "三级"}));
-
-    Date ACTIVITY_END_TIME = DateUtil.stringToDate("2021-02-15 23:59:59", "yyyy-MM-dd HH:mm:ss");
-
     HttpResponseResult pay(DegreeRegistrationActivityDto degreeRegistration) throws Exception;
 
-//    HttpResponseResult theoryPay(DegreeRegistrationActivityDto degreeRegistration) throws Exception;
-
     Boolean updateStatus(StudentPaymentOrder order);
 
     PageInfoDegree<DegreeRegistration> getPageList(DegreeQueryInfo queryInfo);

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/StudentService.java

@@ -126,8 +126,6 @@ public interface StudentService extends BaseService<Integer, Student> {
 
     CloudStudyStudentDataDto getCloudStudyStudentOverView(List<Integer> organIds);
     
-    List<IndexCloudStudyListDto> getCloudStudyStudentOverViewList(List<Integer> organIds);
-
     /**
      * @describe 清理学员云教练连续使用天数
      * @author Joburgess
@@ -195,5 +193,7 @@ public interface StudentService extends BaseService<Integer, Student> {
     //统计训练时长
     List<CloudTeacherSumDto> cloudTeacherSum(StudentCourseConsumerQueryInfo queryInfo);
 
-    List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList1(List<Integer> organIdsList);
+    PageInfo<CloudTeacherSumDto> cloudTeacherSumDetail(StudentCourseConsumerQueryInfo queryInfo);
+
+    List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList(List<Integer> organIdsList);
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentTeacherMapperService.java

@@ -1,9 +1,14 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.StudentTeacherMapper;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface StudentTeacherMapperService extends BaseService<Integer, StudentTeacherMapper>{
 
     void init();
+
+    void updateStudentTeacherMapper(List<CourseSchedule> courseScheduleList);
 }

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -173,7 +173,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     @Autowired
 	private VipGroupCategoryDao vipGroupCategoryDao;
     @Autowired
-	private StudentService studentService;
+	private StudentTeacherMapperService studentTeacherMapperService;
     @Autowired
 	private CourseScheduleConvertDao courseScheduleConvertDao;
 
@@ -4129,6 +4129,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 		if (updateList.size() > 0) {
             courseScheduleDao.batchUpdate(updateList);
+			//更新用户网管、vip课老师
+//			studentTeacherMapperService.updateStudentTeacherMapper(updateList);
 			try {
 				tenantAssetsInfoService.deductAmount(updateList);
 			}catch (Exception e){

+ 10 - 195
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -50,6 +50,8 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
     @Autowired
     private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private StudentTeacherMapperDao studentTeacherMapperDao;
 
     @Override
     public BaseDAO<Integer, DegreeRegistration> getDAO() {
@@ -201,200 +203,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         studentPaymentOrderService.update(studentPaymentOrder);
         return BaseController.succeed(payMap);
     }
-/*
-
-    @Override
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public HttpResponseResult theoryPay(DegreeRegistrationActivityDto degreeRegistration) throws Exception {
-        studentDao.getLocked(degreeRegistration.getUserId());
-
-        List<DegreeRegistration> userLevelDegrees = degreeRegistrationDao.getUserLevelDegrees(degreeRegistration.getUserId(), ACTIVITY_TAG,degreeRegistration.getDegreeType(),degreeRegistration.getSporadicId());
-
-        long endTheoryLevelNum = userLevelDegrees.stream().filter(d -> StringUtils.isNotBlank(d.getTheoryLevel())&&d.getStatus().equals(2)).count();
-        long ingTheoryLevelNum = userLevelDegrees.stream().filter(d -> StringUtils.isNotBlank(d.getTheoryLevel())&&d.getStatus().equals(1)).count();
-
-        if(StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())&&endTheoryLevelNum>0){
-            throw new BizException("您已报考过选择的考级项目");
-        }
-
-        degreeRegistration.setActivityTag(ACTIVITY_TAG);
-
-        Date nowDate = new Date();
-
-        if(ACTIVITY_END_TIME.compareTo(nowDate)<0){
-            throw new BizException("活动已截至");
-        }
-
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
-        degreeRegistration.setMoney(BigDecimal.ZERO);
-
-        List<String> courseInfos = new ArrayList<>();
-
-        if("免考".equals(degreeRegistration.getTheoryLevel())){
-            degreeRegistration.setTheoryLevel(null);
-        }
-        if(StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())){
-            degreeRegistration.setOrderNo(orderNo);
-            BigDecimal theoryMoney = BigDecimal.ZERO;
-            switch (degreeRegistration.getTheoryLevel()) {
-                case "一级":
-                    theoryMoney = new BigDecimal(200);
-                    break;
-                case "二级":
-                    theoryMoney = new BigDecimal(240);
-                    break;
-                case "三级":
-                    theoryMoney = new BigDecimal(280);
-                    break;
-                case "四级":
-                    theoryMoney = new BigDecimal(320);
-                    break;
-                default:
-                    throw new BizException("您选择的乐理级别不存在,请核对");
-            }
-            degreeRegistration.setTheoryMoney(theoryMoney);
-        }else{
-            degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
-        }
-
-        if(Objects.nonNull(degreeRegistration.getSporadicId())||StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())){
-            degreeRegistration.setStatus(1);
-            degreeRegistration.setCreateTime(nowDate);
-            degreeRegistration.setUpdateTime(nowDate);
-            degreeRegistrationDao.insert(degreeRegistration);
-
-            List<DegreeRegistration> updateDegrees = new ArrayList<>();
-            if(ingTheoryLevelNum>0){
-                for (DegreeRegistration userLevelDegree : userLevelDegrees) {
-                    if(Objects.nonNull(userLevelDegree.getSporadicId())&&Objects.nonNull(userLevelDegree.getSporadicId())){
-                        userLevelDegree.setStatus(0);
-                        updateDegrees.add(userLevelDegree);
-                    }
-                    if(Objects.nonNull(userLevelDegree.getTheoryLevel())&&StringUtils.isNotBlank(userLevelDegree.getTheoryLevel())){
-                        userLevelDegree.setStatus(0);
-                        updateDegrees.add(userLevelDegree);
-                    }
-                }
-                if(!CollectionUtils.isEmpty(updateDegrees)){
-                    degreeRegistrationDao.batchUpdate(updateDegrees);
-                }
-            }
-        }
-
-        BigDecimal additionCoursePrice = new BigDecimal("0");
-        if(Objects.nonNull(degreeRegistration.getAdditionCourseInfo())){
-            Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo = degreeRegistration.getAdditionCourseInfo();
-            PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(degreeRegistration.getOrganId());
-            if(Objects.isNull(practiceGroupSellPrice)){
-                throw new BizException("该分部暂未参与此活动");
-            }
-
-            BigDecimal practiceUnitPrice = practiceGroupSellPrice.getOnceOriginalPrice(),
-                    vipUnitPrice = practiceGroupSellPrice.getVipOneStudentTwelveCourseOriginalPriceWithNewUser(),
-                    highUnitPrice = practiceGroupSellPrice.getHighOnlineTenCourseOriginalPriceWithNewUser();
-
-            for (Map.Entry<CourseSchedule.CourseScheduleType, Integer> courseScheduleTypeIntegerEntry : additionCourseInfo.entrySet()) {
-                BigDecimal courseTime = new BigDecimal(courseScheduleTypeIntegerEntry.getValue());
-                switch (courseScheduleTypeIntegerEntry.getKey()){
-                    case VIP:
-                        BigDecimal vipPrice = vipUnitPrice.multiply(courseTime);
-                        additionCoursePrice = additionCoursePrice.add(vipPrice);
-                        courseInfos.add((courseTime.multiply(new BigDecimal(12)))+"节VIP-1V1课程费用:" + vipPrice);
-                        break;
-                    case PRACTICE:
-                        BigDecimal practicePrice = practiceUnitPrice.multiply(courseTime);
-                        additionCoursePrice = additionCoursePrice.add(practicePrice);
-                        courseInfos.add((courseTime.multiply(new BigDecimal(12)))+"节1V1网管课课程费用:" + practicePrice);
-                        break;
-                    case HIGH:
-                        BigDecimal highPrice = highUnitPrice.multiply(courseTime);
-                        additionCoursePrice = additionCoursePrice.add(highPrice);
-                        courseInfos.add((courseTime.multiply(new BigDecimal(10)))+"节乐理课程费用:" + highPrice);
-                        break;
-                }
-            }
-        }
-
-        BigDecimal amount = degreeRegistration.getMoney();
-        amount = amount.add(degreeRegistration.getTheoryMoney());
-        amount = amount.add(additionCoursePrice);
-
-        if(amount.compareTo(degreeRegistration.getPrice())!=0){
-            throw new BizException("商品价格不符");
-        }
-
-        OrderTypeEnum type = OrderTypeEnum.DEGREE_REGISTRATION;
-
-        Integer userId = degreeRegistration.getUserId();
-        String channelType = "";
-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-        studentPaymentOrder.setUserId(userId);
-        studentPaymentOrder.setGroupType(GroupType.SPORADIC);
-        studentPaymentOrder.setOrderNo(orderNo);
-        studentPaymentOrder.setType(type);
-        studentPaymentOrder.setExpectAmount(amount);
-        studentPaymentOrder.setActualAmount(amount);
-        studentPaymentOrder.setStatus(DealStatusEnum.ING);
-        studentPaymentOrder.setClassGroupId(degreeRegistration.getId());
-        if(Objects.nonNull(degreeRegistration.getSporadicId())){
-            studentPaymentOrder.setMusicGroupId(degreeRegistration.getSporadicId().toString());
-        }
-        studentPaymentOrder.setOrganId(degreeRegistration.getOrganId());
-        studentPaymentOrder.setRoutingOrganId(degreeRegistration.getOrganId());
-        if (StringUtils.isNotBlank(degreeRegistration.getTheoryLevel())) {
-            courseInfos.add("乐理" + degreeRegistration.getTheoryLevel() + ",费用:" + degreeRegistration.getTheoryMoney());
-        }
-        studentPaymentOrder.setMemo(StringUtils.join(courseInfos, ";"));
-        studentPaymentOrderService.insert(studentPaymentOrder);
-        studentPaymentOrder.setVersion(0);
-
-        if(BigDecimal.ZERO.compareTo(additionCoursePrice)<0){
-            StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-            studentPaymentOrderDetail.setType(OrderDetailTypeEnum.DEGREE_REGISTRATION);
-            if(Objects.nonNull(degreeRegistration.getAdditionCourseInfo())){
-                studentPaymentOrderDetail.setGoodsIdList(JSON.toJSONString(degreeRegistration.getAdditionCourseInfo()));
-            }
-            studentPaymentOrderDetail.setPrice(additionCoursePrice);
-            studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
-            studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-            studentPaymentOrderDetail.setCreateTime(nowDate);
-            studentPaymentOrderDetail.setUpdateTime(nowDate);
-            studentPaymentOrderDetailDao.insert(studentPaymentOrderDetail);
-        }
-
-        if (amount.compareTo(BigDecimal.ZERO) == 0) {
-            Map<String, String> notifyMap = new HashMap<>();
-            notifyMap.put("tradeState", "1");
-            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
-            notifyMap.put("channelType", channelType);
-            notifyMap.put("orderNo", "");
-            studentPaymentOrderService.updateOrder(notifyMap);
-            return BaseController.failed(HttpStatus.CREATED, notifyMap,"恭喜您,支付成功!");
-        }
-
-        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-
-        String receiver = "kjRegister";
-        Map payMap = payService.getPayMap(
-                amount,
-                BigDecimal.ZERO,
-                orderNo,
-                baseApiUrl + "/api-student/studentOrder/notify",
-                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
-                "乐理考级报名活动",
-                "乐理考级报名活动",
-                degreeRegistration.getOrganId(),
-                receiver
-        );
-
-        studentPaymentOrder.setOrganId(degreeRegistration.getOrganId());
-        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
-        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
-        studentPaymentOrder.setUpdateTime(nowDate);
-        studentPaymentOrderService.update(studentPaymentOrder);
-        return BaseController.succeed(payMap);
-    }*/
 
     @Override
     public Boolean updateStatus(StudentPaymentOrder studentPaymentOrder) {
@@ -447,12 +255,19 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         MapUtil.populateMap(params, queryInfo);
 
         List<DegreeRegistration> dataList = new ArrayList<>();
-        int count = this.findCount(params);
+        int count = degreeRegistrationDao.queryCount(params);
 
         if (count > 0) {
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             dataList = degreeRegistrationDao.queryPage(params);
+            List<Integer> userIds = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+            Map<Integer,String> vipTeacherMapper = MapUtil.convertMybatisMap(studentTeacherMapperDao.queryTeacherMapper(userIds,"VIP"));
+            Map<Integer,String> teacherMapper = MapUtil.convertMybatisMap(studentTeacherMapperDao.queryTeacherMapper(userIds,"NORMAL"));
+            for (DegreeRegistration degreeRegistration : dataList) {
+                degreeRegistration.setVipTeacherName(vipTeacherMapper.get(degreeRegistration.getUserId()));
+                degreeRegistration.setNormalTeacherName(teacherMapper.get(degreeRegistration.getUserId()));
+            }
             DegreeRegistration degree = degreeRegistrationDao.getTotalAmount(params);
             pageInfo.setApplyNum(degreeRegistrationDao.countApplyNum(params));
             pageInfo.setTotalAmount(degree.getMoney());

+ 43 - 109
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -31,7 +31,6 @@ import javax.annotation.PostConstruct;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.*;
-import java.util.Map.Entry;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.BiFunction;
 import java.util.stream.Collectors;
@@ -50,8 +49,6 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
     @Autowired
-    private StudentStatisticsDao studentStatisticsDao;
-    @Autowired
     private MusicGroupDao musicGroupDao;
     @Autowired
     private PracticeGroupDao practiceGroupDao;
@@ -964,81 +961,10 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     @Override
     public CloudStudyStudentDataDto getCloudStudyStudentOverView(List<Integer> organIds) {
         CloudStudyStudentDataDto result = new CloudStudyStudentDataDto();
-//        result.setCloudStudyUseStudentNum(studentDao.getOrgansTotalCloudStudyStudentNum(organIds));
         result.setCloudStudyTodayUseStudentNum(studentDao.getOrgansTodayTotalCloudStudyStudentNum(organIds));
         return result;
     }
 
-    @Override
-	public List<IndexCloudStudyListDto> getCloudStudyStudentOverViewList(List<Integer> organIds) {
-    	
-    	List<IndexCloudStudyListDto> list = studentDao.getCloudStudyStudentOverViewList(organIds);
-    	
-    	Calendar cal = Calendar.getInstance();    
-        cal.setTime(new Date());    
-        //cal.add(Calendar.WEEK_OF_YEAR, -1);// 一周    
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
-        Date endTime = cal.getTime();
-        
-        cal.setTime(new Date());    
-        cal.add(Calendar.WEEK_OF_YEAR, -4);// 一周    
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
-        Date startTime = cal.getTime();
-        
-        List<Mapper> mapperList = studentDao.getOrganActiveCloudStudyStudentNum(organIds, startTime, endTime);
-        
-        Map<Integer, Integer> organActiveNum = new HashMap<Integer, Integer>();
-        for(Mapper mapper : mapperList){
-        	organActiveNum.put(Integer.parseInt(mapper.getKey().toString()), Integer.parseInt(mapper.getValue().toString()));
-        }
-        
-        List<Mapper> organCloudTeacherStudentNum = studentDao.getOrganCloudTeacherStudentNum(organIds);
-        Map<Integer, Integer> organCloudTeacherStudentNumMap = new HashMap<Integer, Integer>();
-        for(Mapper mapper : organCloudTeacherStudentNum){
-        	organCloudTeacherStudentNumMap.put(Integer.parseInt(mapper.getKey().toString()), Integer.parseInt(mapper.getValue().toString()));
-        }
-
-        List<StudentOrganDto> set1 = studentRegistrationDao.queryEffectiveStudent(organIds);
-        List<StudentOrganDto> set2 = courseScheduleStudentPaymentDao.queryRemainCourseStudent(organIds);
-        List<StudentOrganDto> set3 = studentStatisticsDao.queryNoScheduleNumStudent(organIds);
-        
-        Map<Integer,Set<Integer>> map1= set1.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
-        Map<Integer,Set<Integer>> map2= set2.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
-        Map<Integer,Set<Integer>> map3= set3.stream().collect(Collectors.groupingBy(StudentOrganDto :: getOrganId, Collectors.mapping(StudentOrganDto :: getUserId, Collectors.toSet())));
-        
-        Map<Integer,Set<Integer>> organStudentMap = new HashMap<Integer, Set<Integer>>(map1);
-        Set<Integer> temp = null;
-        for(Entry<Integer, Set<Integer>> entry : map2.entrySet()){
-        	temp = organStudentMap.get(entry.getKey());
-        	if(temp == null){
-        		organStudentMap.put(entry.getKey(), entry.getValue());
-        	}else{
-        		temp.addAll(entry.getValue());
-        		organStudentMap.put(entry.getKey(), temp);
-        	}
-        }
-        for(Entry<Integer, Set<Integer>> entry : map3.entrySet()){
-        	temp = organStudentMap.get(entry.getKey());
-        	if(temp == null){
-        		organStudentMap.put(entry.getKey(), entry.getValue());
-        	}else{
-        		temp.addAll(entry.getValue());
-        		organStudentMap.put(entry.getKey(), temp);
-        	}
-        }
-        
-        for(IndexCloudStudyListDto ics : list){
-        	ics.setActiveStudentNum(organActiveNum.get(ics.getOrganId()) == null ? 0 : organActiveNum.get(ics.getOrganId()));
-        	ics.setVipStudentNum(organCloudTeacherStudentNumMap.get(ics.getOrganId()) == null ? 0 : organCloudTeacherStudentNumMap.get(ics.getOrganId()));
-        	ics.setEffectiveStudentNum(organStudentMap.get(ics.getOrganId()) == null ? 0 : organStudentMap.get(ics.getOrganId()).size());
-        	if(ics.getEffectiveStudentNum() > 0){
-        		ics.setVipStudentRate(ics.getVipStudentNum() * 100d / ics.getEffectiveStudentNum());
-        	}
-        }
-        
-		return list;
-	}
-
 	@Override
     public void cleanStudentCloudStudySequenceDays() {
         studentDao.cleanStudentCloudStudySequenceDays();
@@ -1056,17 +982,9 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         }
         List<CloudTeacherActiveTargetDto> targetDtoList = JSONArray.parseArray(cloudTeacherActiveTarget, CloudTeacherActiveTargetDto.class);
         Map<Integer, List<CloudTeacherActiveTargetDto>> targetMap = targetDtoList.stream().collect(Collectors.groupingBy(e -> e.getOrganId()));
-        //获取各分部总人数
-//        List<Map<String, Long>> maps = indexBaseMonthDataDao.countTotalStudentNum();
-//        Map<String, Long> organStudentNumMap = new HashMap<>(20);
-//        if(maps != null && maps.size() > 0){
-//            organStudentNumMap = MapUtil.convertIntegerMap(maps);
-//        }
         params.put("organIdList",organIdList);
         List<CloudTeacherActiveTargetDto> resultList = indexBaseMonthDataDao.countCloudTeacherActive(params);
         for (CloudTeacherActiveTargetDto dto : resultList) {
-//            Long aLong = organStudentNumMap.get(dto.getOrganId().toString());
-//            dto.setTotalNum(aLong==null?0:aLong.intValue());
             List<CloudTeacherActiveTargetDto> targetDtos = targetMap.get(dto.getOrganId());
             if(targetDtos != null && targetDtos.size() > 0){
                 CloudTeacherActiveTargetDto target = targetDtos.get(0);
@@ -1097,22 +1015,15 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         resultMap.put("buyAmount",buyAmount);
         Integer buyNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getBuyNum).sum();
         resultMap.put("buyNum",buyNum);
-//        Integer totalNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getTotalNum).sum();
-//        resultMap.put("totalNum",totalNum);
         Integer targetNum = resultList.stream().mapToInt(CloudTeacherActiveTargetDto::getTargetNum).sum();
         resultMap.put("targetNum",targetNum);
         resultMap.put("avgBuyAmount",0);
-//        resultMap.put("buyScale",0);
         resultMap.put("targetFinishScale",0);
         resultMap.put("targetAmountFinishScale",0);
         if(buyAmount.doubleValue() > 0d && buyNum > 0){
             BigDecimal avgBuyAmount = buyAmount.divide(new BigDecimal(buyNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
             resultMap.put("avgBuyAmount",avgBuyAmount);
         }
-//        if(totalNum > 0 && buyNum > 0){
-//            BigDecimal buyScale = new BigDecimal(buyNum).divide(new BigDecimal(totalNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
-//            resultMap.put("buyScale",buyScale);
-//        }
         if(targetNum > 0 && buyNum > 0){
             BigDecimal targetFinishScale = new BigDecimal(buyNum).divide(new BigDecimal(targetNum), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
             resultMap.put("targetFinishScale",targetFinishScale);
@@ -1150,20 +1061,6 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
                     resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getAvgBuyAmount)).collect(Collectors.toList());
                 }
                 break;
-//            case "totalNum":
-//                if("DESC".equalsIgnoreCase(order)){
-//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTotalNum,Comparator.reverseOrder())).collect(Collectors.toList());
-//                }else {
-//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTotalNum)).collect(Collectors.toList());
-//                }
-//                break;
-//            case "buyScale":
-//                if("DESC".equalsIgnoreCase(order)){
-//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyScale,Comparator.reverseOrder())).collect(Collectors.toList());
-//                }else {
-//                    resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getBuyScale)).collect(Collectors.toList());
-//                }
-//                break;
             case "targetNum":
                 if("DESC".equalsIgnoreCase(order)){
                     resultList = resultList.stream().sorted(Comparator.comparing(CloudTeacherActiveTargetDto::getTargetNum,Comparator.reverseOrder())).collect(Collectors.toList());
@@ -1314,8 +1211,42 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     }
 
     @Override
-    public List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList1(List<Integer> organIdsList) {
-        List<IndexCloudStudySumDto> list = studentDao.getCloudStudyStudentOverViewList1(organIdsList);
+    public PageInfo<CloudTeacherSumDto> cloudTeacherSumDetail(StudentCourseConsumerQueryInfo queryInfo) {
+        PageInfo<CloudTeacherSumDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Date date = DateUtil.stringToDate(queryInfo.getStartDate(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
+        Date date2 = DateUtil.stringToDate(queryInfo.getEndDate(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
+        long weekBetween = DateUtil.weekBetween(date, date2);
+        queryInfo.setWeekBetween(weekBetween);
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<CloudTeacherSumDto> dataList = null;
+        int count = studentDao.countCloudTeacherSumDetail(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = studentDao.queryCloudTeacherSumDetail(params);
+            BigDecimal decimal = new BigDecimal(100);
+            for (CloudTeacherSumDto dto : dataList) {
+                if(dto.getNormalNum().compareTo(BigDecimal.ZERO) == 0){
+                    continue;
+                }
+                BigDecimal normalNum = dto.getNormalNum();
+                dto.setAvgTrainTime(dto.getTrainTotalTime().divide(normalNum,2, BigDecimal.ROUND_DOWN));
+                dto.setTrainRate(dto.getTrainStudentNum().divide(normalNum,2, BigDecimal.ROUND_DOWN).multiply(decimal));
+                dto.setTrainStandRate(dto.getTrain0().divide(normalNum,2, BigDecimal.ROUND_DOWN).multiply(decimal));
+            }
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    public List<IndexCloudStudySumDto> getCloudStudyStudentOverViewList(List<Integer> organIdsList) {
+        List<IndexCloudStudySumDto> list = studentDao.getCloudStudyStudentOverViewList(organIdsList);
         Set<Integer> organIds = list.stream().map(e -> e.getOrganId()).collect(Collectors.toSet());
         Map<Integer,String> organMap = MapUtil.convertMybatisMap(organizationDao.findOrganNameMapList(organIds));
         //获取待激活学员数
@@ -1332,7 +1263,7 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
         Date startTime = cal.getTime();
 
-        Map<Integer,Long> activeMap = MapUtil.convertIntegerMap(studentDao.getOrganActiveCloudStudyStudentNum1(organIdsList, startTime, endTime));
+        Map<Integer,Long> activeMap = MapUtil.convertIntegerMap(studentDao.getOrganActiveCloudStudyStudentNum(organIdsList, startTime, endTime));
         //获取重复购买人数
         Map<Integer,Long> againBuyMap = MapUtil.convertIntegerMap(studentDao.getAgainBuyNum(organIdsList));
         for (IndexCloudStudySumDto dto : list) {
@@ -1344,9 +1275,12 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
             Long integer = activeMap.get(dto.getOrganId());
             dto.setActiveStudentNum(integer==null?0:integer.intValue());
             dto.setVipStudentNum(dto.getEffectiveVipStudentNum() + dto.getWaitActivateVipStudentNum());
-            double studentNum = (double)dto.getVipStudentNum();
-            dto.setVipStudentRate(studentNum / dto.getTotalStudentNum() * 100d);
-//            dto.setAgainBuyRate(dto.getAgainBuyNum() / studentNum);
+            if(dto.getVipStudentNum() != 0){
+                double studentNum = (double)dto.getVipStudentNum();
+                dto.setBuyRate(studentNum / dto.getTotalStudentNum() * 100);
+                dto.setAgainBuyRate(dto.getAgainBuyNum() / studentNum * 100);
+                dto.setVipStudentRate(studentNum / dto.getTotalStudentNum() * 100d);
+            }
         }
         return list;
     }

+ 28 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentTeacherMapperServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.StudentTeacherMapperDao;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.StudentTeacherMapper;
 import com.ym.mec.biz.service.StudentTeacherMapperService;
 import com.ym.mec.common.dal.BaseDAO;
@@ -8,6 +9,13 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType.*;
 
 @Service
 public class StudentTeacherMapperServiceImpl extends BaseServiceImpl<Integer,StudentTeacherMapper> implements StudentTeacherMapperService{
@@ -26,4 +34,24 @@ public class StudentTeacherMapperServiceImpl extends BaseServiceImpl<Integer,Stu
         studentTeacherMapperDao.delAll();
         studentTeacherMapperDao.create();
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateStudentTeacherMapper(List<CourseSchedule> courseScheduleList) {
+        if(CollectionUtils.isEmpty(courseScheduleList)){
+            return;
+        }
+        courseScheduleList= courseScheduleList.stream().filter(e->e.getType() == VIP || e.getType() == PRACTICE ||
+                e.getType() == SINGLE || e.getType() == MIX).collect(Collectors.toList());
+        if(CollectionUtils.isEmpty(courseScheduleList)){
+            return;
+        }
+        List<Long> courseIdList = courseScheduleList.stream().map(e -> e.getId()).collect(Collectors.toList());
+        //获取vip需要更新、新增的数据
+//        List<StudentTeacherMapper> mapperList = studentTeacherMapperDao.initInsertList(courseIdList);
+        List<Long> vipCourseIds = courseScheduleList.stream().filter(e -> e.getType() == VIP).map(e -> e.getId()).collect(Collectors.toList());
+        //获取需要更新的学员
+
+        List<Long> practiceCourseIds = courseScheduleList.stream().filter(e -> e.getType() == PRACTICE).map(e -> e.getId()).collect(Collectors.toList());
+    }
 }

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml

@@ -492,7 +492,7 @@
         left join student_registration sr ON sr.user_id_ = cto.student_id_
         left join music_group mg ON mg.id_ = sr.music_group_id_
         where cto.status_ = 1 AND (s.membership_end_time_ &lt; NOW() OR s.membership_end_time_ IS NULL)
-        AND sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+        AND sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
         <if test="organIds != null and organIds.size > 0">
             AND cto.organ_id_ IN
             <foreach collection="organIds" item="organId" open="(" close=")" separator=",">

+ 43 - 52
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -571,21 +571,6 @@
         </if>
     </select>
     
-    <select id="getOrganCloudTeacherStudentNum" resultType="com.ym.mec.biz.dal.dto.Mapper">
-        SELECT u.organ_id_ `key`,sum(case when a.user_id_ IS NULL then 0 else 1 end) `value`  FROM student s 
-		LEFT JOIN (
-		SELECT s.`user_id_`  FROM `student` s WHERE s.`membership_end_time_` > now()
-		union
-		SELECT cto.`student_id_`  FROM `cloud_teacher_order` cto WHERE cto.`status_` = 1
-		) a on a.user_id_ = s.`user_id_` 
-		LEFT JOIN `sys_user` u on s.`user_id_` = u.`id_`
-		WHERE u.`del_flag_` = 0 AND u.`organ_id_` IN
-        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-            #{organId}
-        </foreach>
-		GROUP BY u.`organ_id_` 
-    </select>
-
     <select id="getOrgansStudentNum" resultType="map">
         SELECT su.organ_id_ 'key',COUNT(DISTINCT user_id_) 'value'
         FROM ((SELECT sr.user_id_
@@ -639,7 +624,7 @@
         FROM sys_music_compare_record smcr
         LEFT JOIN student_registration sr ON smcr.user_id_ = sr.user_id_
         LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
-        WHERE sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+        WHERE sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
         AND smcr.create_time_ > date_sub(curdate(),INTERVAL 0 day)
             AND mg.organ_id_ IN
             <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
@@ -688,21 +673,7 @@
         </foreach>
     </select>
 
-    <select id="getOrganActiveCloudStudyStudentNum" resultType="com.ym.mec.biz.dal.dto.Mapper">
-        SELECT u.`organ_id_` `key`,count(a.user_id_) `value` FROM 
-		(
-		SELECT wd.`user_id_` FROM `sys_music_compare_week_data` wd  
-		WHERE wd.`train_time_` >= 3600 AND wd.`monday_` BETWEEN date(#{startTime}) and date(#{endTime})  GROUP BY `user_id_` HAVING count(*) >= 3
-		    ) a 
-		LEFT JOIN `student` s on a.`user_id_` = s.`user_id_`
-		LEFT JOIN `sys_user` u on u.`id_` = s.`user_id_` 
-		WHERE u.`del_flag_` = 0 AND u.`organ_id_` IN
-        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-            #{organId}
-        </foreach>
-		GROUP BY u.`organ_id_` 
-    </select>
-    <select id="getOrganActiveCloudStudyStudentNum1" resultType="java.util.Map">
+    <select id="getOrganActiveCloudStudyStudentNum" resultType="java.util.Map">
         SELECT mg.`organ_id_` 'key',count(a.user_id_) 'value' FROM
         (
         SELECT wd.`user_id_` FROM `sys_music_compare_week_data` wd
@@ -710,7 +681,7 @@
         ) a
         LEFT JOIN student_registration sr ON a.user_id_ = sr.user_id_
         LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
-        WHERE sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+        WHERE sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
         <if test="organIds != null and organIds.size > 0">
             AND mg.organ_id_ IN
             <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
@@ -720,28 +691,13 @@
         GROUP BY mg.`organ_id_`
     </select>
 
-    <select id="getCloudStudyStudentOverViewList" resultType="com.ym.mec.biz.dal.dto.IndexCloudStudyListDto">
-        SELECT o.`name_` organName,o.`id_` organId,count(s.`user_id_`) totalStudentNum,
-        sum(case when cto.student_id_ IS NULL then 0 else 1 end) waitActivateVipStudentNum,
-        sum(case when s.`membership_end_time_` > now() then 1 else 0 end) effectiveVipStudentNum 
-        FROM student s LEFT JOIN (
-		SELECT distinct cto.`student_id_`  FROM `cloud_teacher_order` cto WHERE cto.`status_` = 1
-		) cto on s.user_id_ = cto.student_id_
-		LEFT JOIN `sys_user` u on s.`user_id_` = u.`id_`
-		LEFT JOIN `organization` o on o.`id_` = u.`organ_id_` 
-		WHERE u.`del_flag_` = 0 AND u.`organ_id_` IN
-        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
-            #{organId}
-        </foreach>
-		GROUP BY u.`organ_id_` 
-    </select>
-    <select id="getCloudStudyStudentOverViewList1" resultType="com.ym.mec.biz.dal.dto.IndexCloudStudySumDto">
+    <select id="getCloudStudyStudentOverViewList" resultType="com.ym.mec.biz.dal.dto.IndexCloudStudySumDto">
         select mg.organ_id_ organId,COUNT(DISTINCT sr.user_id_) totalStudentNum,
                COUNT(DISTINCT CASE WHEN s.membership_end_time_ >= NOW() THEN sr.user_id_ END) effectiveVipStudentNum
         from student_registration sr
         left join music_group mg ON mg.id_ = sr.music_group_id_
         left join student s ON s.user_id_ = sr.user_id_
-        where sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+        where sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
         <if test="organIds != null and organIds.size > 0">
             AND mg.organ_id_ IN
             <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
@@ -1218,7 +1174,7 @@
         SUM(smcr.train_time_) train_total_time_,COUNT(distinct CASE WHEN smcr.train_time_ > 60 THEN smcr.user_id_ END) 'train0'
         from (select distinct sr.user_id_ from music_group mg
         left join student_registration sr ON mg.id_ = sr.music_group_id_
-        where mg.status_ = 'PROGRESS' AND sr.music_group_status_ = 'NORMAL') mg
+        where mg.status_ IN ('PROGRESS','PAUSE') AND sr.music_group_status_ = 'NORMAL') mg
         left join student s ON mg.user_id_ = s.user_id_
         left join (select smcr.user_id_,ROUND(SUM(smcr.play_time_)/60/#{queryInfo.weekBetween}) train_time_ from sys_music_compare_record smcr
         where DATE_FORMAT(smcr.create_time_,'%Y-%m-%d') between #{queryInfo.startDate} AND #{queryInfo.endDate}
@@ -1231,6 +1187,41 @@
         </if>
         group by su.organ_id_
     </select>
+    <select id="countCloudTeacherSumDetail" resultType="java.lang.Integer">
+        select COUNT(distinct stm.teacher_id_)
+        from student_teacher_mapper stm
+        left join (select distinct sr.user_id_ from music_group mg
+        left join student_registration sr ON mg.id_ = sr.music_group_id_
+        where mg.status_ IN ('PROGRESS','PAUSE') AND sr.music_group_status_ = 'NORMAL') mg ON mg.user_id_ = stm.student_id_
+        left join student s ON mg.user_id_ = s.user_id_
+        where s.membership_end_time_ >= NOW() AND stm.teacher_type_ = 'NORMAL'
+        <if test="queryInfo.organId != null and queryInfo.organId != ''">
+            AND FIND_IN_SET(su.organ_id_,#{queryInfo.organId})
+        </if>
+    </select>
+    <select id="queryCloudTeacherSumDetail" resultMap="CloudTeacherSumDto">
+        select COUNT(distinct s.user_id_) normal_num_,COUNT(distinct smcr.user_id_) train_student_num_,
+        COUNT(distinct CASE WHEN smcr.train_time_ &lt; 60 THEN smcr.user_id_ END) 'train1',
+        COUNT(distinct CASE WHEN smcr.train_time_ >= 60 AND smcr.train_time_ &lt; 120 THEN smcr.user_id_ END) 'train2',
+        COUNT(distinct CASE WHEN smcr.train_time_ >= 120 AND smcr.train_time_ &lt; 240 THEN smcr.user_id_ END) 'train3',
+        COUNT(distinct CASE WHEN smcr.train_time_ >= 240 THEN smcr.user_id_ END) 'train4',
+        SUM(smcr.train_time_) train_total_time_,COUNT(distinct CASE WHEN smcr.train_time_ > 60 THEN smcr.user_id_ END) 'train0'
+        from student_teacher_mapper stm
+        left join (select distinct sr.user_id_ from music_group mg
+        left join student_registration sr ON mg.id_ = sr.music_group_id_
+        where mg.status_ IN ('PROGRESS','PAUSE') AND sr.music_group_status_ = 'NORMAL') mg ON mg.user_id_ = stm.student_id_
+        left join student s ON mg.user_id_ = s.user_id_
+        left join (select smcr.user_id_,ROUND(SUM(smcr.play_time_)/60/#{queryInfo.weekBetween}) train_time_ from sys_music_compare_record smcr
+        where DATE_FORMAT(smcr.create_time_,'%Y-%m-%d') between #{queryInfo.startDate} AND #{queryInfo.endDate}
+        group by smcr.user_id_) smcr ON s.user_id_ = smcr.user_id_
+        left JOIN sys_user su ON su.id_ = mg.user_id_
+        where s.membership_end_time_ >= NOW() AND stm.teacher_type_ = 'NORMAL'
+        <if test="queryInfo.organId != null and queryInfo.organId != ''">
+            AND FIND_IN_SET(su.organ_id_,#{queryInfo.organId})
+        </if>
+        group by stm.teacher_id_
+        <include refid="global.limit"/>
+    </select>
 
     <select id="countTeacherSum" resultType="java.lang.Integer">
         select COUNT(distinct su.organ_id_)
@@ -1238,7 +1229,7 @@
         left join student_registration sr ON mg.id_ = sr.music_group_id_
         left join student s ON sr.user_id_ = s.user_id_
         left JOIN sys_user su ON su.id_ = sr.user_id_
-        where mg.status_ = 'PROGRESS' AND sr.music_group_status_ = 'NORMAL' AND s.membership_end_time_ >= NOW()
+        where mg.status_ IN ('PROGRESS','PAUSE') AND sr.music_group_status_ = 'NORMAL' AND s.membership_end_time_ >= NOW()
         <if test="queryInfo.organId != null and queryInfo.organId != ''">
             AND FIND_IN_SET(su.organ_id_,#{queryInfo.organId})
         </if>
@@ -1249,7 +1240,7 @@
         left join student s ON s.user_id_ = sr.user_id_
         where s.membership_end_time_ >= NOW() AND sr.user_id_ IN
         (select cto.student_id_ from cloud_teacher_order cto where cto.amount_ > 0 AND cto.status_ IN (1,2) group by cto.student_id_ HAVING COUNT(id_) > 1)
-          AND sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+          AND sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
         <if test="organIds!=null and organIds.size() > 0">
             AND mg.organ_id_ IN
             <foreach collection="organIds" item="organId" open="(" close=")" separator=",">

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -1783,8 +1783,8 @@ public class ExportController extends BaseController {
         }
         OutputStream outputStream = response.getOutputStream();
         try {
-            String[] header = {"姓名", "性别", "编号", "证件号码", "城市", "学校", "报考乐器", "报考级别", "级别", "乐理级别证书", "家长联系电话", "考级费用", "备注", "缴费状态", "订单编号", "商户订单号", "报名时间"};
-            String[] body = {"name", "gender", "id", "idcard", "city", "school", "subject", "level", "activityTag",
+            String[] header = {"姓名", "性别", "编号", "证件号码",  "VIP老师",  "声部课老师", "城市", "学校", "报考乐器", "报考级别", "级别", "乐理级别证书", "家长联系电话", "考级费用", "备注", "缴费状态", "订单编号", "商户订单号", "报名时间"};
+            String[] body = {"name", "gender", "id", "idcard",  "vipTeacherName",  "normalTeacherName", "city", "school", "subject", "level", "activityTag",
                     "theoryCert", "mobile", "money", "memo", "status == 2?'已缴费':status == 3?'已退费':'未缴费'", "orderNo", "transNo", "createTime"};
             HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList.getRows());
             response.setContentType("application/octet-stream");

+ 12 - 77
mec-web/src/main/java/com/ym/mec/web/controller/StudentManageController.java

@@ -1,7 +1,6 @@
 package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
@@ -14,11 +13,9 @@ import io.swagger.annotations.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 @Api(tags = "学生管理")
@@ -333,58 +330,6 @@ public class StudentManageController extends BaseController {
     }
 
     @ApiOperation(value = "云教练学员数据预览")
-    @GetMapping("/getCloudStudyStudentOverView1")
-    public HttpResponseResult<Object> getCloudStudyStudentOverView1(String organIds) throws Exception {
-        List<Integer> organIdsList;
-        if(StringUtils.isNotBlank(organIds)){
-            organIdsList = Arrays.stream(organIds.split(",")).map(id->Integer.valueOf(id)).collect(Collectors.toList());
-        }else{
-            List<Organization> organizations = organizationService.queryEmployeeOrgan();
-            if(CollectionUtils.isEmpty(organizations)){
-                return succeed();
-            }
-            organIdsList = organizations.stream().map(Organization::getId).collect(Collectors.toList());
-        }
-        
-        List<Integer> ingnoreOrganIdList = Arrays.asList(36,39,41,42,43,44,45,46,47,48,49,50,52,54,56);
-        
-        organIdsList.removeAll(ingnoreOrganIdList);
-        
-        Map<String,Object> result = new HashMap<String, Object>();
-        
-        List<IndexCloudStudyListDto> list = studentService.getCloudStudyStudentOverViewList(organIdsList);
-        Collections.sort(list, new Comparator<IndexCloudStudyListDto>() {
-
-			@Override
-			public int compare(IndexCloudStudyListDto o1, IndexCloudStudyListDto o2) {
-				if(o1.getVipStudentRate() == o2.getVipStudentRate()){
-					return 0;
-				}
-				if(o1.getVipStudentRate() > o2.getVipStudentRate()){
-					return -1;
-				}
-				return 1;
-			}
-        	
-		});
-        
-        result.put("list", list);
-
-        CloudStudyStudentDataDto cloudStudyStudentDataDto = studentService.getCloudStudyStudentOverView(organIdsList);
-
-        cloudStudyStudentDataDto.setCloudStudyLivelyStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getActiveStudentNum)));
-        cloudStudyStudentDataDto.setTotalStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getTotalStudentNum)));
-        cloudStudyStudentDataDto.setEffectiveVipStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getEffectiveVipStudentNum)));
-        cloudStudyStudentDataDto.setWaitActivateVipStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getWaitActivateVipStudentNum)));
-        cloudStudyStudentDataDto.setEffectiveStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getEffectiveStudentNum)));
-        cloudStudyStudentDataDto.setVipStudentNum(list.stream().collect(Collectors.summingInt(IndexCloudStudyListDto :: getVipStudentNum)));
-
-        result.put("overView", cloudStudyStudentDataDto);
-
-        return succeed(result);
-    }
-
-    @ApiOperation(value = "云教练学员数据预览")
     @GetMapping("/getCloudStudyStudentOverView")
     public HttpResponseResult<Map<String,Object>> getCloudStudyStudentOverView(String organIds) throws Exception {
         organIds = organizationService.getEmployeeOrgan(organIds);
@@ -394,7 +339,7 @@ public class StudentManageController extends BaseController {
             List<Integer> ingnoreOrganIdList = Arrays.asList(36,39,41,42,43,44,45,46,47,48,49,50,52,54,56);
             organIdsList.removeAll(ingnoreOrganIdList);
         }
-        List<IndexCloudStudySumDto> list = studentService.getCloudStudyStudentOverViewList1(organIdsList);
+        List<IndexCloudStudySumDto> list = studentService.getCloudStudyStudentOverViewList(organIdsList);
         list = list.stream().sorted(Comparator.comparing(IndexCloudStudySumDto::getVipStudentRate).reversed()).collect(Collectors.toList());
 
         Map<String,Object> result = new HashMap<String, Object>(2);
@@ -411,29 +356,12 @@ public class StudentManageController extends BaseController {
             double studentNum = (double)cloudStudyStudentDataDto.getVipStudentNum();
             cloudStudyStudentDataDto.setBuyRate(studentNum / cloudStudyStudentDataDto.getTotalStudentNum() * 100);
             cloudStudyStudentDataDto.setAgainBuyRate(cloudStudyStudentDataDto.getAgainBuyNum() / studentNum * 100);
+            cloudStudyStudentDataDto.setVipStudentRate(studentNum / cloudStudyStudentDataDto.getTotalStudentNum() * 100d);
         }
         result.put("overView",cloudStudyStudentDataDto);
         return succeed(result);
     }
 
-    @ApiOperation(value = "云教练学员数据预览列表")
-    @GetMapping("/getCloudStudyStudentOverViewList")
-    @PreAuthorize("@pcs.hasPermissions('studentManage/getCloudStudyStudentOverViewList')")
-    public HttpResponseResult<List<IndexCloudStudyListDto>> getCloudStudyStudentOverViewList(String organIds) throws Exception {
-        List<Integer> organIdsList;
-        if(StringUtils.isNotBlank(organIds)){
-            organIdsList = Arrays.stream(organIds.split(",")).map(id->Integer.valueOf(id)).collect(Collectors.toList());
-        }else{
-            List<Organization> organizations = organizationService.queryEmployeeOrgan();
-            if(CollectionUtils.isEmpty(organizations)){
-                return succeed();
-            }
-            organIdsList = organizations.stream().map(Organization::getId).collect(Collectors.toList());
-        }
-        
-        return succeed(studentService.getCloudStudyStudentOverViewList(organIdsList));
-    }
-
     @ApiOperation(value = "分部云教练学员数据预览")
     @GetMapping("/organStudentOverView")
     @PreAuthorize("@pcs.hasPermissions('studentManage/organStudentOverView')")
@@ -447,7 +375,7 @@ public class StudentManageController extends BaseController {
     @ApiOperation(value = "云教练活动统计")
     @GetMapping("/countCloudTeacherActive")
     @PreAuthorize("@pcs.hasPermissions('studentManage/countCloudTeacherActive')")
-    public Object countCloudTeacherActive(CloudTeacherActiveQueryInfo queryInfo) throws Exception {
+    public HttpResponseResult<Map<String, Object>> countCloudTeacherActive(CloudTeacherActiveQueryInfo queryInfo) throws Exception {
         String organIds = organizationService.getEmployeeOrgan("");
         queryInfo.setPage(1);
         queryInfo.setRows(49999);
@@ -459,15 +387,22 @@ public class StudentManageController extends BaseController {
     @ApiOperation(value = "云教练活动统计详情")
     @GetMapping("/countCloudTeacherActiveDetail")
     @PreAuthorize("@pcs.hasPermissions('studentManage/countCloudTeacherActiveDetail')")
-    public Object countCloudTeacherActiveDetail(CloudTeacherActiveQueryInfo queryInfo) throws Exception {
+    public HttpResponseResult<PageInfo<CloudTeacherActiveTargetDetailDto>> countCloudTeacherActiveDetail(CloudTeacherActiveQueryInfo queryInfo) throws Exception {
         return succeed(studentService.countCloudTeacherActiveDetail(queryInfo));
     }
 
     @ApiOperation(value = "新云教练统计")
     @PostMapping("/cloudTeacherSum")
     @PreAuthorize("@pcs.hasPermissions('studentManage/cloudTeacherSum')")
-    public Object cloudTeacherSum(@RequestBody StudentCourseConsumerQueryInfo queryInfo) throws Exception {
+    public HttpResponseResult<List<CloudTeacherSumDto>> cloudTeacherSum(@RequestBody StudentCourseConsumerQueryInfo queryInfo) throws Exception {
         queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
         return succeed(studentService.cloudTeacherSum(queryInfo));
     }
+
+    @ApiOperation(value = "新云教练统计详情")
+    @PostMapping("/cloudTeacherSumDetail")
+    @PreAuthorize("@pcs.hasPermissions('studentManage/cloudTeacherSumDetail')")
+    public HttpResponseResult<PageInfo<CloudTeacherSumDto>> cloudTeacherSumDetail(@RequestBody StudentCourseConsumerQueryInfo queryInfo) throws Exception {
+        return succeed(studentService.cloudTeacherSumDetail(queryInfo));
+    }
 }