1 //假设这是一个service类的片段
2
3 try{
4 //出现异常
5 } catch (Exception e) {
6 e.printStackTrace();
7 //设置手动回滚
8 TransactionAspectSupport.currentTransactionStatus()
9 .setRollbackOnly();
10 }
11 //此时return语句能够执行
12 return xxx;
//普通缴费
@Transactional
public String commonMoney(Receipt rpt,Moneyrecord mors){
rpt.setState(1);
int a=dao.insert(rpt);
if(a<=0) return"缴费失败";
mors.setPric(rpt.getPic());
mors.setExid(rpt.getPid());
mors.setState(1);
boolean tf=mrs.custom(mors);
if(!tf){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return"余额不足";
}
return "OK";