Commit 2b866fbd by 王祖波

配置时间发送销售线索

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