| | |
| | | import com.xcong.excoin.modules.contract.service.RabbitOrderService; |
| | | import com.xcong.excoin.modules.documentary.common.NoticeConstant; |
| | | import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao; |
| | | import com.xcong.excoin.modules.documentary.dao.FollowFollowerProfitDao; |
| | | import com.xcong.excoin.modules.documentary.dao.FollowTraderInfoDao; |
| | | import com.xcong.excoin.modules.documentary.dao.FollowTraderProfitDetailDao; |
| | | import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity; |
| | |
| | | private FollowTraderInfoDao followTraderInfoDao; |
| | | @Resource |
| | | private FollowTraderProfitDetailDao followTraderProfitDetailDao; |
| | | @Resource |
| | | private FollowFollowerProfitDao followFollowerProfitDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | // 盈亏比例(回报率) |
| | | BigDecimal rewardRatio = profitOrLoss.divide(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN); |
| | | |
| | | FollowTraderInfoEntity traderInfoEntity = null; |
| | | // 判断当前订单是否为跟单 |
| | | if (ContractOrderEntity.CONTRACTTYPE_DOCUMENTARY == holdOrderEntity.getContractType()) { |
| | |
| | | traderInfoEntity = followTraderInfoDao.selectTraderInfoByOrderId(holdOrderEntity.getId()); |
| | | if (profitOrLoss.compareTo(BigDecimal.ZERO) > 0) { |
| | | // 计算需返利给交易员的金额 |
| | | BigDecimal returnMoney = profitOrLoss.subtract(traderInfoEntity.getProfitRatio()); |
| | | BigDecimal returnMoney = profitOrLoss.multiply(traderInfoEntity.getProfitRatio()); |
| | | profitOrLoss = profitOrLoss.subtract(returnMoney); |
| | | MemberWalletContractEntity traderWallet = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(traderInfoEntity.getMemberId(), CoinTypeEnum.USDT.name()); |
| | | memberWalletContractDao.increaseWalletContractBalanceById(returnMoney, returnMoney, null, traderWallet.getId()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 盈亏比例(回报率) |
| | | BigDecimal rewardRatio = profitOrLoss.divide(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN); |
| | | |
| | | ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity); |
| | | contractOrderEntity.setId(null); |
| | |
| | | if (MemberEntity.IS_TRADER_Y.equals(memberEntity.getIsTrader())) { |
| | | followOrderOperationService.closingFollowOrders(holdOrderEntity.getOrderNo()); |
| | | } else { |
| | | LogRecordUtils.insertFollowerNotice(memberEntity.getId(), NoticeConstant.CLOSE_ORDER_TITLE, StrUtil.format(NoticeConstant.CLOSE_ORDER_CONTENT, contractOrderEntity.getSymbol(), contractOrderEntity.getClosingPrice(), profitOrLoss)); |
| | | followFollowerProfitDao.updateFollowerProfitByTradeMemberId(holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getOpeningFeeAmount()), profitOrLoss, traderInfoEntity.getMemberId(), memberEntity.getId()); |
| | | LogRecordUtils.insertFollowerNotice(memberEntity.getId(), NoticeConstant.CLOSE_ORDER_TITLE, StrUtil.format(NoticeConstant.CLOSE_ORDER_CONTENT, contractOrderEntity.getSymbol(), contractOrderEntity.getClosingPrice(), profitOrLoss, traderInfoEntity.getNickname())); |
| | | } |
| | | } |
| | | } |
| | |
| | | profitDetailEntity.setOrderNo(orderNo); |
| | | followTraderProfitDetailDao.insert(profitDetailEntity); |
| | | } |
| | | |
| | | /** |
| | | * 全仓模式平仓逻辑 |
| | | */ |
| | | public void closingWholeOrder(ContractHoldOrderEntity contractHoldOrderEntity) { |
| | | |
| | | } |
| | | } |