KKSU
2024-04-17 829f629756e5402bcd3e9f6ef1f9c6dbffbabb11
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -160,7 +161,18 @@
        FollowTraderProfitInfoEntity followTraderProfitInfoEntity = new FollowTraderProfitInfoEntity();
        if(FollowTraderInfoEntity.IS_SETFRIST_Y.equals(type)) {
           followTraderProfitInfoEntity.setType(type);
         followTraderProfitInfoEntity.setTotalProfitRatioSc(2);
        }else {
           String nicknameDto = recordsPageDto.getNickname();
           followTraderProfitInfoEntity.setNickname(nicknameDto);
           int totalProfitRatioSc = recordsPageDto.getTotalProfitRatioSc();
           followTraderProfitInfoEntity.setTotalProfitRatioSc(totalProfitRatioSc);
           int totalFollowerCntSc = recordsPageDto.getTotalFollowerCntSc();
           followTraderProfitInfoEntity.setTotalFollowerCntSc(totalFollowerCntSc);
           int winRateSc = recordsPageDto.getWinRateSc();
           followTraderProfitInfoEntity.setWinRateSc(winRateSc);
        }
        IPage<FollowTraderProfitInfoVo> followTraderProfitInfoList = followTraderProfitInfoDao.selectFollowTraderProfitInfoEntity(page, followTraderProfitInfoEntity);
        
        List<FollowTraderProfitInfoVo> followTraderProfitInfoVoList = followTraderProfitInfoList.getRecords();
@@ -205,6 +217,10 @@
              FollowTraderProfitInfoVo.setDeclaration(declaration);
              Integer isAll = followTraderInfoEntity.getIsAll();
              FollowTraderProfitInfoVo.setIsAll(isAll);
            Date entryTime = followTraderInfoEntity.getEntryTime();
            int datePoor = getDatePoor(entryTime, new Date());
            FollowTraderProfitInfoVo.setEntryDays(datePoor);
              
              String labels = followTraderInfoEntity.getLabels();
              if(StrUtil.isNotEmpty(labels)) {
@@ -271,9 +287,19 @@
      List<FollowRecordsVo> records = historyOrderRecordsVoList.getRecords();
      if(CollUtil.isNotEmpty(records)) {
         for(FollowRecordsVo followRecordsVo : records) {
            BigDecimal totalPrincipal = followRecordsVo.getTotalPrincipal().setScale(2, BigDecimal.ROUND_DOWN);
            followRecordsVo.setTotalPrincipal(totalPrincipal);
            Long memberIdFollow = followRecordsVo.getMemberId();
            Long tradeId = followRecordsVo.getTradeId();
            //获取当前跟随者最后一个历史跟单的保证金
            BigDecimal bondAmount = BigDecimal.ZERO;
            List<BigDecimal> bondamounts = followFollowerProfitDao.selectBondAmountByTradeIdAndMemberId(memberIdFollow,tradeId);
            if(CollUtil.isNotEmpty(bondamounts)){
               bondAmount = bondamounts.get(0).setScale(2, BigDecimal.ROUND_DOWN);
            }
            followRecordsVo.setTotalPrincipal(bondAmount);
//            BigDecimal totalPrincipal = followRecordsVo.getTotalPrincipal().setScale(2, BigDecimal.ROUND_DOWN);
//            followRecordsVo.setTotalPrincipal(totalPrincipal);
            BigDecimal totalProfit = followRecordsVo.getTotalProfit().setScale(2, BigDecimal.ROUND_DOWN);
            followRecordsVo.setTotalProfit(totalProfit);
            
@@ -394,7 +420,7 @@
                  myFollowOrderVo.setLeverRatio(leverRatio);
                  BigDecimal rewardAmount = contractOrderEntity.getRewardAmount().setScale(2, BigDecimal.ROUND_DOWN);
                  myFollowOrderVo.setRewardAmount(rewardAmount);
                  BigDecimal rewardRatio = contractOrderEntity.getRewardRatio().setScale(4, BigDecimal.ROUND_DOWN);
                  BigDecimal rewardRatio = contractOrderEntity.getRewardRatio() == null ? BigDecimal.ZERO : contractOrderEntity.getRewardRatio().setScale(4, BigDecimal.ROUND_DOWN);
                  myFollowOrderVo.setRewardRatio(rewardRatio);
                  int symbolCnt = contractOrderEntity.getSymbolCnt();
                  myFollowOrderVo.setSymbolCnt(symbolCnt);
@@ -515,7 +541,7 @@
            String nickname = followTraderInfoEntity.getNickname();
            myFollowTraderInfoVo.setNickname(nickname);
            BigDecimal totalPrincipal = FollowFollowerProfitEntity.getTotalPrincipal();
            myFollowTraderInfoVo.setTotalPrincipal(totalPrincipal);
            myFollowTraderInfoVo.setTotalPrincipal(totalPrincipal.setScale(2, BigDecimal.ROUND_DOWN));
            BigDecimal totalProfit = FollowFollowerProfitEntity.getTotalProfit();
              myFollowTraderInfoVo.setTotalProfit(totalProfit.setScale(2, BigDecimal.ROUND_DOWN));
@@ -768,6 +794,9 @@
      String declaration = followTraderInfoEntity.getDeclaration();
      Integer isAll = followTraderInfoEntity.getIsAll();
      Integer followNum = followTraderInfoEntity.getFollowNum();
      Date entryTime = followTraderInfoEntity.getEntryTime();
      int datePoor = getDatePoor(entryTime, new Date());
      followTraderProfitInfoVo.setEntryDays(datePoor);
      //获取当前跟单人数
      Map<String, Object> columnMap = new HashMap<>();
      columnMap.put("trade_id", traderId);
@@ -793,6 +822,19 @@
      followTraderProfitInfoVo.setDeclaration(declaration);
      followTraderProfitInfoVo.setIsAll(isAll);
      return Result.ok(followTraderProfitInfoVo);
   }
   //获取两个时间之间的日期
   private int getDatePoor(Date endDate, Date nowDate) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(endDate);
      long time1 = cal.getTimeInMillis();
      cal.setTime(nowDate);
      long time2 = cal.getTimeInMillis();
      long between_days=(time2-time1)/(1000*3600*24);
      int parseInt = Integer.parseInt(String.valueOf(between_days));
      parseInt = parseInt + 1;
      return parseInt ;
   }
   @Override
@@ -967,6 +1009,9 @@
        TradeProfitInfoVo tradeProfitInfoVo = new TradeProfitInfoVo();
        //获取【交易员信息表】数据
        FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectTraderInfoByMemberId(memberId);
        Date entryTime = followTraderInfoEntity.getEntryTime();
      int datePoor = getDatePoor(entryTime, new Date());
      tradeProfitInfoVo.setEntryDays(datePoor);
        if(ObjectUtil.isNotEmpty(followTraderInfoEntity)) {
         Integer followNum = followTraderInfoEntity.getFollowNum();
         //获取当前跟单人数
@@ -1002,7 +1047,11 @@
           tradeProfitInfoVo.setTotalFollowerCnt(totalFollowerCnt);
           BigDecimal totalOrderCnt = followTraderProfitInfoVo.getTotalOrderCnt();
           tradeProfitInfoVo.setTotalOrderCnt(totalOrderCnt);
        }
         BigDecimal thirtyProfitRatio = followTraderProfitInfoVo.getThirtyProfitRatio();
         tradeProfitInfoVo.setThirtyProfitRatio(thirtyProfitRatio);
         BigDecimal thirtyRatio = followTraderProfitInfoVo.getThirtyRatio();
         tradeProfitInfoVo.setThirtyRatio(thirtyRatio);
      }
      return Result.ok(tradeProfitInfoVo);
   }
