Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

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

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleEvaluateDao.java

@@ -11,4 +11,5 @@ import java.util.List;
 
 public interface CourseScheduleEvaluateDao extends BaseDAO<Long, CourseScheduleEvaluate> {
 
+    CourseScheduleEvaluate findByClassGroupId(@Param("classGroupId") Integer classGroupId);
 }

+ 17 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDefaultPracticeGroupSalaryDao.java

@@ -1,9 +1,10 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.util.List;
-
 import com.ym.mec.biz.dal.entity.TeacherDefaultPracticeGroupSalary;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface TeacherDefaultPracticeGroupSalaryDao extends BaseDAO<Long, TeacherDefaultPracticeGroupSalary> {
 
@@ -17,4 +18,17 @@ public interface TeacherDefaultPracticeGroupSalaryDao extends BaseDAO<Long, Teac
     int deleteByUserId(Integer userId);
     
     int batchInsert(List<TeacherDefaultPracticeGroupSalary> teacherDefaultPracticeGroupSalaryList);
-}
+
+    /**
+     * @describe 根据用户和课程时长获取教师课酬
+     * @author Joburgess
+     * @date 2020/2/19
+     * @param userId: 教师编号
+     * @param minutes: 课程时长
+     * @return com.ym.mec.biz.dal.entity.TeacherDefaultPracticeGroupSalary
+     */
+    TeacherDefaultPracticeGroupSalary findByTeacherAndCourseMinutes(@Param("userId")Integer userId,
+																	@Param("minutes") Integer minutes);
+
+
+}

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleEvaluateServiceImpl.java

@@ -34,6 +34,10 @@ public class CourseScheduleEvaluateServiceImpl extends BaseServiceImpl<Long, Cou
         if(classGroup==null){
            throw new BizException("课程不存在!");
         }
+        CourseScheduleEvaluate hasOne = courseScheduleEvaluateDao.findByClassGroupId(courseScheduleEvaluate.getClassGroupId());
+        if(hasOne != null){
+            throw new BizException("报告已添加,请勿重复提交");
+        }
         courseScheduleEvaluate.setMusicGroupId(classGroup.getMusicGroupId());
         courseScheduleEvaluate.setCreateTime(new Date());
         long num = courseScheduleEvaluateDao.insert(courseScheduleEvaluate);

+ 36 - 25
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1089,7 +1089,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         errInfo.append(courseSchedule.getName());
         errInfo.append("(");
         errInfo.append(courseSchedule.getId());
-        errInfo.append(")");
+        errInfo.append(")");
 
         errInfo.append("类型为:");
         switch (type) {
@@ -1636,6 +1636,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 newCourseSchedule.setEndClassTime(endClassTime);
             }*/
 
+            if (Objects.isNull(newCourseSchedule.getGroupType())) {
+                newCourseSchedule.setGroupType(oldCourseSchedule.getGroupType());
+            }
             if (Objects.isNull(newCourseSchedule.getActualTeacherId())) {
                 newCourseSchedule.setActualTeacherId(oldCourseSchedule.getActualTeacherId());
             }
@@ -1738,30 +1741,32 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				}
 			}
 			
