public void commitTransaction(Transaction trans) { String process = trans.getProcess(); Trader trader = trans.getTrader(); int qty = trans.getQty(); double price = trans.getPrice(); double balance = trader.getBalance(); if (process.equals("sell")) balance = balance - qty * price - 5; else balance = balance + qty * price - 5; trans.setStatus("success"); trader.setBalance(balance); trader.setTransaction(trans); traderD.save(trader); }
public void addStock(Stock stock) { stockD.save(stock); }
public void failTransaction(int trans_id) { Transaction trans = transD.findBy("trans_id", trans_id); trans.setStatus("reject"); transD.save(trans); }