提交 7e4cf8cc 作者: gh

定时客服开启

上级 cbe699f6
...@@ -86,7 +86,7 @@ public class SchedulingTask { ...@@ -86,7 +86,7 @@ public class SchedulingTask {
/** /**
* 每10min扫描一次正常客服 * 每10min扫描一次正常客服
*/ */
//@Scheduled(cron = "0 0/10 * * * *") @Scheduled(cron = "0 0/10 * * * *")
public void publishCustomerMessage(){ public void publishCustomerMessage(){
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
......
...@@ -221,39 +221,41 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -221,39 +221,41 @@ 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));
for (CustomerGraphics customerGraphics : customerGraphicsList) { if(!customerGraphicsList.isEmpty()){
//人群包id for (CustomerGraphics customerGraphics : customerGraphicsList) {
Long packId = customerGraphics.getPackId(); //人群包id
//根据人群包找人,并按appId分组 Long packId = customerGraphics.getPackId();
List<CrowdPackageUserVO> userList = registerUserEntityService.getCurrentInPackUserList(packId, false); //根据人群包找人,并按appId分组
//去重 List<CrowdPackageUserVO> userList = registerUserEntityService.getCurrentInPackUserList(packId, false);
Map<String, List<CrowdPackageUserVO>> appidUserMap = userList.stream().collect(Collectors.groupingBy(CrowdPackageUserVO::getAppId, //去重
Collectors.collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(CrowdPackageUserVO::getOpenId))), ArrayList::new))); Map<String, List<CrowdPackageUserVO>> appidUserMap = userList.stream().collect(Collectors.groupingBy(CrowdPackageUserVO::getAppId,
//根据客服id找不同公众号的链接,并按appId分组 Collectors.collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(CrowdPackageUserVO::getOpenId))), ArrayList::new)));
List<ReferralEntityVo> referralList = referralEntityService.findReferralByCustomerGraphicsId(customerGraphics.getId()); //根据客服id找不同公众号的链接,并按appId分组
List<ReferralEntityVo> referralList = referralEntityService.findReferralByCustomerGraphicsId(customerGraphics.getId());
Map<String, List<ReferralEntityVo>> referralMap = referralList.stream().collect(Collectors.groupingBy(ReferralEntityVo::getAppid));
//循环该客服下的所有素材 Map<String, List<ReferralEntityVo>> referralMap = referralList.stream().collect(Collectors.groupingBy(ReferralEntityVo::getAppid));
for (Map.Entry<String, List<ReferralEntityVo>> referralEntry : referralMap.entrySet()) { //循环该客服下的所有素材
for (Map.Entry<String, List<ReferralEntityVo>> referralEntry : referralMap.entrySet()) {
String appid = referralEntry.getKey();
//获取token String appid = referralEntry.getKey();
AuthorizerToken authorizerToken = authorizerTokenService.findTokenByAppid(appid); //获取token
AuthorizerToken authorizerToken = authorizerTokenService.findTokenByAppid(appid);
if (authorizerToken!=null&&authorizerToken.getAuthorizerAccessToken()!=null){
//获取该号的链接实体 if (authorizerToken!=null&&authorizerToken.getAuthorizerAccessToken()!=null){
List<ReferralEntityVo> referralEntityVo = referralMap.get(appid); //获取该号的链接实体
//获取该号的openid List<ReferralEntityVo> referralEntityVo = referralMap.get(appid);
List<CrowdPackageUserVO> packageUserVo = appidUserMap.get(appid); //获取该号的openid
List<CrowdPackageUserVO> packageUserVo = appidUserMap.get(appid);
if (referralEntityVo!=null&&!referralEntityVo.isEmpty()){
if (referralEntityVo!=null&&!referralEntityVo.isEmpty()){
weChatService.sendCustomerMessage(appid,authorizerToken,customerGraphics,packageUserVo,referralEntityVo);
weChatService.sendCustomerMessage(appid,authorizerToken,customerGraphics,packageUserVo,referralEntityVo);
}
} }
} }
} }
updateBatchById(customerGraphicsList);
} }
updateBatchById(customerGraphicsList);
} }
private BaseResult checkExtendBook(String storeType, CrowdPackageConditionMatch storeConditionMatch) { private BaseResult checkExtendBook(String storeType, CrowdPackageConditionMatch storeConditionMatch) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论