|  |  |  | 
|---|
|  |  |  | BigDecimal closingPrice = price.multiply(amount).multiply(tradeSetting.getCoinFeeRatio()); | 
|---|
|  |  |  | //总费用 = 成交价*数量+手续费 | 
|---|
|  |  |  | BigDecimal totalPayPrice = price.multiply(amount).add(closingPrice); | 
|---|
|  |  |  | BigDecimal totalPayPricCoin = nowPrice.multiply(amount).add(closingPrice); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); | 
|---|
|  |  |  | MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode); | 
|---|
|  |  |  | if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) { | 
|---|
|  |  |  | //买入,所需总费用跟用户USDT金额进行比较 | 
|---|
|  |  |  | BigDecimal availableBalance = walletCoinUsdt.getAvailableBalance(); | 
|---|
|  |  |  | if (totalPayPrice.compareTo(availableBalance) > 0) { | 
|---|
|  |  |  | if (totalPayPrice.compareTo(availableBalance) > 0 || totalPayPricCoin.compareTo(availableBalance) > 0) { | 
|---|
|  |  |  | return Result.fail(MessageSourceUtils.getString("order_service_0010")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | 
|---|
|  |  |  | totalPayPrice = nowPrice.multiply(amount).add(closingPrice); | 
|---|
|  |  |  | price = nowPrice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | order.setDealPrice(price); | 
|---|
|  |  |  | order.setDealPrice(nowPrice); | 
|---|
|  |  |  | order.setDealAmount(totalPayPrice); | 
|---|
|  |  |  | order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DONE); | 
|---|
|  |  |  | order.setTradeType(tradeType); | 
|---|
|  |  |  | 
|---|
|  |  |  | detail.setSymbol(symbol); | 
|---|
|  |  |  | detail.setSymbolCnt(amount); | 
|---|
|  |  |  | detail.setEntrustPrice(nowPriceinBigDecimal); | 
|---|
|  |  |  | detail.setDealPrice(price); | 
|---|
|  |  |  | detail.setDealPrice(nowPrice); | 
|---|
|  |  |  | detail.setDealAmount(totalPayPrice); | 
|---|
|  |  |  | detail.setFeeAmount(closingPrice); | 
|---|
|  |  |  | detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<OrderCoinsEntity> findCoinOrderListByMemberIdAndSysmbol = orderCoinsDao.findCoinOrderListByMemberIdAndSysmbol(memberId, symbol, status); | 
|---|
|  |  |  | if (CollUtil.isNotEmpty(findCoinOrderListByMemberIdAndSysmbol)) { | 
|---|
|  |  |  | for (OrderCoinsEntity orderCoinsEntity : findCoinOrderListByMemberIdAndSysmbol) { | 
|---|
|  |  |  | orderCoinsEntity.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsEntity.setMarkPrice(orderCoinsEntity.getMarkPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsEntity.setEntrustCnt(orderCoinsEntity.getEntrustCnt().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsEntity.setEntrustPrice(orderCoinsEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsEntity.setDealCnt(orderCoinsEntity.getDealCnt().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsEntity.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsEntity.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | OrderWalletCoinVo entityToVo = OrderWalletCoinMapper.INSTANCE.entityToVo(orderCoinsEntity); | 
|---|
|  |  |  | entityToVo.setFeeAmount(entityToVo.getFeeAmount()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | entityToVo.setMarkPrice(entityToVo.getMarkPrice()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getMarkPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | entityToVo.setEntrustCnt(entityToVo.getEntrustCnt()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getEntrustCnt().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | entityToVo.setEntrustPrice(entityToVo.getEntrustPrice()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | entityToVo.setDealCnt(entityToVo.getDealCnt()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getDealCnt().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | entityToVo.setDealPrice(entityToVo.getDealPrice()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | entityToVo.setDealAmount(entityToVo.getDealAmount()== null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | arrayList.add(entityToVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | orderCoinsDealEntity.setMemberId(memberId); | 
|---|
|  |  |  | orderCoinsDealEntity.setSymbol(findAllWalletCoinOrderDto.getSymbol()); | 
|---|
|  |  |  | IPage<OrderCoinsDealEntity> list = orderCoinDealDao.findAllWalletCoinOrderInPage(page, orderCoinsDealEntity); | 
|---|
|  |  |  | List<OrderCoinsDealEntity> records = list.getRecords(); | 
|---|
|  |  |  | Page<OrderWalletCoinDealVo> pageEntityToPageVo = OrderWalletCoinDealMapper.INSTANCE.pageEntityToPageVo(list); | 
|---|
|  |  |  | List<OrderWalletCoinDealVo> records = pageEntityToPageVo.getRecords(); | 
|---|
|  |  |  | if(CollUtil.isNotEmpty(records)) { | 
|---|
|  |  |  | for(OrderCoinsDealEntity OrderCoinsDealEntity : records) { | 
|---|
|  |  |  | orderCoinsDealEntity.setSymbolCnt(orderCoinsDealEntity.getSymbolCnt()); | 
|---|
|  |  |  | OrderCoinsDealEntity.setEntrustPrice(orderCoinsDealEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsDealEntity.setDealPrice(orderCoinsDealEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsDealEntity.setDealAmount(orderCoinsDealEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | orderCoinsDealEntity.setFeeAmount(orderCoinsDealEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | for(OrderWalletCoinDealVo orderWalletCoinDealVo : records) { | 
|---|
|  |  |  | orderWalletCoinDealVo.setFeeAmount(orderWalletCoinDealVo.getFeeAmount() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : orderWalletCoinDealVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderWalletCoinDealVo.setDealAmount(orderWalletCoinDealVo.getDealAmount() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : orderWalletCoinDealVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderWalletCoinDealVo.setSymbolCnt(orderWalletCoinDealVo.getSymbolCnt() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : orderWalletCoinDealVo.getSymbolCnt().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderWalletCoinDealVo.setEntrustPrice(orderWalletCoinDealVo.getEntrustPrice() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : orderWalletCoinDealVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderWalletCoinDealVo.setDealPrice(orderWalletCoinDealVo.getDealPrice() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : orderWalletCoinDealVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Page<OrderWalletCoinDealVo> pageEntityToPageVo = OrderWalletCoinDealMapper.INSTANCE.pageEntityToPageVo(list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return Result.ok(pageEntityToPageVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | //获取用户ID | 
|---|
|  |  |  | Long memberId = LoginUserUtils.getAppLoginUser().getId(); | 
|---|
|  |  |  | OrderCoinsDealEntity selectWalletCoinOrder = orderCoinDealDao.selectWalletCoinOrder(orderId, memberId); | 
|---|
|  |  |  | selectWalletCoinOrder.setSymbolCnt(selectWalletCoinOrder.getSymbolCnt()); | 
|---|
|  |  |  | selectWalletCoinOrder.setEntrustPrice(selectWalletCoinOrder.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | selectWalletCoinOrder.setDealPrice(selectWalletCoinOrder.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | selectWalletCoinOrder.setDealAmount(selectWalletCoinOrder.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | selectWalletCoinOrder.setFeeAmount(selectWalletCoinOrder.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVoOrder(selectWalletCoinOrder); | 
|---|
|  |  |  | if(ObjectUtil.isNotEmpty(entityToVo)) { | 
|---|
|  |  |  | entityToVo.setFeeAmount(entityToVo.getFeeAmount() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | entityToVo.setDealAmount(entityToVo.getDealAmount() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | entityToVo.setSymbolCnt(entityToVo.getSymbolCnt() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getSymbolCnt().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | entityToVo.setEntrustPrice(entityToVo.getEntrustPrice() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | entityToVo.setDealPrice(entityToVo.getDealPrice() == null | 
|---|
|  |  |  | ? BigDecimal.ZERO : entityToVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Result.ok(entityToVo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|