|  | @@ -1433,22 +1433,26 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 | 
	
		
			
				|  |  | -    public boolean updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId) {
 | 
	
		
			
				|  |  | +    public BigDecimal updateUserSurplusCourseFee(Integer userId, String musicGroupId, BigDecimal amount, String memo, Integer operatorId) {
 | 
	
		
			
				|  |  |          StudentRegistration studentRegistration = studentRegistrationDao.lockWithUserAndMusic(userId, musicGroupId);
 | 
	
		
			
				|  |  |          if(Objects.isNull(studentRegistration)){
 | 
	
		
			
				|  |  |              throw new BizException("学员注册信息不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if(BigDecimal.ZERO.compareTo(amount)==0){
 | 
	
		
			
				|  |  | -            return true;
 | 
	
		
			
				|  |  | +            return BigDecimal.ZERO;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(amount));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if(BigDecimal.ZERO.compareTo(studentRegistration.getSurplusCourseFee())>0){
 | 
	
		
			
				|  |  | -            return false;
 | 
	
		
			
				|  |  | +        if(amount.abs().compareTo(studentRegistration.getSurplusCourseFee())>0){
 | 
	
		
			
				|  |  | +            if(BigDecimal.ZERO.compareTo(amount)>0){
 | 
	
		
			
				|  |  | +                amount = studentRegistration.getSurplusCourseFee().negate();
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                amount = studentRegistration.getSurplusCourseFee();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(amount));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
 | 
	
		
			
				|  |  |          studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
 | 
	
		
			
				|  |  |          studentCourseFeeDetail.setAmount(amount);
 | 
	
	
		
			
				|  | @@ -1458,6 +1462,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |          studentCourseFeeDetailDao.insert(studentCourseFeeDetail);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          studentRegistrationDao.update(studentRegistration);
 | 
	
		
			
				|  |  | -        return true;
 | 
	
		
			
				|  |  | +        return amount;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |