Commit 2b866fbd by 王祖波

配置时间发送销售线索

parent 15dc9be6
package com.gic.haoban.manage.service.pojo.bo.content;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
......@@ -11,6 +13,8 @@ import java.io.Serializable;
* @Version
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PotentialCustomerStaticsBO implements Serializable {
/**
......
......@@ -279,16 +279,20 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
log.info("处理企业{}下的销售线索通知", context.getEnterpriseId());
List<PotentialCustomerStaticsBO> customerStaticsBos = context.getCustomerStaticsBos();
if (CollectionUtils.isEmpty(customerStaticsBos)) {
// 根据企业id + 时间 循环查询时间段内的有新互动记录的导购id 去重
InteractRecordQO searchQo = new InteractRecordQO();
searchQo.setEnterpriseId(context.getEnterpriseId());
searchQo.setStartTime(context.getStartTime());
searchQo.setEndTime(context.getEndTime());
List<PotentialCustomerStaticsBO> customerStaticsBos = interactRecordService.staticsClerkNewInteractRecord(searchQo);
customerStaticsBos = interactRecordService.staticsClerkNewInteractRecord(searchQo);
if (CollectionUtils.isEmpty(customerStaticsBos)) {
log.info("企业下不存在新增线索的导购 {}", JSON.toJSONString(context));
return;
}
}
context.setCustomerStaticsBos(customerStaticsBos);
// 获取导购与成员关联关联关系
potentialCustomerNotifyBuilder.buildClerkRelations(context);
......
package com.gic.haoban.manage.service.service.content.message;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.content.api.dto.setting.ContentSettingDTO;
import com.gic.content.api.service.ContentSettingApiService;
import com.gic.haoban.manage.api.enums.content.MaterialInteractRecordEventType;
import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordBO;
import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordExtendInfoBO;
import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO;
import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO;
import com.gic.haoban.manage.service.pojo.bo.content.context.InteractRecordMessageContext;
import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext;
import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessageBO;
import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder;
import com.gic.redis.data.util.RedisUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -37,6 +43,8 @@ public class InteractRecordMessageService {
InteractRecordMessageBuilder interactRecordMessageBuilder;
@Autowired
PotentialCustomerService potentialCustomerService;
@Autowired
ContentSettingApiService contentSettingApiService;
/**
* 处理互动记录
......@@ -156,6 +164,17 @@ public class InteractRecordMessageService {
potentialCustomerBO.setTimes(interactRecordBO.getTimes());
potentialCustomerService.saveOrUpdatePotentialCustomer(potentialCustomerBO);
}
ServiceResponse<ContentSettingDTO> response = contentSettingApiService.queryContentSettingInfo(interactRecordMessageBO.getEnterpriseId());
if (response.isSuccess() && response.getResult() != null) {
Integer potentialNotifyInterval = response.getResult().getPotentialNotifyInterval();
if (potentialNotifyInterval != null && potentialNotifyInterval <= 0) {
PotentialCustomerNotifyContext notifyContext = PotentialCustomerNotifyContext.builder()
.enterpriseId(interactRecordMessageBO.getEnterpriseId())
.customerStaticsBos(Lists.newArrayList(new PotentialCustomerStaticsBO(interactRecordBO.getClerkId(), 1)))
.build();
potentialCustomerService.sendPotentialCustomerNotice(notifyContext);
}
}
}finally {
RedisUtil.unlock(recordKey);
}
......
......@@ -14,6 +14,8 @@ import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.content.api.dto.setting.ContentSettingDTO;
import com.gic.content.api.service.ContentSettingApiService;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.dto.enterprise.EnterpriseUsingStatusDTO;
import com.gic.enterprise.api.service.EnterpriseUseForbidService;
......@@ -82,6 +84,8 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
private WxEnterpriseService wxEnterpriseService;
@Autowired
private PotentialCustomerService potentialCustomerService;
@Autowired
private ContentSettingApiService contentSettingApiService;
@Autowired
private EcommerceOrderOutputApiService ecommerceOrderOutputApiService;
......@@ -267,7 +271,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
*/
@Override
public ServiceResponse<Void> potentialCustomerJob(String params) {
Date now = new Date();
Date now = cn.hutool.core.date.DateUtil.beginOfSecond(cn.hutool.core.date.DateUtil.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);
if (currentHour >= 23 || currentHour < 8) {
......@@ -279,7 +283,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
log.info("开通内容权限的企业为空");
return ServiceResponse.success();
}
Date startTime = cn.hutool.core.date.DateUtil.offsetMinute(now, -30).toJdkDate();
Date startTime = null;
// 如果是8点那次的执行 需要获取 23 ~ 8点的数据
if (checkIsTodayFirst(now)) {
log.info("本次执行为当天第一次执行 {}", cn.hutool.core.date.DateUtil.format(now, "yyyy-MM-dd HH:mm:ss"));
......@@ -294,6 +298,18 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
startTime = calendar.getTime();
}
for (String enterpriseId : enterpriseIds) {
Integer potentialNotifyInterval = 30;
ServiceResponse<ContentSettingDTO> response = contentSettingApiService.queryContentSettingInfo(enterpriseId);
if (response.isSuccess() && response.getResult() != null) {
potentialNotifyInterval = response.getResult().getPotentialNotifyInterval();
}
if (potentialNotifyInterval <= 0 || cn.hutool.core.date.DateUtil.minute(now) % potentialNotifyInterval != 0) {
continue;
}
if (startTime == null) {
startTime = cn.hutool.core.date.DateUtil.offsetMinute(now, -potentialNotifyInterval).toJdkDate();
}
log.info("销售线索执行eid:{},potentialNotifyInterval:{}", enterpriseId, potentialNotifyInterval);
PotentialCustomerNotifyContext context = PotentialCustomerNotifyContext.builder()
.enterpriseId(enterpriseId)
.startTime(startTime)
......@@ -314,8 +330,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
int hour_sec = 30 * 60;
private boolean checkIsTodayFirst(Date now) {
DateTime temp = cn.hutool.core.date.DateUtil.offsetSecond(now, -(hour_sec));
return cn.hutool.core.date.DateUtil.hour(temp, true) < 8;
return cn.hutool.core.date.DateUtil.hour(now, true) == 8 && cn.hutool.core.date.DateUtil.minute(now) < 5;
}
......
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