Helius
2020-08-06 39143d1ff3ca043efbf8af09624f409ef7bd4b94
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -10,6 +10,8 @@
import javax.annotation.Resource;
import javax.validation.Valid;
import com.xcong.excoin.modules.documentary.common.NoticeConstant;
import com.xcong.excoin.utils.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -23,6 +25,7 @@
import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
import com.xcong.excoin.modules.documentary.dao.FollowFollowerNoticeDao;
import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao;
import com.xcong.excoin.modules.documentary.dao.FollowFollowerProfitDao;
import com.xcong.excoin.modules.documentary.dao.FollowFollowerSettingDao;
@@ -40,6 +43,7 @@
import com.xcong.excoin.modules.documentary.dto.TradeOrderInfoDto;
import com.xcong.excoin.modules.documentary.dto.UpdateDocumentaryOrderSetDto;
import com.xcong.excoin.modules.documentary.dto.UpdateTradeSetInfoDto;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerNoticeEntity;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerProfitEntity;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerSettingEntity;
@@ -48,6 +52,7 @@
import com.xcong.excoin.modules.documentary.service.DocumentaryService;
import com.xcong.excoin.modules.documentary.vo.DocumentaryOrderInfoVo;
import com.xcong.excoin.modules.documentary.vo.DocumentaryOrderSetInfoVo;
import com.xcong.excoin.modules.documentary.vo.FollowFollowerNoticeVo;
import com.xcong.excoin.modules.documentary.vo.FollowInfoVo;
import com.xcong.excoin.modules.documentary.vo.FollowRecordsVo;
import com.xcong.excoin.modules.documentary.vo.FollowTraderProfitInfoVo;
@@ -68,10 +73,6 @@
import com.xcong.excoin.modules.member.entity.MemberLevelRateEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
import com.xcong.excoin.utils.CacheSettingUtils;
import com.xcong.excoin.utils.CoinTypeConvert;
import com.xcong.excoin.utils.MessageSourceUtils;
import com.xcong.excoin.utils.RedisUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -108,6 +109,8 @@
    private FollowFollowerSettingDao followFollowerSettingDao;
    @Resource
    private FollowFollowerOrderRelationDao followFollowerOrderRelationDao;
    private FollowFollowerNoticeDao followFollowerNoticeDao;
    
   
   @Override
@@ -279,7 +282,7 @@
                 myFollowOrderVo.setLeverRatio(leverRatio);
                 BigDecimal rewardAmount = contractOrderEntity.getRewardAmount().setScale(2, BigDecimal.ROUND_DOWN);
                 myFollowOrderVo.setRewardAmount(rewardAmount);
                 BigDecimal rewardRatio = contractOrderEntity.getRewardRatio().setScale(2, BigDecimal.ROUND_DOWN);
                 BigDecimal rewardRatio = contractOrderEntity.getRewardRatio().setScale(4, BigDecimal.ROUND_DOWN);
                 myFollowOrderVo.setRewardRatio(rewardRatio);
                 int symbolCnt = contractOrderEntity.getSymbolCnt();
                 myFollowOrderVo.setSymbolCnt(symbolCnt);
