From a053811c774ac07340e46561f5d2ab4d892282a0 Mon Sep 17 00:00:00 2001 From: Administrator <1101184511@qq.com> Date: 星期一, 29 七月 2024 02:38:40 +0800 Subject: [PATCH] 渠道功能完善 --- src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentServiceImpl.java | 85 ++++++++++++++++++++++++++++++++---------- 1 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentServiceImpl.java b/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentServiceImpl.java index d1ecdcf..cd7f76c 100644 --- a/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentServiceImpl.java +++ b/src/main/java/com/taoke/autopay/service/impl/agent/ChannelAgentServiceImpl.java @@ -7,6 +7,7 @@ import com.taoke.autopay.utils.AgentAliasUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.yeshi.utils.StringUtil; import javax.annotation.Resource; import java.util.Date; @@ -26,46 +27,53 @@ @Transactional(rollbackFor = Exception.class) @Override - public void addChannelAgent(ChannelAgent agent) throws ChannelAgentException { - ChannelAgentMapper.DaoQuery query=new ChannelAgentMapper.DaoQuery(); + public ChannelAgent addChannelAgent(ChannelAgent agent) throws ChannelAgentException { + ChannelAgentMapper.DaoQuery query = new ChannelAgentMapper.DaoQuery(); query.account = agent.getAccount(); - long count = channelAgentMapper.count(query); - if(count>0){ - throw new ChannelAgentException("璐﹀彿宸插瓨鍦�"); - } - if(agent.getStatus()==null){ - agent.setStatus(ChannelAgent.STATUS_NOMAL); - } + long count = channelAgentMapper.count(query); + if (count > 0) { + throw new ChannelAgentException("璐﹀彿宸插瓨鍦�"); + } + if (agent.getStatus() == null) { + agent.setStatus(ChannelAgent.STATUS_NOMAL); + } + if (agent.getCreateTime() == null) { + agent.setCreateTime(new Date()); + } + channelAgentMapper.insertSelective(agent); - if(agent.getCreateTime()==null){ - agent.setCreateTime(new Date()); - } - channelAgentMapper.insertSelective(agent); - - // 鏇存柊alias - if(agent.getAlias()==null){ + // 鏇存柊alias + if (agent.getAlias() == null) { ChannelAgent update = ChannelAgent.builder().id(agent.getId()).alias(AgentAliasUtil.createAlias(agent.getId())).updateTime(new Date()).build(); + agent.setAlias(update.getAlias()); channelAgentMapper.updateByPrimaryKeySelective(update); } + + return agent; } @Transactional(rollbackFor = Exception.class) @Override public void setAlipayAccount(Long agentId, String name, String account) throws ChannelAgentException { - ChannelAgent agent = channelAgentMapper.selectByPrimaryKeyForUpdate(agentId); - if(agent==null){ - throw new ChannelAgentException("浠g悊ID涓嶅瓨鍦�"); + ChannelAgent agent = channelAgentMapper.selectByPrimaryKeyForUpdate(agentId); + if (agent == null) { + throw new ChannelAgentException("浠g悊ID涓嶅瓨鍦�"); } - ChannelAgent update= ChannelAgent.builder().id(agentId).alipayAccount(account).alipayName(name).alipayUpdateTime(new Date()).updateTime(new Date()).build(); + ChannelAgent update = ChannelAgent.builder().id(agentId).alipayAccount(account).alipayName(name).alipayUpdateTime(new Date()).updateTime(new Date()).build(); updateSelective(update); } @Override + public ChannelAgent selectByPrimaryKey(Long agengId) { + return channelAgentMapper.selectByPrimaryKey(agengId); + } + + @Override public void updateSelective(ChannelAgent agent) { - if(agent.getUpdateTime()==null){ + if (agent.getUpdateTime() == null) { agent.setUpdateTime(new Date()); } channelAgentMapper.updateByPrimaryKeySelective(agent); @@ -80,4 +88,39 @@ public long count(ChannelAgentMapper.DaoQuery query) { return channelAgentMapper.count(query); } + + @Override + public void delete(Long id) { + channelAgentMapper.deleteByPrimaryKey(id); + } + + @Override + public ChannelAgent login(String account, String pwd) throws ChannelAgentException { + + ChannelAgentMapper.DaoQuery query = new ChannelAgentMapper.DaoQuery(); + query.account = account; + query.count = 1; + List<ChannelAgent> list = channelAgentMapper.list(query); + if (list.isEmpty()) { + throw new ChannelAgentException("璐︽埛涓嶅瓨鍦�"); + } + if (!list.get(0).getPwd().equalsIgnoreCase(StringUtil.Md5(pwd))) { + throw new ChannelAgentException("瀵嗙爜閿欒"); + } + + + return list.get(0); + } + + @Override + public ChannelAgent selectByAlias(String alias) { + ChannelAgentMapper.DaoQuery query = new ChannelAgentMapper.DaoQuery(); + query.alias = alias; + query.count = 1; + List<ChannelAgent> list = channelAgentMapper.list(query); + if (list.isEmpty()) { + return null; + } + return list.get(0); + } } -- Gitblit v1.8.0