From 9d1a90e82afba77f14af37fe56bebdba5c17c89e Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 29 May 2020 15:40:26 +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 | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 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 01834ca..f265187 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 @@ -12,6 +12,7 @@ import javax.annotation.Resource; +import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,7 +24,6 @@ import com.xcong.excoin.modules.coin.dao.MemberSelectSymbolsDao; import com.xcong.excoin.modules.coin.dao.OrderCoinDealDao; import com.xcong.excoin.modules.coin.dao.OrderCoinsDao; -import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange; import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity; import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity; import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; @@ -39,7 +39,7 @@ import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao; import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; -import com.xcong.excoin.modules.platform.dao.CnyUsdtExchangeDao; +import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao; import com.xcong.excoin.modules.platform.dao.TradeSettingDao; import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity; import com.xcong.excoin.utils.MessageSourceUtils; @@ -59,7 +59,7 @@ @Resource MemberSelectSymbolsDao memberSelectSymbolsDao; @Resource - CnyUsdtExchangeDao cnyUsdtExchangeDao; + PlatformCnyUsdtExchangeDao cnyUsdtExchangeDao; @Resource OrderCoinsDao orderCoinsDao; @Resource @@ -117,8 +117,8 @@ BigDecimal closePrice = new BigDecimal("100.0000"); List<MemberSelectSymbolsEntity> memSymbols = memberSelectSymbolsDao.selectSymbolByMemIdAndSymbol(memberId, symbol); - - CnyUsdtExchange cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne(); + + PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne(); BigDecimal cnyUsdt = cnyUsdtExchange.getValue(); TransactionPageOfWalletCoinVo transactionPageOfWalletCoinVo = new TransactionPageOfWalletCoinVo(); //是否自选 @@ -321,10 +321,10 @@ @Override @Transactional - public Result cancelEntrustWalletCoinOrder(String orderNo) { + public Result cancelEntrustWalletCoinOrder(String orderId) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); - OrderCoinsEntity orderCoinsEntity = orderCoinsDao.findWalletCoinOrderByOrderNo(orderNo); + OrderCoinsEntity orderCoinsEntity = orderCoinsDao.selectById(orderId); if(ObjectUtil.isNotEmpty(orderCoinsEntity) && orderCoinsEntity.getMemberId() == memberId) { if(orderCoinsEntity.getOrderStatus() == OrderCoinsEntity.ORDERSTATUS_CANCEL){ return Result.fail(MessageSourceUtils.getString("order_service_0012")); @@ -342,7 +342,7 @@ if (ObjectUtil.isNotEmpty(walletCoin)) { //手续费 = 开仓价*数量*手续费率 //返还金额=开仓价*未成交数量+手续费 - BigDecimal returnBalance = orderCoinsEntity.getEntrustPrice().add(orderCoinsEntity.getFeeAmount()); + BigDecimal returnBalance = orderCoinsEntity.getDealAmount().add(orderCoinsEntity.getFeeAmount()); walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); @@ -360,13 +360,12 @@ } }else { //如果是限价卖出,撤单将对应的钱包冻结金额返回 - String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue(); - MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode); + 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)); - walletCoin.setFrozenBalance(BigDecimal.ZERO); + walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN)); memberWalletCoinDao.updateById(walletCoin); // 流水记录 MemberAccountFlowEntity record = new MemberAccountFlowEntity(); @@ -380,7 +379,6 @@ return Result.ok(MessageSourceUtils.getString("order_service_0013")); } } - OrderCoinsDealEntity detail = new OrderCoinsDealEntity(); detail.setMemberId(memberId); detail.setOrderId(orderCoinsEntity.getId()); @@ -388,6 +386,7 @@ 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)); -- Gitblit v1.9.1