Commit 77c891d1 by 18356073052

Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev

2 parents db39422d 911fd870
...@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.enums.MediaType; import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.Threads; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.WeEmpleCodeTag;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto; import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg; import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
...@@ -18,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -18,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -43,30 +41,73 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -43,30 +41,73 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService; private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired @Autowired
private IWeMaterialService weMaterialService; private IWeMaterialService weMaterialService;
@Autowired
private IWeTaskFissionRecordService weTaskFissionRecordService;
@Autowired
private IWeTaskFissionService weTaskFissionService;
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
try { if (message.getExternalUserId() != null) {
if (message.getExternalUserId() != null) { weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId());
weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId()); }
if (message.getState() != null && message.getWelcomeCode() != null) {
if (isNumeric(message.getState())) {
taskFissionRecordHandle(message.getState(), message.getWelcomeCode(), message.getExternalUserId());
} }
//向扫码客户发送欢迎语 empleCodeHandle(message.getState(), message.getWelcomeCode(), message.getUserId(), message.getExternalUserId());
if (message.getState() != null && message.getWelcomeCode() != null) { }
log.info("执行发送欢迎语>>>>>>>>>>>>>>>"); }
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode());
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByActivityScene(message.getState(),message.getUserId()); //裂变任务处理
private void taskFissionRecordHandle(String state, String wecomCode, String externalUserId) {
//查询裂变客户任务记录
WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(state),externalUserId);
if (weTaskFissionRecord != null) {
weTaskFissionRecord.setFissNum(weTaskFissionRecord.getFissNum() + 1);
weTaskFissionRecordService.updateWeTaskFissionRecord(weTaskFissionRecord);
//查询裂变任务详情
WeTaskFission weTaskFission = weTaskFissionService
.selectWeTaskFissionById(weTaskFissionRecord.getTaskFissionId());
if (weTaskFission != null){
//发送欢迎语
String welcomeMsg = weTaskFission.getWelcomeMsg();
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = JSONObject.parseObject(welcomeMsg, WeWelcomeMsg.WeWelcomeMsgBuilder.class);
weWelcomeMsgBuilder.welcome_code(wecomCode);
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
}
}
}
/**
* 活码欢迎语发送
*
* @param state 渠道
* @param wecomCode 欢迎语code
* @param userId 成员id
* @param externalUserId 客户id
*/
private void empleCodeHandle(String state, String wecomCode, String userId, String externalUserId) {
try {
log.info("执行发送欢迎语>>>>>>>>>>>>>>>");
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode);
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByActivityScene(state, userId);
if (messageMap != null) {
String empleCodeId = messageMap.getEmpleCodeId(); String empleCodeId = messageMap.getEmpleCodeId();
//查询活码对应标签 //查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>() List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.eq(WeEmpleCodeTag::getEmpleCodeId, empleCodeId)); .eq(WeEmpleCodeTag::getEmpleCodeId, empleCodeId));
//查询外部联系人与通讯录关系数据 //查询外部联系人与通讯录关系数据
WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>() WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getUserId, message.getUserId()) .eq(WeFlowerCustomerRel::getUserId, userId)
.eq(WeFlowerCustomerRel::getExternalUserid, message.getExternalUserId())); .eq(WeFlowerCustomerRel::getExternalUserid, externalUserId));
//为外部联系人添加员工活码标签 //为外部联系人添加员工活码标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>(); List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
Optional.ofNullable(weFlowerCustomerRel).ifPresent(weFlowerCustomerRel1 -> { Optional.ofNullable(weFlowerCustomerRel).ifPresent(weFlowerCustomerRel1 -> {
Optional.ofNullable(tagList).orElseGet(ArrayList::new).forEach(tag ->{ Optional.ofNullable(tagList).orElseGet(ArrayList::new).forEach(tag -> {
weFlowerCustomerTagRels.add( weFlowerCustomerTagRels.add(
WeFlowerCustomerTagRel.builder() WeFlowerCustomerTagRel.builder()
.flowerCustomerRelId(weFlowerCustomerRel.getId()) .flowerCustomerRelId(weFlowerCustomerRel.getId())
...@@ -79,14 +120,14 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -79,14 +120,14 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
}); });
log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap)); log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap));
if (messageMap != null) { if (messageMap != null) {
if (StringUtils.isNotEmpty(messageMap.getWelcomeMsg())){ if (StringUtils.isNotEmpty(messageMap.getWelcomeMsg())) {
weWelcomeMsgBuilder.text(WeWelcomeMsg.Text.builder() weWelcomeMsgBuilder.text(WeWelcomeMsg.Text.builder()
.content(messageMap.getWelcomeMsg()).build()); .content(messageMap.getWelcomeMsg()).build());
} }
if(StringUtils.isNotEmpty(messageMap.getCategoryId())){ if (StringUtils.isNotEmpty(messageMap.getCategoryId())) {
WeMediaDto weMediaDto = weMaterialService WeMediaDto weMediaDto = weMaterialService
.uploadTemporaryMaterial(messageMap.getMaterialUrl(),messageMap.getMaterialName(), MediaType.IMAGE.getMediaType()); .uploadTemporaryMaterial(messageMap.getMaterialUrl(), messageMap.getMaterialName(), MediaType.IMAGE.getMediaType());
Optional.ofNullable(weMediaDto).ifPresent(media ->{ Optional.ofNullable(weMediaDto).ifPresent(media -> {
weWelcomeMsgBuilder.image(WeWelcomeMsg.Image.builder().media_id(media.getMedia_id()) weWelcomeMsgBuilder.image(WeWelcomeMsg.Image.builder().media_id(media.getMedia_id())
.pic_url(media.getUrl()).build()); .pic_url(media.getUrl()).build());
}); });
...@@ -96,7 +137,19 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -96,7 +137,19 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("执行发送欢迎语失败!",e); log.error("执行发送欢迎语失败!", e);
}
}
private boolean isNumeric(String str) {
try {
new BigDecimal(str);
} catch (Exception e) {
//异常 说明包含非数字。
return false;
} }
return true;
} }
} }
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeTaskFissionRecord; import com.linkwechat.wecom.domain.WeTaskFissionRecord;
import java.util.List; import java.util.List;
...@@ -10,7 +11,7 @@ import java.util.List; ...@@ -10,7 +11,7 @@ import java.util.List;
* @author ruoyi * @author ruoyi
* @date 2021-01-27 * @date 2021-01-27
*/ */
public interface WeTaskFissionRecordMapper { public interface WeTaskFissionRecordMapper extends BaseMapper<WeTaskFissionRecord> {
/** /**
* 查询裂变任务记录 * 查询裂变任务记录
* *
......
...@@ -58,4 +58,7 @@ public interface IWeTaskFissionRecordService { ...@@ -58,4 +58,7 @@ public interface IWeTaskFissionRecordService {
* @return 结果 * @return 结果
*/ */
public int deleteWeTaskFissionRecordById(Long id); public int deleteWeTaskFissionRecordById(Long id);
public WeTaskFissionRecord selectWeTaskFissionRecordByIdAndCustomerId(Long id, String customerId);
} }
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeTaskFissionRecord; import com.linkwechat.wecom.domain.WeTaskFissionRecord;
import com.linkwechat.wecom.mapper.WeTaskFissionRecordMapper; import com.linkwechat.wecom.mapper.WeTaskFissionRecordMapper;
import com.linkwechat.wecom.service.IWeTaskFissionRecordService; import com.linkwechat.wecom.service.IWeTaskFissionRecordService;
...@@ -15,7 +17,7 @@ import java.util.List; ...@@ -15,7 +17,7 @@ import java.util.List;
* @date 2021-01-27 * @date 2021-01-27
*/ */
@Service @Service
public class WeTaskFissionRecordServiceImpl implements IWeTaskFissionRecordService { public class WeTaskFissionRecordServiceImpl extends ServiceImpl<WeTaskFissionRecordMapper,WeTaskFissionRecord> implements IWeTaskFissionRecordService {
@Autowired @Autowired
private WeTaskFissionRecordMapper weTaskFissionRecordMapper; private WeTaskFissionRecordMapper weTaskFissionRecordMapper;
...@@ -84,4 +86,11 @@ public class WeTaskFissionRecordServiceImpl implements IWeTaskFissionRecordServi ...@@ -84,4 +86,11 @@ public class WeTaskFissionRecordServiceImpl implements IWeTaskFissionRecordServi
public int deleteWeTaskFissionRecordById(Long id) { public int deleteWeTaskFissionRecordById(Long id) {
return weTaskFissionRecordMapper.deleteWeTaskFissionRecordById(id); return weTaskFissionRecordMapper.deleteWeTaskFissionRecordById(id);
} }
@Override
public WeTaskFissionRecord selectWeTaskFissionRecordByIdAndCustomerId(Long id, String customerId) {
return weTaskFissionRecordMapper.selectOne(new LambdaQueryWrapper<WeTaskFissionRecord>()
.eq(WeTaskFissionRecord::getId,id)
.eq(WeTaskFissionRecord::getCustomerId,customerId));
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!