| 
					
				 | 
			
			
				@@ -60,6 +60,44 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public boolean updateBalance(Integer userId, BigDecimal decimal, PlatformCashAccountDetailTypeEnum type, String memo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (cashAccount == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			throw new BizException("用户[{}]现金账户不存在", userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			throw new BizException("账户不可用"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		BigDecimal balance = cashAccount.getBalance().add(decimal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (balance.doubleValue() < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			throw new BizException("现金账户[{}]余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysUserCashAccountDetail detail = new SysUserCashAccountDetail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setAmount(decimal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setBalance(cashAccount.getBalance().add(decimal)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setComment(memo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setCreateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setStatus(DealStatusEnum.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		detail.setUserId(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		sysUserCashAccountDetailDao.insert(detail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		cashAccount.setBalance(balance); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		cashAccount.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		sysUserCashAccountDao.update(cashAccount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public boolean updateCourseBalance(Integer userId, BigDecimal decimal) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (cashAccount == null) { 
			 |