| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void cancelHoldOrder(List<Long> ids) { |
| | | log.info("--------"); |
| | | if (CollUtil.isNotEmpty(ids)) { |
| | | try { |
| | | log.info("=========:{}", ids.size()); |
| | | if (ids.size() == 1) { |
| | | log.info("------->>>>>>:{}", ids.get(0)); |
| | | ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectById(ids.get(0)); |
| | | |
| | | log.info(">>>>>>>>>>>>>{}", holdOrderEntity); |
| | | // 判断仓位类型是否逐仓 |
| | | if (holdOrderEntity.getPositionType() == ContractEntrustOrderEntity.POSITION_TYPE_ADD) { |
| | | // 逐仓平仓 |
| | |
| | | * 全仓模式平仓逻辑 |
| | | */ |
| | | public void closingWholeOrder(ContractHoldOrderEntity holdOrderEntity) { |
| | | log.info("进入全仓模式--平仓"); |
| | | String symbol = holdOrderEntity.getSymbol(); |
| | | // 获取最新价 |
| | | BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol))); |
| | |
| | | |
| | | MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(holdOrderEntity.getMemberId(), CoinTypeEnum.USDT.name()); |
| | | if (walletContract != null) { |
| | | log.info("--->逻辑"); |
| | | BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(symbol); |
| | | // 盈亏 |
| | | BigDecimal profitOrLoss = BigDecimal.ZERO; |
| | |
| | | |
| | | BigDecimal changeAmount = profitOrLoss.add(bondAmount).subtract(fee); |
| | | |
| | | memberWalletContractDao.increaseWalletContractBalanceById(changeAmount, fee.negate(), null, walletContract.getId()); |
| | | memberWalletContractDao.increaseWalletContractBalanceById(changeAmount, profitOrLoss.subtract(fee), null, walletContract.getId()); |
| | | |
| | | ThreadPoolUtils.sendWholeForceClosingPrice(holdOrderEntity.getSymbol(), memberEntity); |
| | | // 计算佣金 |