提交 176e62c1 作者: 沈振路

客服消息发送处理逻辑调整

上级 ff55ce09
......@@ -8,10 +8,11 @@ import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
import com.yaoyaozw.customer.entity.CustomerFollowReply;
import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.AccountOrderService;
import com.yaoyaozw.customer.service.CustomerDelayPublishService;
import com.yaoyaozw.customer.service.CustomerGraphicsService;
import com.yaoyaozw.customer.service.*;
import com.yaoyaozw.customer.service.wechat.service.WeChatService;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import com.yaoyaozw.customer.vo.referral.ReferralEntityVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
......@@ -132,5 +134,23 @@ public class TestController {
}
@Resource
private WeChatService weChatService;
@Resource
private RegisterUserEntityService registerUserEntityService;
@Resource
private ReferralEntityService referralEntityService;
@GetMapping("/testSendCustomer")
public void testSendCustomer() {
CustomerGraphics entity = customerGraphicsService.getById(1874011792770990080L);
List<CrowdPackageUserVO> userList = registerUserEntityService.getCurrentInPackUserList(entity.getPackId(), false);
List<ReferralEntityVo> referralEntityVos = referralEntityService.findReferralByCustomerGraphicsId(entity.getId());
weChatService.sendCustomerMessage(userList.get(0).getAppId(), entity, userList, referralEntityVos);
}
}
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.util.ObjectUtil;
import com.github.pagehelper.PageHelper;
......@@ -262,7 +263,12 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
//根据客服id找不同公众号的链接,并按appId分组
List<ReferralEntityVo> referralList = referralEntityService.findReferralByCustomerGraphicsId(customerGraphics.getId());
// 提取出其中的自定义链接
List<ReferralEntityVo> customLinkList = referralList.stream()
.filter(v -> StringUtils.isBlank(v.getAppid()) && StringUtils.isNotBlank(v.getReferral()))
.filter(v -> v.getNewsType() != null && v.getNewsType() == -1)
.collect(Collectors.toList());
// 非自定义链接
Map<String, List<ReferralEntityVo>> referralMap = referralList.stream().filter(a->!StringUtils.isAnyBlank(a.getReferral(), a.getAppid())).collect(Collectors.groupingBy(ReferralEntityVo::getAppid));
//循环该人群包下的所有素材
int singleUserCount = 0;
......@@ -270,7 +276,10 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
String appid = usersEntry.getKey();
try { //获取该号的链接实体
List<ReferralEntityVo> referralEntityVo = referralMap.get(appid);
List<ReferralEntityVo> referralEntityVo = referralMap.getOrDefault(appid, CollectionUtil.newArrayList());
if (CollectionUtil.isNotEmpty(customLinkList)) {
referralEntityVo.addAll(customLinkList);
}
//获取该号的openid
List<CrowdPackageUserVO> packageUserVo = usersEntry.getValue();
singleUserCount += packageUserVo.size();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论