From 595b7935a30e84fba1bc3561d05f9d19d3e32e1f Mon Sep 17 00:00:00 2001
From: Administrator <1101184511@qq.com>
Date: 星期三, 23 四月 2025 00:45:48 +0800
Subject: [PATCH] 后台管理页面完成

---
 src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java |   75 +++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 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 270ac9f..37dbad7 100644
--- a/src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java
+++ b/src/main/java/com/taoke/autopay/service/impl/ClientInfoServiceImpl.java
@@ -2,11 +2,17 @@
 
 import com.taoke.autopay.dao.ClientInfoMapper;
 import com.taoke.autopay.entity.ClientInfo;
+import com.taoke.autopay.entity.SystemConfigKeyEnum;
 import com.taoke.autopay.exception.LoginException;
 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.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -20,6 +26,9 @@
 public class ClientInfoServiceImpl implements ClientInfoService {
     @Resource
     private ClientInfoMapper clientInfoMapper;
+
+    @Resource
+    private SystemConfigService systemConfigService;
 
     @Override
     public ClientInfo login(String account, String pwd) throws LoginException {
@@ -60,4 +69,70 @@
     public List<ClientInfo> listByIds(List<Long> ids) {
         return clientInfoMapper.listByIds(ids);
     }
+
+    @Override
+    public List<ClientInfo> list(ClientInfoMapper.DaoQuery query) {
+        return clientInfoMapper.list(query);
+    }
+
+    @Override
+    public long count(ClientInfoMapper.DaoQuery 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.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);
+        }
+        clientInfoMapper.insertSelective(info);
+        ClientInfo update = new ClientInfo();
+        update.setId(info.getId());
+        update.setName("瀹㈡埛绔�" + (info.getId() - 1));
+
+        clientInfoMapper.updateByPrimaryKeySelective(update);
+    }
+
+    @Override
+    public void setPwd(Long id, String pwd) {
+        ClientInfo update = new ClientInfo();
+        update.setId(id);
+        update.setPwd(pwd);
+        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;
+    }
 }

--
Gitblit v1.8.0