|
@@ -101,6 +101,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
private TeacherAttendanceDao teacherAttendanceDao;
|
|
|
@Autowired
|
|
|
private ContractService contractService;
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupService classGroupService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, VipGroup> getDAO() {
|
|
@@ -146,6 +148,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("该用户不存在");
|
|
|
}
|
|
|
|
|
|
+ String studentIds=vipGroup.getStudentIds();
|
|
|
+ List<String> studentIdList=new ArrayList<>();
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(studentIds)){
|
|
|
+ studentIdList = Arrays.asList(studentIds.split(","));
|
|
|
+ }
|
|
|
+
|
|
|
Date now=new Date();
|
|
|
|
|
|
VipGroupApplyBaseInfoDto vipGroupApplyBaseInfoDto=vipGroup.getVipGroupApplyBaseInfo();
|
|
@@ -193,14 +202,19 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
//如果默认课酬与实际课酬不匹配则需要审批
|
|
|
if(costInfo.get("offlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())!=0||
|
|
|
- costInfo.get("onlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())!=0){
|
|
|
+ costInfo.get("onlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())!=0
|
|
|
+ &&StringUtils.isBlank(studentIds)){
|
|
|
vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
|
|
|
}else{
|
|
|
vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
|
|
|
}
|
|
|
|
|
|
vipGroupApplyBaseInfoDto.setTotalPrice(costInfo.get("totalPrice"));
|
|
|
- vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
|
|
|
+ if(StringUtils.isNotBlank(studentIds)){
|
|
|
+ vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.FINISH);
|
|
|
+ }else{
|
|
|
+ vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
|
|
|
+ }
|
|
|
vipGroupApplyBaseInfoDto.setOrganId(sysUser.getOrganId());
|
|
|
//开课时间为排课的第一节课的开始时间
|
|
|
vipGroupApplyBaseInfoDto.setCourseStartDate(firstCourseSchedule.getStartClassTime());
|
|
@@ -215,6 +229,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
ClassGroup classGroup=new ClassGroup();
|
|
|
classGroup.setSubjectIdList(vipGroupApplyBaseInfoDto.getSubjectIdList());
|
|
|
classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
|
|
|
+ if(StringUtils.isNotBlank(studentIds)){
|
|
|
+ classGroup.setStudentNum(studentIdList.size());
|
|
|
+ }
|
|
|
classGroup.setName(vipGroupApplyBaseInfoDto.getName());
|
|
|
classGroup.setExpectStudentNum(vipGroupApplyBaseInfoDto.getStudentNum());
|
|
|
classGroup.setTotalClassTimes(totalClassTimes);
|
|
@@ -264,6 +281,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
vipGroupApplyBaseInfoDto.setCourseSchedulesJson(JSON.toJSONString(vipGroup.getCourseSchedules()));
|
|
|
vipGroupDao.update(vipGroupApplyBaseInfoDto);
|
|
|
|
|
|
+ if(StringUtils.isNotBlank(studentIds)){
|
|
|
+ List<Integer> collect = studentIdList.stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
|
|
|
+ classGroupService.addStudentIntoClassGroup(vipGroupApplyBaseInfoDto.getId().toString(),classGroup.getId(),collect);
|
|
|
+ createVipGroupCourseScheInfo(vipGroupApplyBaseInfoDto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
SysUser systemUser = sysUserFeignService.queryUserById(systemId);
|
|
|
Set<Integer> roleIds = new HashSet<>(1);
|
|
|
roleIds.add(SysUserRole.OPERATION_EXECUTIVE);
|
|
@@ -500,6 +523,26 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public PageInfo findHaveCourseBalanceStudents(VipGroupQueryInfo queryInfo) {
|
|
|
+ PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List dataList = null;
|
|
|
+ int count = vipGroupDao.countHaveCourseBalanceStudentNum(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = vipGroupDao.findHaveCourseBalanceStudents(params);
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public VipGroupManageDetailDto getVipGroupDetail(Long vipGroupId) {
|
|
|
if(Objects.isNull(vipGroupId)){
|
|
|
throw new BizException("请指定vip课程");
|
|
@@ -1378,22 +1421,80 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void addVipGroupStudents(Long vipGroupId, List<Integer> studentIds) {
|
|
|
if(CollectionUtils.isEmpty(studentIds)){
|
|
|
throw new BizException("请选择学生");
|
|
|
}
|
|
|
if(Objects.isNull(vipGroupId)){
|
|
|
- throw new BizException("请指定班级");
|
|
|
+ throw new BizException("请指定vip课程");
|
|
|
}
|
|
|
+ VipGroup vipGroup=vipGroupDao.get(vipGroupId);
|
|
|
+ if(Objects.isNull(vipGroup)){
|
|
|
+ throw new BizException("未找到指定的vip课程");
|
|
|
+ }
|
|
|
+ ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
|
|
|
+ List<CourseSchedule> surplusCourses = courseScheduleDao.findByClassGroupAndStatus(classGroup.getId(), CourseStatusEnum.NOT_START.getCode());
|
|
|
+ if(CollectionUtils.isEmpty(surplusCourses)){
|
|
|
+ throw new BizException("此vip课程没有剩余课程计划");
|
|
|
+ }
|
|
|
+ BigDecimal surplusCoursesPrice=new BigDecimal(0);
|
|
|
+ surplusCourses.forEach(courseSchedule -> {
|
|
|
+ if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
|
|
|
+ surplusCoursesPrice.add(vipGroup.getOfflineClassesUnitPrice());
|
|
|
+ }else if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)){
|
|
|
+ surplusCoursesPrice.add(vipGroup.getOnlineClassesUnitPrice());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<ImGroupMember> imGroupMemberList = new ArrayList<>();
|
|
|
+ //生成学生单课缴费信息
|
|
|
+ for (Integer studentId:studentIds) {
|
|
|
+ SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
|
|
|
+ if(sysUserCashAccount.getCourseBalance().compareTo(surplusCoursesPrice)<0){
|
|
|
+ throw new BizException("存在课程余额不足的学生");
|
|
|
+ }
|
|
|
+ courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupId,studentId);
|
|
|
+
|
|
|
+ sysUserCashAccountService.updateCourseBalance(studentId,surplusCoursesPrice.negate());
|
|
|
|
|
|
+ imGroupMemberList.add(new ImGroupMember(studentId.toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ ImGroupMember[] imGroupMembers = imGroupMemberList.toArray(new ImGroupMember[imGroupMemberList.size()]);
|
|
|
+ // 创建群组
|
|
|
+ imFeignService.groupCreate(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void stopVipGroupWithNoCreate() {
|
|
|
List<VipGroup> noCreateSuccessVipGroups = vipGroupDao.findNoCreateSuccessVipGroup();
|
|
|
if(CollectionUtils.isEmpty(noCreateSuccessVipGroups)){
|
|
|
return;
|
|
|
}
|
|
|
-// studentPaymentOrderDao.queryByDealStatus()
|
|
|
+ //用户账户资金变动信息列表
|
|
|
+ List<SysUserCashAccountDetail> userCashAccountDetails = new ArrayList<>();
|
|
|
+ for (VipGroup noCreateSuccessVipGroup : noCreateSuccessVipGroups) {
|
|
|
+ List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(noCreateSuccessVipGroup.getId().toString(),
|
|
|
+ OrderTypeEnum.SMALL_CLASS_TO_BUY, DealStatusEnum.SUCCESS);
|
|
|
+ for (StudentPaymentOrder studentPaymentOrder:studentPaymentOrders){
|
|
|
+ //生成账户资金明细
|
|
|
+ sysUserCashAccountService.updateCourseBalance(studentPaymentOrder.getUserId(),studentPaymentOrder.getActualAmount());
|
|
|
+ SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentPaymentOrder.getUserId());
|
|
|
+ SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
+ sysUserIncomeCashAccountDetail.setUserId(studentPaymentOrder.getUserId());
|
|
|
+ sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
|
|
|
+ sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ sysUserIncomeCashAccountDetail.setAmount(studentPaymentOrder.getActualAmount());
|
|
|
+ sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
+ sysUserIncomeCashAccountDetail.setAttribute(studentPaymentOrder.getTransNo());
|
|
|
+ userCashAccountDetails.add(sysUserIncomeCashAccountDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sysUserCashAccountDetailDao.batchInsert(userCashAccountDetails);
|
|
|
}
|
|
|
}
|