Commit fd1b8eaa by songyinghui

feat: 消息推送

parent 95f8d962
...@@ -59,7 +59,7 @@ public enum NoticeMessageTypeEnum { ...@@ -59,7 +59,7 @@ public enum NoticeMessageTypeEnum {
CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail"), CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail"),
MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center"), MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center"),
MATERIAL_WEEK_REPORT(6002, "素材周报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_material_report"), MATERIAL_REPORT_NOTIFY(6002, "素材周报/月报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_material_report"),
POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center"); POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center");
......
...@@ -9,6 +9,9 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -9,6 +9,9 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -141,4 +144,26 @@ public class NoticeMessageUtil { ...@@ -141,4 +144,26 @@ public class NoticeMessageUtil {
logger.info("发送消息异常:{}", e); logger.info("发送消息异常:{}", e);
} }
} }
/**
* 构建小程序跳转url
* @param messageTypeEnum
* @param data
* @return
*/
public static String buildMiniAppUrl(NoticeMessageTypeEnum messageTypeEnum, String data) {
if (StringUtils.isNotBlank(data)) {
try {
data = URLEncoder.encode(data, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage());
}
}
String appUrl = messageTypeEnum.getPageUrl();
if (StringUtils.isNotBlank(messageTypeEnum.getPageType())) {
appUrl += messageTypeEnum.getPageType();
}
appUrl += "&data=" + data;
return appUrl;
}
} }
...@@ -9,6 +9,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff; ...@@ -9,6 +9,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO; import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -16,7 +17,7 @@ import java.util.Collections; ...@@ -16,7 +17,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_WEEK_REPORT; import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY;
/** /**
* @Author MUSI * @Author MUSI
...@@ -24,7 +25,7 @@ import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_WEE ...@@ -24,7 +25,7 @@ import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_WEE
* @Description * @Description
* @Version 好办 周报/月报 上下文 * @Version 好办 周报/月报 上下文
**/ **/
@Slf4j
@Data @Data
@Builder @Builder
public class MaterialReportContext { public class MaterialReportContext {
...@@ -98,22 +99,23 @@ public class MaterialReportContext { ...@@ -98,22 +99,23 @@ public class MaterialReportContext {
*/ */
public List<NoticeMessageBO> buildNotifyMessageBos() { public List<NoticeMessageBO> buildNotifyMessageBos() {
if (CollectionUtils.isEmpty(this.staffClerkRelations)) { if (CollectionUtils.isEmpty(this.staffClerkRelations)) {
log.info("成员未绑定导购, staffId: {}", this.staffId);
return Collections.emptyList(); return Collections.emptyList();
} }
if (StringUtils.isBlank(this.mainStoreId)) { if (StringUtils.isBlank(this.mainStoreId)) {
log.info("成员 {} 没有主门店数据, 区经角色不发送小程序消息通知 ", this.staffId);
return Collections.emptyList(); return Collections.emptyList();
} }
return this.staffClerkRelations return this.staffClerkRelations
.stream() .stream()
.map(item -> { .map(item -> {
NoticeMessageBO noticeMessageBO = new NoticeMessageBO(); NoticeMessageBO noticeMessageBO = new NoticeMessageBO();
noticeMessageBO.setCategoryType(MATERIAL_WEEK_REPORT.getCategory()); noticeMessageBO.setCategoryType(MATERIAL_REPORT_NOTIFY.getCategory());
noticeMessageBO.setMessageType(MATERIAL_WEEK_REPORT.getType()); noticeMessageBO.setMessageType(MATERIAL_REPORT_NOTIFY.getType());
noticeMessageBO.setClerkId(StringUtils.isNotBlank(item.getClerkId()) ? item.getClerkId() : "-1"); noticeMessageBO.setClerkId(StringUtils.isNotBlank(item.getClerkId()) ? item.getClerkId() : "-1");
noticeMessageBO.setStoreId(StringUtils.isNotBlank(item.getStoreId()) ? item.getStoreId() : "-1"); noticeMessageBO.setStoreId(StringUtils.isNotBlank(item.getStoreId()) ? item.getStoreId() : "-1");
noticeMessageBO.setTitle(this.getMessageTitle()); noticeMessageBO.setTitle(this.getMessageTitle());
noticeMessageBO.setTemplateCode(MATERIAL_WEEK_REPORT.getTemplateCode()); noticeMessageBO.setTemplateCode(MATERIAL_REPORT_NOTIFY.getTemplateCode());
noticeMessageBO.setDescription(this.getMessageDesc()); noticeMessageBO.setDescription(this.getMessageDesc());
noticeMessageBO.setEnterpriseId(this.enterpriseId); noticeMessageBO.setEnterpriseId(this.enterpriseId);
noticeMessageBO.setRelationId(this.clerkId); noticeMessageBO.setRelationId(this.clerkId);
......
...@@ -16,7 +16,6 @@ import java.util.Map; ...@@ -16,7 +16,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_WEEK_REPORT;
import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY; import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY;
/** /**
......
...@@ -62,7 +62,7 @@ public class InteractRecordBuilder { ...@@ -62,7 +62,7 @@ public class InteractRecordBuilder {
if (TriggerCustomerChannelType.showDescChannel().contains(channelSource)) { if (TriggerCustomerChannelType.showDescChannel().contains(channelSource)) {
TriggerCustomerChannelType channelType = TriggerCustomerChannelType.getInstance(channelSource); TriggerCustomerChannelType channelType = TriggerCustomerChannelType.getInstance(channelSource);
if (channelType != null) { if (channelType != null) {
stringBuilder.append(String.format("通过[%s]", channelType.getDesc())); stringBuilder.append(String.format("通过%s", channelType.getDesc()));
} }
} }
MaterialInteractRecordEventType instance = MaterialInteractRecordEventType.getInstance(eventType); MaterialInteractRecordEventType instance = MaterialInteractRecordEventType.getInstance(eventType);
......
...@@ -3,7 +3,9 @@ package com.gic.haoban.manage.service.service.content.adaptor; ...@@ -3,7 +3,9 @@ package com.gic.haoban.manage.service.service.content.adaptor;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType; import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated; import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.pojo.bo.content.context.MaterialReportContext; import com.gic.haoban.manage.service.pojo.bo.content.context.MaterialReportContext;
...@@ -74,12 +76,19 @@ public class MaterialReportBuilder { ...@@ -74,12 +76,19 @@ public class MaterialReportBuilder {
*/ */
public void fillMainStore(MaterialReportContext context) { public void fillMainStore(MaterialReportContext context) {
if (CollectionUtils.isEmpty(context.getStaffClerkRelations())) { if (CollectionUtils.isEmpty(context.getStaffClerkRelations())) {
log.info("不存在成员与导购的关联关系 staffId: {}", context.getStaffId());
return; return;
} }
StaffClerkRelationDTO staffClerkRelationDTO = context.getStaffClerkRelations().get(0); if (context.getStaffClerkRelations().size() == 1) {
String wxEnterpriseId = staffClerkRelationDTO.getWxEnterpriseId(); StaffClerkRelationDTO staffClerkRelationDTO = context.getStaffClerkRelations().get(0);
context.setClerkId(staffClerkRelationDTO.getClerkId()); if (staffClerkRelationDTO.getClerkType() != null && staffClerkRelationDTO.getClerkType() == 2) {
TabHaobanClerkMainStoreRelated mainStoreInfo = clerkMainStoreRelatedService.getMainStoreByStaffId(context.getStaffId(), wxEnterpriseId); log.info("成员clerId:{}, staffId: {} 为区经角色", staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getStaffId());
// 区经无主门店
context.setClerkId(staffClerkRelationDTO.getClerkId());
}
return;
}
TabHaobanClerkMainStoreRelated mainStoreInfo = clerkMainStoreRelatedService.getMainStoreByStaffId(context.getStaffId(), context.getStaffInfo().getWxEnterpriseId());
if (mainStoreInfo != null) { if (mainStoreInfo != null) {
context.setMainStoreId(mainStoreInfo.getStoreId()); context.setMainStoreId(mainStoreInfo.getStoreId());
Optional<StaffClerkRelationDTO> mainClerkInfo = context.getStaffClerkRelations() Optional<StaffClerkRelationDTO> mainClerkInfo = context.getStaffClerkRelations()
...@@ -90,6 +99,7 @@ public class MaterialReportBuilder { ...@@ -90,6 +99,7 @@ public class MaterialReportBuilder {
log.info("成员{}与主门店{}不存在导购关联关系", context.getStaffId(), context.getMainStoreId()); log.info("成员{}与主门店{}不存在导购关联关系", context.getStaffId(), context.getMainStoreId());
return; return;
} }
// 成员在主门店时的clerkId
context.setClerkId(mainClerkInfo.get().getClerkId()); context.setClerkId(mainClerkInfo.get().getClerkId());
} }
} }
...@@ -100,6 +110,13 @@ public class MaterialReportBuilder { ...@@ -100,6 +110,13 @@ public class MaterialReportBuilder {
*/ */
public void buildMaterialReportData(MaterialReportContext context) { public void buildMaterialReportData(MaterialReportContext context) {
// 获取该导购 在门店 的周报/月报数据 // 获取该导购 在门店 的周报/月报数据
String clerkId = context.getClerkId();
if (StringUtils.isBlank(context.getMainStoreId())) {
// 区经
}else {
String mainStoreId = context.getMainStoreId();
}
String templatePath = ""; String templatePath = "";
if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) { if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) {
context.setUseMaterialNum(103); context.setUseMaterialNum(103);
...@@ -110,7 +127,6 @@ public class MaterialReportBuilder { ...@@ -110,7 +127,6 @@ public class MaterialReportBuilder {
context.setConvertAmount("12.3万"); context.setConvertAmount("12.3万");
templatePath = month_template_report; templatePath = month_template_report;
} }
// 生成图片地址 // 生成图片地址
String url = DrawImageUtils.drawImage(context.getFactoryCode(), context.getUseMaterialNum() + "", context.getConvertAmount(), templatePath); String url = DrawImageUtils.drawImage(context.getFactoryCode(), context.getUseMaterialNum() + "", context.getConvertAmount(), templatePath);
context.setMaterialReportUrl(url); context.setMaterialReportUrl(url);
...@@ -137,8 +153,7 @@ public class MaterialReportBuilder { ...@@ -137,8 +153,7 @@ public class MaterialReportBuilder {
articleInfo.setAppid(config.getAppid()); articleInfo.setAppid(config.getAppid());
articleInfo.setTitle(context.getMessageTitle()); articleInfo.setTitle(context.getMessageTitle());
articleInfo.setDescription(context.getMessageDesc()); articleInfo.setDescription(context.getMessageDesc());
// pagePath 拼接参数? articleInfo.setPagepath(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, context.extendParams()));
articleInfo.setPagepath("/monthList");
articleInfo.setPicurl(context.getMaterialReportUrl()); articleInfo.setPicurl(context.getMaterialReportUrl());
newsSendMessage.setArticleMessages(Collections.singletonList(articleInfo)); newsSendMessage.setArticleMessages(Collections.singletonList(articleInfo));
return newsSendMessage; return newsSendMessage;
......
package com.gic.haoban.manage.service.service.content.adaptor; package com.gic.haoban.manage.service.service.content.adaptor;
import com.alibaba.fastjson.JSON;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated; import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO; import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
...@@ -15,8 +16,6 @@ import com.gic.haoban.manage.service.service.StaffClerkRelationService; ...@@ -15,8 +16,6 @@ import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService; import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.wechat.api.dto.qywx.ItemDTO; import com.gic.wechat.api.dto.qywx.ItemDTO;
import com.gic.wechat.api.dto.qywx.QywxNewsArticleMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxNewsSendMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO; import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -195,7 +194,7 @@ public class PotentialCustomerNotifyBuilder { ...@@ -195,7 +194,7 @@ public class PotentialCustomerNotifyBuilder {
list.add(wxUserId); list.add(wxUserId);
messageDTO.setAppid(config.getAppid()); messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list); messageDTO.setUserIds(list);
messageDTO.setPage("/pageurl?"); messageDTO.setPage(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, ""));
messageDTO.setTitle("销售线索通知"); messageDTO.setTitle("销售线索通知");
messageDTO.setItems(Collections.singletonList(itemDTO)); messageDTO.setItems(Collections.singletonList(itemDTO));
return messageDTO; return messageDTO;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment