public boolean prepareMinus(BusinessActionContext businessActionContext, final String accountNo,
final double amount) {
//分布式事务ID
final String xid = businessActionContext.getXid();
return fromDsTransactionTemplate.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
try {
//校验账户余额
Account account = fromAccountDAO.getAccountForUpdate(accountNo);
if (account == null) {
throw new RuntimeException("账户不存在");
}
if (account.getAmount() - amount < 0) {
throw new RuntimeException("余额不足");
}
//冻结转账金额
double freezedAmount = account.getFreezedAmount() + amount;
account.setFreezedAmount(freezedAmount);
fromAccountDAO.updateFreezedAmount(account);
System.out.println(String
.format("prepareMinus account[%s] amount[%f], dtx transaction id: %s.", accountNo, amount,
xid));
return true;
} catch (Throwable t) {
t.printStackTrace();
status.setRollbackOnly();
return false;
}
}
});
}
这段代码中对FreezedAmount的操作有何意义?