xiaoyong931011
2020-06-04 60269ab75aa69ecc55a37abc98b3d9873028f7be
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -133,7 +133,7 @@
      // 点差
      transactionPageOfWalletCoinVo.setSpread(tradeSetting.getSpread().setScale(4, BigDecimal.ROUND_DOWN));
      // 手续费用率
      transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getFeeRatio().setScale(4, BigDecimal.ROUND_DOWN));
      transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getCoinFeeRatio().setScale(4, BigDecimal.ROUND_DOWN));
      // 用户可用金额
      transactionPageOfWalletCoinVo.setAvailableBalanceBuy(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
      transactionPageOfWalletCoinVo.setAvailableBalanceSell(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
@@ -169,7 +169,7 @@
            return Result.fail(MessageSourceUtils.getString("order_service_0009"));
         }
         // 手续费用(手续费=建仓价X数量X手续费率)
         BigDecimal closingPrice = price.multiply(amount).multiply(new BigDecimal(MemberWalletCoinEnum.SUBMITSALESWALLETCOINORDER_SERVICERATE.getValue()));
         BigDecimal closingPrice = price.multiply(amount).multiply(tradeSetting.getCoinFeeRatio());
         //总费用 = 成交价*数量+手续费
         BigDecimal totalPayPrice = price.multiply(amount).add(closingPrice);
         
@@ -254,6 +254,7 @@
            detail.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
            detail.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
            detail.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN));
            detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE);
            orderCoinDealDao.insert(detail);
            
            if(OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
@@ -327,6 +328,21 @@
               
               String symbol = orderCoinsEntity.getSymbol();
               
               OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
               detail.setMemberId(memberId);
               detail.setOrderId(orderCoinsEntity.getId());
               detail.setOrderNo(generateSimpleSerialno(memberId.toString()));
               detail.setOrderType(orderCoinsEntity.getOrderType());
               detail.setTradeType(orderCoinsEntity.getTradeType());
               detail.setSymbol(symbol);
               detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_CANCEL);
               detail.setSymbolCnt(orderCoinsEntity.getEntrustCnt());
               detail.setEntrustPrice(orderCoinsEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
               detail.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
               detail.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
               detail.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
               orderCoinDealDao.insert(detail);
               if(OrderCoinsEntity.ORDERTYPE_BUY.equals(orderCoinsEntity.getOrderType())) {
                  //如果是限价买入,撤单将USDT账户冻结金额返回
                  String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
@@ -356,7 +372,7 @@
                  MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
                  if (ObjectUtil.isNotEmpty(walletCoin)) {
                     //返还金额=开仓价*未成交数量
                     BigDecimal returnBalance = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
                     BigDecimal returnBalance = orderCoinsEntity.getDealAmount();
                     walletCoin.setAvailableBalance(returnBalance.setScale(4, BigDecimal.ROUND_DOWN));
                     walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
                     memberWalletCoinDao.updateById(walletCoin);
@@ -372,20 +388,6 @@
                     return Result.ok(MessageSourceUtils.getString("order_service_0013"));
                  }
               }
               OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
               detail.setMemberId(memberId);
               detail.setOrderId(orderCoinsEntity.getId());
               detail.setOrderNo(generateSimpleSerialno(memberId.toString()));
               detail.setOrderType(orderCoinsEntity.getOrderType());
               detail.setTradeType(orderCoinsEntity.getTradeType());
               detail.setSymbol(symbol);
               detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_CANCEL);
               detail.setSymbolCnt(orderCoinsEntity.getEntrustCnt());
               detail.setEntrustPrice(orderCoinsEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
               detail.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
               detail.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
               detail.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
               orderCoinDealDao.insert(detail);
            }
      return Result.fail(MessageSourceUtils.getString("order_service_0043"));
   }