活码扫码统计

1 parent 1f25aa4d
......@@ -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
......
......@@ -205,4 +205,5 @@ public class WeCustomer extends BaseEntity {
//添加方式
private Integer addMethod;
}
package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -122,7 +123,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
}
/**
* 活码欢迎语发送
* 活码欢迎语发送(扫码回掉)
*
* @param state 渠道
* @param wecomCode 欢迎语code
......@@ -137,6 +138,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode);
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByState(state);
if (StringUtils.isNotNull(messageMap)) {
//查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.eq(WeEmpleCodeTag::getEmpleCodeId, messageMap.getEmpleCodeId()));
......
package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeEmpleCodeTag;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
......@@ -53,6 +55,8 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
}
//向扫码客户发送欢迎语
if (message.getState() != null && message.getWelcomeCode() != null) {
log.info("执行发送欢迎语>>>>>>>>>>>>>>>");
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode());
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByScenario(message.getState(),message.getUserId());
......
package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeSensitiveAct;
import com.linkwechat.wecom.domain.WeSensitiveActHit;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.IWeCustomerService;
......@@ -15,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* @author danmo
......@@ -52,13 +51,26 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
WeUser user = weUserService.getById(message.getUserId());
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());
weSensitiveActHit.setOperateTarget(weCustomer.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
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();
weSensitiveActHit.setOperateTargetId(weCustomer.getFirstUserId());
weSensitiveActHit.setOperateTarget(weCustomer.getCustomerName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
}
}
}
......
package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans;
......@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
......@@ -51,38 +53,55 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
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() + "删除!";
TextMessageDto textMessageDto = new TextMessageDto();
textMessageDto.setContent(content);
WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
weMessagePushDto.setMsgtype(MessageType.TEXT.getMessageType());
weMessagePushDto.setTouser(message.getUserId());
weMessagePushDto.setText(textMessageDto);
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> {
weMessagePushDto.setAgentid(Integer.valueOf(agentId));
});
weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString());
//增加敏感行为记录,客户删除员工
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
WeSensitiveActHit weSensitiveActHit = new WeSensitiveActHit();
weSensitiveActHit.setSensitiveActId(weSensitiveAct.getId());
weSensitiveActHit.setSensitiveAct(weSensitiveAct.getActName());
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin");
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperatorId(weCustomer.getUserId());
weSensitiveActHit.setOperator(weCustomer.getName());
weSensitiveActHit.setOperateTargetId(user.getUserId());
weSensitiveActHit.setOperateTarget(user.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
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.setContent(content);
WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
weMessagePushDto.setMsgtype(MessageType.TEXT.getMessageType());
weMessagePushDto.setTouser(message.getUserId());
weMessagePushDto.setText(textMessageDto);
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> {
weMessagePushDto.setAgentid(Integer.valueOf(agentId));
});
weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString());
//增加敏感行为记录,客户删除员工
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
WeSensitiveActHit weSensitiveActHit = new WeSensitiveActHit();
weSensitiveActHit.setSensitiveActId(weSensitiveAct.getId());
weSensitiveActHit.setSensitiveAct(weSensitiveAct.getActName());
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin");
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperatorId(weCustomer.getFirstUserId());
weSensitiveActHit.setOperator(weCustomer.getCustomerName());
weSensitiveActHit.setOperateTargetId(user.getUserId());
weSensitiveActHit.setOperateTarget(user.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
}
}
}
});
......
......@@ -10,6 +10,7 @@ import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.vo.WeCustomerDetailVo;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -155,4 +156,7 @@ public interface IWeCustomerService extends IService<WeCustomer>
* @param params
*/
void getCustomerByCondition(JSONObject params);
void batchAddOrUpdate(List<WeCustomer> weCustomer);
}
......@@ -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"
<insert id="batchAddOrUpdate">
INSERT INTO we_customer(
external_userid,
NAME,
`name`,
avatar,
type,
gender,
......@@ -611,34 +611,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
address,
phone,
add_method,
del_flag
del_flag,
state,
scan_code_add_times
) values
<foreach collection="weCustomers" item="item" index="index" separator=",">
(#{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.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod},
#{item.delFlag}
#{item.delFlag},#{item.state},#{item.scanCodeAddTimes}
)
</foreach>
ON DUPLICATE KEY UPDATE
NAME=IF(we_customer.NAME != null, VALUES(NAME), we_customer.NAME),
avatar=IF(we_customer.avatar != null, VALUES(avatar), we_customer.avatar),
type=IF(we_customer.type != null, VALUES(type), we_customer.type),
gender=IF(we_customer.gender != null, VALUES(gender), we_customer.gender),
unionid=IF(we_customer.unionid != null, VALUES(unionid), we_customer.unionid),
birthday=IF(we_customer.birthday != null,VALUES(birthday), we_customer.birthday),
corp_name=IF(we_customer.corp_name != null, VALUES(corp_name), we_customer.corp_name),
corp_full_name=IF(we_customer.corp_full_name != null, VALUES(corp_full_name), we_customer.corp_full_name),
position=IF(we_customer.position != null, VALUES(position), we_customer.position),
is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat),
first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id),
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time),
qq=IF(we_customer.qq != null, VALUES(qq), we_customer.qq),
email=IF(we_customer.email != null, VALUES(email), we_customer.email),
address=IF(we_customer.address != null, VALUES(address), we_customer.address),
phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone),
add_method=IF(we_customer.add_method != null, VALUES(add_method), we_customer.add_method),
del_flag=IF(we_customer.del_flag != null, VALUES(del_flag), we_customer.del_flag);
NAME=IF(VALUES(NAME)=null and VALUES(NAME)='',we_customer.NAME,VALUES(NAME)),
avatar=IF( VALUES(avatar)=null and VALUES(avatar)='', we_customer.avatar,VALUES(avatar)),
type=IF(VALUES(type),we_customer.type,VALUES(type)),
gender=IF(VALUES(gender) , we_customer.gender,VALUES(gender)),
unionid=IF(VALUES(unionid)=null and VALUES(unionid)='',we_customer.unionid,VALUES(unionid)),
birthday=IF(VALUES(birthday), we_customer.birthday,VALUES(birthday)),
corp_name=IF(VALUES(corp_name)=null and VALUES(corp_name)='',we_customer.corp_name,VALUES(corp_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(VALUES(position)=null and VALUES(position)='',we_customer.position,VALUES(position)),
is_open_chat=IF(VALUES(is_open_chat),we_customer.is_open_chat,VALUES(is_open_chat)),
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(VALUES(first_add_time)=null ,we_customer.first_add_time,VALUES(first_add_time)),
qq=IF(VALUES(qq)=null and VALUES(qq)='', we_customer.qq,VALUES(qq)),
email=IF(VALUES(email)=null and VALUES(email)='',we_customer.email,VALUES(email)),
address=IF(VALUES(address)=null and VALUES(address)='',we_customer.address,VALUES(address)),
phone=IF( VALUES(phone)=null and VALUES(phone)='', we_customer.phone, VALUES(phone)),
add_method=IF(VALUES(add_method),we_customer.add_method,VALUES(add_method)),
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>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!