Browse Source

Merge remote-tracking branch 'origin/master'

周箭河 4 years ago
parent
commit
eab60cabc7

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1779,4 +1779,12 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     List<CourseSchedule> getMusicGroupCourseInfo(@Param("musicGroupId") String musicGroupId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 获取还有剩余课程的学员
+     * @param userIds
+     * @param groupType
+     * @return
+     */
+    List<Integer> findHasCourseStudent(@Param("userIds") List<Integer> userIds, @Param("groupType") String groupType);
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupStudentsDto.java

@@ -54,6 +54,10 @@ public class MusicGroupStudentsDto{
 
     private Boolean isActive = false;
 
+    private Boolean hasVip;
+
+    private Boolean hasPractice;
+
     private Integer isLock;
 
     private String paymentPeriodList;
@@ -70,6 +74,22 @@ public class MusicGroupStudentsDto{
     @ApiModelProperty(value = "欠费金额",required = false)
     private BigDecimal noPaymentAmount;
 
+    public Boolean getHasVip() {
+        return hasVip;
+    }
+
+    public void setHasVip(Boolean hasVip) {
+        this.hasVip = hasVip;
+    }
+
+    public Boolean getHasPractice() {
+        return hasPractice;
+    }
+
+    public void setHasPractice(Boolean hasPractice) {
+        this.hasPractice = hasPractice;
+    }
+
     public BigDecimal getNoPaymentAmount() {
         return noPaymentAmount;
     }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupStudentQueryInfo.java

@@ -20,6 +20,12 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
   @ApiModelProperty(value = "是否激活")
   private Boolean isActive;
 
+  @ApiModelProperty(value = "是否有未开始的vip课")
+  private Boolean hasVip;
+
+  @ApiModelProperty(value = "是否有未开始的网管课")
+  private Boolean hasPractice;
+
   @ApiModelProperty(value = "是否锁定")
   private Integer isLock;
 
@@ -31,6 +37,22 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
 
   private boolean isExport = false;
 
+  public Boolean getHasVip() {
+    return hasVip;
+  }
+
+  public void setHasVip(Boolean hasVip) {
+    this.hasVip = hasVip;
+  }
+
+  public Boolean getHasPractice() {
+    return hasPractice;
+  }
+
+  public void setHasPractice(Boolean hasPractice) {
+    this.hasPractice = hasPractice;
+  }
+
   public boolean getIsExport() {
     return isExport;
   }

+ 15 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -3151,10 +3151,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 					if (DateUtil.minutesBetween(practiceGroup.getCoursesExpireDate(), newCourseSchedule.getEndClassTime()) > 0) {
 						throw new BizException("调整失败: 截止时间超过课程有效期");
 					}
-					practiceGroup.setCoursesStartDate(courseScheduleDao.getFirstTime(practiceGroup.getId(),PRACTICE.getCode()));
-					practiceGroup.setCoursesExpireDate(courseScheduleDao.getLastTime(practiceGroup.getId(),PRACTICE.getCode()));
-					practiceGroup.setUpdateTime(date);
-					practiceGroupDao.update(practiceGroup);
 				}
 			}
         }
@@ -5298,15 +5294,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		Map<Integer, List<CourseScheduleStudentPayment>> otherStudentCourseMap = courseScheduleStudentPayments.stream().filter(c -> !courseMergeInfo.getId().equals(c.getCourseScheduleId())).collect(Collectors.groupingBy(CourseScheduleStudentPayment::getUserId));
 
 		List<CourseScheduleStudentPayment> newPayments = new ArrayList<>();
