|  | @@ -270,11 +270,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  studentRegistrationDao.batchInsert(studentRegistrationList);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  | -            List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | -            if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | -                Date nextPaymentDate = musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null);
 | 
	
		
			
				|  |  | -                musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,nextPaymentDate,"PAID_COMPLETED");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +//            List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | +//            if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | +//                Date nextPaymentDate = musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null);
 | 
	
		
			
				|  |  | +//                musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,nextPaymentDate,"PAID_COMPLETED");
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  |              musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "跨团调整", sysUser.getId(),""));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -371,7 +371,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  amount,
 | 
	
		
			
				|  |  |                  orderNo,
 | 
	
		
			
				|  |  |                  baseApiUrl+"/api-student/studentOrder/notify",
 | 
	
		
			
				|  |  | -                baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  | +                baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  |                  chargeInfo.getTitle(),
 | 
	
		
			
				|  |  |                  chargeInfo.getTitle(),
 | 
	
		
			
				|  |  |                  userId,
 | 
	
	
		
			
				|  | @@ -507,7 +507,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          	if(userCashAccount == null){
 | 
	
		
			
				|  |  |          		throw new BizException("用户账户找不到");
 | 
	
		
			
				|  |  |          	}
 | 
	
		
			
				|  |  | -        	if(userCashAccount.getBalance().subtract(amount).doubleValue() > 0){
 | 
	
		
			
				|  |  | +        	if(userCashAccount.getBalance().subtract(amount).doubleValue() >= 0){
 | 
	
		
			
				|  |  |          		// 更新订单信息
 | 
	
		
			
				|  |  |          		studentPaymentOrder.setBalancePaymentAmount(amount);
 | 
	
		
			
				|  |  |          		studentPaymentOrder.setOrganId(musicGroup.getOrganId());
 | 
	
	
		
			
				|  | @@ -564,7 +564,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  amount,
 | 
	
		
			
				|  |  |                  orderNo,
 | 
	
		
			
				|  |  |                  baseApiUrl+"/api-student/studentOrder/notify",
 | 
	
		
			
				|  |  | -                baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  | +                baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  |                  "乐团报名缴费",
 | 
	
		
			
				|  |  |                  "乐团报名缴费",
 | 
	
		
			
				|  |  |                  userId,
 | 
	
	
		
			
				|  | @@ -705,7 +705,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          		throw new BizException("用户账户找不到");
 | 
	
		
			
				|  |  |          	}
 | 
	
		
			
				|  |  |              studentPaymentOrder.setPaymentChannel("BALANCE");
 | 
	
		
			
				|  |  | -        	if(userCashAccount.getBalance().subtract(amount).doubleValue() > 0){
 | 
	
		
			
				|  |  | +        	if(userCashAccount.getBalance().subtract(amount).doubleValue() >= 0){
 | 
	
		
			
				|  |  |          		// 更新订单信息
 | 
	
		
			
				|  |  |          		studentPaymentOrder.setBalancePaymentAmount(amount);
 | 
	
		
			
				|  |  |          		studentPaymentOrder.setOrganId(musicGroup.getOrganId());
 | 
	
	
		
			
				|  | @@ -761,7 +761,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  amount,
 | 
	
		
			
				|  |  |                  orderNo,
 | 
	
		
			
				|  |  |                  baseApiUrl+"/api-student/studentOrder/notify",
 | 
	
		
			
				|  |  | -                baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  | +                baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  |                  "乐团报名缴费",
 | 
	
		
			
				|  |  |                  "乐团报名缴费",
 | 
	
		
			
				|  |  |                  userId,
 | 
	
	
		
			
				|  | @@ -806,13 +806,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              //删除原有的声部商品组合
 | 
	
		
			
				|  |  |              musicGroupSubjectGoodsGroupDao.delByMusicGroupId(subFeeSettingDto.getMusicGroupId());
 | 
	
		
			
				|  |  |              //如果是进行中,补充缴费信息
 | 
	
		
			
				|  |  | -            if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
 | 
	
		
			
				|  |  | -                List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | -                if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | -                    Date nextPaymentDate = musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null);
 | 
	
		
			
				|  |  | -                    musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,nextPaymentDate,"PAID_COMPLETED");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +//            if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
 | 
	
		
			
				|  |  | +//                List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | +//                if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | +//                    Date nextPaymentDate = musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null);
 | 
	
		
			
				|  |  | +//                    musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,nextPaymentDate,"PAID_COMPLETED");
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  |              List<MusicGroupSubjectPlan> musicGroupSubjectPlans = subFeeSettingDto.getMusicGroupSubjectPlans();
 | 
	
		
			
				|  |  |              if (musicGroupSubjectPlans != null && musicGroupSubjectPlans.size() > 0) {
 | 
	
		
			
				|  |  |                  musicGroupSubjectPlans.forEach(e->{
 | 
	
	
		
			
				|  | @@ -864,7 +864,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          //生成学员费用表
 | 
	
		
			
				|  |  |          List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  |          if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | -            musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null),"PAID_COMPLETED");
 | 
	
		
			
				|  |  | +            musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null),"PAID_COMPLETED");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //记录操作日志
 | 
	
		
			
				|  |  |          musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"确认开团(筹备中 -> 进行中)",sysUser.getId(),""));
 | 
	
	
		
			
				|  | @@ -972,18 +972,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  | -    public void musicGroupStudentFeePatch(List<String> musicGroupIds) {
 | 
	
		
			
				|  |  | -        if(musicGroupIds != null && musicGroupIds.size() > 0){
 | 
	
		
			
				|  |  | -            List<MusicGroupStudentFee> musicGroupStudentFees = null;
 | 
	
		
			
				|  |  | -            for (String musicGroupId: musicGroupIds) {
 | 
	
		
			
				|  |  | -                musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | -                if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | -                    musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null),"PAID_COMPLETED");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +//    @Override
 | 
	
		
			
				|  |  | +//    public void musicGroupStudentFeePatch(List<String> musicGroupIds) {
 | 
	
		
			
				|  |  | +//        if(musicGroupIds != null && musicGroupIds.size() > 0){
 | 
	
		
			
				|  |  | +//            List<MusicGroupStudentFee> musicGroupStudentFees = null;
 | 
	
		
			
				|  |  | +//            for (String musicGroupId: musicGroupIds) {
 | 
	
		
			
				|  |  | +//                musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | +//                if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | +//                    musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null),"PAID_COMPLETED");
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  | +//    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<MusicCardDto> queryUserMusicGroups(Integer userId) {
 | 
	
	
		
			
				|  | @@ -1046,7 +1046,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //删除续费记录
 | 
	
		
			
				|  |  | -        musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | +        musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId,null);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		// 删除课表
 | 
	
		
			
				|  |  |  		courseScheduleDao.deleteCourseSchedulesByMusicGroupID(musicGroupId, GroupType.MUSIC);
 | 
	
	
		
			
				|  | @@ -1138,7 +1138,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 重新设置下次缴费时间
 | 
	
		
			
				|  |  | -        musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null));
 | 
	
		
			
				|  |  | +        List<MusicGroupStudentFee> fees = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | +        Date date = new Date();
 | 
	
		
			
				|  |  | +        fees.forEach(e->{
 | 
	
		
			
				|  |  | +            e.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,e));
 | 
	
		
			
				|  |  | +            e.setUpdateTime(date);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        musicGroupStudentFeeDao.batchUpdate(fees);
 | 
	
		
			
				|  |  | +//        musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null));
 | 
	
		
			
				|  |  |          musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"恢复乐团",sysUser.getId(),""));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //恢复课表
 | 
	
	
		
			
				|  | @@ -1502,7 +1509,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  musicGroupStudentFee.setLatestPaidTime(date);
 | 
	
		
			
				|  |  |                  musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  |                  musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
 | 
	
		
			
				|  |  | -                musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate()));
 | 
	
		
			
				|  |  | +                musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate(),musicGroupStudentFee));
 | 
	
		
			
				|  |  |                  musicGroupStudentFeeDao.update(musicGroupStudentFee);
 | 
	
		
			
				|  |  |          		return null;
 | 
	
		
			
				|  |  |          	}else{
 | 
	
	
		
			
				|  | @@ -1528,7 +1535,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              Map<String, Object> payMap = payService.getPayMap(amount, studentPaymentOrder.getOrderNo(),
 | 
	
		
			
				|  |  |                      baseApiUrl+"/api-student/studentOrder/notify",
 | 
	
		
			
				|  |  | -                    baseApiUrl+"/#/paymentresult?orderNo=" + studentPaymentOrder.getOrderNo(),
 | 
	
		
			
				|  |  | +                    baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + studentPaymentOrder.getOrderNo(),
 | 
	
		
			
				|  |  |                      "续费",
 | 
	
		
			
				|  |  |                      "乐团续费",
 | 
	
		
			
				|  |  |                      userId,
 | 
	
	
		
			
				|  | @@ -1577,7 +1584,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              musicGroupStudentFee.setLatestPaidTime(date);
 | 
	
		
			
				|  |  |              musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  |              musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
 | 
	
		
			
				|  |  | -            musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate()));
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate(),musicGroupStudentFee));
 | 
	
		
			
				|  |  |              musicGroupStudentFeeDao.update(musicGroupStudentFee);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //插入交易明细
 | 
	
	
		
			
				|  | @@ -1789,17 +1796,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			// 删除乐团相关付费周期
 | 
	
		
			
				|  |  |  			musicGroupPaymentCalenderDao.delByGroupId(musicGroupId);
 | 
	
		
			
				|  |  | -			musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | +			musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId,0);
 | 
	
		
			
				|  |  |  			if (months != null && months.size() > 0) {
 | 
	
		
			
				|  |  |  				// 批量插入
 | 
	
		
			
				|  |  |  				musicGroupPaymentCalenderDao.batchAdd(months, musicGroupId);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | -			
 | 
	
		
			
				|  |  | -			//生成学员费用表
 | 
	
		
			
				|  |  | -	        List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | -	        if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | -	            musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null),"PAID_COMPLETED");
 | 
	
		
			
				|  |  | -	        }
 | 
	
		
			
				|  |  | +			if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
 | 
	
		
			
				|  |  | +                //生成学员费用表
 | 
	
		
			
				|  |  | +                List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | +                if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | +                    musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null),"PAID_COMPLETED");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |          musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  |          //修改课程里面的教学点
 |