+			if(newCourseSchedule.getStatus() == CourseStatusEnum.NOT_START && newCourseSchedule.getGroupType() == GroupType.MUSIC){
+				//查询新生(之前排课没有这个人,后来新进来的学生)
+				List<ClassGroupStudentMapper> newStudentList = classGroupStudentMapperDao.queryNewStudentListByCourseScheduleId(courseScheduleId);
+				if(newStudentList.size() > 0){
+					//生成courseScheduleStudentPayment记录
+					for(ClassGroupStudentMapper cgsm : newStudentList){
+						CourseScheduleStudentPayment sp = new CourseScheduleStudentPayment();
+						sp.setClassGroupId(newCourseSchedule.getClassGroupId());
+						sp.setCourseScheduleId(courseScheduleId);
+						sp.setCreateTime(date);
+						sp.setExpectPrice(new BigDecimal(0));
+						sp.setGroupType(GroupType.MUSIC);
+						sp.setMusicGroupId(newCourseSchedule.getMusicGroupId());
+						sp.setUpdateTime(date);
+						sp.setUserId(cgsm.getUserId());
+						
+						insertCourseScheduleStudentPaymentList.add(sp);
+					}
+				}
+			}
+			
 			if ((newCourseSchedule.getStatus() != oldCourseSchedule.getStatus() && newCourseSchedule.getStatus() == CourseStatusEnum.NOT_START)) {
 				//如果已结束修改成了未开始,需要更新学生考勤记录
 				studentAttendanceDao.deleteStudentAttendancesByCourse(courseScheduleId);
 				
 				if(newCourseSchedule.getGroupType() == GroupType.MUSIC){
-					//查询新生(之前排课没有这个人,后来新进来的学生)
-					List<ClassGroupStudentMapper> newStudentList = classGroupStudentMapperDao.queryNewStudentListByCourseScheduleId(courseScheduleId);
-					if(newStudentList.size() > 0){
-						//生成courseScheduleStudentPayment记录
-						for(ClassGroupStudentMapper cgsm : newStudentList){
-							CourseScheduleStudentPayment sp = new CourseScheduleStudentPayment();
-							sp.setClassGroupId(newCourseSchedule.getClassGroupId());
-							sp.setCourseScheduleId(courseScheduleId);
-							sp.setCreateTime(date);
-							sp.setExpectPrice(new BigDecimal(0));
-							sp.setGroupType(GroupType.MUSIC);
-							sp.setMusicGroupId(newCourseSchedule.getMusicGroupId());
-							sp.setUpdateTime(date);
-							sp.setUserId(cgsm.getUserId());
-							
-							insertCourseScheduleStudentPaymentList.add(sp);
-						}
-					}
-					
 					//清理课程作业
 					courseHomeworkService.delHomwworkByCourseScheduleId(courseScheduleId);
 				}
@@ -1833,11 +1838,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 							// 乐团结算方式
 							String settlementType = musicGroupSettlementsMap.get(courseScheduleId);
 							int unitMinutes = 30;
-							if (newCourseSchedule.getType() == CourseScheduleType.CLASSROOM) {
-								unitMinutes = 40;
-							} else if (newCourseSchedule.getType() == CourseScheduleType.HIGH) {
-								unitMinutes = 45;
-							}
 
 							// 如果当前教师是在指定日期之后入职的,则按照3.0的方式结算
 							Teacher teacher = teacherMap.get(teacherId);
@@ -1846,12 +1846,23 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 								settlementType = SalarySettlementTypeEnum.GRADIENT_SALARY.getCode();
 							}
 							if (StringUtils.equals(settlementType, "TEACHER_DEFAULT")) {
+								if (newCourseSchedule.getType() == CourseScheduleType.CLASSROOM) {
+									unitMinutes = 40;
+								} else if (newCourseSchedule.getType() == CourseScheduleType.HIGH) {
+									unitMinutes = 45;
+								}
 								if (ts.getTeacherRole() == TeachTypeEnum.BISHOP) {
 									ts.setExpectSalary(new BigDecimal(tdms.getMainTeacher30MinSalary().doubleValue() * newMinutes / unitMinutes));
 								} else {
 									ts.setExpectSalary(new BigDecimal(tdms.getAssistantTeacher30MinSalary().doubleValue() * newMinutes / unitMinutes));
 								}
 							} else if (StringUtils.equals(settlementType, "GRADIENT_SALARY")) {
+								unitMinutes = 90;
+								if (newCourseSchedule.getType() == CourseScheduleType.CLASSROOM) {
+									unitMinutes = 40;
+								} else if (newCourseSchedule.getType() == CourseScheduleType.HIGH) {
+									unitMinutes = 45;
+								}
 								if (ts.getTeacherRole() == TeachTypeEnum.BISHOP) {
 									ts.setExpectSalary(new BigDecimal(tdms.getMainTeacher90MinSalary().doubleValue() * newMinutes / unitMinutes));
 								} else {

+ 27 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
 import com.ym.mec.biz.service.*;
+import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -105,6 +106,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     private GroupClassService groupService;
     @Autowired
     private PracticeGroupSellPriceDao practiceGroupSellPriceDao;
+    @Autowired
+    private TeacherDefaultPracticeGroupSalaryDao teacherDefaultPracticeGroupSalaryDao;
 
     private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
 
@@ -2537,7 +2540,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         Date now=new Date();
         LocalDate courseStartDay=LocalDate.now();
         if(practiceGroupBuyParams.isRenew()){
-            PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(practiceGroupBuyParams.getUserId(),practiceGroupBuyParams.getGroupId());
+            if(Objects.isNull(practiceGroupBuyParams.getGroupId())){
+                return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择续费的课程");
+            }
+            PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(practiceGroupBuyParams.getStudentId(),practiceGroupBuyParams.getGroupId());
             if(Objects.nonNull(userLatestPracticeGroup)){
                 LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
                 if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(courseStartDay)>=0){
@@ -2683,6 +2689,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseSchedule.setIsLock(1);
         }
         courseScheduleDao.batchAddCourseSchedules(practiceCourses);
+        TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(practiceGroupBuyParams.getUserId(),practiceCourseMinutes);
+        BigDecimal teacherDefaultSalary=new BigDecimal(practiceCourseSalaryConfig.getParanValue());
+        if(Objects.nonNull(teacherDefaultPracticeGroupSalary)){
+            teacherDefaultSalary=teacherDefaultPracticeGroupSalary.getMainTeacherSalary();
+        }
+        BigDecimal studentSingleCourseCost=amount.divide(new BigDecimal(practiceCourses.size()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
         for (CourseSchedule courseSchedule : practiceCourses) {
             //课程与老师薪水表
             CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
@@ -2691,7 +2703,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseScheduleTeacherSalary.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
             courseScheduleTeacherSalary.setUserId(practiceGroupBuyParams.getUserId());
-            courseScheduleTeacherSalary.setExpectSalary(new BigDecimal(practiceCourseSalaryConfig.getParanValue()));
+            courseScheduleTeacherSalary.setExpectSalary(teacherDefaultSalary);
             courseScheduleTeacherSalary.setCreateTime(now);
             courseScheduleTeacherSalary.setUpdateTime(now);
             courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
@@ -2703,7 +2715,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
             courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
-            courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
+            courseScheduleStudentPayment.setExpectPrice(studentSingleCourseCost);
             courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
             courseScheduleStudentPayment.setCreateTime(now);
             courseScheduleStudentPayment.setUpdateTime(now);
@@ -2720,13 +2732,24 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             teacherAttendances.add(teacherAttendance);
         }
         courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
+        courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
         teacherAttendanceDao.batchInsert(teacherAttendances);
 
         try {
             courseScheduleService.checkNewCourseSchedules(practiceCourses,false);
         } catch (Exception e) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return BaseController.failed(HttpStatus.FOUND, e.getMessage());
+            String errMessage=new String();
+            if(e.getMessage().indexOf("主教冲突")!=-1){
+                errMessage="抱歉啦,当前所选时段组合,「" + teacher.getRealName() + "」老师已被预约,请重新选择时段或更换老师后重试。";
+            }else{
+                String courseName=e.getMessage().substring(e.getMessage().indexOf(")-")+2);
+                courseName = courseName.substring(0,courseName.indexOf("("));
+                errMessage="抱歉啦,当前所选时段组合,与您现有课程「";
+                errMessage+=courseName;
+                errMessage+="」时段冲突,请选择其他时段重试。";
+            }
+            return BaseController.failed(HttpStatus.FOUND, errMessage);
         }
 
         StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();

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

@@ -386,7 +386,8 @@
     </select>
     
     <select id="queryNewStudentListByCourseScheduleId" resultMap="ClassGroupStudentMapper">
-       SELECT cgsm.* FROM class_group_student_mapper cgsm LEFT JOIN course_schedule_student_payment cssp on cssp.class_group_id_ = cgsm.class_group_id_ and cssp.user_id_ = cgsm.user_id_ 
+      	SELECT cgsm.* FROM class_group_student_mapper cgsm LEFT JOIN course_schedule cs ON cgsm.class_group_id_= cs.class_group_id_
+		LEFT JOIN course_schedule_student_payment cssp on cssp.course_schedule_id_ = cs.id_ and cssp.user_id_ = cgsm.user_id_
 		WHERE cssp.id_ IS NULL AND cgsm.status_ != 'QUIT' and cssp.course_schedule_id_ = #{courseScheduleId}
     </select>
 </mapper>

+ 24 - 16
mec-biz/src/main/resources/config/mybatis/CourseScheduleEvaluateMapper.xml

@@ -1,19 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace=" com.ym.mec.biz.dal.dao.CourseScheduleEvaluateDao">
-  <resultMap id="CourseScheduleEvaluate" type="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">
-    <id column="id_" jdbcType="BIGINT" property="id" />
-    <result column="music_group_id_" jdbcType="VARCHAR" property="musicGroupId" />
-    <result column="class_group_id_" jdbcType="INTEGER" property="classGroupId" />
-    <result column="course_schedule_id_" jdbcType="BIGINT" property="courseScheduleId" />
-    <result column="teacher_id_" jdbcType="INTEGER" property="teacherId" />
-    <result column="item_" jdbcType="VARCHAR" property="item" />
-    <result column="comment_" jdbcType="LONGVARCHAR" property="comment" />
-    <result column="create_time_" jdbcType="TIMESTAMP" property="createTime" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id_, music_group_id_, class_group_id_, course_schedule_id_, teacher_id_, item_, comment_, 
-    create_time_
-  </sql>
+<mapper namespace="com.ym.mec.biz.dal.dao.CourseScheduleEvaluateDao">
+    <resultMap id="CourseScheduleEvaluate" type="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">
+        <id column="id_" jdbcType="BIGINT" property="id" />
+        <result column="music_group_id_" jdbcType="VARCHAR" property="musicGroupId" />
+        <result column="class_group_id_" jdbcType="INTEGER" property="classGroupId" />
+        <result column="course_schedule_id_" jdbcType="BIGINT" property="courseScheduleId" />
+        <result column="teacher_id_" jdbcType="INTEGER" property="teacherId" />
+        <result column="item_" jdbcType="VARCHAR" property="item" />
+        <result column="comment_" jdbcType="LONGVARCHAR" property="comment" />
+        <result column="create_time_" jdbcType="TIMESTAMP" property="createTime" />
+    </resultMap>
+    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate" useGeneratedKeys="true"
+            keyColumn="id" keyProperty="id">
+        insert into course_schedule_evaluate (music_group_id_, class_group_id_, course_schedule_id_,
+        teacher_id_, item_, comment_,
+        create_time_)
+        values (#{musicGroupId,jdbcType=VARCHAR}, #{classGroupId,jdbcType=INTEGER}, #{courseScheduleId,jdbcType=BIGINT},
+        #{teacherId,jdbcType=INTEGER}, #{item,jdbcType=VARCHAR}, #{comment,jdbcType=LONGVARCHAR},
+        #{createTime,jdbcType=TIMESTAMP})
+    </insert>
+
+    <select id="findByClassGroupId" resultMap="CourseScheduleEvaluate">
+        SELECT * FROM course_schedule_evaluate WHERE class_group_id_ = #{classGroupId}
+    </select>
 </mapper>

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

@@ -2222,6 +2222,7 @@
           LEFT JOIN sys_user su ON cs.actual_teacher_id_=su.id_
         WHERE cs.group_type_='PRACTICE'
           AND cssp.user_id_=#{userId}
+          AND cssp.expect_price_=0
     </select>
     <select id="findTeacherCoursesWithIncludeDateRange" resultMap="CourseSchedule" useCache="false" flushCache="true">
         SELECT

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

@@ -97,7 +97,10 @@
 		teacher_default_practice_group_salary
 	</select>
 
-	<select id="queryByTeacherId" resultMap="TeacherDefaultPracticeGroupSalary">
+	<select id="queryByUserId" resultMap="TeacherDefaultPracticeGroupSalary">
 		SELECT * FROM teacher_default_practice_group_salary where user_id_ = #{userId} ORDER BY id_
 	</select>
+	<select id="findByTeacherAndCourseMinutes" resultMap="TeacherDefaultPracticeGroupSalary">
+		SELECT * FROM teacher_default_practice_group_salary where user_id_ = #{userId} AND minutes_=#{minutes}
+	</select>
 </mapper>

+ 22 - 23
mec-util/src/main/java/com/ym/mec/util/collection/ListUtil.java

@@ -2,7 +2,6 @@ package com.ym.mec.util.collection;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.ListIterator;
 
 public class ListUtil {
 
@@ -13,35 +12,35 @@ public class ListUtil {
 	 * @return
 	 */
 	public static boolean isEquals(List<?> list1, List<?> list2) {
-		if (null != list1 && null != list2) {
-			if(list1.size() != list2.size()){
-				return false;
-			}
-			ListIterator<?> listIterator = list1.listIterator();
-			while(listIterator.hasNext()){
-				Object obj = listIterator.next();
-				if(!list2.contains(obj)){
-					return false;
-				}
-				listIterator.remove();
-				list2.remove(obj);
-			}
+		if (list1 == list2) {
+			return true;
 		}
-		return true;
+		if (list1 == null && list2 == null) {
+			return true;
+		}
+		if (list1 == null || list2 == null) {
+			return false;
+		}
+		if (list1.size() != list2.size()) {
+			return false;
+		}
+		if (list1.containsAll(list2) && list2.containsAll(list1)) {
+			return true;
+		}
+		return false;
 	}
-	
-	
+
 	public static void main(String[] args) {
 		List<Integer> list1 = new ArrayList<Integer>();
 		list1.add(2);
-		list1.add(2);
 		list1.add(1);
-		
+		list1.add(1);
+
 		List<Integer> list2 = new ArrayList<Integer>();
+		list2.add(1);
 		list2.add(2);
-		list2.add(2);
-		list2.add(2);
-		
-		System.out.println(isEquals(list1,list2)? "true" : "false");
+		list2.add(1);
+
+		System.out.println(isEquals(list1, list2) ? "true" : "false");
 	}
 }