| | |
| | | import project.wallet.AssetService; |
| | | import project.wallet.Wallet; |
| | | import project.wallet.WalletService; |
| | | import project.web.admin.AdminContractOrderController; |
| | | import util.DateUtil; |
| | | import util.RandomUtil; |
| | | public class ContractOrderServiceImpl implements ContractOrderService { |
| | |
| | | double totleMoney = wallet.getMoney(); |
| | | profit = Arith.add(profit,totleMoney); |
| | | |
| | | if (map.get("direction") != null) { |
| | | if (map.get("direction") != null && map.get("state").equals("submitted")) { |
| | | String direction = map.get("direction").toString(); |
| | | double liquidationPrice; |
| | | double deposit = profit; |
| | |
| | | double priceDrop = lossPercentage * tradeAvgPrice; |
| | | liquidationPrice = tradeAvgPrice - priceDrop; |
| | | } |
| | | } |
| | | // 检查 liquidationPrice 是否为有效数字 |
| | | if (Double.isInfinite(liquidationPrice) || Double.isNaN(liquidationPrice)) { |
| | | liquidationPrice = 0; // 如果是无效结果,回退为 0 |
| | | } |
| | | DecimalFormat dfs = new DecimalFormat("#.#####"); |
| | | String formattedPrice = dfs.format(liquidationPrice); |
| | |
| | | return ApplicationUtil.executeSelect(ContractOrder.class,"WHERE PARTY_ID=? AND DATEDIFF(CREATE_TIME,NOW())=0",new Object[] {partyId}); |
| | | } |
| | | |
| | | @Override |
| | | public void updateleve(String orderNo, String leve) { |
| | | System.out.println("--------order:"+orderNo+"---------leve:"+leve); |
| | | ContractOrder order = findByOrderNo(orderNo); |
| | | if (order != null) { |
| | | System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); |
| | | order.setLever_rate(Double.valueOf(leve)); |
| | | this.redisHandler.setSync(ContractRedisKeys.CONTRACT_ORDERNO + orderNo,order); |
| | | System.out.println("===============================order"+order.toString()); |
| | | System.out.println("ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"); |
| | | ApplicationUtil.executeUpdate(ContractOrder.class,"WHERE ORDER_NO=?",new Object[] {order}); |
| | | System.out.println("ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); |
| | | } |
| | | } |
| | | |
| | | public void setWalletService(WalletService walletService) { |
| | | this.walletService = walletService; |
| | | } |