소스 검색

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

zouxuan 5 년 전
부모
커밋
dc20d6b66a

+ 4 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -2745,16 +2745,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 						}
 
 						//线上小班课
-						if(newCourseSchedule.getType() == CourseScheduleType.HIGH_ONLINE){
+						if(newCourseSchedule.getType() == CourseScheduleType.HIGH_ONLINE || newCourseSchedule.getType() == CourseScheduleType.MUSIC_NETWORK){
 							Integer studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(ts.getClassGroupId());
 							BigDecimal salary = JSON.parseObject(tdms.getSalaryRuleJson()).getBigDecimal(studentNum.toString());
+							if(Objects.isNull(salary)){
+								throw new BizException("请设置老师默认课酬");
+							}
 							ts.setExpectSalary(salary);
 						}
 
-						if (newCourseSchedule.getType().equals(CourseSchedule.CourseScheduleType.MUSIC_NETWORK)) {
-							ts.setExpectSalary(JSON.parseObject(tdms.getSalaryRuleJson()).getBigDecimal("1"));
-						}
-
 					} else if (newCourseSchedule.getGroupType() == GroupType.VIP) {
 						Map<String, BigDecimal> salaryMap = vipGroupService.countVipGroupPredictFee(vipGroup, teacherId, null, null);
 

+ 41 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -18,6 +18,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 
+import org.apache.poi.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -90,7 +91,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             .getLogger(CourseScheduleTeacherSalaryServiceImpl.class);
 
     //按节数计算课酬的课程类型
-    protected static final Set<CourseSchedule.CourseScheduleType> UNIT_PRICE_COURSE_TYPES=new HashSet<>(Arrays.asList(CourseSchedule.CourseScheduleType.CLASSROOM, CourseSchedule.CourseScheduleType.HIGH, CourseSchedule.CourseScheduleType.HIGH_ONLINE));
+    protected static final Set<CourseSchedule.CourseScheduleType> UNIT_PRICE_COURSE_TYPES=new HashSet<>(Arrays.asList(CourseSchedule.CourseScheduleType.CLASSROOM, CourseSchedule.CourseScheduleType.HIGH, CourseSchedule.CourseScheduleType.HIGH_ONLINE, CourseSchedule.CourseScheduleType.MUSIC_NETWORK));
 
     @Override
     public BaseDAO<Long, CourseScheduleTeacherSalary> getDAO() {
@@ -516,6 +517,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         if (CollectionUtils.isEmpty(courseScheduleIds)) {
             return;
         }
+
         //获取课程对应教学点补贴
         List<Map<Long, BigDecimal>> courseSubsidyByCourses = courseScheduleTeacherSalaryDao.findCourseSubsidyByCourses(courseScheduleIds);
         Map<Integer, BigDecimal> courseSubsidyMap = MapUtil.convertIntegerMap(courseSubsidyByCourses);
@@ -531,6 +533,19 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             return;
         }
 
+        //需要根据实际上课学员结算课酬的课程编号
+        List<Long> needStudentAttendanceCourseScheduleIds = yesterdayCourseSchedules.stream()
+                .filter(c -> CourseSchedule.CourseScheduleType.HIGH_ONLINE.equals(c.getType()) || CourseSchedule.CourseScheduleType.MUSIC_NETWORK.equals(c.getType()))
+                .map(CourseSchedule::getId).collect(Collectors.toList());
+
+        List<StudentAttendance> studentAttendances = studentAttendanceDao.findByCourseIds(needStudentAttendanceCourseScheduleIds);
+        Map<Long, Long> courseNormalStudentsMap = new HashMap<>();
+        if(!CollectionUtils.isEmpty(studentAttendances)){
+            courseNormalStudentsMap =studentAttendances.stream()
+                    .filter(studentAttendance -> StudentAttendanceStatusEnum.NORMAL.equals(studentAttendance.getStatus()))
+                    .collect(Collectors.groupingBy(StudentAttendance::getId, Collectors.counting()));
+        }
+
         //课程对应乐团结算方式集合
         List<Map<String, String>> musicGroupSettlementTypeByCourse = courseScheduleTeacherSalaryDao.findMusicGroupSettlementTypeByCourse(courseScheduleIds);
         Map<String, String> musicGroupSettlementsMap = MapUtil.convertMybatisMap(musicGroupSettlementTypeByCourse);
@@ -596,7 +611,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         //用户账户自己变动信息列表
 //        List<SysUserCashAccountDetail> userCashAccountDetails = new ArrayList<>();
         //计算课酬
-        courseScheduleTeacherSalaries.forEach(courseScheduleTeacherSalary -> {
+        for (CourseScheduleTeacherSalary courseScheduleTeacherSalary : courseScheduleTeacherSalaries) {
             /*TeacherAttendance teacherAttendanceInfo = teacherAttendanceDao.findByTeacherAttendanceInfo(courseScheduleTeacherSalary.getUserId().longValue(), courseScheduleTeacherSalary.getCourseScheduleId());
             if(Objects.isNull(teacherAttendanceInfo)
                 ||(Objects.isNull(teacherAttendanceInfo.getSignInTime())&&Objects.isNull(teacherAttendanceInfo.getSignOutTime()))){
@@ -680,6 +695,29 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
                     }
                     teacherSalary = teacherDefaultSalary.multiply(classTimeDuty).setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
+            }else if(CourseSchedule.CourseScheduleType.MUSIC_NETWORK.equals(courseSchedule.getType())||CourseSchedule.CourseScheduleType.HIGH_ONLINE.equals(courseSchedule.getType())){
+                //根据课程类型获取对应的默认课酬设置列表
+                List<TeacherDefaultMusicGroupSalary> teacherDefaultMusicGroupSalariesWithCourseType = teacherDefaultMusicGroupSalariesGroupByCourseType.get(courseSchedule.getType());
+                if (CollectionUtils.isEmpty(teacherDefaultMusicGroupSalariesWithCourseType)) {
+                    LOGGER.error("存在未指定结算方式的课程类型[{}]", courseScheduleTeacherSalary.getId());
+                }
+
+                //根据教师编号将对应结算方式下的默认课酬设置分组
+                Map<Integer, TeacherDefaultMusicGroupSalary> teacherDefaultMusicGroupSalariesGroupByTeacherId = teacherDefaultMusicGroupSalariesWithCourseType.stream().collect(Collectors.toMap(TeacherDefaultMusicGroupSalary::getUserId, teacherDefaultMusicGroupSalary -> teacherDefaultMusicGroupSalary));
+
+                TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalaryWithTeacherId = teacherDefaultMusicGroupSalariesGroupByTeacherId.get(courseScheduleTeacherSalary.getUserId());
+
+                Long normalStudentNum = courseNormalStudentsMap.get(courseSchedule.getId());
+                if(Objects.isNull(normalStudentNum)){
+                    normalStudentNum = Long.valueOf(0);
+                }
+                if(Objects.nonNull(teacherDefaultMusicGroupSalaryWithTeacherId)&& org.apache.commons.lang3.StringUtils.isNoneBlank(teacherDefaultMusicGroupSalaryWithTeacherId.getSalaryRuleJson())){
+                    JSONObject salaryRuleJsonObject = JSONObject.parseObject(teacherDefaultMusicGroupSalaryWithTeacherId.getSalaryRuleJson());
+                    teacherSalary = salaryRuleJsonObject.getBigDecimal(normalStudentNum.toString());
+                }
+                if(Objects.isNull(teacherSalary)){
+                    teacherSalary = BigDecimal.ZERO;
+                }
             }else{
                 teacherSalary=courseScheduleTeacherSalary.getTeacherActualSalary();
             }
@@ -706,7 +744,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 //            teacherCashAccountDetail.setAttribute(courseScheduleTeacherSalary.getCourseScheduleId().toString());
 //            userCashAccountDetails.add(teacherCashAccountDetail);
 
-        });
+        }
 //        sysUserCashAccountDetailDao.batchInsert(userCashAccountDetails);
     }
 

+ 6 - 5
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -5,7 +5,8 @@ import java.util.*;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.huifu.adapay.core.exception.BaseAdaPayException;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+
 import org.springframework.util.DigestUtils;
 
 public class Payment {
@@ -25,7 +26,7 @@ public class Payment {
         String errorCode = (String) payment.get("error_code");
         if (null != errorCode) {
             String errorMsg = (String) payment.get("error_msg");
-            throw new BaseAdaPayException(errorMsg);
+            throw new ThirdpartyException(errorMsg);
         }
 
         return payment;
@@ -52,7 +53,7 @@ public class Payment {
             paymentParams.put("notify_url", "notify_url");
             System.out.println("关单请求参数:" + JSON.toJSONString(paymentId));
             payment = com.huifu.adapay.model.Payment.close(paymentParams);
-        } catch (BaseAdaPayException e) {
+        } catch (ThirdpartyException e) {
             e.printStackTrace();
         }
 
@@ -83,7 +84,7 @@ public class Payment {
         try {
             System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
             payment = com.huifu.adapay.model.Payment.query(paymentId);
-        } catch (BaseAdaPayException e) {
+        } catch (ThirdpartyException e) {
             e.printStackTrace();
         }
 
@@ -110,7 +111,7 @@ public class Payment {
         String error_code = (String) payment.get("error_code");
         if (null != error_code) {
             String errorMsg = (String) payment.get("error_msg");
-            throw new BaseAdaPayException(errorMsg);
+            throw new ThirdpartyException(errorMsg);
         }
         return payment;
     }