xiaoyong931011
2021-03-31 65f792e975b7ff985bf42003ceb49245904288b2
src/main/java/com/xcong/excoin/modules/documentary/service/impl/FollowOrderOperationServiceImpl.java
@@ -264,47 +264,52 @@
    public void closingFollowOrders(String orderNo) {
        List<FollowFollowerOrderRelationEntity> orderRelations = followFollowerOrderRelationDao.selectFollowHoldOrderByTradeOrderNo(orderNo);
        if (CollUtil.isNotEmpty(orderRelations)) {
            List<Long> orderIds = new ArrayList<>();
            for (FollowFollowerOrderRelationEntity orderRelation : orderRelations) {
                List<Long> ids= new ArrayList<>();
                ids.add(orderRelation.getOrderId());
                orderIds.add(orderRelation.getOrderId());
                rabbitOrderService.cancelHoldOrder(ids);
            }
            if(CollUtil.isNotEmpty(orderIds)){
                //获取对应的平仓记录单号
                List<String> orderNosList = new ArrayList<>();
                for(Long orderId : orderIds) {
                    String orderNos = contractOrderDao.selectOrderNoByOrderIds(orderId);
                    ContractOrderEntity contractOrderEntity = contractOrderDao.selectById(orderId);
                    orderNosList.add(orderNos);
            //生成返利记录和资金变化记录
            List<FollowFollowerOrderRelationEntity> orderRelationDone = followFollowerOrderRelationDao.selectFollowOrderByTradeOrderNo(orderNo);
            if(CollUtil.isNotEmpty(orderRelationDone)) {
               List<Long> orderIds = new ArrayList<>();
               for (FollowFollowerOrderRelationEntity orderRelationd : orderRelationDone) {
                    orderIds.add(orderRelationd.getOrderId());
                }
                //获取总返佣
                BigDecimal totalAmount = followTraderProfitDetailDao.selectFollowHoldOrderByFollowOrderNo(orderNosList);
                totalAmount = (totalAmount == null?BigDecimal.ZERO:totalAmount.setScale(2, BigDecimal.ROUND_DOWN));
                if(totalAmount.compareTo(BigDecimal.ZERO) > 0){
                    //增加返佣提醒
                    String symbol = contractOrderDao.selectById(orderIds.get(0)).getSymbol();
                    String orderNoTrader = orderRelations.get(0).getTradeOrderNo();
                    Long traderMemberId = orderRelations.get(0).getTradeMemberId();
                    LogRecordUtils.insertFollowerNotice(traderMemberId,
                            NoticeConstant.RETURN_MONEY_TITLE,
                            StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT,
                                    orderNoTrader,
                                    symbol,
                                    totalAmount));
                    //带单返利的记录要在资产页面的其他记录
                    LogRecordUtils.insertMemberAccountMoneyChange(
                            traderMemberId,
                            StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT_MAMC,
                                    orderNoTrader,
                                    symbol),
                            totalAmount,
                            MemberWalletCoinEnum.WALLETCOINCODE.getValue(),
                            MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER,
                            MemberAccountMoneyChange.TYPE_WALLET_AGENT);
                }
               if(CollUtil.isNotEmpty(orderIds)){
                   //获取对应的平仓记录单号
                   List<String> orderNosList = new ArrayList<>();
                   for(Long orderId : orderIds) {
                       String orderNos = contractOrderDao.selectOrderNoByOrderIds(orderId);
                       orderNosList.add(orderNos);
                   }
                   //获取总返佣
                   BigDecimal totalAmount = followTraderProfitDetailDao.selectFollowHoldOrderByFollowOrderNo(orderNosList);
                   totalAmount = (totalAmount == null?BigDecimal.ZERO:totalAmount.setScale(2, BigDecimal.ROUND_DOWN));
                   if(totalAmount.compareTo(BigDecimal.ZERO) > 0){
                       //增加返佣提醒
                       String symbol = contractOrderDao.selectById(orderIds.get(0)).getSymbol();
                       String orderNoTrader = orderRelationDone.get(0).getTradeOrderNo();
                       Long traderMemberId = orderRelationDone.get(0).getTradeMemberId();
                       LogRecordUtils.insertFollowerNotice(traderMemberId,
                               NoticeConstant.RETURN_MONEY_TITLE,
                               StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT,
                                       orderNoTrader,
                                       symbol,
                                       totalAmount));
                       //带单返利的记录要在资产页面的其他记录
                       LogRecordUtils.insertMemberAccountMoneyChange(
                               traderMemberId,
                               StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT_MAMC,
                                       orderNoTrader.substring(8),
                                       symbol),
                               totalAmount,
                               MemberWalletCoinEnum.WALLETCOINCODE.getValue(),
                               MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER,
                               MemberAccountMoneyChange.TYPE_WALLET_AGENT);
                   }
               }
            }
        }
    }