From 3ea894165b42672d0a9d93341e84fbc9f24f5294 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 03 Mar 2021 11:39:36 +0800
Subject: [PATCH] 20210321  利润率后台修改,推荐上首页后台设置

---
 src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java b/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
index d25b53d..e5f476a 100644
--- a/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -9,6 +9,8 @@
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
 
+import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.common.utils.RedisUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -18,9 +20,14 @@
 import com.xcong.excoin.common.entity.FebsResponse;
 import com.xcong.excoin.common.entity.QueryRequest;
 import com.xcong.excoin.modules.documentary.dto.FollowTraderInfoDto;
+import com.xcong.excoin.modules.documentary.dto.ModifyProfitRatioDto;
+import com.xcong.excoin.modules.documentary.entity.FollowFollowerProfitEntity;
 import com.xcong.excoin.modules.documentary.entity.FollowTraderInfoEntity;
+import com.xcong.excoin.modules.documentary.entity.FollowTraderLabelEntity;
 import com.xcong.excoin.modules.documentary.entity.FollowTraderProfitInfoEntity;
+import com.xcong.excoin.modules.documentary.mapper.FollowFollowerProfitMapper;
 import com.xcong.excoin.modules.documentary.mapper.FollowTraderInfoMapper;
+import com.xcong.excoin.modules.documentary.mapper.FollowTraderLabelMapper;
 import com.xcong.excoin.modules.documentary.mapper.FollowTraderProfitInfoMapper;
 import com.xcong.excoin.modules.documentary.service.DocumentaryService;
 import com.xcong.excoin.modules.member.entity.MemberAuthenticationEntity;
@@ -30,6 +37,7 @@
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 
@@ -40,11 +48,17 @@
 	
 	private final FollowTraderInfoMapper followTraderInfoMapper;
 	
+	private final FollowFollowerProfitMapper followFollowerProfitMapper;
+	
+	private final FollowTraderLabelMapper followTraderLabelMapper;
+	
 	private final MemberAuthenticationMapper memberAuthenticationMapper;
 	
 	private final MemberMapper memberMapper;
 	
 	private final FollowTraderProfitInfoMapper followTraderProfitInfoMapper;
+
+	private final RedisUtils redisUtils;
 	
 	@Override
 	public IPage<FollowTraderInfoEntity> findTraderListInPage(FollowTraderInfoEntity followTraderInfoEntity,
@@ -115,6 +129,11 @@
 		if(ObjectUtil.isEmpty(selectById)) {
 			return new FebsResponse().fail().message("交易员信息不存在");
 		}
+		BigDecimal profitRatio = BigDecimal.ZERO;
+		String profitRatioStr = followTraderInfoDto.getProfitRatio();
+		if(StrUtil.isNotEmpty(profitRatioStr)) {
+			profitRatio = new BigDecimal(profitRatioStr);
+		}
 		String isok = followTraderInfoDto.getIsok();
 		if("1".equals(isok)) {
 			//更新【会员信息表】数据
@@ -126,6 +145,7 @@
 			memberEntity.setIsTrader(1);
 			memberMapper.updateById(memberEntity);
 			//更新【交易员信息表】数据
+			selectById.setProfitRatio(profitRatio);
 			selectById.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_Y);
 			followTraderInfoMapper.updateById(selectById);
 			//新增【交易员收益信息 】数据
@@ -143,6 +163,9 @@
 			followTraderProfitInfoEntity.setTotalFollowerCnt(BigDecimal.ZERO);
 			followTraderProfitInfoEntity.setTotalOrderCnt(BigDecimal.ZERO);
 			followTraderProfitInfoMapper.insert(followTraderProfitInfoEntity);
+
+			String token = redisUtils.getString("app_" + memberEntity.getId());
+			redisUtils.set("app_" + token, JSONObject.toJSONString(memberEntity), 36000);
 		}else {
 			//更新【交易员信息表】数据
 			selectById.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_N);
@@ -152,12 +175,25 @@
 	}
 
 	@Override
