From b4feede4ca5bf4a9e6c90700b7777493898d2d3b Mon Sep 17 00:00:00 2001 From: Trae AI Date: Thu, 5 Feb 2026 15:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E8=B7=9F?= =?UTF-8?q?=E8=BF=9B=E5=8E=86=E5=8F=B2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/UserController.java | 5 ++ .../web/entity/UserFollowupHistory.java | 69 +++++++++++++++++++ .../web/mapper/UserFollowupHistoryMapper.java | 27 ++++++++ .../com/example/web/service/UserService.java | 3 + .../web/service/impl/UserServiceImpl.java | 40 +++++++++++ .../mapper/UserFollowupHistoryMapper.xml | 24 +++++++ web/src/main/resources/static/index.html | 62 +++++++++++++++++ 7 files changed, 230 insertions(+) create mode 100644 web/src/main/java/com/example/web/entity/UserFollowupHistory.java create mode 100644 web/src/main/java/com/example/web/mapper/UserFollowupHistoryMapper.java create mode 100644 web/src/main/resources/mapper/UserFollowupHistoryMapper.xml diff --git a/web/src/main/java/com/example/web/controller/UserController.java b/web/src/main/java/com/example/web/controller/UserController.java index 8d8038a..81f103a 100644 --- a/web/src/main/java/com/example/web/controller/UserController.java +++ b/web/src/main/java/com/example/web/controller/UserController.java @@ -100,6 +100,11 @@ public class UserController { return userService.getManagersList(); } + @GetMapping("/users/followupHistory") + public List getFollowupHistory(@RequestParam String userId) { + return userService.getFollowupHistory(userId); + } + @PostMapping("/users/assign") public Map assignCustomers(@RequestBody Map params) { return userService.assignCustomers(params); diff --git a/web/src/main/java/com/example/web/entity/UserFollowupHistory.java b/web/src/main/java/com/example/web/entity/UserFollowupHistory.java new file mode 100644 index 0000000..72c6ac6 --- /dev/null +++ b/web/src/main/java/com/example/web/entity/UserFollowupHistory.java @@ -0,0 +1,69 @@ +package com.example.web.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * 客户历史跟进记录表实体类 + */ +@Data +@NoArgsConstructor +public class UserFollowupHistory { + private Integer id; // 主键ID + private String user_id; // 关联的用户ID,对应users表的userId + private String followup_content; // 跟进内容 + private String followup_person; // 跟进人 + private String phone_number; // 客户电话号码 + private LocalDateTime created_at; // 创建时间 + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUser_id() { + return user_id; + } + + public void setUser_id(String user_id) { + this.user_id = user_id; + } + + public String getFollowup_content() { + return followup_content; + } + + public void setFollowup_content(String followup_content) { + this.followup_content = followup_content; + } + + public String getFollowup_person() { + return followup_person; + } + + public void setFollowup_person(String followup_person) { + this.followup_person = followup_person; + } + + public String getPhone_number() { + return phone_number; + } + + public void setPhone_number(String phone_number) { + this.phone_number = phone_number; + } + + public LocalDateTime getCreated_at() { + return created_at; + } + + public void setCreated_at(LocalDateTime created_at) { + this.created_at = created_at; + } +} diff --git a/web/src/main/java/com/example/web/mapper/UserFollowupHistoryMapper.java b/web/src/main/java/com/example/web/mapper/UserFollowupHistoryMapper.java new file mode 100644 index 0000000..f39bc43 --- /dev/null +++ b/web/src/main/java/com/example/web/mapper/UserFollowupHistoryMapper.java @@ -0,0 +1,27 @@ +package com.example.web.mapper; + +import com.example.web.entity.UserFollowupHistory; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 客户历史跟进记录表Mapper + */ +@Mapper +public interface UserFollowupHistoryMapper { + /** + * 插入跟进记录 + * @param userFollowupHistory 跟进记录实体 + * @return 影响行数 + */ + int insert(UserFollowupHistory userFollowupHistory); + + /** + * 根据用户ID查询跟进记录 + * @param user_id 用户ID + * @return 跟进记录列表 + */ + List selectByUserId(@Param("user_id") String user_id); +} diff --git a/web/src/main/java/com/example/web/service/UserService.java b/web/src/main/java/com/example/web/service/UserService.java index 8201fab..b5aeae5 100644 --- a/web/src/main/java/com/example/web/service/UserService.java +++ b/web/src/main/java/com/example/web/service/UserService.java @@ -35,4 +35,7 @@ public interface UserService { // 获取人员列表 Map getPersonnelList(); + + // 获取跟进历史记录 + List getFollowupHistory(String userId); } diff --git a/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java b/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java index 5c8eeea..25e9bc6 100644 --- a/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java +++ b/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java @@ -4,12 +4,14 @@ import com.example.web.entity.InformationTra; import com.example.web.entity.Managers; import com.example.web.entity.Personnel; import com.example.web.entity.Product; +import com.example.web.entity.UserFollowupHistory; import com.example.web.entity.UserTrace; import com.example.web.entity.Users; import com.example.web.entity.UsersManagements; import com.example.web.entity.CustomerApply; import com.example.web.mapper.PersonnelMapper; import com.example.web.mapper.ProductMapper; +import com.example.web.mapper.UserFollowupHistoryMapper; import com.example.web.mapper.UserTraceMapper; import com.example.web.mapper.UsersMapper; import com.example.web.mapper.ManagersMapper; @@ -54,6 +56,9 @@ public class UserServiceImpl implements UserService { @Autowired private UserTraceMapper userTraceMapper; + @Autowired + private UserFollowupHistoryMapper userFollowupHistoryMapper; + @Override public Map getUserList(Map requestParams) { Map result = new HashMap<>(); @@ -213,6 +218,27 @@ public class UserServiceImpl implements UserService { // 更新跟进信息 usersMapper.updateFollowup(params); + // 写入跟进历史记录 + if (user != null) { + // 保存当前数据源 + String currentDataSource = DataSourceContextHolder.getDataSource(); + try { + // 切换到wechat数据源 + DataSourceContextHolder.setDataSource("wechat"); + + UserFollowupHistory history = new UserFollowupHistory(); + history.setUser_id(userId); + history.setFollowup_content(followup); + history.setFollowup_person(userName); + history.setPhone_number(user.getPhoneNumber()); + history.setCreated_at(LocalDateTime.now()); + userFollowupHistoryMapper.insert(history); + } finally { + // 恢复原数据源 + DataSourceContextHolder.setDataSource(currentDataSource); + } + } + // 记录跟进操作 InformationTra tra = createInformationTra( managercompany, @@ -881,4 +907,18 @@ public class UserServiceImpl implements UserService { } return result; } + + @Override + public List getFollowupHistory(String userId) { + // 保存当前数据源 + String currentDataSource = DataSourceContextHolder.getDataSource(); + try { + // 切换到wechat数据源 + DataSourceContextHolder.setDataSource("wechat"); + return userFollowupHistoryMapper.selectByUserId(userId); + } finally { + // 恢复原数据源 + DataSourceContextHolder.setDataSource(currentDataSource); + } + } } diff --git a/web/src/main/resources/mapper/UserFollowupHistoryMapper.xml b/web/src/main/resources/mapper/UserFollowupHistoryMapper.xml new file mode 100644 index 0000000..1a25dd9 --- /dev/null +++ b/web/src/main/resources/mapper/UserFollowupHistoryMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + INSERT INTO user_followup_history (user_id, followup_content, followup_person, phone_number, created_at) + VALUES (#{user_id}, #{followup_content}, #{followup_person}, #{phone_number}, #{created_at}) + + + + diff --git a/web/src/main/resources/static/index.html b/web/src/main/resources/static/index.html index d229307..1596da7 100644 --- a/web/src/main/resources/static/index.html +++ b/web/src/main/resources/static/index.html @@ -4944,6 +4944,14 @@ + + +
+

跟进历史记录

+
+
加载中...
+
+
@@ -6113,6 +6121,9 @@ document.getElementById('detailModal').style.display = 'block'; // 防止背景滚动 document.body.style.overflow = 'hidden'; + + // 获取并显示跟进历史记录 + loadFollowupHistory(userId); } function closeDetailModal() { @@ -6121,6 +6132,57 @@ document.body.style.overflow = 'auto'; } + // 加载跟进历史记录 + function loadFollowupHistory(userId) { + var url = '/KH/api/users/followupHistory?userId=' + encodeURIComponent(userId); + var followupHistoryList = document.getElementById('followupHistoryList'); + + followupHistoryList.innerHTML = '
加载中...
'; + + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + if (xhr.status == 200) { + try { + var historyList = JSON.parse(xhr.responseText); + if (historyList && historyList.length > 0) { + var html = ''; + historyList.forEach(function(history) { + html += '
'; + html += '
'; + html += '跟进人:'; + html += '' + (history.followup_person || '-') + ''; + html += '
'; + html += '
'; + html += '跟进时间:'; + html += '' + (history.created_at ? formatDateTime(history.created_at) : '-') + ''; + html += '
'; + html += '
'; + html += '跟进内容:'; + html += '
'; + html += '
'; + html += history.followup_content || '-'; + html += '
'; + html += '
'; + }); + followupHistoryList.innerHTML = html; + } else { + followupHistoryList.innerHTML = '
暂无跟进历史记录
'; + } + } catch (e) { + followupHistoryList.innerHTML = '
加载失败,请重试
'; + console.error('解析跟进历史记录失败:', e); + } + } else { + followupHistoryList.innerHTML = '
加载失败,请重试
'; + console.error('获取跟进历史记录失败:', xhr.status, xhr.statusText); + } + } + }; + xhr.send(); + } + function saveJianDaoYun() { var userId = document.getElementById('jianDaoYunUserId').value; var usersManagements = userInfo.usersManagements;