您的位置:首页 > 编程语言 > Java开发

spring mvc 异常处理手动回滚 SQL log不回滚

2017-02-16 00:00 302 查看
/**
* 购买股权
*
* @param map
* @return
*/
@Override
@Transactional
public Map<String, String> buyStock(Map<String, Long> map) {
Assert.notNull(map.get("memberId"));
Assert.notNull(map.get("id"));
Map<String, String> requestBody = null;
try {
//        查询股权价格
StockPrice stockPrice = stockPriceService.queryStockPriceById(map.get("id"));
if (stockPrice != null) {
//        返回融宝请求体
requestBody = payLogService.getPostBody(map.get("memberId").toString(), stockPrice.getPrice());
if (requestBody != null) {
//        添加一条订单信息
stockOrderService.addStrockOrder(new StockOrder(map.get("memberId"), requestBody.get("order_no"),
map.get("id"), stockPrice.getStockNum(), stockPrice.getPrice(), Constant.ORDER_BUY, Constant.ORDER_UNDONE));
}
}
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
requestBody = null;
//exception_log 表存储引擎不能为innodb
exceptionLogService.addExceptionLog(new ExceptionLog("购买股权失败", e.getMessage()));
}
return requestBody;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: