|
@@ -23,6 +23,7 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -89,15 +90,18 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("请选择指导老师");
|
|
|
}
|
|
|
|
|
|
- if(vipGroup.getCourseSchedules().size()!=vipGroup.getVipGroupApplyBaseInfo().getAllCourseNum()){
|
|
|
+ if(vipGroup.getCourseSchedules().size()!=(vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()+vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum())){
|
|
|
throw new BizException("课时总数不匹配!");
|
|
|
}
|
|
|
|
|
|
Map<TeachModeEnum, List<CourseSchedule>> courseScheduleGroup = vipGroup.getCourseSchedules().stream().collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
|
|
|
- if(courseScheduleGroup.get(TeachModeEnum.OFFLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()){
|
|
|
+
|
|
|
+ if((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE))&&vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()!=0)
|
|
|
+ ||(!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE))&&(courseScheduleGroup.get(TeachModeEnum.OFFLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()))){
|
|
|
throw new BizException("线下课课时数量安排有误!");
|
|
|
}
|
|
|
- if(courseScheduleGroup.get(TeachModeEnum.ONLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()){
|
|
|
+ if((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE))&&vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()!=0)
|
|
|
+ ||(!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE))&&(courseScheduleGroup.get(TeachModeEnum.ONLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()))){
|
|
|
throw new BizException("线上课课时数量安排有误!");
|
|
|
}
|
|
|
|
|
@@ -107,9 +111,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
//生成vip课信息
|
|
|
VipGroupApplyBaseInfoDto vipGroupApplyBaseInfoDto=vipGroup.getVipGroupApplyBaseInfo();
|
|
|
+ List<String> bySubIds = subjectDao.findBySubIds(vipGroupApplyBaseInfoDto.getSubjectIdList());
|
|
|
+ StringBuffer className=new StringBuffer(StringUtils.join(bySubIds,","));
|
|
|
+ className.append("•");
|
|
|
+ className.append(vipGroupApplyBaseInfoDto.getName());
|
|
|
+ vipGroupApplyBaseInfoDto.setName(className.toString());
|
|
|
vipGroupApplyBaseInfoDto.setTotalPrice(countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
|
|
|
vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
|
|
|
- vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice()));
|
|
|
+ vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice()).get("totalPrice"));
|
|
|
vipGroupDao.insert(vipGroupApplyBaseInfoDto);
|
|
|
|
|
|
//获取vip课类型信息
|
|
@@ -117,9 +126,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
//创建班级信息
|
|
|
ClassGroup classGroup=new ClassGroup();
|
|
|
+ classGroup.setSubjectIdList(vipGroupApplyBaseInfoDto.getSubjectIdList());
|
|
|
classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
|
|
|
classGroup.setName(vipGroupApplyBaseInfoDto.getName());
|
|
|
classGroup.setExpectStudentNum(vipGroupApplyBaseInfoDto.getExpectStudentNum());
|
|
|
+ classGroup.setTotalClassTimes(vipGroupApplyBaseInfoDto.getOnlineClassesNum()+vipGroupApplyBaseInfoDto.getOfflineClassesNum());
|
|
|
classGroup.setType(ClassGroupTypeEnum.VIP);
|
|
|
classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
|
classGroupDao.insert(classGroup);
|
|
@@ -139,13 +150,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
//创建班级老师关联记录
|
|
|
ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
|
|
|
classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
- classGroupTeacherMapper.setUserId(Integer.parseInt(vipGroupApplyBaseInfoDto.getTeacherId().toString()));
|
|
|
+ classGroupTeacherMapper.setUserId(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
|
|
|
|
|
|
//创建班级与老师课酬记录
|
|
|
ClassGroupTeacherSalary classGroupTeacherSalary=new ClassGroupTeacherSalary();
|
|
|
classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
- classGroupTeacherSalary.setUserId(Integer.parseInt(vipGroupApplyBaseInfoDto.getTeacherId().toString()));
|
|
|
+ classGroupTeacherSalary.setUserId(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
classGroupTeacherSalary.setSalary(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
|
|
|
classGroupTeacherSalary.setOnlineClassesSalary(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary());
|
|
|
classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
@@ -156,6 +167,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
&&courseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
|
|
|
throw new BizException("课时安排时间超出范围!");
|
|
|
}
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
|
|
|
courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
});
|
|
|
courseScheduleService.batchAddCourseSchedule(vipGroup.getCourseSchedules());
|
|
@@ -413,6 +425,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
@Override
|
|
|
public StudentVipGroupDetailDto getVipGroupShowDetail(Long vipGroupId) {
|
|
|
+ if(Objects.isNull(vipGroupId)){
|
|
|
+ throw new BizException("请指定vip课程");
|
|
|
+ }
|
|
|
return vipGroupDao.getVipGroupDetail(vipGroupId);
|
|
|
}
|
|
|
|
|
@@ -475,7 +490,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
String orderNo=StringUtils.join(new String[]{user.getId().toString(),String.valueOf(System.currentTimeMillis())});
|
|
|
studentPaymentOrder.setOrderNo(orderNo);
|
|
|
studentPaymentOrder.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
- studentPaymentOrder.setExpectAmount(countVipGroupPredictFee(vipGroup,vipGroup.getOnlineClassesUnitPrice(),vipGroup.getOfflineClassesUnitPrice()));
|
|
|
+ studentPaymentOrder.setExpectAmount(countVipGroupPredictFee(vipGroup,vipGroup.getOnlineClassesUnitPrice(),vipGroup.getOfflineClassesUnitPrice()).get("totalPrice"));
|
|
|
if(vipGroupActivity.getType()==VipGroupActivityTypeEnum.DISCOUNT){
|
|
|
studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount().multiply(new BigDecimal(vipGroupActivity.getAttribute1())));
|
|
|
}else{
|
|
@@ -511,15 +526,67 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
* 计算VIP课程预计收费
|
|
|
*/
|
|
|
@Override
|
|
|
- public BigDecimal countVipGroupPredictFee(VipGroup vipGroup,BigDecimal onlineClassesUnitPrice,BigDecimal offlineClassesUnitPrice){
|
|
|
+ public Map<String,BigDecimal> countVipGroupPredictFee(VipGroup vipGroup,BigDecimal onlineClassesUnitPrice,BigDecimal offlineClassesUnitPrice){
|
|
|
+ if(Objects.isNull(vipGroup.getUserId())){
|
|
|
+ throw new BizException("请指定教师");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Objects.isNull(vipGroup.getVipGroupCategoryId())){
|
|
|
+ throw new BizException("请指定课程形式");
|
|
|
+ }
|
|
|
+
|
|
|
+ TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(vipGroup.getUserId().longValue(),
|
|
|
+ vipGroup.getVipGroupCategoryId());
|
|
|
+
|
|
|
+ if(Objects.isNull(teacherDefaultVipGroupSalary)){
|
|
|
+ throw new BizException("课程形式不存在");
|
|
|
+ }
|
|
|
+
|
|
|
VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
|
|
|
- if(Objects.isNull(vipGroup)){
|
|
|
- throw new BizException("该课未指定活动方案");
|
|
|
+
|
|
|
+ if(Objects.isNull(vipGroupActivity)){
|
|
|
+ throw new BizException("指定的活动方案不存在");
|
|
|
}
|
|
|
+
|
|
|
+ VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
|
|
|
+
|
|
|
+ Map<String,BigDecimal> results=new HashMap<>(1);
|
|
|
+
|
|
|
BigDecimal offlineClassNum=new BigDecimal(vipGroup.getOfflineClassesNum());
|
|
|
BigDecimal onlineClassNum=new BigDecimal(vipGroup.getOnlineClassesNum());
|
|
|
BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
|
|
|
BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
|
|
|
+
|
|
|
+ //教师课酬线上单课酬计算
|
|
|
+ switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
|
|
|
+ case TEACHER_DEFAULT:
|
|
|
+ results.put("onlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary());
|
|
|
+ break;
|
|
|
+ case RATIO_DISCOUNT:
|
|
|
+ results.put("onlineTeacherSalary",onlineClassesUnitPrice.multiply((vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())));
|
|
|
+ break;
|
|
|
+ case FIXED_SALARY:
|
|
|
+ results.put("onlineTeacherSalary",vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new BizException("未指定课酬结算标准!");
|
|
|
+ }
|
|
|
+ //教师线下单课酬计算
|
|
|
+ switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
|
|
|
+ case TEACHER_DEFAULT:
|
|
|
+ results.put("offlineTeacherSalary",teacherDefaultVipGroupSalary.getOfflineClassesSalary());
|
|
|
+ break;
|
|
|
+ case RATIO_DISCOUNT:
|
|
|
+ results.put("offlineTeacherSalary",offlineClassesUnitPrice.multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()));
|
|
|
+ break;
|
|
|
+ case FIXED_SALARY:
|
|
|
+ results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new BizException("未指定课酬结算标准!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //课程购买费用计算
|
|
|
BigDecimal totalPrice;
|
|
|
switch (vipGroupActivity.getType()){
|
|
|
case BASE_ACTIVITY:
|
|
@@ -536,18 +603,21 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
|
|
|
}
|
|
|
offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
|
|
|
- }else{
|
|
|
+ }else if(vipGroup.getGiveTeachMode()==TeachModeEnum.ONLINE){
|
|
|
if(onlineClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
|
|
|
onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
|
|
|
}
|
|
|
onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
|
|
|
+ }else{
|
|
|
+ throw new BizException("请指定赠送课程类型!");
|
|
|
}
|
|
|
totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
|
|
|
break;
|
|
|
default:
|
|
|
throw new BizException("活动类型错误!");
|
|
|
}
|
|
|
- return totalPrice;
|
|
|
+ results.put("totalPrice",totalPrice);
|
|
|
+ return results;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -573,7 +643,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Map surplusClassTimes=MapUtil.convertMybatisMap(vipGroupDao.countSurplusClassTimes(vipGroupId));
|
|
|
studentApplyRefunds.setExpectAmount(countVipGroupPredictFee(vipGroup,
|
|
|
new BigDecimal(surplusClassTimes.get(TeachModeEnum.ONLINE.getCode()).toString()),
|
|
|
- new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString())));
|
|
|
+ new BigDecimal(surplusClassTimes.get(TeachModeEnum.OFFLINE.getCode()).toString())).get("totalPrice"));
|
|
|
studentApplyRefunds.setStatus(AuditStatusEnum.ING);
|
|
|
String orderNo=StringUtils.join(new String[]{studentId.toString(),String.valueOf(System.currentTimeMillis())});
|
|
|
studentApplyRefunds.setOrderNo(orderNo);
|
|
@@ -585,6 +655,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void applyRefundAudit(StudentApplyRefunds studentApplyRefunds) {
|
|
|
+ if(Objects.isNull(studentApplyRefunds.getId())){
|
|
|
+ throw new BizException("请指定退费订单!");
|
|
|
+ }
|
|
|
StudentApplyRefunds oldStudentApplyRefunds=studentApplyRefundsDao.get(studentApplyRefunds.getId());
|
|
|
oldStudentApplyRefunds.setStatus(studentApplyRefunds.getStatus());
|
|
|
if(null==studentApplyRefunds.getActualAmount()){
|
|
@@ -676,4 +749,49 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
return courseScheduleDao.findStudentNamesByCourseSchedule(courseScheduleId);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void stopGroup(Long vipGroupId) {
|
|
|
+ if(Objects.isNull(vipGroupId)){
|
|
|
+ throw new BizException("请指定vip课");
|
|
|
+ }
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(vipGroupId);
|
|
|
+ if(Objects.isNull(vipGroup)){
|
|
|
+ throw new BizException("该课程不存在");
|
|
|
+ }
|
|
|
+ if(vipGroup.getStatus()==VipGroupStatusEnum.FINISH||vipGroup.getStatus()==VipGroupStatusEnum.CANCEL){
|
|
|
+ throw new BizException("该课程已结束或者已被停止,无法进行此操作");
|
|
|
+ }
|
|
|
+ if(vipGroup.getStatus()==VipGroupStatusEnum.NOT_START){
|
|
|
+ vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
|
|
|
+ vipGroupDao.update(vipGroup);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Map<Long, BigDecimal>> maps = vipGroupDao.countSurplusCourseFee(vipGroupId);
|
|
|
+ if(CollectionUtils.isEmpty(maps)){
|
|
|
+ vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
|
|
|
+ vipGroupDao.update(vipGroup);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, BigDecimal> studentSurplusClassFees = MapUtil.convertMybatisMap(maps);
|
|
|
+ for(Long userId:studentSurplusClassFees.keySet()){
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId);
|
|
|
+ if(null==studentPaymentOrder){
|
|
|
+ throw new BizException("未找到相关订单信息!");
|
|
|
+ }
|
|
|
+ sysUserCashAccountService.updateBalance(userId.intValue(),studentSurplusClassFees.get(userId));
|
|
|
+ SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId.intValue());
|
|
|
+ SysUserCashAccountDetail sysUserCashAccountDetail=new SysUserCashAccountDetail();
|
|
|
+ sysUserCashAccountDetail.setUserId(userId.intValue());
|
|
|
+ sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
|
|
|
+ sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ sysUserCashAccountDetail.setAmount(studentSurplusClassFees.get(userId));
|
|
|
+ sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
+ sysUserCashAccountDetail.setAttribute(studentPaymentOrder.getOrderNo());
|
|
|
+ sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
|
|
|
+ }
|
|
|
+ vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
|
|
|
+ vipGroupDao.update(vipGroup);
|
|
|
+ }
|
|
|
}
|