From 02e5110d2c6fddf471d13c4db0a591528ca0036a Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Tue, 8 Jun 2021 18:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=A2=E6=88=B7=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysServiceTopicController.java | 10 +- .../com/stdiet/custom/domain/SysCustomer.java | 8 ++ .../custom/mapper/SysServicesTopicMapper.java | 4 + .../stdiet/custom/server/WebSocketServer.java | 2 +- .../service/ISysServicesTopicService.java | 4 + .../impl/SysServicesTopicServiceImp.java | 9 ++ .../mapper/custom/SysCustomerMapper.xml | 82 +++++++------ .../mapper/custom/SysServicesTopicMapper.xml | 51 +++++++- stdiet-ui/src/api/custom/message.js | 8 ++ stdiet-ui/src/store/modules/message.js | 112 +++++++++++++----- .../custom/message/messageBrowser/Comment.vue | 4 +- .../custom/message/messageBrowser/index.vue | 76 +++++++++++- .../views/custom/message/userInfo/index.vue | 41 ++++++- 13 files changed, 332 insertions(+), 79 deletions(-) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java index 45b74e292..399d4fefe 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java @@ -20,10 +20,16 @@ public class SysServiceTopicController extends BaseController { @GetMapping("/list") public TableDataInfo list(SysServicesTopic topic) { - startPage(); - return getDataTable(servicesTopicService.selectSysServicesTopicByUserIdAndRole(topic)); + return getDataTable(servicesTopicService.selectTopicListByUid(topic)); } + @GetMapping("/customers") + public TableDataInfo customers(SysServicesTopic topic) { + startPage(); + return getDataTable(servicesTopicService.selectCustomerListByUserIdAndRole(topic)); + } + + // @PutMapping("/update/status") // public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) { // return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion)); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java index 072923305..a29e915ad 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java @@ -71,18 +71,26 @@ public class SysCustomer extends BaseEntity /** 主营养师 */ @Excel(name = "主营养师") + private String dietitianName; + private Long mainDietitian; /** 营养师助理 */ @Excel(name = "营养师助理") + private String assDietitianName; + private Long assistantDietitian; /** 售后营养师 */ @Excel(name = "售后营养师") + private String afterDietitianName; + private Long afterDietitian; /** 销售人员 */ @Excel(name = "销售人员") + private String salesName; + private Long salesman; /** 负责人 */ diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java index 0217a94e8..eb910321f 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java @@ -7,6 +7,8 @@ import java.util.List; public interface SysServicesTopicMapper { List selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic); + List selectCustomerListByUserIdAndRole(SysServicesTopic topic); + int insertSysServicesTopic(SysServicesTopic topic); int insertSysServicesTopicStatus(List topics); @@ -20,4 +22,6 @@ public interface SysServicesTopicMapper { List selectSysServicesTopicSessionByTopicId(String topicId); List selectUnreadTopicCount(List topics); + + List selectTopicListByUid(SysServicesTopic topic); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java b/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java index 7bc506c04..0cc9f0217 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java @@ -27,7 +27,7 @@ public class WebSocketServer { //private static ConcurrentHashMap websocketList = new ConcurrentHashMap<>(); // 与某个客户端的连接会话,需要通过它来给客户端发送数据 private Session session; - // 接收sid + // 接收sidw private String sid = ""; public static CopyOnWriteArraySet getWebSocketSet() { diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java index 054424584..e8059405e 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java @@ -8,6 +8,8 @@ public interface ISysServicesTopicService { List selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic); + List selectCustomerListByUserIdAndRole(SysServicesTopic topic); + SysServicesTopic insertSysServicesTopic(SysServicesTopic topic); int updateSysServicesTopicStatus(SysServicesTopic topic); @@ -19,4 +21,6 @@ public interface ISysServicesTopicService { List selectSysServicesTopicSessionByTopicId(String topicId); List selectUnreadTopicCount(List topic); + + List selectTopicListByUid(SysServicesTopic topic); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java index 1e57ffabd..10496bdd3 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java @@ -30,6 +30,10 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService { return servicesTopicMapper.selectSysServicesTopicByUserIdAndRole(topic); } + @Override + public List selectCustomerListByUserIdAndRole(SysServicesTopic topic) { + return servicesTopicMapper.selectCustomerListByUserIdAndRole(topic); + } @Override public SysServicesTopic insertSysServicesTopic(SysServicesTopic topic) { @@ -187,4 +191,9 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService { public List selectUnreadTopicCount(List statusList) { return servicesTopicMapper.selectUnreadTopicCount(statusList); } + + @Override + public List selectTopicListByUid(SysServicesTopic topic) { + return servicesTopicMapper.selectTopicListByUid(topic); + } } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml index ff5a0fa16..756e76742 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml @@ -5,38 +5,50 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, name, phone, email, fans_time, fans_channel, address, pay_date, start_date, purchase_num, pay_total, main_dietitian, assistant_dietitian, after_dietitian, salesman, charge_person, follow_status, create_time, create_by, update_time, update_by, channel_id from sys_customer + SELECT DISTINCT(uid)AS uid, MAX(update_time) AS update_time, MIN(create_time) AS create_time, MIN(`read`) AS + `read`, role FROM ( + SELECT * FROM ( + SELECT topic_id, `read`, create_time, update_time, 'customer' AS role FROM sys_services_topic_status + + + WHERE role = 'dietician' + + + WHERE role = #{role} AND uid = #{uid} + + + + ) AS status + LEFT JOIN (SELECT topic_id, uid, del_flag FROM sys_services_topic ) AS topic USING(topic_id) + WHERE del_flag = 0 + ORDER BY `read` ASC, update_time DESC + ) AS userList GROUP BY uid + + + diff --git a/stdiet-ui/src/api/custom/message.js b/stdiet-ui/src/api/custom/message.js index 7b81d2223..a29d6772a 100644 --- a/stdiet-ui/src/api/custom/message.js +++ b/stdiet-ui/src/api/custom/message.js @@ -1,5 +1,13 @@ import request from "@/utils/request"; +export function fetchCustomerList(query) { + return request({ + url: "/services/topic/customers", + method: "get", + params: query + }); +} + export function fetchTopicList(query) { return request({ url: "/services/topic/list", diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index 168bf4cbb..5dbfcd752 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -1,4 +1,7 @@ -import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; +import { + getCustomerPhysicalSignsByCusId, + getCustomer +} from "@/api/custom/customer"; import { dealHealthy } from "@/utils/healthyData"; import { listRecipesPlanByCusId, @@ -6,6 +9,7 @@ import { } from "@/api/custom/recipesPlan"; import { + fetchCustomerList, fetchTopicList, postTopicReply, fetchTopicDetail, @@ -14,14 +18,24 @@ import { const oriState = { pageNum: 1, + cusLoading: false, + customerList: [], + selCusId: "", + // topicList: [], - detailData: {}, + topicLoading: false, selTopicId: "", + // + detailData: {}, + detailLoading: false, + // healthyData: {}, healthDataLoading: false, healthyDataType: 0, avoidFoodIds: [], // + customerData: {}, + // planList: [], planListLoading: false }; @@ -44,42 +58,71 @@ const mutations = { const actions = { async init({ dispatch }, payload) { - dispatch("fetchTopicListApi", {}); + dispatch("fetchCustomerListActions", {}); }, - async fetchTopicListApi({ dispatch, commit, rootGetters, state }, payload) { - const { - roles: [role], - userId - } = rootGetters; - const { detailData, pageNum, topicList } = state; - const result = await fetchTopicList({ + + async fetchCustomerListActions( + { dispatch, commit, rootGetters, state }, + payload + ) { + // prettier-ignore + const { roles: [role], userId } = rootGetters; + const { customerList, pageNum } = state; + commit("save", { cusLoading: true }); + const result = await fetchCustomerList({ role, uid: userId, pageSize: 20, pageNum }); - if (result.code === 200) { - if (!detailData.topicId) { - // 默认展示第一个 - const [defTopic] = result.rows; - dispatch("fetchTopicDetailActions", { - topicId: defTopic.topicId, - id: defTopic.id, - uid: defTopic.uid - }); - } - if (result.rows.length) { - commit("save", { - pageNum: pageNum + 1, - topicList: [...topicList, ...result.rows] - }); + let mPageNum = pageNum, + mCustomerList = customerList; + if (result.code === 200 && result.rows.length) { + // + if (!customerList.length) { + const [defCustomer] = result.rows; + dispatch("fetchTopicListApi", { fromUid: defCustomer.uid }); } + // + mPageNum += 1; + mCustomerList = [...customerList, ...result.rows]; } + commit("save", { + pageNum: mPageNum, + cusLoading: false, + customerList: mCustomerList + }); + }, + async fetchTopicListApi({ dispatch, commit, rootGetters, state }, payload) { + // prettier-ignore + const { roles: [role], userId } = rootGetters; + const { fromUid } = payload; + commit("save", { selCusId: fromUid, topicLoading: true }); + const result = await fetchTopicList({ + role, + uid: userId, + fromUid + }); + let mTopicList = []; + if (result.code === 200 && result.rows.length) { + // 默认展示第一个 + const [defTopic] = result.rows; + dispatch("fetchTopicDetailActions", { + topicId: defTopic.topicId, + id: defTopic.id, + uid: defTopic.uid + }); + mTopicList = result.rows; + } + commit("save", { + topicList: mTopicList, + topicLoading: false + }); }, async fetchTopicDetailActions({ commit, dispatch, state }, payload) { - const { topicId, id, uid } = payload; - const { healthyData, planList } = state; - commit("save", { selTopicId: topicId }); + const { topicId, id = 0, uid } = payload; + const { healthyData, planList, customerData } = state; + commit("save", { selTopicId: topicId, detailLoading: true }); // 客户信息 if (healthyData.customerId !== parseInt(uid)) { dispatch("getHealthyData", { cusId: uid, callback: payload.callback }); @@ -88,11 +131,20 @@ const actions = { if (!planList.length || planList[0].cusId !== parseInt(uid)) { dispatch("getRecipesPlanActions", { cusId: uid }); } - + // 客户档案 + if (customerData.id !== parseInt(uid)) { + dispatch("getCustomerFileActions", { cusId: uid }); + } // const result = await fetchTopicDetail({ topicId, id }); if (result.code === 200) { - commit("save", { detailData: result.data[0] }); + commit("save", { detailData: result.data[0], detailLoading: false }); + } + }, + async getCustomerFileActions({ commit }, payload) { + const result = await getCustomer(payload.cusId); + if (result.code === 200) { + commit("save", { customerData: result.data }); } }, async postTopicReplyActions( diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue index e60aaa6f4..4ede7df5e 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue @@ -1,8 +1,8 @@