| | |
| | | StringBuffer queryString = new StringBuffer( |
| | | "SELECT orders.UUID id,orders.SYMBOL symbol,orders.AMOUNT_CLOSE amount_close,orders.CLOSE_AVG_PRICE close_avg_price," |
| | | + "orders.STOP_PRICE_PROFIT stop_price_profit,orders.STOP_PRICE_LOSS stop_price_loss," |
| | | + "orders.ORDER_NO order_no,orders.TRADE_AVG_PRICE trade_avg_price," |
| | | + "orders.ORDER_NO order_no,orders.PARTY_ID party_id,orders.TRADE_AVG_PRICE trade_avg_price," |
| | | + "orders.DIRECTION direction,orders.UNIT_AMOUNT unit_amount," |
| | | + "orders.STATE state,orders.FEE fee,orders.PROFIT profit,orders.CREATE_TIME createTime," |
| | | + "orders.DEPOSIT deposit,orders.DEPOSIT_OPEN deposit_open,orders.CLOSE_TIME closeTime," |
| | | + "orders.VOLUME_OPEN volume_open,orders.VOLUME volume,orders.LEVER_RATE as lever_rate,item.NAME itemname,"); |
| | | queryString.append(" wallet.MONEY money, "); |
| | | queryString.append(" party.USERNAME username,party.USERCODE usercode,party.ROLENAME rolename "); |
| | | queryString.append(" party.USERNAME username,party.USERCODE usercode,party.ROLENAME rolename,party.REMARKS remarks "); |
| | | |
| | | queryString.append( |
| | | " FROM T_CONTRACT_ORDER orders LEFT JOIN PAT_PARTY party ON orders.PARTY_ID = party.UUID LEFT JOIN T_WALLET wallet ON wallet.PARTY_ID = party.UUID LEFT JOIN T_ITEM item ON orders.SYMBOL=item.SYMBOL WHERE 1 = 1 "); |
| | |
| | | */ |
| | | double rate = Arith.div(volume, order.getVolume_open()); |
| | | |
| | | //profit = Arith.mul(Arith.add(order.getDeposit(), order.getProfit()), rate); |
| | | //平仓收益 |
| | | double mul = Arith.mul(order.getDeposit_open(), order.getLever_rate());//仓位 |
| | | double div = Arith.div(mul, order.getTrade_avg_price());//持有币的数量 |
| | | double amount = Arith.mul(div, Arith.sub(order.getClose_avg_price(), order.getTrade_avg_price())); |
| | | |
| | | profit = Arith.add(Arith.mul(order.getDeposit_open(),rate),Arith.mul(order.getProfit(),rate)); |
| | | order.setAmount_close(Arith.add(order.getAmount_close(), profit)); |
| | | order.setVolume(Arith.sub(order.getVolume(), volume)); |
| | |
| | | Arith.add(Arith.add(order.getAmount_close(),Arith.mul(order.getProfit(),rate)), order.getDeposit()), |
| | | order.getDeposit_open()))); |
| | | } else { |
| | | map.put("profit", df.format(Arith.sub(Arith.add(order.getAmount_close(), order.getDeposit()), order.getDeposit_open()))); |
| | | map.put("profit", df.format(order.getProfit())); |
| | | } |
| | | // double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString()); |
| | | // |
| | |
| | | if(residueMoney > 0){ |
| | | wallet.setMoney(residueMoney); |
| | | redisHandler.setSync(WalletRedisKeys.WALLET_PARTY_ID + wallet.getPartyId().toString(), wallet); |
| | | redisHandler.pushAsyn(WalletRedisKeys.WALLET_QUEUE_UPDATE, new WalletMessage(order.getPartyId().toString(), amount)); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | public Page pagedQuery(int pageNo, int pageSize, String status, String rolename, String loginPartyId, |
| | | String username,String orderNo,String symbol,String direction,Double volume) { |
| | | StringBuffer queryString = new StringBuffer("SELECT party.USERCODE usercode,party.ROLENAME rolename,orders.UUID id,orders.SYMBOL symbol," |
| | | StringBuffer queryString = new StringBuffer("SELECT party.USERCODE usercode,party.ROLENAME rolename,party.REMARKS remarks,orders.UUID id,orders.SYMBOL symbol," |
| | | + "orders.ORDER_NO order_no,orders.TRADE_AVG_PRICE trade_avg_price,orders.DIRECTION direction,orders.PROFIT_LOSS profit_loss," |
| | | + "orders.UNIT_AMOUNT unit_amount,orders.STATE state,FORMAT(orders.FEE,1) fee," + "orders.PROFIT profit," |
| | | + "FORMAT(orders.VOLUME,1) volume,item.NAME itemname,orders.TIMENUM timenum,orders.TIMEUNIT timeunit," |
| | |
| | | * 计算全仓收益 保证金 |
| | | */ |
| | | double profit = 0; |
| | | List<ContractOrder> contractOrders = contractOrderService.findSubmitted(this.getLoginPartyId(), null, null); |
| | | List<ContractOrder> contractOrders = contractOrderService.findSubmitted(map.get("party_id").toString(), null, null); |
| | | for (int f = 0; f < contractOrders.size(); f++) { |
| | | ContractOrder close_line = contractOrders.get(f); |
| | | if(close_line.getProfit() > 0){ |
| | |
| | | }else{ |
| | | profit = Arith.add(profit, close_line.getDeposit()); |
| | | } } |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(this.getLoginPartyId()); |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(map.get("party_id").toString()); |
| | | double totleMoney = wallet.getMoney(); |
| | | profit = Arith.add(profit,totleMoney); |
| | | |
| | |
| | | * 计算全仓收益 保证金 |
| | | */ |
| | | double profit = 0; |
| | | List<ContractOrder> contractOrders = contractOrderService.findSubmitted(this.getLoginPartyId(), null, null); |
| | | List<ContractOrder> contractOrders = contractOrderService.findSubmitted(map.get("party_id").toString(), null, null); |
| | | for (int f = 0; f < contractOrders.size(); f++) { |
| | | ContractOrder close_line = contractOrders.get(f); |
| | | if(close_line.getProfit() > 0){ |
| | | profit = Arith.add(profit, Arith.add(close_line.getProfit(), close_line.getDeposit())); |
| | | }else{ |
| | | profit = Arith.add(profit, close_line.getDeposit()); |
| | | } |
| | | } |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(this.getLoginPartyId()); |
| | | double totleMoney = wallet.getMoney(); |
| | | profit = Arith.add(profit,totleMoney); |
| | | } } |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(map.get("party_id").toString()); |
| | | |
| | | |
| | | if (map.get("direction") != null) { |