正常修改
不加事务出现异常只减少了钱 没有增加钱
出现异常添加事务事务出现回滚 数据一致性有保障
也可以加到 ServiceImpl 上
@Override
public void transferMoney(Long send, Long receive, BigDecimal money) {
UserAccount one = this.lambdaQuery().eq(UserAccount::getId, send).one();
UpdateWrapper sendWrapper = new UpdateWrapper<>();
sendWrapper.eq("id",send).set("money",one.getMoney().subtract(money));
this.update(sendWrapper);
int i = 0;
final int res = 10 / i;
UserAccount two = this.lambdaQuery().eq(UserAccount::getId, receive).one();
UpdateWrapper receiveWrapper = new UpdateWrapper<>();
receiveWrapper.eq("id",receive).set("money",two.getMoney().add(money));
this.update(receiveWrapper);
}



