From 035edfa382d349ba66240fbfef68c14c7cfc95d1 Mon Sep 17 00:00:00 2001 From: admin <1101184511@qq.com> Date: 星期五, 08 八月 2025 01:20:21 +0800 Subject: [PATCH] 功能完善 --- src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java | 130 +++++++++++++++++++++++++++++++----------- 1 files changed, 95 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java b/src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java index 6bda45d..3c841fc 100644 --- a/src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java +++ b/src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java @@ -1,16 +1,19 @@ package com.taoke.autopay.service.impl; import com.taoke.autopay.dao.ClientInfoMapper; +import com.taoke.autopay.entity.ClientAdditionalInfo; import com.taoke.autopay.entity.ClientInfo; +import com.taoke.autopay.entity.SystemConfigKeyEnum; import com.taoke.autopay.exception.LoginException; +import com.taoke.autopay.service.ClientAdditionalInfoService; import com.taoke.autopay.service.ClientInfoService; +import com.taoke.autopay.service.SystemConfigService; +import com.taoke.autopay.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @author hxh @@ -22,6 +25,12 @@ public class ClientInfoServiceImpl implements ClientInfoService { @Resource private ClientInfoMapper clientInfoMapper; + + @Resource + private SystemConfigService systemConfigService; + + @Resource + private ClientAdditionalInfoService clientAdditionalInfoService; @Override public ClientInfo login(String account, String pwd) throws LoginException { @@ -52,9 +61,7 @@ @Override public void setActiveTime(Long id, Date date) { - ClientInfo info = new ClientInfo(); - info.setId(id); - info.setActiveTime(date); + ClientInfo info = ClientInfo.builder().id(id).activeTime(date).build(); clientInfoMapper.updateByPrimaryKeySelective(info); } @@ -70,47 +77,100 @@ @Override public long count(ClientInfoMapper.DaoQuery query) { - return clientInfoMapper.count(query); + return clientInfoMapper.count(query); } @Transactional(rollbackFor = Exception.class) @Override public void add(ClientInfo info) { - if(info.getPwd()==null){ - info.setPwd("123456"); - } - if(info.getRule()==null){ - info.setRule(ClientInfo.RULE_COMMON); - } - if(info.getCreateTime()==null){ - info.setCreateTime(new Date()); - } + if (info.getPwd() == null) { + info.setPwd("123456"); + } + if (info.getRule() == null) { + info.setRule(ClientInfo.RULE_COMMON); + } + if (info.getCreateTime() == null) { + info.setCreateTime(new Date()); + } - if(info.getAccount()==null) { - // 鏌ヨ鏈�澶х殑璐﹀彿 - ClientInfoMapper.DaoQuery query = new ClientInfoMapper.DaoQuery(); - query.sortList = Arrays.asList(new String[]{"id desc"}); - query.count = 1; - List<ClientInfo> list = list(query); - long maxId = 0; - if (list.size() > 0) { - maxId = list.get(0).getId(); - } - info.setAccount("c" + maxId); - } + if (info.getAccount() == null) { + // 鏌ヨ鏈�澶х殑璐﹀彿 + ClientInfoMapper.DaoQuery query = new ClientInfoMapper.DaoQuery(); + query.sortList = Arrays.asList(new String[]{"id desc"}); + query.clientType = info.getClientType(); + query.count = 1; + List<ClientInfo> list = list(query); + long maxId = 0; + if (!list.isEmpty()) { + maxId =Long.parseLong(StringUtil.getNumberFromString(list.get(0).getAccount()).split(",")[0]) + 1; + } + if(info.getClientType()==ClientInfo.CLIENT_TYPE_AGENT_PAYMENT) { + info.setAccount(ClientInfo.ClientType.AGENT_PAYMENT.getAccountPrefix() + maxId); + }else if(info.getClientType()==ClientInfo.CLIENT_TYPE_ORDER){ + info.setAccount(ClientInfo.ClientType.ORDER.getAccountPrefix() + maxId); + } + } clientInfoMapper.insertSelective(info); - ClientInfo update=new ClientInfo(); - update.setId(info.getId()); - update.setName("瀹㈡埛绔�"+(info.getId()-1)); - + ClientInfo update = ClientInfo.builder() + .id(info.getId()) + .name("瀹㈡埛绔�" + (info.getId() - 1)) + .build(); clientInfoMapper.updateByPrimaryKeySelective(update); } @Override public void setPwd(Long id, String pwd) { - ClientInfo update=new ClientInfo(); - update.setId(id); - update.setPwd(pwd); + ClientInfo update = ClientInfo.builder() + .id( id) + .pwd(pwd) + .build(); clientInfoMapper.updateByPrimaryKeySelective(update); } + + @Override + public List<Long> getRePayClientIds() { + List<Long> idList = new ArrayList<>(); + + String clientIds = systemConfigService.getValueCache(SystemConfigKeyEnum.RE_EXCUTE_PAY_CLIENTS); + if (StringUtil.isNullOrEmpty(clientIds)) { + return idList; + } + String[] ids = clientIds.trim().split(","); + for (String id : ids) { + idList.add(Long.parseLong(id)); + } + return idList; + } + + @Override + public List<ClientInfo> getAvailableClientsForOrder() { + ClientInfoMapper.DaoQuery query = new ClientInfoMapper.DaoQuery(); + query.clientType = ClientInfo.CLIENT_TYPE_ORDER; + query.count = Integer.MAX_VALUE; + query.minActiveTime = new Date(System.currentTimeMillis()-1000*60*30);// 30鍒嗛挓鍐呮椿璺冪殑璁惧 + List<ClientInfo> clientInfoList = list(query); + if(clientInfoList.isEmpty()){ + return clientInfoList; + } + // 鑾峰彇鐢佃瘽鍙风爜锛屾敮浠樺疂璐﹀彿锛屾敮浠樺疂瀵嗙爜 + List<Long> clientIds=new ArrayList<>(); + clientInfoList.forEach(clientInfo -> { + clientIds.add(clientInfo.getId()); + }); + Map<Long, ClientAdditionalInfo> map = clientAdditionalInfoService.getClientAdditionalInfoMap(clientIds); + for(int i=0;i<clientInfoList.size();i++){ + ClientAdditionalInfo info = map.get(clientInfoList.get(i).getId()); + if(info==null){ + clientInfoList.remove(i); + i--; + continue; + } + if(StringUtil.isNullOrEmpty(info.getMobile())||StringUtil.isNullOrEmpty(info.getAlipayAccount())||StringUtil.isNullOrEmpty(info.getAlipayPassword())){ + clientInfoList.remove(i); + i--; + continue; + } + } + return clientInfoList; + } } -- Gitblit v1.8.0