活码扫码统计

1 parent 1f25aa4d
...@@ -150,6 +150,13 @@ public class WeCustomerController extends BaseController ...@@ -150,6 +150,13 @@ public class WeCustomerController extends BaseController
} }
@GetMapping("/getCustomersInfoAndSynch")
public AjaxResult getCustomersInfoAndSynchWeCustomer(String externalUserid,String userId){
weCustomerService.getCustomersInfoAndSynchWeCustomer(externalUserid,userId);
return AjaxResult.success();
}
/** /**
* 客户打标签 * 客户打标签
* @param weMakeCustomerTag * @param weMakeCustomerTag
......
...@@ -205,4 +205,5 @@ public class WeCustomer extends BaseEntity { ...@@ -205,4 +205,5 @@ public class WeCustomer extends BaseEntity {
//添加方式 //添加方式
private Integer addMethod; private Integer addMethod;
} }
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -122,7 +123,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -122,7 +123,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
} }
/** /**
* 活码欢迎语发送 * 活码欢迎语发送(扫码回掉)
* *
* @param state 渠道 * @param state 渠道
* @param wecomCode 欢迎语code * @param wecomCode 欢迎语code
...@@ -137,6 +138,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -137,6 +138,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode); WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode);
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByState(state); WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByState(state);
if (StringUtils.isNotNull(messageMap)) { if (StringUtils.isNotNull(messageMap)) {
//查询活码对应标签 //查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>() List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.eq(WeEmpleCodeTag::getEmpleCodeId, messageMap.getEmpleCodeId())); .eq(WeEmpleCodeTag::getEmpleCodeId, messageMap.getEmpleCodeId()));
......
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSONObject; 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.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeEmpleCodeTag; import com.linkwechat.wecom.domain.WeEmpleCodeTag;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel; import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel; import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
...@@ -53,6 +55,8 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -53,6 +55,8 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
} }
//向扫码客户发送欢迎语 //向扫码客户发送欢迎语
if (message.getState() != null && message.getWelcomeCode() != null) { if (message.getState() != null && message.getWelcomeCode() != null) {
log.info("执行发送欢迎语>>>>>>>>>>>>>>>"); log.info("执行发送欢迎语>>>>>>>>>>>>>>>");
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode()); WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode());
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByScenario(message.getState(),message.getUserId()); WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByScenario(message.getState(),message.getUserId());
......
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.WeSensitiveAct;
import com.linkwechat.wecom.domain.WeSensitiveActHit;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy; import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.IWeCustomerService; import com.linkwechat.wecom.service.IWeCustomerService;
...@@ -15,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author danmo * @author danmo
...@@ -52,13 +51,26 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy { ...@@ -52,13 +51,26 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
WeUser user = weUserService.getById(message.getUserId()); WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperator(user.getName()); weSensitiveActHit.setOperator(user.getName());
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,message.getExternalUserId())
.eq(WeCustomer::getFirstUserId,message.getUserId()));
weSensitiveActHit.setOperateTargetId(weCustomer.getUserId()); List<WeCustomerList> weCustomerList = weCustomerService.findWeCustomerList(WeCustomerList.builder()
weSensitiveActHit.setOperateTarget(weCustomer.getName()); .externalUserid(message.getExternalUserId())
.firstUserId(message.getUserId())
.delFlag(new Integer(1))
.build());
if(CollectionUtil.isNotEmpty(weCustomerList)) {
WeCustomerList weCustomer = weCustomerList.stream().findFirst().get();
weSensitiveActHit.setOperateTargetId(weCustomer.getFirstUserId());
weSensitiveActHit.setOperateTarget(weCustomer.getCustomerName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit); weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
}
} }
} }
......
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; 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.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
...@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Optional; import java.util.Optional;
/** /**
...@@ -51,10 +53,19 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -51,10 +53,19 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> { Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch(); String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) { if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) {
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getFirstUserId,message.getUserId())
.eq(WeCustomer::getExternalUserid,message.getExternalUserId()));
String content = "您已经被客户@" + weCustomer.getName() + "删除!"; List<WeCustomerList> weCustomerList = weCustomerService.findWeCustomerList(WeCustomerList.builder()
.externalUserid(message.getExternalUserId())
.firstUserId(message.getUserId())
.delFlag(new Integer(1))
.build());
if(CollectionUtil.isNotEmpty(weCustomerList)){
WeCustomerList weCustomer = weCustomerList.stream().findFirst().get();
String content = "您已经被客户@" + weCustomer.getCustomerName() + "删除!";
TextMessageDto textMessageDto = new TextMessageDto(); TextMessageDto textMessageDto = new TextMessageDto();
textMessageDto.setContent(content); textMessageDto.setContent(content);
WeMessagePushDto weMessagePushDto = new WeMessagePushDto(); WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
...@@ -77,12 +88,20 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -77,12 +88,20 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime())); weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin"); weSensitiveActHit.setCreateBy("admin");
WeUser user = weUserService.getById(message.getUserId()); WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperatorId(weCustomer.getUserId()); weSensitiveActHit.setOperatorId(weCustomer.getFirstUserId());
weSensitiveActHit.setOperator(weCustomer.getName()); weSensitiveActHit.setOperator(weCustomer.getCustomerName());
weSensitiveActHit.setOperateTargetId(user.getUserId()); weSensitiveActHit.setOperateTargetId(user.getUserId());
weSensitiveActHit.setOperateTarget(user.getName()); weSensitiveActHit.setOperateTarget(user.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit); weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
} }
}
} }
}); });
......
...@@ -10,6 +10,7 @@ import com.linkwechat.wecom.domain.dto.WeWelcomeMsg; ...@@ -10,6 +10,7 @@ import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.vo.WeCustomerDetailVo; import com.linkwechat.wecom.domain.vo.WeCustomerDetailVo;
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 org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -155,4 +156,7 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -155,4 +156,7 @@ public interface IWeCustomerService extends IService<WeCustomer>
* @param params * @param params
*/ */
void getCustomerByCondition(JSONObject params); void getCustomerByCondition(JSONObject params);
void batchAddOrUpdate(List<WeCustomer> weCustomer);
} }
...@@ -712,5 +712,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -712,5 +712,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
} }
@Override
public void batchAddOrUpdate(List<WeCustomer> weCustomer) {
this.baseMapper.batchAddOrUpdate(weCustomer);
}
} }
...@@ -592,7 +592,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -592,7 +592,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchAddOrUpdate"> <insert id="batchAddOrUpdate">
INSERT INTO we_customer( INSERT INTO we_customer(
external_userid, external_userid,
NAME, `name`,
avatar, avatar,
type, type,
gender, gender,
...@@ -611,34 +611,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -611,34 +611,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
address, address,
phone, phone,
add_method, add_method,
del_flag del_flag,
state,
scan_code_add_times
) values ) values
<foreach collection="weCustomers" item="item" index="index" separator=","> <foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday}, (#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday},
#{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime}, #{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},
#{item.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod}, #{item.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod},
#{item.delFlag} #{item.delFlag},#{item.state},#{item.scanCodeAddTimes}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
NAME=IF(we_customer.NAME != null, VALUES(NAME), we_customer.NAME), NAME=IF(VALUES(NAME)=null and VALUES(NAME)='',we_customer.NAME,VALUES(NAME)),
avatar=IF(we_customer.avatar != null, VALUES(avatar), we_customer.avatar), avatar=IF( VALUES(avatar)=null and VALUES(avatar)='', we_customer.avatar,VALUES(avatar)),
type=IF(we_customer.type != null, VALUES(type), we_customer.type), type=IF(VALUES(type),we_customer.type,VALUES(type)),
gender=IF(we_customer.gender != null, VALUES(gender), we_customer.gender), gender=IF(VALUES(gender) , we_customer.gender,VALUES(gender)),
unionid=IF(we_customer.unionid != null, VALUES(unionid), we_customer.unionid), unionid=IF(VALUES(unionid)=null and VALUES(unionid)='',we_customer.unionid,VALUES(unionid)),
birthday=IF(we_customer.birthday != null,VALUES(birthday), we_customer.birthday), birthday=IF(VALUES(birthday), we_customer.birthday,VALUES(birthday)),
corp_name=IF(we_customer.corp_name != null, VALUES(corp_name), we_customer.corp_name), corp_name=IF(VALUES(corp_name)=null and VALUES(corp_name)='',we_customer.corp_name,VALUES(corp_name)),
corp_full_name=IF(we_customer.corp_full_name != null, VALUES(corp_full_name), we_customer.corp_full_name), corp_full_name=IF(VALUES(corp_full_name)=null and VALUES(corp_full_name)='', we_customer.corp_full_name,VALUES(corp_full_name)),
position=IF(we_customer.position != null, VALUES(position), we_customer.position), position=IF(VALUES(position)=null and VALUES(position)='',we_customer.position,VALUES(position)),
is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat), is_open_chat=IF(VALUES(is_open_chat),we_customer.is_open_chat,VALUES(is_open_chat)),
first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id), first_user_id=IF(VALUES(first_user_id)=null and VALUES(first_user_id)='', we_customer.first_user_id,VALUES(first_user_id)),
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time), first_add_time=IF(VALUES(first_add_time)=null ,we_customer.first_add_time,VALUES(first_add_time)),
qq=IF(we_customer.qq != null, VALUES(qq), we_customer.qq), qq=IF(VALUES(qq)=null and VALUES(qq)='', we_customer.qq,VALUES(qq)),
email=IF(we_customer.email != null, VALUES(email), we_customer.email), email=IF(VALUES(email)=null and VALUES(email)='',we_customer.email,VALUES(email)),
address=IF(we_customer.address != null, VALUES(address), we_customer.address), address=IF(VALUES(address)=null and VALUES(address)='',we_customer.address,VALUES(address)),
phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone), phone=IF( VALUES(phone)=null and VALUES(phone)='', we_customer.phone, VALUES(phone)),
add_method=IF(we_customer.add_method != null, VALUES(add_method), we_customer.add_method), add_method=IF(VALUES(add_method),we_customer.add_method,VALUES(add_method)),
del_flag=IF(we_customer.del_flag != null, VALUES(del_flag), we_customer.del_flag); del_flag=IF(VALUES(del_flag), we_customer.del_flag, VALUES(del_flag)),
state=IF( VALUES(state)=null and VALUES(state)='', we_customer.state, VALUES(state));
</insert> </insert>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!