From 7d098b8c03c2a3f2dc7b51f73cc8d16b56dfa764 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 18 May 2021 16:44:41 +0800
Subject: [PATCH] 20210518 订单
---
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java | 199 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 199 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 f9bc1ca..5872b91 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
@@ -1,16 +1,20 @@
package com.xcong.excoin.modules.documentary.service.impl;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.common.utils.RedisUtils;
+import com.xcong.excoin.modules.documentary.vo.SeeFollowerInfoVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -20,6 +24,7 @@
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;
@@ -36,6 +41,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;
@@ -66,6 +72,11 @@
List<FollowTraderInfoEntity> records = followTraderInfoEntitys.getRecords();
if(CollUtil.isNotEmpty(records)) {
for(FollowTraderInfoEntity followTraderInfo : records) {
+ //获取当前跟单人数
+ Long traderId = followTraderInfo.getId();
+ String followNowNumString = followTraderInfoMapper.selectFollowNowBytraderId(traderId);
+ followTraderInfo.setFollowNumNow(followNowNumString);
+
Long memberId = followTraderInfo.getMemberId();
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("member_id", memberId);
@@ -127,6 +138,14 @@
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);
+ }
+ if(profitRatio.compareTo(BigDecimal.ZERO) < 0 || profitRatio.compareTo(BigDecimal.ONE) >= 0){
+ return new FebsResponse().fail().message("利润率设置规则:只允许0到1之间的小数");
+ }
String isok = followTraderInfoDto.getIsok();
if("1".equals(isok)) {
//更新【会员信息表】数据
@@ -138,6 +157,8 @@
memberEntity.setIsTrader(1);
memberMapper.updateById(memberEntity);
//更新【交易员信息表】数据
+ selectById.setProfitRatio(profitRatio);
+ selectById.setEntryTime(new Date());
selectById.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_Y);
followTraderInfoMapper.updateById(selectById);
//新增【交易员收益信息 】数据
@@ -160,6 +181,7 @@
redisUtils.set("app_" + token, JSONObject.toJSONString(memberEntity), 36000);
}else {
//更新【交易员信息表】数据
+ selectById.setEntryTime(new Date());
selectById.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_N);
followTraderInfoMapper.updateById(selectById);
}
@@ -229,4 +251,181 @@
followTraderLabelMapper.updateById(followTraderLabelEntity);
}
+ @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);
+ }
+ if(profitRatio.compareTo(BigDecimal.ZERO) < 0 || profitRatio.compareTo(BigDecimal.ONE) >= 0){
+ return new FebsResponse().fail().message("利润率设置规则:只允许0到1之间的小数");
+ }
+ //最大跟随人数
+ boolean matches = isMatches(modifyProfitRatioDto.getFollowNum());
+ if(!matches) {
+ return new FebsResponse().fail().message("最大跟随人数只能输入正整数");
+ }
+ Integer followNum = Integer.parseInt(modifyProfitRatioDto.getFollowNum());
+ if(ObjectUtil.isEmpty(followNum) || followNum == 0) {
+ return new FebsResponse().fail().message("最大跟随人数不能为0");
+ }
+
+ String followNumNow = followTraderInfoMapper.selectFollowNowBytraderId(id);
+ int parseInt = Integer.parseInt(followNumNow);
+ if(parseInt > followNum){
+ return new FebsResponse().fail().message("请填写大于当前跟随人数"+parseInt+"的整数");
+ }
+ //更新【交易员信息表】数据
+ selectById.setProfitRatio(profitRatio);
+ selectById.setFollowNum(followNum);
+ followTraderInfoMapper.updateById(selectById);
+ return new FebsResponse().success();
+ }
+
+ public boolean isMatches(String bot){
+ boolean flag=false;
+ try{
+ String regex="^[1-9]+[0-9]*$";
+ //^[1-9]+\\d*$
+ Pattern p=Pattern.compile(regex);
+ Matcher m=p.matcher(bot);
+ if(m.find()){
+ System.out.println("successss");
+ return true;
+ }else{
+ System.out.println("falsss");
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ return flag;
+ }
+
+ @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();
+ }
+
+ @Override
+ public IPage<FollowTraderProfitInfoEntity> findTraderProfitInfoInfoInPage(
+ FollowTraderProfitInfoEntity followTraderProfitInfoEntity, QueryRequest request) {
+
+ Page<FollowTraderProfitInfoEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
+ IPage<FollowTraderProfitInfoEntity> FollowTraderProfitInfoEntitys = followTraderProfitInfoMapper.findTraderProfitInfoInfoInPage(page, followTraderProfitInfoEntity);
+ List<FollowTraderProfitInfoEntity> records = FollowTraderProfitInfoEntitys.getRecords();
+
+ if(CollUtil.isNotEmpty(records)) {
+ for(FollowTraderProfitInfoEntity followTraderProfitInfo : records) {
+ Long traderId = followTraderProfitInfo.getTraderId();
+ FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoMapper.selectById(traderId);
+ //利润率
+ BigDecimal profitRatio = BigDecimal.ZERO;
+ //总返利
+ BigDecimal profitRatioTotal = BigDecimal.ZERO;
+ if(ObjectUtil.isNotEmpty(followTraderInfoEntity)) {
+ profitRatio = followTraderInfoEntity.getProfitRatio();
+ profitRatioTotal = new BigDecimal(followTraderInfoMapper.selectProfitRatioTotal(followTraderInfoEntity.getMemberId())).setScale(2, RoundingMode.HALF_UP);
+ }
+ followTraderProfitInfo.setProfitRatio(profitRatio);
+ followTraderProfitInfo.setProfitRatioTotal(profitRatioTotal);
+
+ Long memberId = followTraderProfitInfo.getMemberId();
+ Map<String, Object> columnMap = new HashMap<>();
+ columnMap.put("member_id", memberId);
+ List<MemberAuthenticationEntity> selectByMap = memberAuthenticationMapper.selectByMap(columnMap );
+ if(CollUtil.isNotEmpty(selectByMap)) {
+ MemberAuthenticationEntity memberAuthenticationEntity = selectByMap.get(0);
+ String firstName = memberAuthenticationEntity.getFirstName();
+ String secondName = memberAuthenticationEntity.getSecondName();
+ String realName = firstName + secondName;
+ followTraderProfitInfo.setRealName(realName);
+ }
+ }
+ }
+ return FollowTraderProfitInfoEntitys;
+ }
+
+ @Override
+ public IPage<SeeFollowerInfoVo> findlistSeeFollowerInfo(QueryRequest request, FollowTraderProfitInfoEntity followTraderProfitInfoEntity) {
+
+ Long id = followTraderProfitInfoEntity.getId();
+ if(ObjectUtil.isEmpty(id)) {
+ return null;
+ }
+ //获取交易员信息
+ FollowTraderProfitInfoEntity FollowTraderProfitInfo = followTraderProfitInfoMapper.selectById(id);
+ if(ObjectUtil.isEmpty(FollowTraderProfitInfo)) {
+ return null;
+ }
+ Long traderId = FollowTraderProfitInfo.getTraderId();
+ Long traderMemberId = FollowTraderProfitInfo.getMemberId();
+ FollowTraderInfoEntity FollowTraderInfo = followTraderInfoMapper.selectById(traderId);
+ if(ObjectUtil.isEmpty(FollowTraderInfo)) {
+ return null;
+ }
+ //获取当前的跟随者
+ Page<SeeFollowerInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize());
+ IPage<SeeFollowerInfoVo> seeFollowerInfoVos = followFollowerProfitMapper.findFollowFollowerProfitInfo(page, FollowTraderInfo);
+ List<SeeFollowerInfoVo> records = seeFollowerInfoVos.getRecords();
+ if(CollUtil.isNotEmpty(records)) {
+ for(SeeFollowerInfoVo seeFollowerInfoVo : records) {
+ long memberId = seeFollowerInfoVo.getMemberId();
+ MemberEntity memberEntity = memberMapper.selectById(memberId);
+ if(ObjectUtil.isNotEmpty(memberEntity)) {
+ String phone = memberEntity.getPhone();
+ String email = memberEntity.getEmail();
+ String inviteId = memberEntity.getInviteId();
+ seeFollowerInfoVo.setPhone(phone);
+ seeFollowerInfoVo.setEmail(email);
+ seeFollowerInfoVo.setInviteId(inviteId);
+ //合约账户总资产
+ String totalString = memberMapper.selectMemberWalletContractByMemberId(memberId);
+ BigDecimal contractTotal = new BigDecimal(totalString);
+ seeFollowerInfoVo.setContractTotal(contractTotal);
+ //总返利
+ String totalProfitStr = followTraderInfoMapper.selectAllProfitByMemberIdAndTraderMemberId(memberId,traderMemberId);
+ BigDecimal totalProfit = new BigDecimal(totalProfitStr);
+ seeFollowerInfoVo.setProfitTotal(totalProfit);
+
+ Map<String, Object> columnMap = new HashMap<>();
+ columnMap.put("member_id", memberId);
+ List<MemberAuthenticationEntity> selectByMap = memberAuthenticationMapper.selectByMap(columnMap );
+ if(CollUtil.isNotEmpty(selectByMap)) {
+ MemberAuthenticationEntity memberAuthenticationEntity = selectByMap.get(0);
+ String firstName = memberAuthenticationEntity.getFirstName();
+ String secondName = memberAuthenticationEntity.getSecondName();
+ String realName = firstName + secondName;
+ seeFollowerInfoVo.setRealName(realName);
+ }
+ }
+ }
+ }
+
+ return seeFollowerInfoVos;
+ }
+
}
--
Gitblit v1.9.1