Commit aec935d1 by xinlaa

Merge branch 'master' of https://gitee.com/LinkWeChat/link-wechat into master

2 parents 5372cf86 7e8b677f
...@@ -156,6 +156,7 @@ wecome: ...@@ -156,6 +156,7 @@ wecome:
- /externalcontact/transfer - /externalcontact/transfer
- /externalcontact/groupchat/transfer - /externalcontact/groupchat/transfer
- /externalcontact/get_unassigned_list - /externalcontact/get_unassigned_list
- /externalcontact/send_welcome_msg
fileUplodUrl: /media/upload,/media/uploadimg fileUplodUrl: /media/upload,/media/uploadimg
needProviderTokenUrl: needProviderTokenUrl:
- /service/get_login_info - /service/get_login_info
......
...@@ -5,11 +5,13 @@ import com.dtflys.forest.annotation.Query; ...@@ -5,11 +5,13 @@ import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request; import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.WeCustomerDto; import com.linkwechat.wecom.domain.dto.WeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeResultDto; import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit; import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail; import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserList; import com.linkwechat.wecom.domain.dto.customer.ExternalUserList;
import com.linkwechat.wecom.domain.dto.customer.FollowUserList; import com.linkwechat.wecom.domain.dto.customer.FollowUserList;
import java.util.Map; import java.util.Map;
/** /**
...@@ -74,4 +76,11 @@ public interface WeCustomerClient { ...@@ -74,4 +76,11 @@ public interface WeCustomerClient {
WeResultDto makeCustomerLabel(@DataObject CutomerTagEdit cutomerTagEdit); WeResultDto makeCustomerLabel(@DataObject CutomerTagEdit cutomerTagEdit);
/**
* 客户发送欢迎语
*/
@Request(url = "/externalcontact/send_welcome_msg",
type = "POST")
WeResultDto sendWelcomeMsg(@DataObject WeWelcomeMsg wxCpWelcomeMsg);
} }
package com.linkwechat.wecom.domain.dto;
import lombok.Data;
@Data
public class WeEmpleCodeDto {
/**
* 欢迎语
*/
private String welcomeMsg;
/**
* 欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语
*/
private Integer welcomeMsgTplType;
/**
* 分类id
*/
private String categoryId;
/**
* 本地资源文件地址
*/
private String materialUrl;
/**
* 文本内容、图片文案
*/
private String content;
/**
* 图片名称
*/
private String materialName;
/**
* 摘要
*/
private String digest;
/**
* 封面本地资源文件
*/
private String coverUrl;
}
package com.linkwechat.wecom.domain.dto;
import lombok.Builder;
import lombok.Data;
import me.chanjar.weixin.cp.bean.external.msg.Image;
import me.chanjar.weixin.cp.bean.external.msg.Link;
import me.chanjar.weixin.cp.bean.external.msg.MiniProgram;
import me.chanjar.weixin.cp.bean.external.msg.Text;
/**
* @author admin
* @date 2020-11-18
*/
@Data
@Builder
public class WeWelcomeMsg {
private String welcome_code;
private Text text;
private Image image;
private Link link;
private MiniProgram miniprogram;
}
package com.linkwechat.wecom.factory.impl; package com.linkwechat.wecom.factory.impl;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.Threads;
import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeCallBackEventFactory; import com.linkwechat.wecom.factory.WeCallBackEventFactory;
import com.linkwechat.wecom.service.IWeCustomerService; import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeEmpleCodeService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService; import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.cp.bean.external.msg.Image;
import me.chanjar.weixin.cp.bean.external.msg.Text;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,6 +26,10 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +26,10 @@ import org.springframework.stereotype.Service;
@Slf4j @Slf4j
public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory { public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory {
@Autowired @Autowired
private IWeEmpleCodeService weEmpleCodeService;
@Autowired
private IWeMsgTlpScopeService weMsgTlpScopeService;
@Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
@Autowired @Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService; private IWeFlowerCustomerRelService weFlowerCustomerRelService;
...@@ -62,7 +74,7 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory ...@@ -62,7 +74,7 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory
private void delFollowUser(WxCpXmlMessageVO message) { private void delFollowUser(WxCpXmlMessageVO message) {
if (message.getUserId() != null && message.getExternalUserId() != null) { if (message.getUserId() != null && message.getExternalUserId() != null) {
weFlowerCustomerRelService.deleteFollowUser(message.getUserId(),message.getExternalUserId()); weFlowerCustomerRelService.deleteFollowUser(message.getUserId(), message.getExternalUserId());
} }
} }
...@@ -88,5 +100,35 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory ...@@ -88,5 +100,35 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory
if (message.getExternalUserId() != null) { if (message.getExternalUserId() != null) {
weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId()); weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId());
} }
try {
Threads.SINGLE_THREAD_POOL.submit(new Runnable() {
@Override
public void run() {
//向扫码客户发送欢迎语
if (message.getState() != null && message.getWelcomeCode() != null) {
log.info("执行发送欢迎语>>>>>>>>>>>>>>>");
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode());
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByActivityScene(message.getState());
if (messageMap != null) {
if (StringUtils.isNotEmpty(messageMap.getWelcomeMsg())){
Text text = new Text();
text.setContent(messageMap.getWelcomeMsg());
weWelcomeMsgBuilder.text(text);
}
if(StringUtils.isNotEmpty(messageMap.getCategoryId())){
Image image = new Image();
image.setMediaId(messageMap.getCategoryId());
image.setPicUrl(messageMap.getMaterialUrl());
weWelcomeMsgBuilder.image(image);
}
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
}
}
}
});
} catch (Exception e) {
e.printStackTrace();
log.error("执行发送欢迎语失败!",e);
}
} }
} }
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeEmpleCode; import com.linkwechat.wecom.domain.WeEmpleCode;
import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 员工活码Mapper接口 * 员工活码Mapper接口
* *
...@@ -77,4 +78,11 @@ public interface WeEmpleCodeMapper extends BaseMapper<WeEmpleCode> ...@@ -77,4 +78,11 @@ public interface WeEmpleCodeMapper extends BaseMapper<WeEmpleCode>
* @return 结果 * @return 结果
*/ */
public int batchRemoveWeEmpleCodeIds(@Param("ids") List<String> ids); public int batchRemoveWeEmpleCodeIds(@Param("ids") List<String> ids);
/**
* 通过活动场景获取客户欢迎语
* @param activityScene 活动场景
* @return
*/
public WeEmpleCodeDto selectWelcomeMsgByActivityScene(@Param("activityScene") String activityScene);
} }
...@@ -3,9 +3,11 @@ package com.linkwechat.wecom.service; ...@@ -3,9 +3,11 @@ package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeUser; import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo; import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag; import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import java.util.List; import java.util.List;
/** /**
...@@ -89,4 +91,10 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -89,4 +91,10 @@ public interface IWeCustomerService extends IService<WeCustomer>
*/ */
public void deleteCustomersByEid(String externalUserid); public void deleteCustomersByEid(String externalUserid);
/**
* 向客户发送欢迎语
* @param weWelcomeMsg
*/
public void sendWelcomeMsg(WeWelcomeMsg weWelcomeMsg);
} }
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeEmpleCode; import com.linkwechat.wecom.domain.WeEmpleCode;
import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto;
import java.util.List; import java.util.List;
...@@ -71,6 +72,10 @@ public interface IWeEmpleCodeService extends IService<WeEmpleCode> ...@@ -71,6 +72,10 @@ public interface IWeEmpleCodeService extends IService<WeEmpleCode>
*/ */
public int batchRemoveWeEmpleCodeIds(List<String> ids); public int batchRemoveWeEmpleCodeIds(List<String> ids);
/**
* 通过活动场景获取客户欢迎语
* @param activityScene 活动场景
* @return
*/
public WeEmpleCodeDto selectWelcomeMsgByActivityScene(String activityScene);
} }
...@@ -15,6 +15,7 @@ import com.linkwechat.wecom.client.WeCustomerClient; ...@@ -15,6 +15,7 @@ import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.client.WeUserClient; import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.domain.*; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.AllocateWeCustomerDto; import com.linkwechat.wecom.domain.dto.AllocateWeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.dto.customer.*; import com.linkwechat.wecom.domain.dto.customer.*;
import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagDto; import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagDto;
import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagListDto; import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagListDto;
...@@ -24,6 +25,7 @@ import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo; ...@@ -24,6 +25,7 @@ import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag; import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.mapper.WeCustomerMapper; import com.linkwechat.wecom.mapper.WeCustomerMapper;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
...@@ -605,5 +607,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -605,5 +607,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
this.removeById(externalUserid); this.removeById(externalUserid);
} }
@Override
public void sendWelcomeMsg(WeWelcomeMsg weWelcomeMsg) {
weCustomerClient.sendWelcomeMsg(weWelcomeMsg);
}
} }
...@@ -2,9 +2,12 @@ package com.linkwechat.wecom.service.impl; ...@@ -2,9 +2,12 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeExternalContactClient; import com.linkwechat.wecom.client.WeExternalContactClient;
import com.linkwechat.wecom.domain.WeEmpleCode; import com.linkwechat.wecom.domain.WeEmpleCode;
import com.linkwechat.wecom.domain.WeEmpleCodeUseScop; import com.linkwechat.wecom.domain.WeEmpleCodeUseScop;
import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto;
import com.linkwechat.wecom.domain.dto.WeExternalContactDto; import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
import com.linkwechat.wecom.mapper.WeEmpleCodeMapper; import com.linkwechat.wecom.mapper.WeEmpleCodeMapper;
import com.linkwechat.wecom.service.IWeEmpleCodeService; import com.linkwechat.wecom.service.IWeEmpleCodeService;
...@@ -14,7 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,7 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -62,10 +67,10 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -62,10 +67,10 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
List<WeEmpleCodeUseScop> weEmpleCodeUseScopList = empleCode.getWeEmpleCodeUseScops(); List<WeEmpleCodeUseScop> weEmpleCodeUseScopList = empleCode.getWeEmpleCodeUseScops();
if (CollectionUtil.isNotEmpty(weEmpleCodeUseScopList)){ if (CollectionUtil.isNotEmpty(weEmpleCodeUseScopList)){
String useUserName = weEmpleCodeUseScopList.stream().map(WeEmpleCodeUseScop::getBusinessName) String useUserName = weEmpleCodeUseScopList.stream().map(WeEmpleCodeUseScop::getBusinessName)
.collect(Collectors.joining(",")); .filter(StringUtils::isNotEmpty).collect(Collectors.joining(","));
empleCode.setUseUserName(useUserName); empleCode.setUseUserName(useUserName);
String mobile = weEmpleCodeUseScopList.stream().map(WeEmpleCodeUseScop::getMobile) String mobile = weEmpleCodeUseScopList.stream().map(WeEmpleCodeUseScop::getMobile)
.collect(Collectors.joining(",")); .filter(StringUtils::isNotEmpty).collect(Collectors.joining(","));
empleCode.setMobile(mobile); empleCode.setMobile(mobile);
} }
}); });
...@@ -82,6 +87,8 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -82,6 +87,8 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void insertWeEmpleCode(WeEmpleCode weEmpleCode) { public void insertWeEmpleCode(WeEmpleCode weEmpleCode) {
weEmpleCode.setCreateTime(new Date());
weEmpleCode.setCreateBy(SecurityUtils.getUsername());
WeExternalContactDto.WeContactWay weContactWay = getWeContactWay(weEmpleCode); WeExternalContactDto.WeContactWay weContactWay = getWeContactWay(weEmpleCode);
try { try {
WeExternalContactDto weExternalContactDto = weExternalContactClient.addContactWay(weContactWay); WeExternalContactDto weExternalContactDto = weExternalContactClient.addContactWay(weContactWay);
...@@ -172,6 +179,11 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -172,6 +179,11 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
return this.baseMapper.batchRemoveWeEmpleCodeIds(ids); return this.baseMapper.batchRemoveWeEmpleCodeIds(ids);
} }
@Override
public WeEmpleCodeDto selectWelcomeMsgByActivityScene(String activityScene) {
return this.baseMapper.selectWelcomeMsgByActivityScene(activityScene);
}
private WeExternalContactDto.WeContactWay getWeContactWay(WeEmpleCode weEmpleCode) { private WeExternalContactDto.WeContactWay getWeContactWay(WeEmpleCode weEmpleCode) {
WeExternalContactDto.WeContactWay weContactWay = new WeExternalContactDto.WeContactWay(); WeExternalContactDto.WeContactWay weContactWay = new WeExternalContactDto.WeContactWay();
List<WeEmpleCodeUseScop> weEmpleCodeUseScops = weEmpleCode.getWeEmpleCodeUseScops(); List<WeEmpleCodeUseScop> weEmpleCodeUseScops = weEmpleCode.getWeEmpleCodeUseScops();
......
...@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="qrCode" column="qr_code" /> <result property="qrCode" column="qr_code" />
<collection property="weEmpleCodeUseScops" ofType="com.linkwechat.wecom.domain.WeEmpleCodeUseScop"> <collection property="weEmpleCodeUseScops" ofType="com.linkwechat.wecom.domain.WeEmpleCodeUseScop">
<result property="businessId" column="business_id" /> <result property="businessId" column="business_id" />
<result property="businessName" column="business_ame" /> <result property="businessName" column="business_name" />
<result property="mobile" column="mobile" /> <result property="mobile" column="mobile" />
</collection> </collection>
<collection property="weEmpleCodeTags" ofType="com.linkwechat.wecom.domain.WeEmpleCodeTag"> <collection property="weEmpleCodeTags" ofType="com.linkwechat.wecom.domain.WeEmpleCodeTag">
...@@ -177,6 +177,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -177,6 +177,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<select id="selectWelcomeMsgByActivityScene" parameterType="String" resultType="com.linkwechat.wecom.domain.dto.WeEmpleCodeDto">
select
wmt.welcome_msg ,
wmt.welcome_msg_tpl_type,
wm.category_id,
wm.material_url,
wm.content,
wm.material_name,
wm.digest,
wm.cover_url
from
we_emple_code wecode
left join
we_msg_tlp_scope wmts on wecode.welcome_msg = wmts .msg_tlp_id
left join we_msg_tlp wmt on wmt.id = wmts .msg_tlp_id
left join we_material wm on wm .id = wmt.media_id
where wmt.del_flag =0
<if test="activityScene != null and activityScene != ''">
and wecode.activity_scene = #{activityScene}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!