yonge 5 år sedan
förälder
incheckning
ce82060410

+ 7 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysTenantAccountServiceImpl.java

@@ -37,9 +37,15 @@ public class SysTenantAccountServiceImpl extends BaseServiceImpl<Integer, SysTen
 	@Override
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 	public boolean update(Integer userId, int minutes, String orderNo, TransType type, String transNo, BigDecimal cashAmount, String memo) {
+
+		Date date = new Date();
 		SysTenantAccount tenantAccount = sysTenantAccountDao.getLocked(userId);
 		if (tenantAccount == null) {
-			throw new BizException("用户[{}]现金账户不存在", userId);
+			tenantAccount = new SysTenantAccount();
+			tenantAccount.setUserId(userId);
+			tenantAccount.setCreateTime(date);
+			tenantAccount.setUpdateTime(date);
+			sysTenantAccountDao.insert(tenantAccount);
 		}
 
 		if (tenantAccount.getStatus() != AccountStatus.NORMAL) {
@@ -50,8 +56,6 @@ public class SysTenantAccountServiceImpl extends BaseServiceImpl<Integer, SysTen
 			throw new BizException("账户[{}]可用时间不足,可用时间剩{}分钟", userId, tenantAccount.getAvailableMinutes());
 		}
 
-		Date date = new Date();
-
 		tenantAccount.setAvailableMinutes(balance);
 		tenantAccount.setUpdateTime(date);
 		sysTenantAccountDao.update(tenantAccount);