Commit fd1b8eaa by songyinghui

feat: 消息推送

parent 95f8d962
......@@ -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"),
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");
......
......@@ -9,6 +9,9 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -141,4 +144,26 @@ public class NoticeMessageUtil {
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;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -16,7 +17,7 @@ import java.util.Collections;
import java.util.List;
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
......@@ -24,7 +25,7 @@ import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_WEE
* @Description
* @Version 好办 周报/月报 上下文
**/
@Slf4j
@Data
@Builder
public class MaterialReportContext {
......@@ -98,22 +99,23 @@ public class MaterialReportContext {
*/
public List<NoticeMessageBO> buildNotifyMessageBos() {
if (CollectionUtils.isEmpty(this.staffClerkRelations)) {
log.info("成员未绑定导购, staffId: {}", this.staffId);
return Collections.emptyList();
}
if (StringUtils.isBlank(this.mainStoreId)) {
log.info("成员 {} 没有主门店数据, 区经角色不发送小程序消息通知 ", this.staffId);
return Collections.emptyList();
}
return this.staffClerkRelations
.stream()
.map(item -> {
NoticeMessageBO noticeMessageBO = new NoticeMessageBO();
noticeMessageBO.setCategoryType(MATERIAL_WEEK_REPORT.getCategory());
noticeMessageBO.setMessageType(MATERIAL_WEEK_REPORT.getType());
noticeMessageBO.setCategoryType(MATERIAL_REPORT_NOTIFY.getCategory());
noticeMessageBO.setMessageType(MATERIAL_REPORT_NOTIFY.getType());
noticeMessageBO.setClerkId(StringUtils.isNotBlank(item.getClerkId()) ? item.getClerkId() : "-1");
noticeMessageBO.setStoreId(StringUtils.isNotBlank(item.getStoreId()) ? item.getStoreId() : "-1");
noticeMessageBO.setTitle(this.getMessageTitle());
noticeMessageBO.setTemplateCode(MATERIAL_WEEK_REPORT.getTemplateCode());
noticeMessageBO.setTemplateCode(MATERIAL_REPORT_NOTIFY.getTemplateCode());
noticeMessageBO.setDescription(this.getMessageDesc());
noticeMessageBO.setEnterpriseId(this.enterpriseId);
noticeMessageBO.setRelationId(this.clerkId);
......
......@@ -16,7 +16,6 @@ import java.util.Map;
import java.util.Optional;
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;
/**
......
......@@ -62,7 +62,7 @@ public class InteractRecordBuilder {
if (TriggerCustomerChannelType.showDescChannel().contains(channelSource)) {
TriggerCustomerChannelType channelType = TriggerCustomerChannelType.getInstance(channelSource);
if (channelType != null) {
stringBuilder.append(String.format("通过[%s]", channelType.getDesc()));
stringBuilder.append(String.format("通过%s", channelType.getDesc()));
}
}
MaterialInteractRecordEventType instance = MaterialInteractRecordEventType.getInstance(eventType);
......
......@@ -3,7 +3,9 @@ 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.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
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.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.pojo.bo.content.context.MaterialReportContext;
......@@ -74,12 +76,19 @@ public class MaterialReportBuilder {
*/
public void fillMainStore(MaterialReportContext context) {
if (CollectionUtils.isEmpty(context.getStaffClerkRelations())) {
log.info("不存在成员与导购的关联关系 staffId: {}", context.getStaffId());
return;
}
if (context.getStaffClerkRelations().size() == 1) {
StaffClerkRelationDTO staffClerkRelationDTO = context.getStaffClerkRelations().get(0);
String wxEnterpriseId = staffClerkRelationDTO.getWxEnterpriseId();
if (staffClerkRelationDTO.getClerkType() != null && staffClerkRelationDTO.getClerkType() == 2) {
log.info("成员clerId:{}, staffId: {} 为区经角色", staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getStaffId());
// 区经无主门店
context.setClerkId(staffClerkRelationDTO.getClerkId());
TabHaobanClerkMainStoreRelated mainStoreInfo = clerkMainStoreRelatedService.getMainStoreByStaffId(context.getStaffId(), wxEnterpriseId);
}
return;
}
TabHaobanClerkMainStoreRelated mainStoreInfo = clerkMainStoreRelatedService.getMainStoreByStaffId(context.getStaffId(), context.getStaffInfo().getWxEnterpriseId());
if (mainStoreInfo != null) {
context.setMainStoreId(mainStoreInfo.getStoreId());
Optional<StaffClerkRelationDTO> mainClerkInfo = context.getStaffClerkRelations()
......@@ -90,6 +99,7 @@ public class MaterialReportBuilder {
log.info("成员{}与主门店{}不存在导购关联关系", context.getStaffId(), context.getMainStoreId());
return;
}
// 成员在主门店时的clerkId
context.setClerkId(mainClerkInfo.get().getClerkId());
}
}
......@@ -100,6 +110,13 @@ public class MaterialReportBuilder {
*/
public void buildMaterialReportData(MaterialReportContext context) {
// 获取该导购 在门店 的周报/月报数据
String clerkId = context.getClerkId();
if (StringUtils.isBlank(context.getMainStoreId())) {
// 区经
}else {
String mainStoreId = context.getMainStoreId();
}
String templatePath = "";
if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) {
context.setUseMaterialNum(103);
......@@ -110,7 +127,6 @@ public class MaterialReportBuilder {
context.setConvertAmount("12.3万");
templatePath = month_template_report;
}
// 生成图片地址
String url = DrawImageUtils.drawImage(context.getFactoryCode(), context.getUseMaterialNum() + "", context.getConvertAmount(), templatePath);
context.setMaterialReportUrl(url);
......@@ -137,8 +153,7 @@ public class MaterialReportBuilder {
articleInfo.setAppid(config.getAppid());
articleInfo.setTitle(context.getMessageTitle());
articleInfo.setDescription(context.getMessageDesc());
// pagePath 拼接参数?
articleInfo.setPagepath("/monthList");
articleInfo.setPagepath(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, context.extendParams()));
articleInfo.setPicurl(context.getMaterialReportUrl());
newsSendMessage.setArticleMessages(Collections.singletonList(articleInfo));
return newsSendMessage;
......
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.StaffDTO;
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.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
......@@ -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.notify.NoticeMessageService;
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.service.qywx.QywxSuiteApiService;
import lombok.extern.slf4j.Slf4j;
......@@ -195,7 +194,7 @@ public class PotentialCustomerNotifyBuilder {
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage("/pageurl?");
messageDTO.setPage(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, ""));
messageDTO.setTitle("销售线索通知");
messageDTO.setItems(Collections.singletonList(itemDTO));
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