-		List<CourseScheduleStudentPayment> updatePayments = new ArrayList<>();
+//		List<CourseScheduleStudentPayment> updatePayments = new ArrayList<>();
 
 		for (Map.Entry<Integer, List<CourseScheduleStudentPayment>> otherStudentCourseMapEntry : otherStudentCourseMap.entrySet()) {
 			List<CourseScheduleStudentPayment> studentCoursePayments = otherStudentCourseMapEntry.getValue();
 			BigDecimal salary = studentCoursePayments.stream().map(CourseScheduleStudentPayment::getExpectPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 			if(mainStudentCourseMap.containsKey(otherStudentCourseMapEntry.getKey())){
-				CourseScheduleStudentPayment updatePayment = mainStudentCourseMap.get(otherStudentCourseMapEntry.getKey());
-				updatePayment.setExpectPrice(updatePayment.getExpectPrice().add(salary));
-				updatePayments.add(updatePayment);
+//				CourseScheduleStudentPayment updatePayment = mainStudentCourseMap.get(otherStudentCourseMapEntry.getKey());
+//				updatePayment.setExpectPrice(updatePayment.getExpectPrice().add(salary));
+//				updatePayments.add(updatePayment);
 
 //				for (CourseScheduleStudentPayment studentCoursePayment : studentCoursePayments) {
 //					studentCoursePayment.setExpectPrice(BigDecimal.ZERO);
@@ -5320,7 +5316,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			newPayment.setClassGroupId(courseMergeInfo.getClassGroupId());
 			newPayment.setMusicGroupId(courseMergeInfo.getMusicGroupId());
 			newPayment.setGroupType(courseMergeInfo.getGroupType());
-			newPayment.setExpectPrice(salary);
+			newPayment.setExpectPrice(BigDecimal.ZERO);
 			newPayment.setId(null);
 			newPayment.setBeMerged(true);
 			newPayments.add(newPayment);
@@ -5357,9 +5353,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		}
 		courseScheduleDao.batchUpdate(mergeCourses);
 
-		if(!CollectionUtils.isEmpty(updatePayments)){
-			courseScheduleStudentPaymentDao.batchUpdate(updatePayments);
-		}
+//		if(!CollectionUtils.isEmpty(updatePayments)){
+//			courseScheduleStudentPaymentDao.batchUpdate(updatePayments);
+//		}
 		if(!CollectionUtils.isEmpty(newPayments))
 			courseScheduleStudentPaymentDao.batchInsert(newPayments);
 
@@ -5390,7 +5386,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		List<CourseScheduleStudentPayment> otherCoursePayments = courseScheduleStudentPayments.stream().filter(c -> c.getCourseScheduleId().equals(mainCourseId)).collect(Collectors.toList());
 
 		List<Integer> deletePaymentIds = new ArrayList<>();
-		List<CourseScheduleStudentPayment> updatePayments = new ArrayList<>();
+//		List<CourseScheduleStudentPayment> updatePayments = new ArrayList<>();
 
 		otherCoursePayments.sort(Comparator.comparing(CourseScheduleStudentPayment::getCreateTime).reversed());
 		for (CourseScheduleStudentPayment otherCoursePayment : otherCoursePayments) {
@@ -5402,12 +5398,14 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				deletePaymentIds.add(mainCoursePayment.getId().intValue());
 				continue;
 			}
-			mainCoursePayment.setExpectPrice(mainCoursePayment.getExpectPrice().subtract(otherCoursePayment.getExpectPrice()));
-			updatePayments.add(mainCoursePayment);
+//			mainCoursePayment.setExpectPrice(mainCoursePayment.getExpectPrice().subtract(otherCoursePayment.getExpectPrice()));
+//			updatePayments.add(mainCoursePayment);
 		}
 
-		courseScheduleStudentPaymentDao.batchDeleteWithID(deletePaymentIds);
-		courseScheduleStudentPaymentDao.batchUpdate(updatePayments);
+		if(!CollectionUtils.isEmpty(deletePaymentIds)){
+			courseScheduleStudentPaymentDao.batchDeleteWithID(deletePaymentIds);
+		}
+//		courseScheduleStudentPaymentDao.batchUpdate(updatePayments);
 
 		List<CourseScheduleModifyLog> insertCourseScheduleModifyLogList = new ArrayList<>();
 		for (CourseSchedule courseSchedule : courseSchedules) {

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

@@ -698,7 +698,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			return;
 		}
 		List<CourseScheduleStudentPayment> needUpdates = new ArrayList<>();
-		Map<CourseStatusEnum, List<CourseScheduleStudentPaymentDto>> statusCoursesMap = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPaymentDto::getCourseStatus));
+		Map<CourseStatusEnum, List<CourseScheduleStudentPaymentDto>> statusCoursesMap = courseScheduleStudentPayments.stream().filter(c->Objects.nonNull(c.getCourseStatus())).collect(Collectors.groupingBy(CourseScheduleStudentPaymentDto::getCourseStatus));
 		if(statusCoursesMap.containsKey(CourseStatusEnum.NOT_START)){
 			List<CourseScheduleStudentPaymentDto> notStartCourses = statusCoursesMap.get(CourseStatusEnum.NOT_START);
 			for (CourseScheduleStudentPaymentDto notStartCourse : notStartCourses) {

+ 54 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -416,6 +416,32 @@ public class StudentManageServiceImpl implements StudentManageService {
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         List<MusicGroupStudentsDto> dataList = null;
+        List<StudentRegistration> studentRegistrations = studentRegistrationDao.getMusicGroupStu(queryInfo.getMusicGroupId());
+        if(studentRegistrations.size() == 0){
+            return pageInfo;
+        }
+        List<Integer> userIds = studentRegistrations.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+        if(queryInfo.getHasVip() != null){
+            //有剩余课程的学员
+            List<Integer> hasVipStudent = courseScheduleDao.findHasCourseStudent(userIds,"VIP");
+            if(queryInfo.getHasVip()){
+                userIds = hasVipStudent;
+            }else {
+                userIds.removeAll(hasVipStudent);
+            }
+        }
+        if(queryInfo.getHasPractice() != null && userIds.size() > 0){
+            List<Integer> hasPracticeStudent = courseScheduleDao.findHasCourseStudent(userIds,"PRACTICE");
+            if(queryInfo.getHasPractice()){
+                userIds = hasPracticeStudent;
+            }else {
+                userIds.removeAll(hasPracticeStudent);
+            }
+        }
+        if(userIds.size() == 0){
+            return pageInfo;
+        }
+        params.put("userIds",userIds);
         int count = studentManageDao.countMusicGroupStudent(params);
         if (queryInfo.getIsExport() && count > 50000) {
             throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
@@ -437,7 +463,12 @@ public class StudentManageServiceImpl implements StudentManageService {
                     }
                 }
             }
+            List<Integer> collect = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+            List<Integer> hasVipStudent = courseScheduleDao.findHasCourseStudent(collect,"VIP");
+            List<Integer> hasPracticeStudent = courseScheduleDao.findHasCourseStudent(collect,"PRACTICE");
             dataList.forEach(e->{
+                e.setHasVip(hasVipStudent.contains(e.getUserId()));
+                e.setHasPractice(hasPracticeStudent.contains(e.getUserId()));
                 e.setNoPaymentAmount(totalAmountMap.get(e.getUserId()));
             });
         }
@@ -450,13 +481,35 @@ public class StudentManageServiceImpl implements StudentManageService {
 
     @Override
     public Object musicGroupStudentsSum(String musicGroupId) {
-        Map<String, Integer> resultMap = new HashMap<>(3);
+        Map<String, Object> resultMap = new HashMap<>(3);
         //乐团在读人数
         resultMap.put("studying", studentManageDao.countStudyNum(musicGroupId));
         //退团人数
         resultMap.put("quit", studentManageDao.countQuitNum(musicGroupId));
         //新增人数
         resultMap.put("add", studentManageDao.countAddNum(musicGroupId));
+        //未完成vip、网管课学员数量/该乐团在读学员人数*100%
+        List<StudentRegistration> studentRegistrations = studentRegistrationDao.getMusicGroupStu(musicGroupId);
+        if(studentRegistrations.size() == 0){
+            resultMap.put("vipRate","0.00%");
+            resultMap.put("practiceRate","0.00%");
+        }
+        List<Integer> userIds = studentRegistrations.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+        List<Integer> hasVipStudent = courseScheduleDao.findHasCourseStudent(userIds,"VIP");
+        double size = userIds.size()+0d;
+        if(hasVipStudent.size() == 0){
+            resultMap.put("vipRate","0.00%");
+        }else {
+            double d = (hasVipStudent.size() / size) * 100;
+            resultMap.put("vipRate",String.format("%.2f", d) + "%");
+        }
+        List<Integer> hasPracticeStudent = courseScheduleDao.findHasCourseStudent(userIds,"PRACTICE");
+        if(hasPracticeStudent.size() == 0){
+            resultMap.put("practiceRate","0.00%");
+        }else {
+            double d = (hasPracticeStudent.size() / size) * 100;
+            resultMap.put("practiceRate",String.format("%.2f", d) + "%");
+        }
         return resultMap;
     }
 

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

@@ -276,8 +276,8 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
         SysUserCoursesAccountDetail sysUserCoursesAccountDetail = new SysUserCoursesAccountDetail();
         if(changeMoney.compareTo(cashAccount.getCourseBalance())>0){
             changeMoney = changeMoney.subtract(cashAccount.getCourseBalance());
+            sysUserCoursesAccountDetail.setAmount(cashAccount.getCourseBalance());
             cashAccount.setCourseBalance(BigDecimal.ZERO);
-            sysUserCoursesAccountDetail.setAmount(changeMoney);
         }else{
             cashAccount.setCourseBalance(cashAccount.getCourseBalance().subtract(changeMoney));
             sysUserCoursesAccountDetail.setAmount(changeMoney);

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3538,4 +3538,15 @@
             AND cs.teach_mode_ = 'OFFLINE'
         ORDER BY cs.id_ ASC
     ]]></select>
+    <select id="findHasCourseStudent" resultType="java.lang.Integer">
+        SELECT cssp.user_id_ FROM course_schedule cs
+        LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
+        WHERE cssp.user_id_ IN
+        <foreach collection="userIds" separator="," item="item" close=")" open="(">
+            #{item}
+        </foreach>
+        AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
+        AND cs.group_type_ = #{groupType}
+        GROUP BY cssp.user_id_
+    </select>
 </mapper>

+ 6 - 5
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -626,16 +626,17 @@
 	<select id="findNeedUpdateActualPriceStudentCourses" resultMap="CourseScheduleStudentPaymentDto">
 		SELECT
 			cssp.*,
-			CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_,
-			cs.status_ course_status_
+			CASE WHEN cs.new_course_id_ IS NULL THEN CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) ELSE CONCAT( cs1.class_date_, ' ', cs1.start_class_time_ ) END course_start_time_,
+			CASE WHEN cs.new_course_id_ IS NULL THEN cs.status_ ELSE cs1.status_ END course_status_
 		FROM
 			course_schedule_student_payment cssp
-		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+			LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+			LEFT JOIN course_schedule cs1 ON cs.new_course_id_=cs1.id_
 		WHERE
 			cssp.batch_no_ IS NOT NULL
 			AND cs.id_ IS NOT NULL
-			AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
-			AND ((cs.status_ IN ('OVER', 'UNDERWAY') AND (cssp.actual_price_ IS NULL OR cssp.actual_price_ &lt; cssp.expect_price_))
+			AND (((cs.status_ IN ('OVER', 'UNDERWAY') OR cs1.status_ IN ( 'OVER', 'UNDERWAY' ))
+			          AND (cssp.actual_price_ IS NULL OR cssp.actual_price_ &lt; cssp.expect_price_))
 			OR ( cs.status_ = 'NOT_START' AND cssp.actual_price_ IS NOT NULL AND cssp.actual_price_ &gt; 0))
 			<if test="groupIds!=null and groupIds.size()>0">
 				AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml

@@ -453,6 +453,12 @@
             <if test="isActive != null and isActive == false">
                 and su.password_ is null
             </if>
+            <if test="userIds != null">
+                AND sr.user_id_ IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
         </where>
     </sql>
     <resultMap id="MusicGroupStudentsDto" type="com.ym.mec.biz.dal.dto.MusicGroupStudentsDto">

+ 2 - 0
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -353,6 +353,7 @@
             AND vg.organ_id_ = #{organId} AND IF(vg.student_id_list_ IS NULL,1,FIND_IN_SET(#{userId},
             vg.student_id_list_))
             AND vg.vip_group_activity_id_ IS NOT NULL