+	@Transactional
 	public FebsResponse traderGetOut(@NotNull(message = "{required}") Long id) {
 		FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoMapper.selectById(id);
 		if(ObjectUtil.isEmpty(followTraderInfoEntity)) {
 			return new FebsResponse().fail().message("交易员信息不存在");
 		}
 		Long memberId = followTraderInfoEntity.getMemberId();
+		
+		Map<String, Object> columnMap = new HashMap<>();
+		columnMap.put("trade_member_id", memberId);
+		List<FollowFollowerProfitEntity> selectByMap = followFollowerProfitMapper.selectByMap(columnMap);
+		if(CollUtil.isNotEmpty(selectByMap)) {
+			for(FollowFollowerProfitEntity FollowFollowerProfitEntity : selectByMap ) {
+				FollowFollowerProfitEntity.setIsFollow(FollowFollowerProfitEntity.IS_FOLLOW_N);
+				followFollowerProfitMapper.updateById(FollowFollowerProfitEntity);
+			}
+		}
+		followTraderInfoEntity.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_N);
+		followTraderInfoMapper.updateById(followTraderInfoEntity);
 		MemberEntity memberEntity = memberMapper.selectById(memberId);
 		memberEntity.setIsTrader(2);
 		memberMapper.updateById(memberEntity);
@@ -176,4 +212,76 @@
 		return new FebsResponse().success();
 	}
 
+	@Override
+	public IPage<FollowTraderLabelEntity> traderLabelList(FollowTraderLabelEntity followTraderLabelEntity,
+			QueryRequest request) {
+		Page<FollowTraderLabelEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
+		IPage<FollowTraderLabelEntity> followTraderLabelEntitys = followTraderLabelMapper.findFollowTraderLabelEntitysInPage(page, followTraderLabelEntity);
+		return followTraderLabelEntitys;
+	}
+
+	@Override
+	public FebsResponse traderLabelDelete(@NotNull(message = "{required}") Long id) {
+		followTraderLabelMapper.deleteById(id);
+		return new FebsResponse().success();
+	}
+
+	@Override
+	public void followLabelSetAdd(@Valid FollowTraderLabelEntity followTraderLabelEntity) {
+		
+		followTraderLabelMapper.insert(followTraderLabelEntity);
+	}
+
+	@Override
+	public void followLabelSetUpdate(@Valid FollowTraderLabelEntity followTraderLabelEntity) {
+		followTraderLabelMapper.updateById(followTraderLabelEntity);
+	}
+
+	@Override
+	public IPage<FollowTraderProfitInfoEntity> findTraderDataInfoInfoInPage(FollowTraderProfitInfoEntity followTraderProfitInfoEntity, QueryRequest request) {
+		return null;
+	}
+
+	@Override
+	@Transactional
+	public FebsResponse modifyProfitRatio(@Valid ModifyProfitRatioDto modifyProfitRatioDto) {
+		Long id = modifyProfitRatioDto.getId();
+		FollowTraderInfoEntity selectById = followTraderInfoMapper.selectById(id);
+		if(ObjectUtil.isEmpty(selectById)) {
+			return new FebsResponse().fail().message("交易员信息不存在");
+		}
+		BigDecimal profitRatio = BigDecimal.ZERO;
+		String profitRatioStr = modifyProfitRatioDto.getProfitRatio();
+		if(StrUtil.isNotEmpty(profitRatioStr)) {
+			profitRatio = new BigDecimal(profitRatioStr);
+		}
+		//更新【交易员信息表】数据
+		selectById.setProfitRatio(profitRatio);
+		selectById.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_Y);
+		followTraderInfoMapper.updateById(selectById);
+		return new FebsResponse().success();
+	}
+
+	@Override
+	public FebsResponse traderGetOn(@NotNull(message = "{required}") Long id) {
+		FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoMapper.selectById(id);
+		if(ObjectUtil.isEmpty(followTraderInfoEntity)) {
+			return new FebsResponse().fail().message("交易员信息不存在");
+		}
+		followTraderInfoEntity.setIsSetFrist(FollowTraderInfoEntity.IS_SETFRIST_Y);
+		followTraderInfoMapper.updateById(followTraderInfoEntity);
+		return new FebsResponse().success();
+	}
+
+	@Override
+	public FebsResponse traderGetOutFrist(@NotNull(message = "{required}") Long id) {
+		FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoMapper.selectById(id);
+		if(ObjectUtil.isEmpty(followTraderInfoEntity)) {
+			return new FebsResponse().fail().message("交易员信息不存在");
+		}
+		followTraderInfoEntity.setIsSetFrist(FollowTraderInfoEntity.IS_SETFRIST_N);
+		followTraderInfoMapper.updateById(followTraderInfoEntity);
+		return new FebsResponse().success();
+	}
+
 }

--
Gitblit v1.9.1