Helius
2020-08-03 cbefbc44b0d438a70ddadea887e5b4034cbb2224
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -52,6 +52,7 @@
import com.xcong.excoin.modules.documentary.vo.MemberIsTradeVo;
import com.xcong.excoin.modules.documentary.vo.MyFollowOrderVo;
import com.xcong.excoin.modules.documentary.vo.MyFollowTraderInfoVo;
import com.xcong.excoin.modules.documentary.vo.TraderStatusVo;
import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.dao.MemberLevelRateDao;
import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
@@ -393,6 +394,8 @@
            myFollowTraderInfoVo.setTotalPrincipal(totalPrincipal);
            BigDecimal totalProfit = FollowFollowerProfitEntity.getTotalProfit();
              myFollowTraderInfoVo.setTotalProfit(totalProfit.setScale(2, BigDecimal.ROUND_DOWN));
            myFollowTraderInfoVo.setTradeId(tradeId);
              myFollowOrderVos.add(myFollowTraderInfoVo);
           }
      }
@@ -434,49 +437,65 @@
   public Result getDocumentaryOrderSet(@Valid DocumentaryOrderSetDto documentaryOrderSetDto) {
      //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        //新增【跟随者设置】数据
        FollowFollowerSettingEntity followFollowerSettingEntity = new FollowFollowerSettingEntity();
        followFollowerSettingEntity.setMemberId(memberId);
        Long traderId = documentaryOrderSetDto.getTraderId();
        followFollowerSettingEntity.setTradeId(traderId);
        FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(traderId);
        Long traderMemberId = followTraderInfoEntity.getMemberId();
        followFollowerSettingEntity.setTradeMemberId(traderMemberId);
        followFollowerSettingEntity.setSymbols(documentaryOrderSetDto.getSymbols());
        followFollowerSettingEntity.setFollowType(documentaryOrderSetDto.getFollowType());
        followFollowerSettingEntity.setFollowCnt(documentaryOrderSetDto.getFollowCnt());
        followFollowerSettingEntity.setMaxFollowCnt(documentaryOrderSetDto.getMaxFollowCnt());
        followFollowerSettingDao.insert(followFollowerSettingEntity);
      //更新【跟随者收益】数据
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("member_id", memberId);
        List<FollowFollowerProfitEntity> selectByMap = followFollowerProfitDao.selectByMap(columnMap);
        if(CollUtil.isNotEmpty(selectByMap)) {
           FollowFollowerProfitEntity followFollowerProfitEntity = selectByMap.get(0);
           followFollowerProfitEntity.setIsFollow(FollowFollowerProfitEntity.IS_FOLLOW_Y);
           followFollowerProfitDao.updateById(followFollowerProfitEntity);
        }else {
           FollowFollowerProfitEntity followFollowerProfitEntity = new FollowFollowerProfitEntity();
           followFollowerProfitEntity.setMemberId(memberId);
           followFollowerProfitEntity.setTradeId(traderId);
           followFollowerProfitEntity.setTradeMemberId(traderMemberId);
           followFollowerProfitEntity.setTotalPrincipal(BigDecimal.ZERO);
           followFollowerProfitEntity.setTotalProfit(BigDecimal.ZERO);
           followFollowerProfitEntity.setIsFollow(FollowFollowerProfitEntity.IS_FOLLOW_Y);
           followFollowerProfitDao.insert(followFollowerProfitEntity);
        }
      Long traderId = documentaryOrderSetDto.getTraderId();
      FollowTraderInfoEntity traderInfoEntity = followTraderInfoDao.selectTraderInfoByMemberId(memberId);
      if (traderInfoEntity != null) {
         return Result.fail("交易员不能进行跟单");
      }
      FollowFollowerSettingEntity isExistSetting = followFollowerSettingDao.selectOneBymemberIdAndTradeId(memberId, traderId);
      if (isExistSetting == null) {
         //新增【跟随者设置】数据
         FollowFollowerSettingEntity followFollowerSettingEntity = new FollowFollowerSettingEntity();
         followFollowerSettingEntity.setMemberId(memberId);
         followFollowerSettingEntity.setTraderId(traderId);
         FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(traderId);
         Long traderMemberId = followTraderInfoEntity.getMemberId();
         followFollowerSettingEntity.setTraderMemberId(traderMemberId);
         followFollowerSettingEntity.setSymbols(documentaryOrderSetDto.getSymbols());
         followFollowerSettingEntity.setFollowType(documentaryOrderSetDto.getFollowType());
         followFollowerSettingEntity.setFollowCnt(documentaryOrderSetDto.getFollowCnt());
         followFollowerSettingEntity.setMaxFollowCnt(documentaryOrderSetDto.getMaxFollowCnt());
         followFollowerSettingDao.insert(followFollowerSettingEntity);
         //更新【跟随者收益】数据
         Map<String, Object> columnMap = new HashMap<>();
         columnMap.put("member_id", memberId);
         List<FollowFollowerProfitEntity> selectByMap = followFollowerProfitDao.selectByMap(columnMap);
         if (CollUtil.isNotEmpty(selectByMap)) {
            FollowFollowerProfitEntity followFollowerProfitEntity = selectByMap.get(0);
            followFollowerProfitEntity.setIsFollow(FollowFollowerProfitEntity.IS_FOLLOW_Y);
            followFollowerProfitDao.updateById(followFollowerProfitEntity);
         } else {
            FollowFollowerProfitEntity followFollowerProfitEntity = new FollowFollowerProfitEntity();
            followFollowerProfitEntity.setMemberId(memberId);
            followFollowerProfitEntity.setTradeId(traderId);
            followFollowerProfitEntity.setTradeMemberId(traderMemberId);
            followFollowerProfitEntity.setTotalPrincipal(BigDecimal.ZERO);
            followFollowerProfitEntity.setTotalProfit(BigDecimal.ZERO);
            followFollowerProfitEntity.setIsFollow(FollowFollowerProfitEntity.IS_FOLLOW_Y);
            followFollowerProfitDao.insert(followFollowerProfitEntity);
         }
      } else {
         isExistSetting.setSymbols(documentaryOrderSetDto.getSymbols());
         isExistSetting.setFollowType(documentaryOrderSetDto.getFollowType());
         isExistSetting.setFollowCnt(documentaryOrderSetDto.getFollowCnt());
         isExistSetting.setMaxFollowCnt(documentaryOrderSetDto.getMaxFollowCnt());
         followFollowerSettingDao.updateById(isExistSetting);
      }
      return Result.ok(MessageSourceUtils.getString("member_service_0024"));
   }
   @Override
   public Result getDocumentaryOrderSetInfo() {
   public Result getDocumentaryOrderSetInfo(String tradeId) {
      //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        DocumentaryOrderSetInfoVo documentaryOrderSetInfoVo = new DocumentaryOrderSetInfoVo();
        long parseLong = Long.parseLong(tradeId);
        //获取【跟随者设置】数据
        FollowFollowerSettingEntity followFollowerSettingEntity = followFollowerSettingDao.selectDocumentaryOrderSetInfoBymemberId(memberId);
        Long tradeId = followFollowerSettingEntity.getTradeId();
        documentaryOrderSetInfoVo.setTraderId(tradeId);
        FollowFollowerSettingEntity followFollowerSettingEntity = followFollowerSettingDao.selectOneBymemberIdAndTradeId(memberId,parseLong);
        documentaryOrderSetInfoVo.setTraderId(parseLong);
        
        FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(tradeId);
        String avatar = followTraderInfoEntity.getAvatar();
@@ -484,7 +503,11 @@
        
        String nickname = followTraderInfoEntity.getNickname();
        documentaryOrderSetInfoVo.setNickname(nickname);
      documentaryOrderSetInfoVo.setProfit(followTraderInfoEntity.getProfitRatio());
        if (followFollowerSettingEntity == null) {
           return Result.ok(documentaryOrderSetInfoVo);
      }
        String symbols = followFollowerSettingEntity.getSymbols();
        documentaryOrderSetInfoVo.setSymbols(symbols);
        
@@ -496,7 +519,6 @@
        
        Integer maxFollowCnt = followFollowerSettingEntity.getMaxFollowCnt();
        documentaryOrderSetInfoVo.setMaxFollowCnt(maxFollowCnt);
        
      return Result.ok(documentaryOrderSetInfoVo);
   }
@@ -525,11 +547,24 @@
        Long traderId = updateDocumentaryOrderSetDto.getTraderId();
        //更新【跟随者设置】数据
        FollowFollowerSettingEntity followFollowerSettingEntity = followFollowerSettingDao.selectOneBymemberIdAndTradeId(memberId, traderId);
        followFollowerSettingEntity.setSymbols(updateDocumentaryOrderSetDto.getSymbols());
        followFollowerSettingEntity.setFollowType(updateDocumentaryOrderSetDto.getFollowType());
        followFollowerSettingEntity.setFollowCnt(updateDocumentaryOrderSetDto.getFollowCnt());
        followFollowerSettingEntity.setMaxFollowCnt(updateDocumentaryOrderSetDto.getMaxFollowCnt());
        followFollowerSettingDao.updateById(followFollowerSettingEntity);
        if (followFollowerSettingEntity == null) {
           FollowTraderInfoEntity traderInfoEntity = followTraderInfoDao.selectById(traderId);
         followFollowerSettingEntity = new FollowFollowerSettingEntity();
         followFollowerSettingEntity.setSymbols(updateDocumentaryOrderSetDto.getSymbols());
         followFollowerSettingEntity.setFollowType(updateDocumentaryOrderSetDto.getFollowType());
         followFollowerSettingEntity.setFollowCnt(updateDocumentaryOrderSetDto.getFollowCnt());
         followFollowerSettingEntity.setMaxFollowCnt(updateDocumentaryOrderSetDto.getMaxFollowCnt());
         followFollowerSettingEntity.setTraderId(traderId);
         followFollowerSettingEntity.setMemberId(memberId);
         followFollowerSettingEntity.setTraderMemberId(traderInfoEntity.getMemberId());
         followFollowerSettingDao.insert(followFollowerSettingEntity);
      } else {
         followFollowerSettingEntity.setSymbols(updateDocumentaryOrderSetDto.getSymbols());
         followFollowerSettingEntity.setFollowType(updateDocumentaryOrderSetDto.getFollowType());
         followFollowerSettingEntity.setFollowCnt(updateDocumentaryOrderSetDto.getFollowCnt());
         followFollowerSettingEntity.setMaxFollowCnt(updateDocumentaryOrderSetDto.getMaxFollowCnt());
         followFollowerSettingDao.updateById(followFollowerSettingEntity);
      }
      
      return Result.ok(MessageSourceUtils.getString("member_service_0024"));
   }
