|
@@ -149,6 +149,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
private GroupClassService groupClassService;
|
|
|
@Autowired
|
|
|
private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupStudentCoursePriceDao vipGroupStudentCoursePriceDao;
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory
|
|
|
.getLogger(VipGroup.class);
|
|
@@ -205,23 +207,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
|
|
|
&&Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())){
|
|
|
- throw new BizException("请设置教师课酬");
|
|
|
+ throw new BizException("请设置课程单价");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
|
|
|
throw new BizException("请选择学员");
|
|
|
}
|
|
|
|
|
|
- if(Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())){
|
|
|
- vipGroupApplyBaseInfoDto.setOnlineTeacherSalary(new BigDecimal(0));
|
|
|
- }
|
|
|
-
|
|
|
- if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())){
|
|
|
- vipGroupApplyBaseInfoDto.setOfflineTeacherSalary(new BigDecimal(0));
|
|
|
+ if(Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())||Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())){
|
|
|
+ throw new BizException("请设置教师课酬");
|
|
|
}
|
|
|
|
|
|
- //获取活动信息
|
|
|
- VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId().intValue());
|
|
|
Integer totalClassTimes=vipGroupApplyBaseInfoDto.getOnlineClassesNum()+vipGroupApplyBaseInfoDto.getOfflineClassesNum();
|
|
|
//获取第一节课
|
|
|
CourseSchedule firstCourseSchedule = vipGroup.getCourseSchedules().stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
|
|
@@ -241,12 +237,20 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("创建失败,报名截止时间必须在开课时间前一天");
|
|
|
}
|
|
|
|
|
|
+ List<Integer> canBuyStudentIds = Arrays.stream(vipGroupApplyBaseInfoDto.getStudentIdList().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
|
|
|
+ List<VipGroupStudentCoursePrice> vscps = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取活动信息
|
|
|
+ VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId());
|
|
|
//判断课程安排是否超出范围
|
|
|
- if(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime())){
|
|
|
+ if(Objects.nonNull(vipGroupActivity)&&(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime()))){
|
|
|
if(latestCourseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
|
|
|
||firstCourseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
|
|
|
throw new BizException("课时安排时间超出范围!");
|
|
|
}
|
|
|
+ for (Integer canBuyStudentId : canBuyStudentIds) {
|
|
|
+ vscps.add(new VipGroupStudentCoursePrice(canBuyStudentId, vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice()));
|
|
|
+ }
|
|
|
}else{
|
|
|
VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle = vipGroupDefaultClassesCycleDao.findByOrganAndClassTimes(totalClassTimes);
|
|
|
|
|
@@ -256,6 +260,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("课时安排时间超出范围!");
|
|
|
}
|
|
|
}
|
|
|
+ vscps = vipGroup.getVipGroupApplyBaseInfo().getVipGroupStudentCoursePrices();
|
|
|
+ vipGroupApplyBaseInfoDto.setTotalPrice(new BigDecimal(0));
|
|
|
+ for (VipGroupStudentCoursePrice vscp : vscps) {
|
|
|
+ if(Objects.isNull(vscp.getOnlineClassesUnitPrice())||Objects.isNull(vscp.getOfflineClassesUnitPrice())){
|
|
|
+ throw new BizException("请设置课程单价");
|
|
|
+ }
|
|
|
+ vscp.setPaymentPrice(vscp.getOfflineClassesUnitPrice().multiply(new BigDecimal(vipGroupApplyBaseInfoDto.getOfflineClassesNum())).add(vscp.getOnlineClassesUnitPrice().multiply(new BigDecimal(vipGroupApplyBaseInfoDto.getOnlineClassesNum()))));
|
|
|
+ vipGroupApplyBaseInfoDto.setTotalPrice(vipGroupApplyBaseInfoDto.getTotalPrice().add(vscp.getPaymentPrice()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int repeatVipGroups = vipGroupDao.countUserRepeatVipGroupInCourseStartEndTime(vipGroupApplyBaseInfoDto.getUserId(), firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
@@ -267,9 +280,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(Objects.isNull(vipGroupCategory)){
|
|
|
throw new BizException("课程形式不存在");
|
|
|
}
|
|
|
-
|
|
|
- List<Integer> canBuyStudentIds = Arrays.stream(vipGroupApplyBaseInfoDto.getStudentIdList().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
|
|
|
-
|
|
|
List<String> studentNames = studentDao.getStudentNames(canBuyStudentIds);
|
|
|
|
|
|
//生成vip课信息
|
|
@@ -360,6 +370,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
vipGroupDao.insert(vipGroupApplyBaseInfoDto);
|
|
|
|
|
|
+ vscps.forEach(e->e.setVipGroupId(vipGroupApplyBaseInfoDto.getId()));
|
|
|
+ vipGroupStudentCoursePriceDao.batchInsert(vscps);
|
|
|
+
|
|
|
vipGroup.getVipGroupApplyBaseInfo().setId(vipGroupApplyBaseInfoDto.getId());
|
|
|
|
|
|
//创建班级信息
|
|
@@ -972,14 +985,38 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("请设置教师课酬");
|
|
|
}
|
|
|
|
|
|
- if(Objects.isNull(vipGroup.getVipGroupActivityId())){
|
|
|
- throw new BizException("请指定活动方案");
|
|
|
+ if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
|
|
|
+ throw new BizException("请设置教师VIP课课酬");
|
|
|
}
|
|
|
|
|
|
- VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
|
|
|
+ VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
|
|
|
+
|
|
|
+ Map<String,BigDecimal> results=new HashMap<>(1);
|
|
|
+
|
|
|
+ int normalStudentNum = 0;
|
|
|
+ if(Objects.nonNull(vipGroup.getId())){
|
|
|
+ normalStudentNum = classGroupStudentMapperDao.countGroupNormalStudentNum(GroupType.VIP, vipGroup.getId().toString());
|
|
|
+ }
|
|
|
|
|
|
if(Objects.isNull(vipGroupActivity)){
|
|
|
- throw new BizException("指定的活动方案不存在");
|
|
|
+ vipGroup.setTotalPrice(new BigDecimal(0));
|
|
|
+ for (VipGroupStudentCoursePrice vscp : ((VipGroupApplyBaseInfoDto)vipGroup).getVipGroupStudentCoursePrices()) {
|
|
|
+ if(Objects.isNull(vscp.getOnlineClassesUnitPrice())||Objects.isNull(vscp.getOfflineClassesUnitPrice())){
|
|
|
+ throw new BizException("请设置课程单价");
|
|
|
+ }
|
|
|
+ vscp.setPaymentPrice(vscp.getOfflineClassesUnitPrice().multiply(new BigDecimal(vipGroup.getOfflineClassesNum())).add(vscp.getOnlineClassesUnitPrice().multiply(new BigDecimal(vipGroup.getOnlineClassesNum()))));
|
|
|
+ vipGroup.setTotalPrice(vipGroup.getTotalPrice().add(vscp.getPaymentPrice()));
|
|
|
+ }
|
|
|
+ BigDecimal ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
+ BigDecimal ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
+ if(Objects.nonNull(vipGroup.getStatus())&&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("totalPrice",vipGroup.getTotalPrice());
|
|
|
+ results.put("onlineTeacherSalary",ots);
|
|
|
+ results.put("offlineTeacherSalary",ofts);
|
|
|
+ return results;
|
|
|
}
|
|
|
|
|
|
VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
|
|
@@ -988,8 +1025,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("课酬结算方案错误");
|
|
|
}
|
|
|
|
|
|
- Map<String,BigDecimal> results=new HashMap<>(1);
|
|
|
-
|
|
|
BigDecimal offlineClassNum=new BigDecimal(vipGroup.getOfflineClassesNum());
|
|
|
BigDecimal onlineClassNum=new BigDecimal(vipGroup.getOnlineClassesNum());
|
|
|
onlineClassesUnitPrice=Objects.isNull(onlineClassesUnitPrice)?vipGroup.getOnlineClassesUnitPrice():onlineClassesUnitPrice;
|
|
@@ -1044,34 +1079,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
|
|
|
|
|
|
- int normalStudentNum = 0;
|
|
|
- if(Objects.nonNull(vipGroup.getId())){
|
|
|
- normalStudentNum = classGroupStudentMapperDao.countGroupNormalStudentNum(GroupType.VIP, vipGroup.getId().toString());
|
|
|
- }
|
|
|
-
|
|
|
-// if(JobNatureEnum.PART_TIME.equals(teacher.getJobNature())){
|
|
|
-// BigDecimal ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
-// BigDecimal ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
-// 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(Objects.isNull(teacherOnlineSalary)){
|
|
|
switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
|
|
|
case TEACHER_DEFAULT:
|
|
|
- if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
|
|
|
- teacherOnlineSalary=new BigDecimal(0);
|
|
|
- }else{
|
|
|
- teacherOnlineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
- }
|
|
|
+ teacherOnlineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
results.put("onlineTeacherSalary",teacherOnlineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
break;
|
|
|
case RATIO_DISCOUNT:
|
|
@@ -1097,11 +1110,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(Objects.isNull(teacherOfflineSalary)){
|
|
|
switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
|
|
|
case TEACHER_DEFAULT:
|
|
|
- if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
|
|
|
- teacherOfflineSalary=new BigDecimal(0);
|
|
|
- }else{
|
|
|
- teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
- }
|
|
|
+ teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
|
|
|
results.put("offlineTeacherSalary",teacherOfflineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
break;
|
|
|
case RATIO_DISCOUNT:
|
|
@@ -2827,6 +2836,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Map<Integer, VipGroupStudentCoursePrice> studentCoursePriceMap = new HashMap<>();
|
|
|
+ if(Objects.isNull(vipGroup.getVipGroupActivityId())){
|
|
|
+ List<VipGroupStudentCoursePrice> vipGroupStudentCoursePrice = vipGroupStudentCoursePriceDao.getVipGroupStudentCoursePrice(vipGroupId, null);
|
|
|
+ studentCoursePriceMap = vipGroupStudentCoursePrice.stream().collect(Collectors.toMap(VipGroupStudentCoursePrice::getStudentId, v->v, (v1, v2)->v1));
|
|
|
+ }
|
|
|
+
|
|
|
VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroup(vipGroup.getId());
|
|
|
if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
|
|
|
throw new BizException("课程单价设置错误");
|
|
@@ -2996,10 +3011,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
//生成学生单课缴费信息
|
|
|
for (Integer studentId:studentIds) {
|
|
|
- SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
|
|
|
- if(sysUserCashAccount.getCourseBalance().compareTo(surplusCoursesPrice)<0){
|
|
|
- throw new BizException("存在课程余额不足的学生");
|
|
|
+ if(Objects.isNull(vipGroupActivity)){
|
|
|
+ VipGroupStudentCoursePrice vipGroupStudentCoursePrice = studentCoursePriceMap.get(studentId);
|
|
|
+ if(Objects.isNull(vipGroupStudentCoursePrice)||Objects.isNull(vipGroupStudentCoursePrice.getOfflineClassesUnitPrice())||Objects.isNull(vipGroupStudentCoursePrice.getOnlineClassesUnitPrice())){
|
|
|
+ throw new BizException("学员缴费设置有误");
|
|
|
+ }
|
|
|
+ vipGroup.setOfflineClassesUnitPrice(vipGroupStudentCoursePrice.getOfflineClassesUnitPrice());
|
|
|
+ vipGroup.setOnlineClassesUnitPrice(vipGroupStudentCoursePrice.getOnlineClassesUnitPrice());
|
|
|
+ surplusCoursesPrice = vipGroupStudentCoursePrice.getOfflineClassesUnitPrice().multiply(new BigDecimal(offlineCourseTimes)).add(vipGroupStudentCoursePrice.getOnlineClassesUnitPrice().multiply(new BigDecimal(onlineCourseTimes)));
|
|
|
}
|
|
|
+
|
|
|
+ sysUserCashAccountService.subtractFromCourseBalanceAndBalance(studentId,surplusCoursesPrice,PlatformCashAccountDetailTypeEnum.PAY_FEE, "后台添加学员扣减账户金额");
|
|
|
// courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupId,studentId);
|
|
|
|
|
|
List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
|
|
@@ -3046,8 +3068,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
|
|
|
- sysUserCashAccountService.updateCourseBalance(studentId,sysUserCashAccount.getCourseBalance().subtract(surplusCoursesPrice),PlatformCashAccountDetailTypeEnum.PAY_FEE, surplusCoursesPrice.negate(), "后台添加学员扣除课程余额");
|
|
|
-
|
|
|
//创建班级学生关联记录
|
|
|
ClassGroupStudentMapper classGroupStudentMapper;
|
|
|
|