From e97de23d9cfccb826c9ab636ff10f8496a9c25f2 Mon Sep 17 00:00:00 2001 From: "feng.li" Date: Fri, 22 Dec 2023 17:03:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8D=A1=E7=89=87=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=93=BE=E6=8E=A5=E6=B7=BB=E5=8A=A0=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=8F=8A=E8=B7=AF=E5=BE=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cool/store/enums/FeiShuNoticeMsgEnum.java | 35 +++++++++++++------ .../store/http/EventCenterHttpRequest.java | 26 ++++++++++---- .../store/service/impl/EcSyncServiceImpl.java | 1 - .../exhibition/ExhibitionServiceImpl.java | 2 +- .../cool/store/service/EventRequestTest.java | 32 +++++++++-------- 5 files changed, 62 insertions(+), 34 deletions(-) diff --git a/coolstore-partner-common/src/main/java/com/cool/store/enums/FeiShuNoticeMsgEnum.java b/coolstore-partner-common/src/main/java/com/cool/store/enums/FeiShuNoticeMsgEnum.java index 66a6d3142..3b3708de6 100644 --- a/coolstore-partner-common/src/main/java/com/cool/store/enums/FeiShuNoticeMsgEnum.java +++ b/coolstore-partner-common/src/main/java/com/cool/store/enums/FeiShuNoticeMsgEnum.java @@ -9,28 +9,33 @@ import com.alibaba.fastjson.JSONObject; */ public enum FeiShuNoticeMsgEnum { - common_notice("工作台通知", "{0}", "img_v2_45d7a901-1eab-498b-a760-b38d287f0c1g", "1567d83b966f2d312fd7fcd2e72dbce9"), - ALLOCATION_INVESTMENT_MANAGER("分配招商经理", "有新的线索于 {0} 分配给您,线索信息 {1} 手机号 {2},请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9"), - TRANS_INVESTMENT_MANAGER("转让招商经理", "有新的线索于 {0} 转让给您,线索信息 {1} 手机号 {2},请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9"), - BATCH_TRANS_INVESTMENT_MANAGER("收到新线索", "有{0}条新线索于 {1} 转让给您,请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9"), - EC_RECEIVE_LINE("收到EC新线索", "有{0}条新线索于EC同步给您,线索信息 {1},请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9"), - INTENTION_APPLY("加盟意向申请", "您有一个【加盟意向申请】待审核,申请人 {0} 手机号 {1} 于 {2} 提交加盟意向申请,请及时处理", "img_v2_c909097d-67d1-4c11-a911-a2584b67ca6g", "1567d83b966f2d312fd7fcd2e72dbce9"), - FOLLOW_TASK("线索跟进任务", "{0}", "img_v2_1960b7ef-8c4e-4c3d-8b67-3d918a85578g", "1567d83b966f2d312fd7fcd2e72dbce9"), - INTERVIEW_APPOINTMENT("面试预约申请", "您有一个【面试预约申请】待处理,预约人 {0} 手机号 {1} ,预约面试时间 {2} ","img_v2_107bb06b-2a7a-43e1-a6ae-e5d2f2dae17g", "1567d83b966f2d312fd7fcd2e72dbce9"), - EXHIBITION_COLLABORATOR("会销协作通知", "{0} 已将您添加为【{1}】的会销协作人,日期为 {2},地点为“{3}” ","img_v2_107bb06b-2a7a-43e1-a6ae-e5d2f2dae17g", "1567d83b966f2d312fd7fcd2e72dbce9"), - PARTNER_SIGNUP_EXHIBITION("线索已报名会销", "您跟进的线索客户{0} {1} 已报名于 {2} 举办的【{3}】 ,地点为“{4}”","img_v2_107bb06b-2a7a-43e1-a6ae-e5d2f2dae17g", "1567d83b966f2d312fd7fcd2e72dbce9"), + common_notice("工作台通知", "{0}", "img_v2_45d7a901-1eab-498b-a760-b38d287f0c1g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", ""), + ALLOCATION_INVESTMENT_MANAGER("分配招商经理", "有新的线索于 {0} 分配给您,线索信息 {1} 手机号 {2},请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), + TRANS_INVESTMENT_MANAGER("转让招商经理", "有新的线索于 {0} 转让给您,线索信息 {1} 手机号 {2},请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), + BATCH_TRANS_INVESTMENT_MANAGER("收到新线索", "有{0}条新线索于 {1} 转让给您,请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), + EC_RECEIVE_LINE("收到EC新线索", "有{0}条新线索于EC同步给您,线索信息 {1},请及时跟进", "img_v2_33296002-829e-490e-bd11-0d9ae763a67g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), + INTENTION_APPLY("加盟意向申请", "您有一个【加盟意向申请】待审核,申请人 {0} 手机号 {1} 于 {2} 提交加盟意向申请,请及时处理", "img_v2_c909097d-67d1-4c11-a911-a2584b67ca6g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), + FOLLOW_TASK("线索跟进任务", "{0}", "img_v2_1960b7ef-8c4e-4c3d-8b67-3d918a85578g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/"), + INTERVIEW_APPOINTMENT("面试预约申请", "您有一个【面试预约申请】待处理,预约人 {0} 手机号 {1} ,预约面试时间 {2} ","img_v2_107bb06b-2a7a-43e1-a6ae-e5d2f2dae17g", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), + EXHIBITION_COLLABORATOR("会销协作通知", "{0} 已将您添加为【{1}】的会销协作人,日期为 {2},地点为“{3}” ","img_v3_026c_d561bb71-f085-40ca-9c36-5fe134cacd2g", "1567d83b966f2d312fd7fcd2e72dbce9", "/joint-sales/manage-detail", "/mobile/joint-sales/manage-detail"), + PARTNER_SIGNUP_EXHIBITION("线索已报名会销", "您跟进的线索客户{0} {1} 已报名于 {2} 举办的【{3}】 ,地点为“{4}”","img_v3_026c_5bcf178d-19e6-4445-9677-f748a3f916fg", "1567d83b966f2d312fd7fcd2e72dbce9", "/work/bench", "/mobile"), ; private String title; private String content; private String imageMediaId; private String templateCode; + //卡片对应的跳转地址 + private String PCPath; + private String mobilePath; - FeiShuNoticeMsgEnum(String title, String content, String imageMediaId, String templateCode) { + FeiShuNoticeMsgEnum(String title, String content, String imageMediaId, String templateCode, String PCPath, String mobilePath) { this.title = title; this.content = content; this.imageMediaId = imageMediaId; this.templateCode = templateCode; + this.PCPath = PCPath; + this.mobilePath = mobilePath; } public String getTitle() { @@ -49,6 +54,14 @@ public enum FeiShuNoticeMsgEnum { return templateCode; } + public String getPCPath() { + return PCPath; + } + + public String getMobilePath() { + return mobilePath; + } + public JSONObject getMessageObject() { JSONObject object = new JSONObject(); object.put("name", this.title); diff --git a/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java b/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java index 90b356cc5..4f28efdac 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java @@ -11,7 +11,6 @@ import com.cool.store.request.event.CreateSingleEventRequest; import com.cool.store.request.event.SendMsgRequest; import com.cool.store.response.event.CreateEventResponse; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; @@ -21,6 +20,7 @@ import java.text.MessageFormat; import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Objects; /** * @author Fun Li 2023/10/23 10:01 @@ -76,19 +76,24 @@ public class EventCenterHttpRequest { * 发送飞书通知 * @param msgEnum {@link com.cool.store.enums.FeiShuNoticeMsgEnum} * @param receiverIds 接收者 id,飞书为 user_id,不是 open_id - * @param objects 消息参数,飞书消息卡片为 参数名:参数 + * @param objects 消息参数,飞书消息卡片为 参数名:参数,若路径跳转需要路径参数,也一起包含在里面 */ @Async public void sendFeiShuNotice(FeiShuNoticeMsgEnum msgEnum, List receiverIds, Object... objects) throws ApiException { //1. 组织消息参数,SendMsgRequest 的 cardParams,需要填入的参数为模板中 ${} 中的参数 HashMap cardParams = new HashMap<>(); + String PCPath = msgEnum.getPCPath(); + String mobilePath = msgEnum.getMobilePath(); + String pathVariable = getPathVariable(msgEnum, objects); + String PCWholePath = PCLinkUrl + PCPath + pathVariable; + String mobileWholePath = mobileLinkUrl + mobilePath + pathVariable; cardParams.put("title", msgEnum.getTitle()); cardParams.put("content", MessageFormat.format(msgEnum.getContent(),objects)); cardParams.put("img_key", msgEnum.getImageMediaId()); - cardParams.put("common_url", PCLinkUrl); - cardParams.put("pc_url", PCLinkUrl); - cardParams.put("ios_url", mobileLinkUrl); - cardParams.put("android_url", mobileLinkUrl); + cardParams.put("common_url", PCWholePath); + cardParams.put("pc_url", PCWholePath); + cardParams.put("ios_url", mobileWholePath); + cardParams.put("android_url", mobileWholePath); //2. 组织消息发送请求体,即 CreateSingleEventRequest 的 content 字段 SendMsgRequest sendFeiShuMsgRequest = SendMsgRequest.builder() @@ -144,4 +149,13 @@ public class EventCenterHttpRequest { createSingleEvent(createEventRequest); } + private String getPathVariable(FeiShuNoticeMsgEnum msgEnum, Object... objects) { + String pathVariable = ""; + if (Objects.requireNonNull(msgEnum) == FeiShuNoticeMsgEnum.EXHIBITION_COLLABORATOR) { + pathVariable = "?id=" + objects[0]; + System.arraycopy(objects, 1, objects, 0, objects.length - 1); + } + return pathVariable; + } + } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EcSyncServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EcSyncServiceImpl.java index a0611a24a..219802d73 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EcSyncServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EcSyncServiceImpl.java @@ -8,7 +8,6 @@ import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.cool.store.constants.CommonConstants; -import com.cool.store.constants.MessageConstants; import com.cool.store.dao.*; import com.cool.store.dto.log.BlackListLogDTO; import com.cool.store.dto.log.LineLogInfo; diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/exhibition/ExhibitionServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/exhibition/ExhibitionServiceImpl.java index cf8cd153e..450e9cdae 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/exhibition/ExhibitionServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/exhibition/ExhibitionServiceImpl.java @@ -842,7 +842,7 @@ public class ExhibitionServiceImpl implements ExhibitionService { List userIds = exhibitionDTO.getCollaborators().stream().map(CollaboratorDTO::getCollaborateId).collect(Collectors.toList()); List userIdsByUserIds = enterpriseUserDAO.getFeishuUserIdListByUserIds(userIds); eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.EXHIBITION_COLLABORATOR, userIdsByUserIds,userInfo.getName(), - exhibitionDTO.getExhibitionName(),exhibitionDTO.getStartDate(),exhibitionDTO.getLocation()); + exhibitionDTO.getId(),exhibitionDTO.getExhibitionName(),exhibitionDTO.getStartDate(),exhibitionDTO.getLocation()); } } } diff --git a/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java b/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java index 05eedb8f1..e04dd4a8d 100644 --- a/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java +++ b/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java @@ -31,27 +31,29 @@ public class EventRequestTest extends AbstractJUnit4SpringContextTests { @Test public void testSendFeiShuNotice() throws ApiException { //招商企业 - //eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.common_notice, Arrays.asList("9818f98c"), "测试"); + //eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.common_notice, Arrays.asList("34f4a9ga"), "测试"); //任务中枢企业 eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.ALLOCATION_INVESTMENT_MANAGER, Arrays.asList("661c6cfg"), "2023-10-24 10:09:04", "测试", "1008611"); } @Test public void testFeishuNotice() throws ApiException { - //1. 工作台通知 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.common_notice, Arrays.asList("9818f98c"), "测试"); - //2. 分配招商经理 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.ALLOCATION_INVESTMENT_MANAGER, Arrays.asList("9818f98c"), "2011-11-11 11:11:11", "测试", "1008611"); - //3. 转让招商经理 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.TRANS_INVESTMENT_MANAGER, Arrays.asList("9818f98c"), "2011-11-11 11:11:11", "测试", "1008611"); - //4. 收到新线索 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.BATCH_TRANS_INVESTMENT_MANAGER, Arrays.asList("9818f98c"), "1", "2023-10-24 16:40:07"); - //5. 加盟意向申请 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.INTENTION_APPLY, Arrays.asList("9818f98c"), "测试", "1008611", "2023-10-24 16:40:07"); - //6. 线索跟进任务 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.FOLLOW_TASK, Arrays.asList("9818f98c"), "测试线索跟进任务"); - //7. 面试预约申请 - eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.INTERVIEW_APPOINTMENT, Arrays.asList("9818f98c"), "测试", "1008611", "2023-10-24 16:40:07"); +// //1. 工作台通知 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.common_notice, Arrays.asList("34f4a9ga"), "测试"); +// //2. 分配招商经理 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.ALLOCATION_INVESTMENT_MANAGER, Arrays.asList("34f4a9ga"), "2011-11-11 11:11:11", "测试", "1008611"); +// //3. 转让招商经理 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.TRANS_INVESTMENT_MANAGER, Arrays.asList("34f4a9ga"), "2011-11-11 11:11:11", "测试", "1008611"); +// //4. 收到新线索 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.BATCH_TRANS_INVESTMENT_MANAGER, Arrays.asList("34f4a9ga"), "1", "2023-10-24 16:40:07"); +// //5. 加盟意向申请 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.INTENTION_APPLY, Arrays.asList("34f4a9ga"), "测试", "1008611", "2023-10-24 16:40:07"); +// //6. 线索跟进任务 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.FOLLOW_TASK, Arrays.asList("34f4a9ga"), "测试线索跟进任务"); +// //7. 面试预约申请 +// eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.INTERVIEW_APPOINTMENT, Arrays.asList("34f4a9ga"), "测试", "1008611", "2023-10-24 16:40:07"); + //8. 会销协作通知 + eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.EXHIBITION_COLLABORATOR, Arrays.asList("34f4a9ga"), "6", "老大", "会销", "2023-12-31", "系东方大酒店"); } @Test