| | |
| | | /** |
| | | * 加上杠杆 |
| | | */ |
| | | //25x手续费3.75% 50x手续费7.5% 100x手续费15% 200x手续费30% |
| | | if(order.getLeverRate().doubleValue() == 25){ |
| | | item.setUnitFee(new BigDecimal("0.0375")); |
| | | }else if(order.getLeverRate().doubleValue() == 50){ |
| | | item.setUnitFee(new BigDecimal("0.075")); |
| | | }else if(order.getLeverRate().doubleValue() == 100){ |
| | | item.setUnitFee(new BigDecimal("0.15")); |
| | | }else if(order.getLeverRate().doubleValue() == 200){ |
| | | item.setUnitFee(new BigDecimal("0.30")); |
| | | } |
| | | |
| | | BigDecimal fee = order.getDeposit().multiply(order.getLeverRate()).multiply(item.getUnitFee()); |
| | | BigDecimal fee = order.getDeposit().multiply(item.getUnitFee()); |
| | | fee = fee.setScale(4, RoundingMode.DOWN); // 保留两位小数 |
| | | order.setFee(fee); |
| | | } |
| | |
| | | Wallet wallet = this.walletService.findByUserId(order.getPartyId()); |
| | | BigDecimal amountBefore = wallet.getMoney(); |
| | | BigDecimal totalAmountCost = order.getDeposit().add(order.getFee()); |
| | | |
| | | log.info("amountBefore:"+amountBefore); |
| | | log.info("totalAmountCost:"+totalAmountCost); |
| | | if (amountBefore.compareTo(totalAmountCost) < 0) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | throw new YamiShopBindException("not sufficient funds"); |
| | | } |
| | | |
| | | //如果是限价单先扣钱 |
| | |
| | | return list(queryWrapper); |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(); |
| | | if (new BigDecimal("1432.34").compareTo(new BigDecimal("1432.34")) < 0) { |
| | | throw new YamiShopBindException("not sufficient funds"); |
| | | } |
| | | |
| | | } |
| | | } |