Пример #1
0
 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);
 }
Пример #2
0
 public void addStock(Stock stock) {
   stockD.save(stock);
 }
Пример #3
0
 public void failTransaction(int trans_id) {
   Transaction trans = transD.findBy("trans_id", trans_id);
   trans.setStatus("reject");
   transD.save(trans);
 }