@@ -607,7 +610,7 @@
      FollowTraderProfitInfoVo followTraderProfitInfoVo = followTraderProfitInfoDao.selectOneByMemberId(memberId);
      MemberEntity user = LoginUserUtils.getUser();
      if(ObjectUtil.isNotEmpty(user)) {
         FollowFollowerProfitEntity followFollowerProfitEntity = followFollowerProfitDao.selectDocumentaryOrderSetInfoBymemberIdAndTradeId(memberId, traderId);
         FollowFollowerProfitEntity followFollowerProfitEntity = followFollowerProfitDao.selectDocumentaryOrderSetInfoBymemberIdAndTradeId(user.getId(), traderId);
         if(ObjectUtil.isNotEmpty(followFollowerProfitEntity)) {
            followTraderProfitInfoVo.setDocumentaryType(followFollowerProfitEntity.getIsFollow());
         }else {
@@ -635,6 +638,16 @@
        if(MemberEntity.CERTIFY_STATUS_Y != certifyStatus) {
           return Result.fail(MessageSourceUtils.getString("member_controller_0009"));
        }
        //不可以处于跟单状态
        Map<String, Object> columnMaps = new HashMap<>();
        columnMaps.put("member_id", memberId);
        columnMaps.put("is_follow", 1);
        List<FollowFollowerProfitEntity> followFollowerProfitEntitys = followFollowerProfitDao.selectByMap(columnMaps);
        if(CollUtil.isNotEmpty(followFollowerProfitEntitys)) {
           return Result.fail(MessageSourceUtils.getString("documentary_service_0015"));
        }
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("member_id", memberId);
      List<FollowTraderInfoEntity> selectByMap = followTraderInfoDao.selectByMap(columnMap);
@@ -645,7 +658,8 @@
        //新增【交易员信息表】数据
        FollowTraderInfoEntity followTraderInfoEntity = new FollowTraderInfoEntity();
        followTraderInfoEntity.setMemberId(memberId);
        followTraderInfoEntity.setAvatar(FollowTraderInfoEntity.AVATAR_DEFAULT);
        followTraderInfoEntity.setProfitRatio(BigDecimal.valueOf(0.1));
//        followTraderInfoEntity.setAvatar(FollowTraderInfoEntity.AVATAR_DEFAULT);
        String phone = memberEntity.getPhone();
        String email = memberEntity.getEmail();
        if(StrUtil.isNotEmpty(phone)) {
@@ -821,7 +835,7 @@
               
               // 回报率
               BigDecimal returnRate = rewardRatio.divide(contractHoldOrderEntity.getBondAmount().subtract(contractHoldOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN);
               myFollowOrderVo.setRewardRatio(returnRate.setScale(2, BigDecimal.ROUND_DOWN));
               myFollowOrderVo.setRewardRatio(returnRate.setScale(4, BigDecimal.ROUND_DOWN));
               
               myFollowOrderVos.add(myFollowOrderVo);
            }
@@ -927,9 +941,50 @@
        FollowFollowerProfitEntity followFollowerProfitEntity = followFollowerProfitDao.selectById(id);
        followFollowerProfitEntity.setIsFollow(FollowFollowerProfitEntity.IS_FOLLOW_N);
        followFollowerProfitDao.updateById(followFollowerProfitEntity);
        //删除【跟随者设置】
        Map<String, Object> columnMap = new HashMap<>();
        Long followMemberId = followFollowerProfitEntity.getMemberId();
        Long tradeId = followFollowerProfitEntity.getTradeId();
        columnMap.put("member_id", followMemberId);
        columnMap.put("trader_id", tradeId);
        List<FollowFollowerSettingEntity> selectByMap = followFollowerSettingDao.selectByMap(columnMap);
        if(CollUtil.isNotEmpty(selectByMap)) {
           for(FollowFollowerSettingEntity followFollowerSettingEntity : selectByMap) {
              followFollowerSettingDao.deleteById(followFollowerSettingEntity.getId());
           }
        }
      FollowTraderInfoEntity traderInfoEntity = followTraderInfoDao.selectTraderInfoByMemberId(memberId);
      if (traderInfoEntity != null) {
         LogRecordUtils.insertFollowerNotice(memberId, NoticeConstant.STOP_FOLLOW_TITLE, StrUtil.format(NoticeConstant.STOP_FOLLOW_CONTENT, traderInfoEntity.getNickname()));
      }
      return Result.ok(MessageSourceUtils.getString("member_service_0026"));
   }
   @Override
   public Result getFollowFollowerNoticeList() {
      //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        List<FollowFollowerNoticeVo> arrayList = new ArrayList<>();
        Map<String, Object> columnMap = new HashMap<>();
        columnMap.put("member_id", memberId);
      List<FollowFollowerNoticeEntity> selectByMap = followFollowerNoticeDao.selectByMap(columnMap );
      if(CollUtil.isNotEmpty(selectByMap)) {
         for(FollowFollowerNoticeEntity followFollowerNoticeEntity : selectByMap) {
            FollowFollowerNoticeVo followFollowerNoticeVo = new FollowFollowerNoticeVo();
            String title = followFollowerNoticeEntity.getTitle();
            followFollowerNoticeVo.setTitle(title);
            String content = followFollowerNoticeEntity.getContent();
            followFollowerNoticeVo.setContent(content);
            arrayList.add(followFollowerNoticeVo);
         }
      }
      return Result.ok(arrayList);
   }