@@ -1118,6 +1167,7 @@
                          BigDecimal rewardAmount = orderEntity.getRewardAmount();
                          allRewardAmount = allRewardAmount.add(rewardAmount);
                          BigDecimal rewardRatio = orderEntity.getRewardRatio();
                        rewardRatio = rewardRatio == null ? BigDecimal.ZERO : rewardRatio;
                          allRewardRatio = allRewardRatio.add(rewardRatio);
                       }
                    }
@@ -1140,7 +1190,7 @@
                 myFollowOrderVo.setLeverRatio(leverRatio);
                 BigDecimal rewardAmount = contractOrderEntity.getRewardAmount().setScale(2, BigDecimal.ROUND_DOWN);
                 myFollowOrderVo.setRewardAmount(rewardAmount);
                 BigDecimal rewardRatio = contractOrderEntity.getRewardRatio().setScale(4, BigDecimal.ROUND_DOWN);
                 BigDecimal rewardRatio = contractOrderEntity.getRewardRatio() == null ? BigDecimal.ZERO : contractOrderEntity.getRewardRatio().setScale(4, BigDecimal.ROUND_DOWN);
                 myFollowOrderVo.setRewardRatio(rewardRatio);
                 int symbolCnt = contractOrderEntity.getSymbolCnt();
                 myFollowOrderVo.setSymbolCnt(symbolCnt);
@@ -1189,8 +1239,18 @@
            
            Long id = followFollowerProfitEntity.getId();
            myFollowTraderInfoVo.setId(id);
            BigDecimal totalPrincipal = followFollowerProfitEntity.getTotalPrincipal();
            myFollowTraderInfoVo.setTotalPrincipal(totalPrincipal);
            Long tradeId = followFollowerProfitEntity.getTradeId();
            //获取当前跟随者最后一个历史跟单的保证金
            BigDecimal bondAmount = BigDecimal.ZERO;
            List<BigDecimal> bondamounts = followFollowerProfitDao.selectBondAmountByTradeIdAndMemberId(followMemberId,tradeId);
            if(CollUtil.isNotEmpty(bondamounts)){
               bondAmount = bondamounts.get(0).setScale(2, BigDecimal.ROUND_DOWN);
            }
            myFollowTraderInfoVo.setTotalPrincipal(bondAmount);
//            BigDecimal totalPrincipal = followFollowerProfitEntity.getTotalPrincipal();
//            myFollowTraderInfoVo.setTotalPrincipal(totalPrincipal);
            BigDecimal totalProfit = followFollowerProfitEntity.getTotalProfit();
            myFollowTraderInfoVo.setTotalProfit(totalProfit.setScale(2, BigDecimal.ROUND_DOWN));