From 411814a852dd16cd634b79eceeff5d5aa9483d96 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 05 Jun 2020 16:17:28 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git --- src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java | 79 +++++++++++++++++++++++++++++---------- 1 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java index 0136a1e..7187136 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java @@ -13,9 +13,12 @@ import javax.annotation.Resource; import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity; +import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity; + import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum; @@ -41,6 +44,7 @@ import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao; +import com.xcong.excoin.modules.platform.dao.PlatformSymbolsCoinDao; import com.xcong.excoin.modules.platform.dao.TradeSettingDao; import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity; import com.xcong.excoin.utils.CoinTypeConvert; @@ -71,6 +75,8 @@ MemberAccountFlowEntityDao memberAccountFlowEntityDao; @Resource RedisUtils redisUtils; + @Resource + PlatformSymbolsCoinDao platformSymbolsCoinDao; @Override public String generateSimpleSerialno(String userId) { @@ -133,7 +139,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 +175,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 +260,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 +334,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(); @@ -355,9 +377,9 @@ //如果是限价卖出,撤单将对应的钱包冻结金额返回 MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol); if (ObjectUtil.isNotEmpty(walletCoin)) { - //返还金额=开仓价*未成交数量 - BigDecimal returnBalance = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance()); - walletCoin.setAvailableBalance(returnBalance.setScale(4, BigDecimal.ROUND_DOWN)); + + BigDecimal returnBalance = orderCoinsEntity.getEntrustCnt(); + walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoin); // 流水记录 @@ -372,33 +394,19 @@ 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")); } @Override - public Result findAllWalletCoinOrder() { + public Result findAllWalletCoinOrder(String symbol) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); OrderWalletCoinDealListVo orderWalletCoinDealListVo = new OrderWalletCoinDealListVo(); List<OrderWalletCoinDealVo> arrayList = new ArrayList<OrderWalletCoinDealVo>(); - List<OrderCoinsDealEntity> selectAllWalletCoinOrder = orderCoinDealDao.selectAllWalletCoinOrder(memberId); + List<OrderCoinsDealEntity> selectAllWalletCoinOrder = orderCoinDealDao.selectAllWalletCoinOrderBySymbol(memberId,symbol); if(CollUtil.isNotEmpty(selectAllWalletCoinOrder)) { for(OrderCoinsDealEntity orderCoinsDealEntity: selectAllWalletCoinOrder) { OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVoOrder(orderCoinsDealEntity); @@ -474,4 +482,33 @@ return Result.ok(findCollectListVo); } + @Override + public Result searchSymbolResultList() { + //获取用户ID + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + FindCollectListVo findCollectListVo = new FindCollectListVo(); + List<MemberSelectSymbolsVo> list = new ArrayList<>(); + + Map<String, Object> columnMap = new HashMap<>(); + List<PlatformSymbolsCoinEntity> selectByMap = platformSymbolsCoinDao.selectByMap(columnMap); + + List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol = memberSelectSymbolsDao.selectSymbolByMemId(memberId); + for(PlatformSymbolsCoinEntity platformSymbolsCoinEntity : selectByMap) { + MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo(); + memberSelectSymbolsVo.setSymbol(platformSymbolsCoinEntity.getName()); + if(CollUtil.isNotEmpty(selectSymbolByMemIdAndSymbol)) { + for(MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectSymbolByMemIdAndSymbol) { + if(platformSymbolsCoinEntity.getName().equals(memberSelectSymbolsEntity.getSymbol())) { + memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_YES); + } + } + }else { + memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO); + } + list.add(memberSelectSymbolsVo); + } + findCollectListVo.setMemberSelectSymbolsVo(list); + return Result.ok(findCollectListVo); + } + } -- Gitblit v1.9.1