| | |
| | | public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price, BigDecimal amount) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | |
|
| | | BigDecimal nowPriceinBigDecimal = price;
|
| | | //查询当前价
|
| | | BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
|
| | |
|
| | |
| | |
|
| | | // 创建订单
|
| | | OrderCoinsEntity order = new OrderCoinsEntity();
|
| | | if (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType)) {
|
| | | if ((OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(1) && price.compareTo(nowPrice) < 0)
|
| | | || (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(2) && price.compareTo(nowPrice) > 0)) {
|
| | | // 如果是限价交易直接插入主表数据
|
| | | order.setMemberId(memberId);
|
| | | order.setOrderNo(generateSimpleSerialno(memberId.toString()));
|
| | |
| | | order.setEntrustCnt(amount);
|
| | | order.setEntrustPrice(price);
|
| | | order.setDealCnt(amount);
|
| | | if ((OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(1) && price.compareTo(nowPrice) >= 0)
|
| | | || (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType) && type.equals(2) && price.compareTo(nowPrice) <= 0)) {
|
| | | // 手续费用(手续费=建仓价X数量X手续费率)
|
| | | closingPrice = nowPrice.multiply(amount).multiply(tradeSetting.getCoinFeeRatio());
|
| | | //总费用 = 成交价*数量+手续费
|
| | | totalPayPrice = nowPrice.multiply(amount).add(closingPrice);
|
| | | price = nowPrice;
|
| | | }
|
| | | order.setDealPrice(price);
|
| | | order.setDealAmount(totalPayPrice);
|
| | | order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DONE);
|
| | |
| | | detail.setTradeType(tradeType);
|
| | | detail.setSymbol(symbol);
|
| | | detail.setSymbolCnt(amount);
|
| | | detail.setEntrustPrice(price);
|
| | | detail.setEntrustPrice(nowPriceinBigDecimal);
|
| | | detail.setDealPrice(price);
|
| | | detail.setDealAmount(totalPayPrice);
|
| | | detail.setFeeAmount(closingPrice);
|