Commit 81906b10 by songyinghui

feat: 销售线索通知

parent 1863fc31
...@@ -55,28 +55,15 @@ public class PotentialCustomerNotifyContext { ...@@ -55,28 +55,15 @@ public class PotentialCustomerNotifyContext {
*/ */
private List<StaffClerkRelationDTO> staffClerkRelations; private List<StaffClerkRelationDTO> staffClerkRelations;
/**
* 导购新销售线索统计
*/
List<PotentialCustomerStaticsBO> customerStaticsBos; List<PotentialCustomerStaticsBO> customerStaticsBos;
/**
public static NoticeMessageBO buildMessage(String clerkId, int count) { * 构建小程序消息通知
* @return
*/
NoticeMessageBO noticeMessageBO = new NoticeMessageBO();
// noticeMessageBO.setCategoryType(POTENTIAL_CUSTOMER_NOTIFY.getCategory());
// noticeMessageBO.setMessageType(POTENTIAL_CUSTOMER_NOTIFY.getType());
// noticeMessageBO.setClerkId(clerkId);
// noticeMessageBO.setStoreId("");
// noticeMessageBO.setTitle("销售线索通知");
// noticeMessageBO.setTemplateCode(POTENTIAL_CUSTOMER_NOTIFY.getTemplateCode());
// noticeMessageBO.setDescription(String.format("新增%s个客户的销售线索,请及时跟进", count));
// noticeMessageBO.setEnterpriseId(this.enterpriseId);
// noticeMessageBO.setRelationId(this.clerkId);
// noticeMessageBO.setMessageContent();
return noticeMessageBO;
}
public List<NoticeMessageBO> buildNoticeMessage() { public List<NoticeMessageBO> buildNoticeMessage() {
if (CollectionUtils.isEmpty(this.customerStaticsBos)) { if (CollectionUtils.isEmpty(this.customerStaticsBos)) {
return Collections.emptyList(); return Collections.emptyList();
......
...@@ -113,6 +113,7 @@ public class PotentialCustomerNotifyBuilder { ...@@ -113,6 +113,7 @@ public class PotentialCustomerNotifyBuilder {
public void sendHaoBanNotifyMessage(PotentialCustomerNotifyContext context) { public void sendHaoBanNotifyMessage(PotentialCustomerNotifyContext context) {
List<NoticeMessageBO> noticeMessageBos = context.buildNoticeMessage(); List<NoticeMessageBO> noticeMessageBos = context.buildNoticeMessage();
if (CollectionUtils.isEmpty(noticeMessageBos)) { if (CollectionUtils.isEmpty(noticeMessageBos)) {
log.info("好办消息为空");
return; return;
} }
noticeMessageService.addNoticeMessageBatch(noticeMessageBos); noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
...@@ -125,6 +126,7 @@ public class PotentialCustomerNotifyBuilder { ...@@ -125,6 +126,7 @@ public class PotentialCustomerNotifyBuilder {
*/ */
public void sendApplicationMessage(PotentialCustomerNotifyContext context) { public void sendApplicationMessage(PotentialCustomerNotifyContext context) {
if (CollectionUtils.isEmpty(context.getCustomerStaticsBos()) || CollectionUtils.isEmpty(context.getStaffClerkRelations())) { if (CollectionUtils.isEmpty(context.getCustomerStaticsBos()) || CollectionUtils.isEmpty(context.getStaffClerkRelations())) {
log.info("发送应用消息 参数缺失 {}");
return; return;
} }
Map<String, PotentialCustomerStaticsBO> customerStaticsBOMap = context.getCustomerStaticsBos() Map<String, PotentialCustomerStaticsBO> customerStaticsBOMap = context.getCustomerStaticsBos()
...@@ -134,21 +136,32 @@ public class PotentialCustomerNotifyBuilder { ...@@ -134,21 +136,32 @@ public class PotentialCustomerNotifyBuilder {
Map<String, WxEnterpriseQwDTO> clerkEnterpriseMap = new HashMap<>(); Map<String, WxEnterpriseQwDTO> clerkEnterpriseMap = new HashMap<>();
for (StaffClerkRelationDTO staffClerkRelation : context.getStaffClerkRelations()) { for (StaffClerkRelationDTO staffClerkRelation : context.getStaffClerkRelations()) {
PotentialCustomerStaticsBO customerStaticsBO = customerStaticsBOMap.get(staffClerkRelation.getClerkId());
if (customerStaticsBO == null || customerStaticsBO.getNum() == null || customerStaticsBO.getNum() == 0) {
log.info("导购不存在新访问");
continue;
}
String staffId = staffClerkRelation.getStaffId(); String staffId = staffClerkRelation.getStaffId();
TabHaobanClerkMainStoreRelated temp = clerkMainStoreMap.get(staffId); TabHaobanClerkMainStoreRelated temp = clerkMainStoreMap.get(staffId);
if (temp == null) {
TabHaobanClerkMainStoreRelated tabHaobanClerkMainStoreRelated = clerkMainStoreRelatedService.selectByWxEnterpriseIdAndStoreId(staffId, staffClerkRelation.getWxEnterpriseId());
if (tabHaobanClerkMainStoreRelated == null) {
tabHaobanClerkMainStoreRelated = new TabHaobanClerkMainStoreRelated();
}
clerkMainStoreMap.put(staffId, tabHaobanClerkMainStoreRelated);
temp = clerkMainStoreMap.get(staffId);
}
if (temp != null) { if (temp != null) {
if (StringUtils.isBlank(temp.getStoreId())) { if (StringUtils.isBlank(temp.getStoreId())) {
// 该成员无主门店 // 该成员无主门店
log.info("成员无主门店 {}", staffId);
continue; continue;
} }
if (StringUtils.isBlank(temp.getStoreId())) { if (StringUtils.isBlank(temp.getStoreId())) {
log.info("成员不存在主门店 {}", staffId); log.info("成员不存在主门店 {}", staffId);
continue; continue;
} }
PotentialCustomerStaticsBO customerStaticsBO = customerStaticsBOMap.get(staffClerkRelation.getClerkId());
if (customerStaticsBO == null || customerStaticsBO.getNum() == null || customerStaticsBO.getNum() == 0) {
return;
}
// 需要发送应用消息 // 需要发送应用消息
WxEnterpriseQwDTO wxEnterpriseQwDTO = clerkEnterpriseMap.get(staffClerkRelation.getWxEnterpriseId()); WxEnterpriseQwDTO wxEnterpriseQwDTO = clerkEnterpriseMap.get(staffClerkRelation.getWxEnterpriseId());
if (wxEnterpriseQwDTO == null) { if (wxEnterpriseQwDTO == null) {
...@@ -157,17 +170,13 @@ public class PotentialCustomerNotifyBuilder { ...@@ -157,17 +170,13 @@ public class PotentialCustomerNotifyBuilder {
} }
wxEnterpriseQwDTO = clerkEnterpriseMap.get(staffClerkRelation.getWxEnterpriseId()); wxEnterpriseQwDTO = clerkEnterpriseMap.get(staffClerkRelation.getWxEnterpriseId());
if (wxEnterpriseQwDTO == null) { if (wxEnterpriseQwDTO == null) {
log.info("企业信息不存在 {}", staffClerkRelation.getWxEnterpriseId());
return; return;
} }
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO, customerStaticsBO.getNum()); QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO, customerStaticsBO.getNum());
qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO); boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
continue; log.info("发送应用消息结果 {}", sendMessage);
} }
TabHaobanClerkMainStoreRelated tabHaobanClerkMainStoreRelated = clerkMainStoreRelatedService.selectByWxEnterpriseIdAndStoreId(staffId, staffClerkRelation.getWxEnterpriseId());
if (tabHaobanClerkMainStoreRelated == null) {
tabHaobanClerkMainStoreRelated = new TabHaobanClerkMainStoreRelated();
}
clerkMainStoreMap.put(staffId, tabHaobanClerkMainStoreRelated);
} }
} }
......
package com.gic.haoban.manage.service.service.content.impl; package com.gic.haoban.manage.service.service.content.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
...@@ -155,6 +156,8 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService { ...@@ -155,6 +156,8 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
@Override @Override
public void sendPotentialCustomerNotice(PotentialCustomerNotifyContext context) { public void sendPotentialCustomerNotice(PotentialCustomerNotifyContext context) {
log.info("处理企业{}下的销售线索通知", context.getEnterpriseId());
// 根据企业id + 时间 循环查询时间段内的有新互动记录的导购id 去重 // 根据企业id + 时间 循环查询时间段内的有新互动记录的导购id 去重
InteractRecordQO searchQo = new InteractRecordQO(); InteractRecordQO searchQo = new InteractRecordQO();
searchQo.setEnterpriseId(context.getEnterpriseId()); searchQo.setEnterpriseId(context.getEnterpriseId());
...@@ -162,6 +165,7 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService { ...@@ -162,6 +165,7 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
searchQo.setEndTime(context.getEndTime()); searchQo.setEndTime(context.getEndTime());
List<PotentialCustomerStaticsBO> customerStaticsBos = interactRecordService.staticsClerkNewInteractRecord(searchQo); List<PotentialCustomerStaticsBO> customerStaticsBos = interactRecordService.staticsClerkNewInteractRecord(searchQo);
if (CollectionUtils.isEmpty(customerStaticsBos)) { if (CollectionUtils.isEmpty(customerStaticsBos)) {
log.info("企业下不存在新增线索的导购 {}", JSON.toJSONString(context));
return; return;
} }
context.setCustomerStaticsBos(customerStaticsBos); context.setCustomerStaticsBos(customerStaticsBos);
......
...@@ -205,8 +205,8 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic ...@@ -205,8 +205,8 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
*/ */
@Override @Override
public ServiceResponse<Void> potentialCustomerJob(String params) { public ServiceResponse<Void> potentialCustomerJob(String params) {
Date now = new Date(); Date now = new Date();
log.info("potentialCustomerJob 执行销售线索通知 {}", cn.hutool.core.date.DateUtil.format(now, "yyyy-MM-dd HH:mm:ss"));
int currentHour = cn.hutool.core.date.DateUtil.hour(now, true); int currentHour = cn.hutool.core.date.DateUtil.hour(now, true);
if (currentHour >= 23 || currentHour < 8) { if (currentHour >= 23 || currentHour < 8) {
log.info("当前时间处于消息禁发时间, 忽略{}", cn.hutool.core.date.DateUtil.format(now, "yyyy-MM-dd HH:mm:ss")); log.info("当前时间处于消息禁发时间, 忽略{}", cn.hutool.core.date.DateUtil.format(now, "yyyy-MM-dd HH:mm:ss"));
...@@ -214,6 +214,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic ...@@ -214,6 +214,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
} }
List<String> enterpriseIds = groupMessageService.hasMaterialRightEnterprise(); List<String> enterpriseIds = groupMessageService.hasMaterialRightEnterprise();
if (CollectionUtils.isEmpty(enterpriseIds)) { if (CollectionUtils.isEmpty(enterpriseIds)) {
log.info("开通内容权限的企业为空");
return ServiceResponse.success(); return ServiceResponse.success();
} }
Date startTime = cn.hutool.core.date.DateUtil.offsetMinute(now, -30).toJdkDate(); Date startTime = cn.hutool.core.date.DateUtil.offsetMinute(now, -30).toJdkDate();
......
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil; import com.gic.commons.util.DateUtil;
import com.gic.haoban.manage.api.dto.content.log.TriggerCustomerDetailLogDTO; import com.gic.haoban.manage.api.dto.content.log.TriggerCustomerDetailLogDTO;
import com.gic.haoban.manage.api.enums.content.ClerkShareMaterialType; import com.gic.haoban.manage.api.enums.content.ClerkShareMaterialType;
...@@ -7,8 +8,10 @@ import com.gic.haoban.manage.api.enums.content.TriggerCustomerChannelType; ...@@ -7,8 +8,10 @@ import com.gic.haoban.manage.api.enums.content.TriggerCustomerChannelType;
import com.gic.haoban.manage.api.service.content.task.QywxGroupMsgTaskApiService; import com.gic.haoban.manage.api.service.content.task.QywxGroupMsgTaskApiService;
import com.gic.haoban.manage.service.pojo.bo.content.ClerkShareLogBO; import com.gic.haoban.manage.service.pojo.bo.content.ClerkShareLogBO;
import com.gic.haoban.manage.service.pojo.bo.content.GroupMessageInfoBo; import com.gic.haoban.manage.service.pojo.bo.content.GroupMessageInfoBo;
import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext;
import com.gic.haoban.manage.service.service.content.ClerkShareLogService; import com.gic.haoban.manage.service.service.content.ClerkShareLogService;
import com.gic.haoban.manage.service.service.content.GroupMessageService; import com.gic.haoban.manage.service.service.content.GroupMessageService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.squareup.moshi.Json; import com.squareup.moshi.Json;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -33,6 +36,9 @@ public class GroupMessageServiceTest { ...@@ -33,6 +36,9 @@ public class GroupMessageServiceTest {
private ClerkShareLogService clerkShareLogService; private ClerkShareLogService clerkShareLogService;
@Autowired @Autowired
private QywxGroupMsgTaskApiService qywxGroupMsgTaskApiService; private QywxGroupMsgTaskApiService qywxGroupMsgTaskApiService;
@Autowired
PotentialCustomerService potentialCustomerService;
String eid = "ff8080815dacd3a2015dacd3ef5c0000"; String eid = "ff8080815dacd3a2015dacd3ef5c0000";
String wxEid = "ca66a01b79474c40b3e7c7f93daf1a3b"; String wxEid = "ca66a01b79474c40b3e7c7f93daf1a3b";
...@@ -70,4 +76,14 @@ public class GroupMessageServiceTest { ...@@ -70,4 +76,14 @@ public class GroupMessageServiceTest {
groupMessageInfoBo.setEndTime(currentTime); groupMessageInfoBo.setEndTime(currentTime);
groupMessageService.handlerGroupMessage(groupMessageInfoBo); groupMessageService.handlerGroupMessage(groupMessageInfoBo);
} }
@Test
public void potentialCustomerMessageTest(){
PotentialCustomerNotifyContext context = PotentialCustomerNotifyContext.builder()
.enterpriseId(eid)
.startTime(cn.hutool.core.date.DateUtil.beginOfDay(new Date()))
.endTime(cn.hutool.core.date.DateUtil.endOfDay(new Date()))
.build();
potentialCustomerService.sendPotentialCustomerNotice(context);
}
} }
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