Ret ret = fail() ;
boolean isSuccess = Db.tx(()->{
BigDecimal totalAmount = BigDecimal.ZERO ; //订单的总金额
boolean allSuccess = true ;
for (int i = 0; i < proIds.length; i++) {
String productId = proIds[i] ;
Ret rets = this.checkOrderIsValid(productId);
if (rets.isFail()) {
ret.set("err" , rets.get("err"));
allSuccess = false ;
break ;
}
//其他逻辑...
}
ret.set("totalAmount" , totalAmount);
return allSuccess ;
});
if (isSuccess == false) {
return ret ;
}
//其他的逻辑...
最后总是会有这样的提示信息:
com.jfinal.plugin.activerecord.NestedTransactionHelpException: Notice the outer transaction that the nested transaction return false
如果isSuccess == false,也无法执行到最后的判断语句:
if (isSuccess == false) {
return ret ;
}
到底怎么用才对呀
在控制台看一下 jfinal action report 中输出的拦截器信息,找一找 Tx.class 是不是存在,用 @Clear(Tx.class) 删之