From 373f08dd87acf015d0c70356cd6a9ad44e5cc470 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Mon, 15 Jun 2020 17:48:46 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java b/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java index 7dfc27a..b07af97 100644 --- a/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xcong.excoin.common.entity.FebsConstant; +import com.xcong.excoin.common.entity.FebsResponse; import com.xcong.excoin.common.entity.QueryRequest; import com.xcong.excoin.common.exception.FebsException; import com.xcong.excoin.common.utils.Md5Util; @@ -21,6 +22,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import sun.management.Agent; import java.util.Arrays; import java.util.Date; @@ -85,6 +87,7 @@ addUser.setType(FebsConstant.USER_TYPE_AGENT); addUser.setSystem(FebsConstant.SYSTEM_AGENT); addUser.setCreateTime(new Date()); + addUser.setMobile(agentUser.getTelphone()); addUser.setInviteId(agentUser.getInviteId()); addUser.setAgentName(agentUser.getName()); addUser.setPassword(Md5Util.encrypt(addUser.getUsername(), User.DEFAULT_PASSWORD)); @@ -110,6 +113,7 @@ agentFriendRelationMapper.insert(agentFriendRelation); } + @Transactional(rollbackFor = Exception.class) @Override public void delAgent(String[] ids) { List<String> list = Arrays.asList(ids); @@ -124,4 +128,33 @@ user.setPassword(Md5Util.encrypt(user.getUsername(), User.DEFAULT_PASSWORD)); userMapper.updateById(user); } + + @Transactional(rollbackFor = Exception.class) + @Override + public void editAgent(AgentUser agentUser, User user) { + if (FebsConstant.USER_TYPE_ADMIN.equals(user.getType())) { + user.setInviteId(FebsConstant.DEFAULT_REFERER_ID); + } + + AgentFriendRelationEntity agentFriendRelationEntity = agentFriendRelationMapper.selectAgentFriendRelationByUserId(agentUser.getId()); + if (!user.getInviteId().equals(agentFriendRelationEntity.getRefererId())) { + throw new FebsException("不是该用户直接上级,无法修改"); + } + + if (!FebsConstant.USER_TYPE_ADMIN.equals(user.getType())) { + AgentFriendRelationEntity friendRelationEntity = agentFriendRelationMapper.selectAgentFriendRelationByUserId(user.getUserId()); + if (agentUser.getReturnRatio().compareTo(friendRelationEntity.getReturnRatio()) > 0) { + throw new FebsException("返佣比例需小于上级的返佣比例"); + } + } + + User editUser = new User(); + editUser.setUserId(agentUser.getId()); + editUser.setMobile(agentUser.getTelphone()); + editUser.setAgentName(agentUser.getName()); + userMapper.updateById(editUser); + + agentFriendRelationEntity.setReturnRatio(agentUser.getReturnRatio()); + agentFriendRelationMapper.updateById(agentFriendRelationEntity); + } } -- Gitblit v1.9.1