|
@@ -273,9 +273,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Map<String, BigDecimal> costInfo = countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
|
|
|
vipGroupApplyBaseInfoDto.getUserId(),
|
|
|
vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
|
|
|
- vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(),
|
|
|
- true,
|
|
|
- true);
|
|
|
+ vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice());
|
|
|
|
|
|
// BigDecimal offlineClassNum=new BigDecimal(vipGroupApplyBaseInfoDto.getOfflineClassesNum());
|
|
|
// BigDecimal onlineClassNum=new BigDecimal(vipGroupApplyBaseInfoDto.getOnlineClassesNum());
|
|
@@ -976,9 +974,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
public <K extends VipGroup> Map<String,BigDecimal> countVipGroupPredictFee(K vipGroup,
|
|
|
Integer teacherId,
|
|
|
BigDecimal onlineClassesUnitPrice,
|
|
|
- BigDecimal offlineClassesUnitPrice,
|
|
|
- boolean computeTotalPrice,
|
|
|
- boolean useDefaultTeacherSalary){
|
|
|
+ BigDecimal offlineClassesUnitPrice){
|
|
|
|
|
|
if(Objects.isNull(teacherId)){
|
|
|
throw new BizException("请指定教师");
|
|
@@ -988,10 +984,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("请指定课程形式");
|
|
|
}
|
|
|
|
|
|
- if(Objects.isNull(vipGroup.getSingleClassMinutes())){
|
|
|
- throw new BizException("请指定课程时长");
|
|
|
- }
|
|
|
-
|
|
|
VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroup.getVipGroupCategoryId().intValue());
|
|
|
if(Objects.isNull(vipGroupCategory)){
|
|
|
throw new BizException("未找到课程形式");
|
|
@@ -1000,6 +992,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(teacherId,
|
|
|
vipGroup.getVipGroupCategoryId());
|
|
|
|
|
|
+ if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
+ throw new BizException("请设置教师课酬");
|
|
|
+ }
|
|
|
+
|
|
|
if(Objects.isNull(vipGroup.getVipGroupActivityId())){
|
|
|
throw new BizException("请指定活动方案");
|
|
|
}
|
|
@@ -1010,6 +1006,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("指定的活动方案不存在");
|
|
|
}
|
|
|
|
|
|
+ Teacher teacher = teacherDao.get(teacherId);
|
|
|
+
|
|
|
VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
|
|
|
|
|
|
if(Objects.isNull(vipGroupSalarySettlementDto)){
|
|
@@ -1018,12 +1016,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
Map<String,BigDecimal> results=new HashMap<>(1);
|
|
|
|
|
|
- //课程时长与结算单位时长占比
|
|
|
BigDecimal offlineClassNum=new BigDecimal(vipGroup.getOfflineClassesNum());
|
|
|
BigDecimal onlineClassNum=new BigDecimal(vipGroup.getOnlineClassesNum());
|
|
|
- onlineClassesUnitPrice=Objects.isNull(onlineClassesUnitPrice)?new BigDecimal(0):onlineClassesUnitPrice;
|
|
|
+ onlineClassesUnitPrice=Objects.isNull(onlineClassesUnitPrice)?vipGroup.getOnlineClassesUnitPrice():onlineClassesUnitPrice;
|
|
|
+ if(Objects.isNull(onlineClassesUnitPrice)){
|
|
|
+ onlineClassesUnitPrice = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
|
|
|
- offlineClassesUnitPrice=Objects.isNull(offlineClassesUnitPrice)?new BigDecimal(0):offlineClassesUnitPrice;
|
|
|
+ offlineClassesUnitPrice=Objects.isNull(offlineClassesUnitPrice)?vipGroup.getOfflineClassesUnitPrice():offlineClassesUnitPrice;
|
|
|
+ if(Objects.isNull(offlineClassesUnitPrice)){
|
|
|
+ offlineClassesUnitPrice = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
|
|
|
BigDecimal totalClassNum=offlineClassNum.add(onlineClassNum);
|
|
|
BigDecimal teacherOnlineSalary=null,teacherOfflineSalary=null;
|
|
@@ -1067,13 +1070,25 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
|
|
|
|
|
|
+ if(JobNatureEnum.PART_TIME.equals(teacher.getJobNature())||vipGroupCategory.getStudentNum()>1){
|
|
|
+ int normalStudentNum = 0;
|
|
|
+ BigDecimal ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
+ BigDecimal ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
+ if(Objects.nonNull(vipGroup.getId())){
|
|
|
+ normalStudentNum = classGroupStudentMapperDao.countGroupNormalStudentNum(GroupType.VIP, vipGroup.getId().toString());
|
|
|
+ }
|
|
|
+ if(normalStudentNum>0&&normalStudentNum!=vipGroupCategory.getStudentNum()){
|
|
|
+ ots = ots.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ofts = ofts.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+ results.put("onlineTeacherSalary", ots);
|
|
|
+ results.put("offlineTeacherSalary", ofts);
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+
|
|
|
//教师课酬线上单课酬计算
|
|
|
if(Objects.nonNull(vipGroupSalarySettlementDto.getOnlineSalarySettlement())){
|
|
|
- if(vipGroup instanceof VipGroupApplyBaseInfoDto&&!useDefaultTeacherSalary
|
|
|
- &&vipGroupActivity.getSalaryReadonlyFlag().equals("1")){
|
|
|
- teacherOnlineSalary=((VipGroupApplyBaseInfoDto) vipGroup).getOnlineTeacherSalary();
|
|
|
- results.put("onlineTeacherSalary",teacherOnlineSalary);
|
|
|
- }
|
|
|
if(Objects.isNull(teacherOnlineSalary)){
|
|
|
switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
|
|
|
case TEACHER_DEFAULT:
|
|
@@ -1100,14 +1115,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }else{
|
|
|
- results.put("onlineTeacherSalary", new BigDecimal(0));
|
|
|
}
|
|
|
|
|
|
//教师线下单课酬计算
|
|
|
if(Objects.nonNull(vipGroupSalarySettlementDto.getOfflineSalarySettlement())){
|
|
|
- if(vipGroup instanceof VipGroupApplyBaseInfoDto&&!useDefaultTeacherSalary
|
|
|
- &&vipGroupActivity.getSalaryReadonlyFlag().equals("1")){
|
|
|
+ if(vipGroup instanceof VipGroupApplyBaseInfoDto){
|
|
|
teacherOfflineSalary=((VipGroupApplyBaseInfoDto) vipGroup).getOfflineTeacherSalary();
|
|
|
results.put("offlineTeacherSalary",teacherOfflineSalary);
|
|
|
}
|
|
@@ -1132,8 +1144,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("未指定课酬结算标准!");
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- results.put("offlineTeacherSalary", new BigDecimal(0));
|
|
|
}
|
|
|
|
|
|
return results;
|
|
@@ -1876,12 +1886,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
courseScheduleService.batchAddCourseSchedule(newCourseSchedules);
|
|
|
|
|
|
- TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId(), vipGroup.getVipGroupCategoryId());
|
|
|
-
|
|
|
- if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
- throw new BizException("请设置默认课酬");
|
|
|
- }
|
|
|
-
|
|
|
ClassGroupTeacherMapper oldClassGroupTeacherMapper = classGroupTeacherMapperDao.findByClassGroupAndTeacher(classGroup.getId(),oldTeacherId);
|
|
|
if(Objects.nonNull(oldClassGroupTeacherMapper)){
|
|
|
ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
|
|
@@ -1893,11 +1897,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
|
|
|
}
|
|
|
|
|
|
+ Map<String, BigDecimal> salaryMap = countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);
|
|
|
+
|
|
|
//创建老师单节课课酬信息
|
|
|
courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
|
|
|
newCourseSchedules,
|
|
|
- teacherDefaultVipGroupSalary.getOfflineClassesSalary(),
|
|
|
- teacherDefaultVipGroupSalary.getOfflineClassesSalary());
|
|
|
+ salaryMap.get("onlineTeacherSalary"),
|
|
|
+ salaryMap.get("offlineTeacherSalary"));
|
|
|
}
|
|
|
|
|
|
BigDecimal surplusCourseFee = new BigDecimal(0);
|
|
@@ -2524,12 +2530,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
courseScheduleService.batchAddCourseSchedule(vipGroupApplyDto.getCourseSchedules());
|
|
|
|
|
|
- ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroup.getId().intValue(), vipGroup.getUserId());
|
|
|
+ Map<String, BigDecimal> map = countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);
|
|
|
+
|
|
|
+ BigDecimal teacherSalary=BigDecimal.ZERO;
|
|
|
|
|
|
BigDecimal onlineTeacherSalary=null,offlineTeacherSalary=null,zero=new BigDecimal(0);
|
|
|
- if(Objects.nonNull(classGroupTeacherSalary)){
|
|
|
- onlineTeacherSalary=classGroupTeacherSalary.getOnlineClassesSalary();
|
|
|
- offlineTeacherSalary=classGroupTeacherSalary.getSalary();
|
|
|
+
|
|
|
+ if(Objects.nonNull(map)){
|
|
|
+ onlineTeacherSalary=map.get("onlineTeacherSalary");
|
|
|
+ offlineTeacherSalary=map.get("offlineTeacherSalary");
|
|
|
}
|
|
|
|
|
|
if(Objects.isNull(onlineTeacherSalary)){
|
|
@@ -2540,19 +2549,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
offlineTeacherSalary = new BigDecimal(0);
|
|
|
}
|
|
|
|
|
|
- TeacherDefaultVipGroupSalary byTeacherAndCategory = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId(), vipGroup.getVipGroupCategoryId());
|
|
|
-
|
|
|
- if(onlineTeacherSalary.compareTo(zero)<=0){
|
|
|
- if(Objects.nonNull(byTeacherAndCategory)){
|
|
|
- onlineTeacherSalary=byTeacherAndCategory.getOfflineClassesSalary();
|
|
|
- }
|
|
|
- }
|
|
|
- if(offlineTeacherSalary.compareTo(zero)<=0){
|
|
|
- if(Objects.nonNull(byTeacherAndCategory)){
|
|
|
- offlineTeacherSalary=byTeacherAndCategory.getOfflineClassesSalary();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//创建老师单节课课酬信息
|
|
|
courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
|
|
|
vipGroupApplyDto.getCourseSchedules(),
|
|
@@ -2650,13 +2646,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(courseNum==0){
|
|
|
courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
|
|
|
- ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroupId.intValue(), vipGroup.getUserId());
|
|
|
+ Map<String, BigDecimal> salaryMap = countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);
|
|
|
|
|
|
//创建老师单节课课酬信息
|
|
|
courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
|
|
|
courseSchedules,
|
|
|
- classGroupTeacherSalary.getOnlineClassesSalary(),
|
|
|
- classGroupTeacherSalary.getSalary());
|
|
|
+ salaryMap.get("onlineTeacherSalary"),
|
|
|
+ salaryMap.get("offlineTeacherSalary"));
|
|
|
}
|
|
|
imGroupMemberList.add(new ImGroupMember(vipGroup.getUserId().toString()));
|
|
|
}
|