在cancelOrder中执行OrderDAO.cancelOrder时后台已抛异常,但却仍然执行了OrderDAO.cleanOrder 且数据没有回滚,不知道什么原因
具体请看代码:
public static boolean cancelOrder(final Dao dao, final String orderId)
{
try
{
Trans.exec(new Atom()
{
public void run()
{
OrderVO orderVO = dao.fetch(OrderVO.class, orderId);
if (orderVO != null)
{
orderVO.setOrderState(CommonConstants.ORDER.ORDER_STATE_CANCEL);
dao.update(orderVO);
//将订单数据移入历史表
OrderDAO.cancelOrder(dao, orderId);
OrderDAO.cancelSubOrder(dao, orderId);
//删除在途订单信息
OrderDAO.cleanOrder(dao, orderId);
}
}
});
return true;
}
catch (Exception e)
{
e.printStackTrace();
log.error(e);
}
return false;
}
```
/**
* 作废订单
*
* @param dao
* @param orderId
* @return
*/
public static boolean cancelOrder(Dao dao, String orderId)
{
try
{
Sql sql = Sqls.create("insert into cd_order_his select * ,now() from cd_order where orderId = @orderId");
sql.params().set("orderId", orderId);
dao.execute(sql);
return true;
}
catch (Exception e)
{
e.printStackTrace();
log.error(e);
}
return false;
}
``````
/**
* 删除订单数据
*
* @param dao
* @param userVO
* @return
*/
public static boolean cleanOrder(Dao dao, String orderId)
{
try
{
Sql sql = Sqls.create("delete from cd_order where orderId = @orderId");
sql.params().set("orderId", orderId);
dao.execute(sql);
sql = Sqls.create("delete from cd_order_goods where orderId = @orderId");
sql.params().set("orderId", orderId);
dao.execute(sql);
return true;
}
catch (Exception e)
{
e.printStackTrace();
log.error(e);
}
return false;
}