@@ -558,8 +593,15 @@
        MemberEntity memberEntity = memberDao.selectById(memberId);
        Integer certifyStatus = memberEntity.getCertifyStatus();
        if(MemberEntity.CERTIFY_STATUS_Y != certifyStatus) {
           return Result.ok(MessageSourceUtils.getString("member_controller_0009"));
           return Result.fail(MessageSourceUtils.getString("member_controller_0009"));
        }
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("member_id", memberId);
      List<FollowTraderInfoEntity> selectByMap = followTraderInfoDao.selectByMap(columnMap);
      if(CollUtil.isNotEmpty(selectByMap)) {
         return Result.fail(MessageSourceUtils.getString("submit_repeat"));
      }
        //新增【交易员信息表】数据
        FollowTraderInfoEntity followTraderInfoEntity = new FollowTraderInfoEntity();
        followTraderInfoEntity.setMemberId(memberId);
@@ -579,6 +621,30 @@
        followTraderInfoDao.insert(followTraderInfoEntity);
      return Result.ok(MessageSourceUtils.getString("member_service_0024"));
   }
   @Override
   public Result beTraderStatus() {
      //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberEntity memberEntity = memberDao.selectById(memberId);
        TraderStatusVo traderStatusVo = new TraderStatusVo();
        Integer isTraer = memberEntity.getIsTrader();
        traderStatusVo.setIsTrader(isTraer);
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("member_id", memberId);
      List<FollowTraderInfoEntity> selectByMap = followTraderInfoDao.selectByMap(columnMap);
      if(CollUtil.isNotEmpty(selectByMap)) {
         for(FollowTraderInfoEntity followTraderInfoEntity : selectByMap) {
            Integer verifyStatus = followTraderInfoEntity.getVerifyStatus();
            traderStatusVo.setVerifyStatus(verifyStatus);
         }
      }else{
         traderStatusVo.setVerifyStatus(4);
      }
      return Result.ok(traderStatusVo);
   }