+            AND vgc.music_theory_ = 0
             <if test="subjectId!=null">
                 AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
             </if>
@@ -407,6 +408,7 @@
         FROM
         vip_group vg
         LEFT JOIN class_group cg ON vg.id_=cg.music_group_id_ AND cg.group_type_ = 'VIP'
+        LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
         <include refid="studentVipGroupQueryCondition"/>
     </select>
     <select id="getVipGroupBaseInfo" resultMap="vipGroupManageDetailDto">

+ 1 - 1
mec-util/src/main/java/com/ym/mec/util/excel/POIUtil.java

@@ -252,7 +252,7 @@ public class POIUtil {
 							obj = sdf.format(obj);
 						}
 						
-					} catch (NestedNullException e) {
+					} catch (Exception e) {
 						LOGGER.warn(e.getMessage());
 						obj = null;
 					}

+ 10 - 5
mec-web/src/main/java/com/ym/mec/web/controller/EmployeeController.java

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @Author Joburgess
@@ -146,7 +147,7 @@ public class EmployeeController extends BaseController {
 
     @ApiOperation(value = "获取教务人员")
     @GetMapping("/findEducationUsers")
-    public HttpResponseResult findEducationUsers(Integer userId){
+    public HttpResponseResult findEducationUsers(Integer userId, Integer organId){
         SysUser sysUser;
         if(userId == null){
             sysUser = sysUserFeignService.queryUserInfo();
@@ -157,11 +158,15 @@ public class EmployeeController extends BaseController {
             sysUser = sysUserFeignService.queryUserById(userId);
         }
         String organIds = new String();
-        if (!sysUser.getIsSuperAdmin()) {
-            Employee employee = employeeService.get(sysUser.getId());
-            if (StringUtils.isEmpty(organIds)) {
-                organIds = employee.getOrganIdList();
+        if(Objects.isNull(organId)){
+            if (!sysUser.getIsSuperAdmin()) {
+                Employee employee = employeeService.get(sysUser.getId());
+                if (StringUtils.isEmpty(organIds)) {
+                    organIds = employee.getOrganIdList();
+                }
             }
+        }else{
+            organIds = organId.toString();
         }
         return succeed(employeeService.findByRole("4,5",organIds));
     }

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

@@ -1251,9 +1251,9 @@ public class ExportController extends BaseController {
                 }
             }
             String[] header = {"学员编号", "学员姓名", "性别", "联系电话", "年级", "班级", "专业", "学员状态", "新增学员", "缴费金额",
-                        "下次缴费日期", "是否报名缴费", "是否激活", "欠费总额"};
+                        "下次缴费日期", "是否报名缴费", "是否激活", "是否有剩余VIP", "是否有剩余网管课", "欠费总额"};
             String[] body = {"userId", "realName", "gender", "phone", "currentGrade", "currentClass", "subjectName", "studentStatus", "isNewStudentStr",
-                    "courseFee", "nextPaymentDateStr", "paymentStatus.desc", "activeName","noPaymentAmount"};
+                    "courseFee", "nextPaymentDateStr", "paymentStatus.desc", "activeName", "hasVip ? '是' : '否'", "hasPractice ? '是' : '否'","noPaymentAmount"};
             HSSFWorkbook workbook = POIUtil.exportExcel(header, body, musicGroupStudentsDtoPageInfo.getRows());
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");