提交 62be57d5 作者: gh

订单活跃关闭,定时客服开启

上级 4f512eac
...@@ -44,7 +44,7 @@ public class SchedulingTask { ...@@ -44,7 +44,7 @@ public class SchedulingTask {
/** /**
* 拉取付费订单(每15min一次) * 拉取付费订单(每15min一次)
*/ */
@Scheduled(cron = "0 5/15 * * * *") //@Scheduled(cron = "0 5/15 * * * *")
public void retrieveOrderData(){ public void retrieveOrderData(){
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -63,7 +63,7 @@ public class SchedulingTask { ...@@ -63,7 +63,7 @@ public class SchedulingTask {
/** /**
* 更新付费用户近一月平均充值(每天一次:4点10分) * 更新付费用户近一月平均充值(每天一次:4点10分)
*/ */
@Scheduled(cron = "0 10 4 * * *") //@Scheduled(cron = "0 10 4 * * *")
public void retrieveMonthOrder(){ public void retrieveMonthOrder(){
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
......
...@@ -15,11 +15,8 @@ import com.yaoyaozw.customer.constants.CustomerCommonConstant; ...@@ -15,11 +15,8 @@ import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO; import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
import com.yaoyaozw.customer.entity.AuthorizerToken; import com.yaoyaozw.customer.entity.*;
import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO; import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO;
import com.yaoyaozw.customer.entity.CrowdPackageCondition;
import com.yaoyaozw.customer.entity.CrowdPackageConditionMatch;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper; import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService; import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService;
import com.yaoyaozw.customer.service.CrowdPackageConditionService; import com.yaoyaozw.customer.service.CrowdPackageConditionService;
...@@ -41,7 +38,6 @@ import java.util.stream.Collectors; ...@@ -41,7 +38,6 @@ import java.util.stream.Collectors;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.mapper.CustomerGraphicsMapper; import com.yaoyaozw.customer.mapper.CustomerGraphicsMapper;
import com.yaoyaozw.customer.service.CustomerGraphicsService; import com.yaoyaozw.customer.service.CustomerGraphicsService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -224,16 +220,29 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -224,16 +220,29 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
List<CustomerGraphics> customerGraphicsList = list(new QueryWrapper<CustomerGraphics>().eq(CustomerGraphics.COL_POST_TIME, requestDate).eq(CustomerGraphics.COL_SEND_STATUS,9)); List<CustomerGraphics> customerGraphicsList = list(new QueryWrapper<CustomerGraphics>().eq(CustomerGraphics.COL_POST_TIME, requestDate).eq(CustomerGraphics.COL_SEND_STATUS,9));
List<CrowdPackage> crowdPackageList = crowdPackageService.list();
Map<Long, CrowdPackage> crowdPackageMap = crowdPackageList.stream().collect(Collectors.toMap(CrowdPackage::getId, a -> a));
if(!customerGraphicsList.isEmpty()){ if(!customerGraphicsList.isEmpty()){
LOCAL_LOG.info("start sendCustomerMessage"); LOCAL_LOG.info("start sendCustomerMessage");
for (CustomerGraphics customerGraphics : customerGraphicsList) { for (CustomerGraphics customerGraphics : customerGraphicsList) {
//人群包id //人群包id
Long packId = customerGraphics.getPackId(); Long packId = customerGraphics.getPackId();
CrowdPackage crowdPackage = crowdPackageMap.get(packId);
Long activeTimeMax = crowdPackage.getActiveTimeMax();
Long activeTimeMin = crowdPackage.getActiveTimeMin();
//根据人群包找人,并按appId分组 //根据人群包找人,并按appId分组
List<CrowdPackageUserVO> userList = registerUserEntityService.getCurrentInPackUserList(packId, false); List<CrowdPackageUserVO> userList = registerUserEntityService.getCurrentInPackUserList(packId, false);
//去重
Map<String, List<CrowdPackageUserVO>> appidUserMap = userList.stream().collect(Collectors.groupingBy(CrowdPackageUserVO::getAppId, //1.活跃时间判断,2.用户去重
Collectors.collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(CrowdPackageUserVO::getOpenId))), ArrayList::new))); Map<String, List<CrowdPackageUserVO>> appidUserMap = userList.stream()
.filter(a->a.getLastActive()!=null&&(activeTimeMin==null||a.getLastActive().getTime()>activeTimeMin)&&(activeTimeMax==null||a.getLastActive().getTime()<activeTimeMax))
.collect(Collectors.groupingBy(CrowdPackageUserVO::getAppId, Collectors.collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(CrowdPackageUserVO::getOpenId))), ArrayList::new)));
//根据客服id找不同公众号的链接,并按appId分组 //根据客服id找不同公众号的链接,并按appId分组
List<ReferralEntityVo> referralList = referralEntityService.findReferralByCustomerGraphicsId(customerGraphics.getId()); List<ReferralEntityVo> referralList = referralEntityService.findReferralByCustomerGraphicsId(customerGraphics.getId());
......
package com.yaoyaozw.customer.service.wechat.service; package com.yaoyaozw.customer.service.wechat.service;
import com.yaoyaozw.customer.entity.AuthorizerToken; import com.yaoyaozw.customer.entity.*;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO; import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO; import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import com.yaoyaozw.customer.vo.referral.ReferralEntityVo; import com.yaoyaozw.customer.vo.referral.ReferralEntityVo;
...@@ -26,6 +23,7 @@ public interface WeChatService { ...@@ -26,6 +23,7 @@ public interface WeChatService {
/** /**
* 定时发送客服消息 * 定时发送客服消息
*/ */
void sendCustomerMessage(String appid, AuthorizerToken authorizerToken, CustomerGraphics customerGraphics, List<CrowdPackageUserVO>openidList, List<ReferralEntityVo> referralEntityVo); void sendCustomerMessage(String appid, AuthorizerToken authorizerToken, CustomerGraphics customerGraphics,
List<CrowdPackageUserVO>openidList, List<ReferralEntityVo> referralEntityVo);
} }
...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service.wechat.service; ...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service.wechat.service;
import com.yaoyaozw.customer.constants.CustomerCommonConstant; import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.entity.AuthorizerToken; import com.yaoyaozw.customer.entity.AuthorizerToken;
import com.yaoyaozw.customer.entity.CrowdPackage;
import com.yaoyaozw.customer.entity.CustomerDelayPublish; import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.yaoyaozw.customer.entity.CustomerGraphics; import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.service.AuthorizerTokenService; import com.yaoyaozw.customer.service.AuthorizerTokenService;
...@@ -125,7 +126,8 @@ public class WeChatServiceImpl implements WeChatService{ ...@@ -125,7 +126,8 @@ public class WeChatServiceImpl implements WeChatService{
@Override @Override
public void sendCustomerMessage(String appid, AuthorizerToken authorizerToken, CustomerGraphics customerGraphics, List<CrowdPackageUserVO> openidList, List<ReferralEntityVo> referralEntityVo) { public void sendCustomerMessage(String appid, AuthorizerToken authorizerToken, CustomerGraphics customerGraphics, List<CrowdPackageUserVO> openidList,
List<ReferralEntityVo> referralEntityVo) {
//token //token
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(customerPath).queryParam("access_token",authorizerToken.getAuthorizerAccessToken()); UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(customerPath).queryParam("access_token",authorizerToken.getAuthorizerAccessToken());
//构建请求参数(文本/图文) //构建请求参数(文本/图文)
...@@ -146,7 +148,6 @@ public class WeChatServiceImpl implements WeChatService{ ...@@ -146,7 +148,6 @@ public class WeChatServiceImpl implements WeChatService{
customerRequest.setTouser(crowdPackageUserVO.getOpenId()); customerRequest.setTouser(crowdPackageUserVO.getOpenId());
try { try {
WeChatResponseEntity response=(WeChatResponseEntity)weChatRestService.httpPostRequest(uriComponentsBuilder, customerRequest,WeChatResponseEntity.class); WeChatResponseEntity response=(WeChatResponseEntity)weChatRestService.httpPostRequest(uriComponentsBuilder, customerRequest,WeChatResponseEntity.class);
if(SUCCESS_CODE.equals(response.getErrcode())){ if(SUCCESS_CODE.equals(response.getErrcode())){
...@@ -164,7 +165,6 @@ public class WeChatServiceImpl implements WeChatService{ ...@@ -164,7 +165,6 @@ public class WeChatServiceImpl implements WeChatService{
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally { }finally {
latch.countDown(); latch.countDown();
......
...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.vo.customer; ...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.vo.customer;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* @author darker * @author darker
...@@ -23,6 +24,8 @@ public class CrowdPackageUserVO implements Serializable { ...@@ -23,6 +24,8 @@ public class CrowdPackageUserVO implements Serializable {
private Long setupId; private Long setupId;
private Date lastActive;
private String inPackage; private String inPackage;
private String storeType; private String storeType;
......
...@@ -92,9 +92,10 @@ ...@@ -92,9 +92,10 @@
setup_id, setup_id,
open_id, open_id,
in_Package, in_Package,
app_id app_id,
last_active
from register_user_entity from register_user_entity
where find_in_set(#{packageId}, in_package) where find_in_set(#{packageId}, in_package) and TIMESTAMPDIFF(HOUR,last_active,now() ) &lt; 48
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论