Helius
2021-03-04 f494010eae547cc9b0c9ead89968de6e9731ea40
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -60,6 +60,7 @@
import com.xcong.excoin.modules.documentary.entity.FollowTraderLabelEntity;
import com.xcong.excoin.modules.documentary.entity.FollowTraderProfitInfoEntity;
import com.xcong.excoin.modules.documentary.service.DocumentaryService;
import com.xcong.excoin.modules.documentary.vo.BeTraderConditionVo;
import com.xcong.excoin.modules.documentary.vo.DocumentaryOrderInfoVo;
import com.xcong.excoin.modules.documentary.vo.DocumentaryOrderSetInfoVo;
import com.xcong.excoin.modules.documentary.vo.FollowFollowerNoticeVo;
@@ -284,7 +285,43 @@
      }else {
         followInfoVo.setNickname(phone);
      }
      List<ContractHoldOrderEntity> myFollowOrder = followFollowerProfitDao.getFollowOrderNowRecords(memberId);
      BigDecimal totalBondAmount = BigDecimal.ZERO;
      BigDecimal profitOrLess = BigDecimal.ZERO;
      if (CollUtil.isNotEmpty(myFollowOrder)) {
         for(ContractHoldOrderEntity contractHoldOrderEntity : myFollowOrder) {
            BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(contractHoldOrderEntity.getSymbol())));
            BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(contractHoldOrderEntity.getSymbol());
            // 盈亏
            BigDecimal rewardRatio = BigDecimal.ZERO;
            // 开多
            if (contractHoldOrderEntity.OPENING_TYPE_MORE == contractHoldOrderEntity.getOpeningType()) {
               // (最新价-开仓价)*规格*张数
               rewardRatio = newPrice.subtract(contractHoldOrderEntity.getOpeningPrice()).multiply(lotNumber).multiply(new BigDecimal(contractHoldOrderEntity.getSymbolCnt()));
               // 开空
            } else {
               // (开仓价-最新价)*规格*张数
               rewardRatio = contractHoldOrderEntity.getOpeningPrice().subtract(newPrice).multiply(lotNumber).multiply(new BigDecimal(contractHoldOrderEntity.getSymbolCnt()));
            }
            if (member.getIsProfit() == MemberEntity.IS_PROFIT_Y) {
               PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
               if (rewardRatio.compareTo(BigDecimal.ZERO) > -1) {
                  rewardRatio = rewardRatio.multiply(BigDecimal.ONE.subtract(tradeSettingEntity.getProfitParam()));
               }
            }
            profitOrLess = profitOrLess.add(rewardRatio).setScale(2, BigDecimal.ROUND_DOWN);
            totalBondAmount = totalBondAmount.add(contractHoldOrderEntity.getBondAmount());
         }
      }
      followInfoVo.setTotalAmount(totalBondAmount);
      followInfoVo.setTotalProfitOrLess(profitOrLess);
      BigDecimal totalPrincipals =  BigDecimal.ZERO;
      BigDecimal totalProfits =  BigDecimal.ZERO;
      Map<String, Object> columnMap = new HashMap<>();
@@ -621,8 +658,11 @@
        documentaryOrderSetInfoVo.setFollowCnt(followCnt);
        
        Integer maxFollowCnt = followFollowerSettingEntity.getMaxFollowCnt();
        documentaryOrderSetInfoVo.setMaxFollowCnt(maxFollowCnt);
        if(maxFollowCnt > 0){
           documentaryOrderSetInfoVo.setMaxFollowCnt(maxFollowCnt.toString());
      }
        documentaryOrderSetInfoVo.setMaxFollowCnt(null);
        log.info(memberId + "-最大持仓张数-"+maxFollowCnt.toString());
      return Result.ok(documentaryOrderSetInfoVo);
   }
@@ -1131,6 +1171,7 @@
      }
      MemberSettingEntity memberSettingEntity = memberSettingDao.selectMemberSettingByMemberId(memberId);
      if(ObjectUtil.isNotEmpty(memberSettingEntity)) {
         log.info(memberId + "的消息提醒状态变更");
         memberSettingEntity.setMessageReminder(0);
         memberSettingDao.updateById(memberSettingEntity);
      }
@@ -1158,6 +1199,13 @@
      }
      return Result.ok(arrayList);
   }
   @Override
   public Result beTraderCondition() {
      String type = "apply_trader_rule";
      List<BeTraderConditionVo> beTraderConditionVos = followTraderInfoDao.selectBeTraderCondition(type);
      return Result.ok(beTraderConditionVos);
   }