提交轨迹相关代码

1 parent 92e9c821
Showing 21 changed files with 477 additions and 201 deletions
...@@ -210,10 +210,10 @@ public class WeCustomerController extends BaseController ...@@ -210,10 +210,10 @@ public class WeCustomerController extends BaseController
List<WeCustomerTrajectory> weCustomerTrajectories = iWeCustomerTrajectoryService List<WeCustomerTrajectory> weCustomerTrajectories = iWeCustomerTrajectoryService
.followUpRecord(externalUserid, userId, trajectoryType); .followUpRecord(externalUserid, userId, trajectoryType);
TableDataInfo dataTable = getDataTable(weCustomerTrajectories); // TableDataInfo dataTable = getDataTable(weCustomerTrajectories);
dataTable.setLastSyncTime( // dataTable.setLastSyncTime(
iWeSynchRecordService.findUpdateLatestTime(SynchRecordConstants.SYNCH_MOMENTS_INTERACTE) // iWeSynchRecordService.findUpdateLatestTime(SynchRecordConstants.SYNCH_MOMENTS_INTERACTE)
);//最近同步时间 // );//最近同步时间
return getDataTable(weCustomerTrajectories); return getDataTable(weCustomerTrajectories);
} }
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
...@@ -35,6 +36,9 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -35,6 +36,9 @@ public class WeCustomerPortraitController extends BaseController {
@Autowired @Autowired
private IWeTagService iWeTagService; private IWeTagService iWeTagService;
@Autowired
private IWeTagGroupService iWeTagGroupService;
@Autowired @Autowired
private IWeUserService iWeUserService; private IWeUserService iWeUserService;
...@@ -49,6 +53,11 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -49,6 +53,11 @@ public class WeCustomerPortraitController extends BaseController {
private IWeCustomerTrajectoryService iWeCustomerTrajectoryService; private IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
@Autowired
IWeMomentsService iWeMomentsService;
/** /**
* 根据客户id和当前企业员工id获取客户详细信息 * 根据客户id和当前企业员工id获取客户详细信息
* @param externalUserid * @param externalUserid
...@@ -91,8 +100,17 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -91,8 +100,17 @@ public class WeCustomerPortraitController extends BaseController {
* @return * @return
*/ */
@GetMapping(value = "/findAllTags") @GetMapping(value = "/findAllTags")
public AjaxResult findAllTags(String userId){ public AjaxResult findAllTags(Integer groupTagType,String userId){
if(groupTagType.equals(new Integer(1))){//企业标签
return AjaxResult.success(
iWeTagGroupService.selectWeTagGroupList(
WeTagGroup.builder()
.groupTagType(1)
.build()
)
);
}
return AjaxResult.success( return AjaxResult.success(
iWeTagService.list( iWeTagService.list(
new LambdaQueryWrapper<WeTag>() new LambdaQueryWrapper<WeTag>()
...@@ -101,6 +119,7 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -101,6 +119,7 @@ public class WeCustomerPortraitController extends BaseController {
) )
); );
} }
...@@ -205,7 +224,7 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -205,7 +224,7 @@ public class WeCustomerPortraitController extends BaseController {
/** /**
* 添加或编辑轨迹 *编辑跟进动态
* @param trajectory * @param trajectory
* @return * @return
*/ */
...@@ -213,7 +232,7 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -213,7 +232,7 @@ public class WeCustomerPortraitController extends BaseController {
public AjaxResult addOrEditWaitHandle(@RequestBody WeCustomerTrajectory trajectory){ public AjaxResult addOrEditWaitHandle(@RequestBody WeCustomerTrajectory trajectory){
iWeCustomerTrajectoryService.saveOrUpdate(trajectory); iWeCustomerService.addOrEditWaitHandle(trajectory);
return AjaxResult.success(); return AjaxResult.success();
} }
...@@ -250,6 +269,19 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -250,6 +269,19 @@ public class WeCustomerPortraitController extends BaseController {
/**
* 个人朋友圈互动数据同步
* @param userId
* @return
*/
@GetMapping("/synchMomentsInteracte/{userId}")
public AjaxResult synchMomentsInteracte(@PathVariable String userId){
iWeMomentsService.synchMomentsInteracte(CollectionUtil.newArrayList(userId));
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
......
package com.linkwechat.common.enums;
import java.util.stream.Stream;
/**
* 客户添加方式
*/
public enum CustomerAddWay {
ADD_WAY_WZLY(0,"未知来源"),
ADD_WAY_SMEWM(1,"扫描二维码"),
ADD_WAY_SSSJH(2,"搜索手机号"),
ADD_WAY_MPFX(3,"名片分享"),
ADD_WAY_QL(4,"群聊"),
ADD_WAY_SJTXL(5,"手机通讯录"),
ADD_WAY_WXLXR(6,"微信联系人"),
ADD_WAY_LZWXTJHY(7,"来自微信的添加好友申请"),
ADD_WAY_KFRY(8,"安装第三方应用时自动添加的客服人员"),
ADD_WAY_SSYX(9,"搜索邮箱"),
ADD_WAY_SPHZYTJ(10,"视频号主页添加"),
ADD_WAY_LBCYGX(201,"内部成员共享"),
ADD_WAY_GLYFP(202,"管理员/负责人分配");
private Integer key;
private String val;
CustomerAddWay(Integer key,String val){
this.key=key;
this.val=val;
}
public Integer getKey() {
return key;
}
public void setKey(Integer key) {
this.key = key;
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
public static CustomerAddWay of(Integer type){
return Stream.of(values()).filter(s->s.getKey().equals(type)).findFirst().orElseGet(null);
}
}
package com.linkwechat.common.enums; package com.linkwechat.common.enums;
import java.util.stream.Stream;
public enum TrajectorySceneType { public enum TrajectorySceneType {
TRAJECTORY_TYPE_XXDT_BCZL(TrajectoryType.TRAJECTORY_TYPE_XXDT.getType(),"信息动态-补充资料",1), TRAJECTORY_TITLE_TJYG(1,"添加员工","%s通过:%s 方式添加员工:%s"),
TRAJECTORY_TYPE_XXDT_SZBQ(TrajectoryType.TRAJECTORY_TYPE_XXDT.getType(),"信息动态-设置标签",2); TRAJECTORY_TITLE_SCYG(2,"删除员工","%s删除员工%s"),
TRAJECTORY_TITLE_JRQL(3,"加入群聊","{客户名}通过{添加的方式}加入群聊{群名}"),
TRAJECTORY_TITLE_TCQL(4,"退出群聊","{客户名}退出群聊{员工名}"),
TRAJECTORY_TITLE_GXQYBQ(5,"更新企业标签","员工:%s,更新客户标签:%s"),
TRAJECTORY_TITLE_GXGRBQ(6,"更新个人标签","员工:%s,更新个人标签:%s"),
TRAJECTORY_TITLE_BJBQ(7,"编辑信息","员工:%s 编辑了:%s的详细资料"),
TRAJECTORY_TITLE_TJGJ(8,"添加更进","员工%s添加跟进:%s"),
TRAJECTORY_TITLE_DZPYQ(9,"点赞朋友圈","%s点赞了员工%s的朋友圈"),
TRAJECTORY_TITLE_PLPYQ(10,"评论朋友圈","%s评论了员工%s的朋友圈");
private String name; private String name;
private Integer type; private Integer type;
private String msgTpl;
private Integer key;
TrajectorySceneType( Integer type,String name,Integer key) { TrajectorySceneType( Integer type,String name,String msgTpl) {
this.name = name; this.name = name;
this.type = type; this.type = type;
this.key=key; this.msgTpl=msgTpl;
} }
...@@ -37,11 +48,15 @@ public enum TrajectorySceneType { ...@@ -37,11 +48,15 @@ public enum TrajectorySceneType {
this.type = type; this.type = type;
} }
public Integer getKey() { public String getMsgTpl() {
return key; return msgTpl;
}
public void setMsgTpl(String msgTpl) {
this.msgTpl = msgTpl;
} }
public void setKey(Integer key) { public static TrajectorySceneType of(Integer type){
this.key = key; return Stream.of(values()).filter(s->s.getType().equals(type)).findFirst().orElseGet(null);
} }
} }
...@@ -11,12 +11,12 @@ import java.util.stream.Stream; ...@@ -11,12 +11,12 @@ import java.util.stream.Stream;
public enum TrajectoryType { public enum TrajectoryType {
TRAJECTORY_TYPE_XXDT(1,"信息动态"), TRAJECTORY_TYPE_XXDT(1,"客户动态"),
TRAJECTORY_TYPE_SJDT(2,"社交动态"), TRAJECTORY_TYPE_SJDT(2,"员工动态"),
TRAJECTORY_TYPE_HDGZ(3,"活动规则"), TRAJECTORY_TYPE_HDGZ(3,"互动动态"),
TRAJECTORY_TYPE_DBDT(4,"待办动态"); TRAJECTORY_TYPE_DBDT(4,"跟进动态");
private String name; private String name;
......
...@@ -201,6 +201,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils ...@@ -201,6 +201,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static int getAge(Date birthDay) throws Exception { public static int getAge(Date birthDay) throws Exception {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算 if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.exception.CustomException; import com.linkwechat.common.exception.CustomException;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.wecom.annotation.SynchRecord; import com.linkwechat.wecom.annotation.SynchRecord;
import com.linkwechat.wecom.constants.SynchRecordConstants;
import com.linkwechat.wecom.domain.WeSynchRecord; import com.linkwechat.wecom.domain.WeSynchRecord;
import com.linkwechat.wecom.service.IWeSynchRecordService; import com.linkwechat.wecom.service.IWeSynchRecordService;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
...@@ -40,6 +41,7 @@ public class SynchRecordAop { ...@@ -40,6 +41,7 @@ public class SynchRecordAop {
public void doBefore(ProceedingJoinPoint joinPoint) throws Throwable { public void doBefore(ProceedingJoinPoint joinPoint) throws Throwable {
SynchRecord annotationLog = getAnnotationLog(joinPoint); SynchRecord annotationLog = getAnnotationLog(joinPoint);
if(null != annotationLog){ if(null != annotationLog){
List<WeSynchRecord> weSynchRecords = iWeSynchRecordService.list(new LambdaQueryWrapper<WeSynchRecord>() List<WeSynchRecord> weSynchRecords = iWeSynchRecordService.list(new LambdaQueryWrapper<WeSynchRecord>()
.eq(WeSynchRecord::getSynchType,annotationLog.synchType()) .eq(WeSynchRecord::getSynchType,annotationLog.synchType())
.between(WeSynchRecord::getSynchTime,DateUtils.getBeforeByHourTime(2) .between(WeSynchRecord::getSynchTime,DateUtils.getBeforeByHourTime(2)
......
...@@ -93,8 +93,23 @@ public class WeCustomerList { ...@@ -93,8 +93,23 @@ public class WeCustomerList {
private String departmentIds; private String departmentIds;
private String remark;
private String phone;
private String email;
private String address;
private String qq;
private String position;
private String corpName;
private String otherDescr;
//0正常;1:删除; //0正常;1:删除;
private Integer delFlag=new Integer(0); private Integer delFlag;
} }
...@@ -70,4 +70,7 @@ public class WeCustomerPortrait { ...@@ -70,4 +70,7 @@ public class WeCustomerPortrait {
//客户类型 1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户 //客户类型 1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户
private Integer customerType; private Integer customerType;
//跟进动态
private String content;
} }
...@@ -13,6 +13,7 @@ import lombok.experimental.SuperBuilder; ...@@ -13,6 +13,7 @@ import lombok.experimental.SuperBuilder;
import java.sql.Time; import java.sql.Time;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 活动轨迹相关 * 活动轨迹相关
...@@ -25,24 +26,16 @@ import java.util.Date; ...@@ -25,24 +26,16 @@ import java.util.Date;
public class WeCustomerTrajectory extends BaseEntity { public class WeCustomerTrajectory extends BaseEntity {
@TableId @TableId
private String id; private String id;
//轨迹类型(1:信息动态;2:社交动态;3:跟进动态;4:待办动态)
private Integer trajectoryType; private Integer trajectoryType;
//外部联系人id //外部联系人id
private String externalUserid; private String externalUserid;
//文案内容 //文案内容
private String content; private String content;
//处理日期
private Date createDate;
//处理开始时间
private String startTime;
//处理结束时间
private String endTime;
@TableField(exist = false)
private String trackContent;
//文案子内容
private String contentSub;
...@@ -53,16 +46,12 @@ public class WeCustomerTrajectory extends BaseEntity { ...@@ -53,16 +46,12 @@ public class WeCustomerTrajectory extends BaseEntity {
private String userId; private String userId;
//当前应用的id
private String agentId;
//1:跟踪中;2:待跟进;3:已拒绝;4:已成交;
//1:待跟进;2:跟进中;3:已成交;4:无意向;5:已流失
private Integer trackState; private Integer trackState;
//跟进内容
@TableField(exist = false)
private String trackContent;
//跟进时间 //跟进时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm") @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
...@@ -76,4 +65,15 @@ public class WeCustomerTrajectory extends BaseEntity { ...@@ -76,4 +65,15 @@ public class WeCustomerTrajectory extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String userName; private String userName;
@TableField(exist = false)
private List<TrajectRel> trajectRelList;
@Data
@Builder
public static class TrajectRel{
private String userId;
private String customerId;
}
} }
...@@ -93,6 +93,8 @@ public class ExternalUserDetail extends WeResultDto { ...@@ -93,6 +93,8 @@ public class ExternalUserDetail extends WeResultDto {
private String oper_userid; private String oper_userid;
/**标签**/ /**标签**/
private String[] tag_id; private String[] tag_id;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过创建「联系我」方式指定 */
private String state;
} }
} }
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
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.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.entity.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.MessageType; import com.linkwechat.common.enums.MessageType;
import com.linkwechat.common.enums.TrackState;
import com.linkwechat.common.enums.TrajectorySceneType;
import com.linkwechat.common.enums.TrajectoryType;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.callback.WeBackBaseVo; import com.linkwechat.wecom.domain.callback.WeBackBaseVo;
import com.linkwechat.wecom.domain.callback.WeBackCustomerVo; import com.linkwechat.wecom.domain.callback.WeBackCustomerVo;
import com.linkwechat.wecom.client.WeMessagePushClient; import com.linkwechat.wecom.client.WeMessagePushClient;
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.dto.WeMessagePushDto; import com.linkwechat.wecom.domain.dto.WeMessagePushDto;
import com.linkwechat.wecom.domain.dto.message.TextMessageDto; import com.linkwechat.wecom.domain.dto.message.TextMessageDto;
import com.linkwechat.wecom.factory.WeEventStrategy; import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.IWeCorpAccountService; import com.linkwechat.wecom.service.*;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeSensitiveActHitService;
import com.linkwechat.wecom.service.IWeUserService;
import lombok.extern.slf4j.Slf4j; 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;
...@@ -45,6 +43,9 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -45,6 +43,9 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeUserService weUserService; private IWeUserService weUserService;
@Autowired
private IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
@Override @Override
public void eventHandle(WeBackBaseVo message) { public void eventHandle(WeBackBaseVo message) {
WeBackCustomerVo customerInfo = (WeBackCustomerVo) message; WeBackCustomerVo customerInfo = (WeBackCustomerVo) message;
...@@ -57,30 +58,48 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -57,30 +58,48 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
} }
WeCustomer customer = new WeCustomer(); WeCustomer customer = new WeCustomer();
customer.setDelFlag(1); customer.setDelFlag(1);
weCustomerService.update(customer,new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getFirstUserId,customerInfo.getUserID()) customer.setTrackState(TrackState.STATE_YLS.getType());
.eq(WeCustomer::getExternalUserid,customerInfo.getExternalUserID()).eq(WeCustomer::getDelFlag,0)); if(weCustomerService.update(customer,new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getFirstUserId,customerInfo.getUserID())
.eq(WeCustomer::getExternalUserid,customerInfo.getExternalUserID()).eq(WeCustomer::getDelFlag,0))){
WeCorpAccount validWeCorpAccount = weCorpAccountService.findValidWeCorpAccount();
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch(); //添加跟进动态
if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) { iWeCustomerTrajectoryService.createTrajectory( ListUtil.toList(WeCustomerTrajectory.TrajectRel.builder()
String content = "您已经被客户@" + weCustomer.getCustomerName() + "删除!"; .customerId(weCustomer.getExternalUserid())
TextMessageDto textMessageDto = new TextMessageDto(); .userId(weCustomer.getFirstUserId())
textMessageDto.setContent(content); .build()), TrajectoryType.TRAJECTORY_TYPE_XXDT.getType(), TrajectorySceneType.TRAJECTORY_TITLE_SCYG.getType(),null,
WeMessagePushDto weMessagePushDto = new WeMessagePushDto(); null
weMessagePushDto.setMsgtype(MessageType.TEXT.getMessageType()); );
weMessagePushDto.setTouser(customerInfo.getUserID());
weMessagePushDto.setText(textMessageDto); WeCorpAccount validWeCorpAccount = weCorpAccountService.findValidWeCorpAccount();
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> { String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
weMessagePushDto.setAgentid(Integer.valueOf(agentId)); if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) {
}); String content = "您已经被客户@" + weCustomer.getCustomerName() + "删除!";
TextMessageDto textMessageDto = new TextMessageDto();
weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString()); textMessageDto.setContent(content);
} WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
}); weMessagePushDto.setMsgtype(MessageType.TEXT.getMessageType());
weMessagePushDto.setTouser(customerInfo.getUserID());
extracted(message, customerInfo, weCustomer); weMessagePushDto.setText(textMessageDto);
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> {
weMessagePushDto.setAgentid(Integer.valueOf(agentId));
});
weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString());
}
});
extracted(message, customerInfo, weCustomer);
}
} }
} catch (Exception e) { } catch (Exception e) {
log.error("删除跟进成员事件>>>>>>>>>>>>>param:{},ex:{}", JSONObject.toJSONString(message), e); log.error("删除跟进成员事件>>>>>>>>>>>>>param:{},ex:{}", JSONObject.toJSONString(message), e);
......
...@@ -41,19 +41,22 @@ public class WeCallBackUpdateGroupImpl extends WeEventStrategy { ...@@ -41,19 +41,22 @@ public class WeCallBackUpdateGroupImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeGroupMemberService groupMemberService; private IWeGroupMemberService groupMemberService;
@Override @Override
public void eventHandle(WeBackBaseVo message) { public void eventHandle(WeBackBaseVo message) {
WeBackCustomerGroupVo customerGroupInfo = (WeBackCustomerGroupVo) message; WeBackCustomerGroupVo customerGroupInfo = (WeBackCustomerGroupVo) message;
try { try {
weGroupService.updateWeGroup(customerGroupInfo.getChatId()); weGroupService.updateWeGroup(customerGroupInfo.getChatId());
String updateDetail = customerGroupInfo.getUpdateDetail(); String updateDetail = customerGroupInfo.getUpdateDetail();
if (updateDetail.equals(CallbackEventUpdateDetail.ADD_MEMBER.getType())) { if (updateDetail.equals(CallbackEventUpdateDetail.ADD_MEMBER.getType())) { //成员入群
// 添加成员,该群的实际群活码扫码次数需要加1 // 添加成员,该群的实际群活码扫码次数需要加1
groupCodeActualService.updateScanTimesByChatId(customerGroupInfo.getChatId()); groupCodeActualService.updateScanTimesByChatId(customerGroupInfo.getChatId());
ThreadUtil.execAsync(() ->{ ThreadUtil.execAsync(() ->{
groupFissionEnterCheck(customerGroupInfo.getChatId()); groupFissionEnterCheck(customerGroupInfo.getChatId());
}); });
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("update>>>>>>>>>param:{},ex:{}",customerGroupInfo.getChatId(),e); log.error("update>>>>>>>>>param:{},ex:{}",customerGroupInfo.getChatId(),e);
......
...@@ -136,4 +136,11 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -136,4 +136,11 @@ public interface IWeCustomerService extends IService<WeCustomer>
long noRepeatCountCustomer(WeCustomerList weCustomerList); long noRepeatCountCustomer(WeCustomerList weCustomerList);
/**
* 客户跟进记录
* @param trajectory
*/
void addOrEditWaitHandle(WeCustomerTrajectory trajectory);
} }
...@@ -3,15 +3,16 @@ package com.linkwechat.wecom.service; ...@@ -3,15 +3,16 @@ package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeCustomerTrajectory; import com.linkwechat.wecom.domain.WeCustomerTrajectory;
import io.lettuce.core.dynamic.annotation.Param; import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
public interface IWeCustomerTrajectoryService extends IService<WeCustomerTrajectory> { public interface IWeCustomerTrajectoryService extends IService<WeCustomerTrajectory> {
void waitHandleMsg(String url);
void inforMationNews(String userId,String externalUserid,Integer trajectoryType);
void deleteSynchTrajectory(); void deleteSynchTrajectory();
...@@ -19,4 +20,7 @@ public interface IWeCustomerTrajectoryService extends IService<WeCustomerTraject ...@@ -19,4 +20,7 @@ public interface IWeCustomerTrajectoryService extends IService<WeCustomerTraject
List<WeCustomerTrajectory> followUpRecord(String externalUserid, List<WeCustomerTrajectory> followUpRecord(String externalUserid,
String userId,Integer trajectoryType); String userId,Integer trajectoryType);
void createTrajectory(List<WeCustomerTrajectory.TrajectRel> trajectRels,Integer trajectoryType,Integer trajectorySence,String others,Integer trackState);
} }
...@@ -145,9 +145,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -145,9 +145,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>(); List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
List<WeCustomerTrajectory> trajectories=new ArrayList<>();
List<WeUser> weUsers = iWeUserService.list();
list.forEach(userDetail -> { list.forEach(userDetail -> {
...@@ -158,20 +155,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -158,20 +155,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setCustomerName(userDetail.getExternal_contact().getName()); weCustomer.setCustomerName(userDetail.getExternal_contact().getName());
weCustomer.setDelFlag(new Integer(0)); weCustomer.setDelFlag(new Integer(0));
Optional.ofNullable(userDetail.getFollow_info()).ifPresent(followInfo -> { Optional.ofNullable(userDetail.getFollow_info()).ifPresent(followInfo -> {
trajectories.add( weCustomer.setState(followInfo.getState());
WeCustomerTrajectory.builder()
.trajectoryType(TrajectoryType.TRAJECTORY_TYPE_DBDT.getType())
.externalUserid(weCustomer.getExternalUserid())
.trackState(TrackState.STATE_DGJ.getType())
.isSynch(false)
.content("待跟进状态")
.title("同步客户设置跟进状态")
.trackTime(new Date(followInfo.getCreatetime() * 1000L))
.userId(followInfo.getUserid())
.build()
);
weCustomer.setFirstUserId(followInfo.getUserid()); weCustomer.setFirstUserId(followInfo.getUserid());
weCustomer.setFirstAddTime(new Date(followInfo.getCreatetime() * 1000L)); weCustomer.setFirstAddTime(new Date(followInfo.getCreatetime() * 1000L));
weCustomer.setAddMethod(followInfo.getAdd_way()); weCustomer.setAddMethod(followInfo.getAdd_way());
...@@ -195,16 +179,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -195,16 +179,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}); });
if(CollectionUtil.isNotEmpty(trajectories)){
iWeCustomerTrajectoryService.deleteSynchTrajectory();
List<List<WeCustomerTrajectory>> traJectorys = Lists.partition(trajectories, 500);
for(List<WeCustomerTrajectory> traJectory: traJectorys){
//清空状态为等待跟进的数据
iWeCustomerTrajectoryService.saveBatch(traJectory);
}
}
if (CollectionUtil.isNotEmpty(weFlowerCustomerTagRels)) { if (CollectionUtil.isNotEmpty(weFlowerCustomerTagRels)) {
List<List<WeFlowerCustomerTagRel>> tagRels = Lists.partition(weFlowerCustomerTagRels, 500); List<List<WeFlowerCustomerTagRel>> tagRels = Lists.partition(weFlowerCustomerTagRels, 500);
...@@ -434,6 +408,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -434,6 +408,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
public void makeLabel(WeMakeCustomerTag weMakeCustomerTag) { public void makeLabel(WeMakeCustomerTag weMakeCustomerTag) {
List<WeTag> addTag = weMakeCustomerTag.getAddTag(); List<WeTag> addTag = weMakeCustomerTag.getAddTag();
List<WeTag> lodAddTag = weMakeCustomerTag.getAddTag();
if(CollectionUtil.isNotEmpty(addTag)){ if(CollectionUtil.isNotEmpty(addTag)){
//校验是否有标签在库里不存在 //校验是否有标签在库里不存在
...@@ -448,6 +423,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -448,6 +423,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}else{ }else{
new WeComException("部门标签不存在"); new WeComException("部门标签不存在");
} }
lodAddTag=weTagList;
CutomerTagEdit cutomerTagEdit = CutomerTagEdit.builder() CutomerTagEdit cutomerTagEdit = CutomerTagEdit.builder()
.external_userid(weMakeCustomerTag.getExternalUserid()) .external_userid(weMakeCustomerTag.getExternalUserid())
.userid(weMakeCustomerTag.getUserId()) .userid(weMakeCustomerTag.getUserId())
...@@ -498,6 +475,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -498,6 +475,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
); );
} }
}else{//为空,取消当前客户所有标签 }else{//为空,取消当前客户所有标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>() List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()) .eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
...@@ -521,6 +502,23 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -521,6 +502,23 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
} }
} }
} }
iWeCustomerTrajectoryService.createTrajectory(
ListUtil.toList(WeCustomerTrajectory.TrajectRel.builder()
.customerId(weMakeCustomerTag.getExternalUserid())
.userId(weMakeCustomerTag.getUserId())
.build()),TrajectoryType.TRAJECTORY_TYPE_SJDT.getType(),
weMakeCustomerTag.getIsCompanyTag()?
TrajectorySceneType.TRAJECTORY_TITLE_GXQYBQ.getType():
TrajectorySceneType.TRAJECTORY_TITLE_GXGRBQ.getType(),
CollectionUtil.isNotEmpty(lodAddTag)?
String.join(",",lodAddTag.stream().map(WeTag::getName).collect(Collectors.toList())):"暂无标签",null);
} }
...@@ -560,11 +558,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -560,11 +558,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setCustomerName(externalUserDetail.getExternal_contact().getName()); weCustomer.setCustomerName(externalUserDetail.getExternal_contact().getName());
weCustomer.setCustomerType(externalUserDetail.getExternal_contact().getType()); weCustomer.setCustomerType(externalUserDetail.getExternal_contact().getType());
weCustomer.setDelFlag(new Integer(0)); weCustomer.setDelFlag(new Integer(0));
List<ExternalUserDetail.FollowUser> follow_user = externalUserDetail.getFollow_user(); List<ExternalUserDetail.FollowUser> follow_user = externalUserDetail.getFollow_user();
if(CollectionUtil.isNotEmpty(follow_user)){ if(CollectionUtil.isNotEmpty(follow_user)){
ExternalUserDetail.FollowUser followUser = follow_user.stream().filter(e -> e.getUserid().equals(userId)).findFirst().get(); ExternalUserDetail.FollowUser followUser = follow_user.stream().filter(e -> e.getUserid().equals(userId)).findFirst().get();
if(null != followUser){ if(null != followUser){
weCustomer.setState(followUser.getState());
weCustomer.setFirstAddTime(new Date(followUser.getCreatetime() * 1000L)); weCustomer.setFirstAddTime(new Date(followUser.getCreatetime() * 1000L));
weCustomer.setAddMethod(followUser.getAddWay()); weCustomer.setAddMethod(followUser.getAddWay());
this.baseMapper.batchAddOrUpdate( this.baseMapper.batchAddOrUpdate(
...@@ -587,6 +587,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -587,6 +587,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}); });
iWeFlowerCustomerTagRelService.batchAddOrUpdate(tagRels); iWeFlowerCustomerTagRelService.batchAddOrUpdate(tagRels);
} }
//生成轨迹
iWeCustomerTrajectoryService.createTrajectory(ListUtil.toList(
WeCustomerTrajectory.TrajectRel.builder()
.userId(externalUserid)
.customerId(externalUserid)
.build()
),TrajectoryType.TRAJECTORY_TYPE_XXDT.getType(),TrajectorySceneType.TRAJECTORY_TITLE_TJYG.getType(),
CustomerAddWay.of(followUser.getAddWay()).getVal()
,null);
} }
} }
} }
...@@ -650,12 +662,19 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -650,12 +662,19 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setOtherDescr(weCustomerPortrait.getDescription()); weCustomer.setOtherDescr(weCustomerPortrait.getDescription());
this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>() if(this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId,weCustomerPortrait.getUserId()) .eq(WeCustomer::getFirstUserId,weCustomerPortrait.getUserId())
.eq(WeCustomer::getExternalUserid,weCustomerPortrait.getExternalUserid())); .eq(WeCustomer::getExternalUserid,weCustomerPortrait.getExternalUserid()))){
//添加轨迹内容(信息动态) iWeCustomerTrajectoryService.createTrajectory( ListUtil.toList(WeCustomerTrajectory.TrajectRel.builder()
iWeCustomerTrajectoryService.inforMationNews(weCustomerPortrait.getUserId(),weCustomerPortrait.getExternalUserid(), TrajectorySceneType.TRAJECTORY_TYPE_XXDT_BCZL.getKey()); .customerId(weCustomer.getExternalUserid())
.userId(weCustomer.getFirstUserId())
.build()),TrajectoryType.TRAJECTORY_TYPE_SJDT.getType(),TrajectorySceneType.TRAJECTORY_TITLE_BJBQ.getType(),null,null);
}
// //添加轨迹内容(信息动态)
// iWeCustomerTrajectoryService.inforMationNews(weCustomerPortrait.getUserId(),weCustomerPortrait.getExternalUserid(), TrajectorySceneType.TRAJECTORY_TYPE_XXDT_BCZL.getKey());
} }
...@@ -677,6 +696,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -677,6 +696,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomerList.stream().findFirst().get() weCustomerList.stream().findFirst().get()
); );
List<WeCustomerDetail.TrackUser> trackUsers=new ArrayList<>(); List<WeCustomerDetail.TrackUser> trackUsers=new ArrayList<>();
weCustomerList.stream().forEach(k->{ weCustomerList.stream().forEach(k->{
trackUsers.add(WeCustomerDetail.TrackUser.builder() trackUsers.add(WeCustomerDetail.TrackUser.builder()
.addMethod(k.getAddMethod()) .addMethod(k.getAddMethod())
...@@ -837,4 +857,40 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -837,4 +857,40 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
} }
/**
* 客户跟进记录
* @param trajectory
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void addOrEditWaitHandle(WeCustomerTrajectory trajectory) {
WeCustomer weCustomer = this.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid, trajectory.getExternalUserid())
.eq(WeCustomer::getFirstUserId, trajectory.getUserId()));
if(weCustomer != null){
weCustomer.setTrackState(trajectory.getTrackState());
weCustomer.setTrackContent(trajectory.getContent());
weCustomer.setTrackTime(new Date());
if(this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getFirstUserId,
weCustomer.getFirstUserId())
.eq(WeCustomer::getExternalUserid,weCustomer.getExternalUserid()))){
iWeCustomerTrajectoryService.createTrajectory(
ListUtil.toList(WeCustomerTrajectory.TrajectRel.builder()
.customerId(trajectory.getExternalUserid())
.userId(trajectory.getUserId())
.build()),TrajectoryType.TRAJECTORY_TYPE_DBDT.getType(),
TrajectorySceneType.TRAJECTORY_TITLE_TJGJ.getType(),trajectory.getContent(),trajectory.getTrackState());
}
}
}
} }
...@@ -10,6 +10,7 @@ import com.linkwechat.common.enums.TrajectorySceneType; ...@@ -10,6 +10,7 @@ import com.linkwechat.common.enums.TrajectorySceneType;
import com.linkwechat.common.enums.TrajectoryType; import com.linkwechat.common.enums.TrajectoryType;
import com.linkwechat.wecom.client.WeMessagePushClient; import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeCustomerList;
import com.linkwechat.wecom.domain.WeCustomerTrajectory; import com.linkwechat.wecom.domain.WeCustomerTrajectory;
import com.linkwechat.wecom.domain.WeUser; import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.dto.WeMessagePushDto; import com.linkwechat.wecom.domain.dto.WeMessagePushDto;
...@@ -17,13 +18,15 @@ import com.linkwechat.wecom.domain.dto.message.TextMessageDto; ...@@ -17,13 +18,15 @@ import com.linkwechat.wecom.domain.dto.message.TextMessageDto;
import com.linkwechat.wecom.mapper.WeCustomerMapper; import com.linkwechat.wecom.mapper.WeCustomerMapper;
import com.linkwechat.wecom.mapper.WeCustomerTrajectoryMapper; import com.linkwechat.wecom.mapper.WeCustomerTrajectoryMapper;
import com.linkwechat.wecom.mapper.WeUserMapper; import com.linkwechat.wecom.mapper.WeUserMapper;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeCustomerTrajectoryService; import com.linkwechat.wecom.service.IWeCustomerTrajectoryService;
import com.linkwechat.wecom.service.IWeUserService; import com.linkwechat.wecom.service.IWeUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -31,82 +34,16 @@ public class WeCustomerTrajectoryServiceImpl extends ServiceImpl<WeCustomerTraje ...@@ -31,82 +34,16 @@ public class WeCustomerTrajectoryServiceImpl extends ServiceImpl<WeCustomerTraje
@Autowired
private WeMessagePushClient weMessagePushClient;
//
//
//// @Autowired
//// private IWeCustomerService iWeCustomerService;
//
@Autowired
private WeCustomerMapper weCustomerMapper;
//
//
//
// @Autowired
// private IWeUserService iWeUserService;
@Autowired
private WeUserMapper weUserMapper;
/** @Autowired
* 待办理处理通知 private IWeUserService iWeUserService;
*/
@Override
public void waitHandleMsg(String url) {
//获取所有满足时间的通知
List<WeCustomerTrajectory> trajectories = this.list(new LambdaQueryWrapper<WeCustomerTrajectory>()
.ne(WeCustomerTrajectory::getStatus, Constants.DELETE_CODE)
.last(" AND concat_ws(' ',create_date,start_time) <= DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s')" +
" AND concat_ws(' ',create_date,end_time) >= DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s')"));
if(CollectionUtil.isNotEmpty(trajectories)){
List<WeCustomer> weCustomers = weCustomerMapper.selectBatchIds(
trajectories.stream().map(WeCustomerTrajectory::getExternalUserid).collect(Collectors.toList())
);
Map<String, WeCustomer> weCustomerMap
= weCustomers.stream().collect(Collectors.toMap(WeCustomer::getExternalUserid, a -> a, (k1, k2) -> k1));
//给员工发送通知
trajectories.stream().forEach(k->{
weMessagePushClient.sendMessageToUser(WeMessagePushDto.builder()
.touser(k.getUserId())
.msgtype(MessageType.TEXT.getMessageType())
.agentid(Integer.parseInt(k.getAgentId()))
.text(TextMessageDto.builder()
.content("您有一项关于客户"+weCustomerMap.get(k.getExternalUserid()).getCustomerName()+"的待办任务提醒,请尽快处理,\n<a href="+url+">点击查看客户详情。</a>")
.build())
.build(),
String.valueOf(1000012)
);
});
} @Autowired
} @Lazy
private IWeCustomerService iWeCustomerService;
/**
* 信息动态编辑
* @param userId
* @param externalUserid
* @param trajectoryType
*/
@Override
public void inforMationNews(String userId, String externalUserid, Integer trajectoryType) {
WeUser weUser = weUserMapper.selectById(userId);
if(null != weUser){
this.save(
WeCustomerTrajectory.builder()
.externalUserid(externalUserid)
.trajectoryType(TrajectoryType.TRAJECTORY_TYPE_XXDT.getType())
.createTime(new DateTime())
.userId(userId)
.content(
TrajectorySceneType.TRAJECTORY_TYPE_XXDT_BCZL.getKey().equals(trajectoryType)?
"员工"+weUser.getName()+"编辑了当前客户信息":"员工"+weUser.getName()+"编辑了当前客户标签"
).build()
);
}
}
@Override @Override
public void deleteSynchTrajectory() { public void deleteSynchTrajectory() {
...@@ -119,4 +56,91 @@ public class WeCustomerTrajectoryServiceImpl extends ServiceImpl<WeCustomerTraje ...@@ -119,4 +56,91 @@ public class WeCustomerTrajectoryServiceImpl extends ServiceImpl<WeCustomerTraje
} }
/***
* 构建轨迹
* @param trajectRels 员工客户构建关系列表
* @param trajectoryType 轨迹类型
* @param trajectorySence 轨迹场景,落实到标签
* @param others 其他附加条件,比如多个标签,逗号隔开等
*/
@Override
@Async
public void createTrajectory(List<WeCustomerTrajectory.TrajectRel> trajectRels, Integer trajectoryType, Integer trajectorySence,String others,Integer trackState) {
List<WeCustomerTrajectory> trajectories=new ArrayList<>();
trajectRels.stream().forEach(k->{
WeCustomerTrajectory trajectory = WeCustomerTrajectory.builder()
.externalUserid(k.getCustomerId())
.trajectoryType(trajectoryType)
.title(TrajectorySceneType.of(trajectorySence).getName())
.trackTime(new Date())
.userId(k.getUserId())
.trackState(trackState)
.build();
if(TrajectorySceneType.TRAJECTORY_TITLE_TJYG.getType().equals(trajectorySence)
||TrajectorySceneType.TRAJECTORY_TITLE_SCYG.getType().equals(trajectorySence)
||TrajectorySceneType.TRAJECTORY_TITLE_DZPYQ.getType().equals(trajectorySence)
||TrajectorySceneType.TRAJECTORY_TITLE_PLPYQ.getType().equals(trajectorySence)
||TrajectorySceneType.TRAJECTORY_TITLE_BJBQ.getType().equals(trajectorySence)){
trajectory.setContent(
String.format(TrajectorySceneType.of(trajectorySence).getMsgTpl(),
iWeUserService.getById(k.getUserId()).getName(),
iWeCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId, k.getUserId())
.eq(WeCustomer::getExternalUserid, k.getCustomerId())).getCustomerName())
);
} else if(TrajectorySceneType.TRAJECTORY_TITLE_GXQYBQ.getType().equals(trajectorySence)
||TrajectorySceneType.TRAJECTORY_TITLE_GXGRBQ.getType().equals(trajectorySence)
||TrajectorySceneType.TRAJECTORY_TITLE_TJGJ.getType().equals(trajectorySence)){
trajectory.setContent(
String.format(TrajectorySceneType.of(trajectorySence).getMsgTpl(),
iWeUserService.getById(k.getUserId()).getName(),
others)
);
}else if(TrajectorySceneType.TRAJECTORY_TITLE_SCYG.getType().equals(trajectorySence)){
trajectory.setContent(
String.format(TrajectorySceneType.of(trajectorySence).getMsgTpl(),
iWeCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId, k.getUserId())
.eq(WeCustomer::getExternalUserid, k.getCustomerId())).getCustomerName()
, iWeUserService.getById(k.getUserId()).getName())
);
}else if(TrajectorySceneType.TRAJECTORY_TITLE_TJYG.getType().equals(trajectorySence)){
trajectory.setContent(
String.format(TrajectorySceneType.of(trajectorySence).getMsgTpl(),
iWeCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId, k.getUserId())
.eq(WeCustomer::getExternalUserid, k.getCustomerId())).getCustomerName(),
others,
iWeUserService.getById(k.getUserId()).getName())
);
}
trajectories.add(
trajectory
);
});
if(CollectionUtil.isNotEmpty(trajectories)){
this.deleteSynchTrajectory();
this.saveBatch(trajectories);
}
}
} }
...@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.MediaType; import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.enums.TrajectorySceneType;
import com.linkwechat.common.enums.TrajectoryType;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
...@@ -16,20 +18,14 @@ import com.linkwechat.common.utils.Threads; ...@@ -16,20 +18,14 @@ import com.linkwechat.common.utils.Threads;
import com.linkwechat.wecom.annotation.SynchRecord; import com.linkwechat.wecom.annotation.SynchRecord;
import com.linkwechat.wecom.client.WeMomentsClient; import com.linkwechat.wecom.client.WeMomentsClient;
import com.linkwechat.wecom.constants.SynchRecordConstants; import com.linkwechat.wecom.constants.SynchRecordConstants;
import com.linkwechat.wecom.domain.WeAllocateCustomer; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.WeMoments;
import com.linkwechat.wecom.domain.WeMomentsInteracte;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.WeResultDto; import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail; import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail;
import com.linkwechat.wecom.domain.dto.customer.FollowUserList; import com.linkwechat.wecom.domain.dto.customer.FollowUserList;
import com.linkwechat.wecom.domain.dto.moments.*; import com.linkwechat.wecom.domain.dto.moments.*;
import com.linkwechat.wecom.mapper.WeMomentsMapper; import com.linkwechat.wecom.mapper.WeMomentsMapper;
import com.linkwechat.wecom.service.IWeMaterialService; import com.linkwechat.wecom.service.*;
import com.linkwechat.wecom.service.IWeMomentsService;
import com.linkwechat.wecom.service.IWeUserService;
import com.linkwechat.wecom.service.WeMomentsInteracteService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
...@@ -63,6 +59,9 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments ...@@ -63,6 +59,9 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
@Autowired @Autowired
WeMomentsInteracteService weMomentsInteracteService; WeMomentsInteracteService weMomentsInteracteService;
@Autowired
IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
...@@ -322,7 +321,6 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments ...@@ -322,7 +321,6 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
* @param userIds * @param userIds
*/ */
@Override @Override
@SynchRecord(synchType = SynchRecordConstants.SYNCH_MOMENTS_INTERACTE)
public void synchMomentsInteracte(List<String> userIds) { public void synchMomentsInteracte(List<String> userIds) {
SecurityContext securityContext = SecurityContextHolder.getContext(); SecurityContext securityContext = SecurityContextHolder.getContext();
...@@ -341,14 +339,48 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments ...@@ -341,14 +339,48 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
.eq(WeMoments::getDelFlag, WeConstans.WE_SUCCESS_CODE)); .eq(WeMoments::getDelFlag, WeConstans.WE_SUCCESS_CODE));
if(CollectionUtil.isNotEmpty(weMoments)){ if(CollectionUtil.isNotEmpty(weMoments)){
List<WeMomentsInteracte> interactes=new ArrayList<>(); List<WeMomentsInteracte> interactes=new ArrayList<>();
//点赞集合
List<WeCustomerTrajectory.TrajectRel> dzTrajectrels=new ArrayList<>();
List<WeCustomerTrajectory.TrajectRel> plTrajectrels=new ArrayList<>();
weMoments.stream().forEach(moment->{ weMoments.stream().forEach(moment->{
interactes.addAll( interactes.addAll(
getInteracte(moment.getMomentId(), moment.getCreator()) getInteracte(moment.getMomentId(), moment.getCreator())
); );
interactes.stream().forEach(k->{
WeCustomerTrajectory.TrajectRel trajectRel = WeCustomerTrajectory.TrajectRel.builder()
.userId(moment.getCreator())
.build();
if(k.getInteracteUserType().equals(new Integer(1))){//客户
trajectRel.setCustomerId(k.getInteracteUserId());
}
if(k.getInteracteType().equals(new Integer(0))){//评论
plTrajectrels.add(trajectRel);
}else{//点赞
dzTrajectrels.add(trajectRel);
}
});
}); });
if(CollectionUtil.isNotEmpty(interactes)){ if(CollectionUtil.isNotEmpty(interactes)){
weMomentsInteracteService.batchAddOrUpdate(interactes); weMomentsInteracteService.batchAddOrUpdate(interactes);
} }
if(CollectionUtil.isNotEmpty(dzTrajectrels)){//点赞
iWeCustomerTrajectoryService.createTrajectory(dzTrajectrels, TrajectoryType.TRAJECTORY_TYPE_HDGZ.getType(), TrajectorySceneType.TRAJECTORY_TITLE_DZPYQ.getType(),null,null);
}
if(CollectionUtil.isNotEmpty(plTrajectrels)){//评论
iWeCustomerTrajectoryService.createTrajectory(plTrajectrels, TrajectoryType.TRAJECTORY_TYPE_HDGZ.getType(), TrajectorySceneType.TRAJECTORY_TITLE_PLPYQ.getType(),null,null);
}
} }
......
...@@ -21,7 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -21,7 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wc.first_add_time, wc.first_add_time,
wc.birthday, wc.birthday,
wc.gender, wc.gender,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id in (wu.department)) as departmentName (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id in (wu.department)) as departmentName,
wc.phone,
wc.email,
wc.address,
wc.qq,
wc.position,
wc.corp_name as corpName,
wc.other_descr as otherDescr
FROM FROM
we_customer wc we_customer wc
LEFT JOIN we_user wu ON wc.first_user_id=wu.user_id LEFT JOIN we_user wu ON wc.first_user_id=wu.user_id
...@@ -126,7 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -126,7 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP_CONCAT(if(wt.tag_type=1,wt.`tag_id`,null )) as tagIds, GROUP_CONCAT(if(wt.tag_type=1,wt.`tag_id`,null )) as tagIds,
GROUP_CONCAT(if(wt.tag_type=1,wt.`name`,null )) as tagNames, GROUP_CONCAT(if(wt.tag_type=1,wt.`name`,null )) as tagNames,
GROUP_CONCAT(if(wt.tag_type=3,wt.`tag_id`,null )) as personTagIds, GROUP_CONCAT(if(wt.tag_type=3,wt.`tag_id`,null )) as personTagIds,
GROUP_CONCAT(if(wt.tag_type=3,wt.`name`,null )) as personTagNames GROUP_CONCAT(if(wt.tag_type=3,wt.`name`,null )) as personTagNames,
wc.track_content as content
FROM FROM
we_customer wc we_customer wc
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.user_id = wc.first_user_id AND wfcrf.del_flag=0 LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.user_id = wc.first_user_id AND wfcrf.del_flag=0
...@@ -201,12 +209,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -201,12 +209,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
address, address,
phone, phone,
add_method, add_method,
del_flag del_flag,
state
) values ) values
<foreach collection="weCustomers" item="item" index="index" separator=","> <foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.customerName},#{item.avatar},#{item.customerType},#{item.gender}, #{item.unionid},#{item.birthday}, (#{item.externalUserid},#{item.customerName},#{item.avatar},#{item.customerType},#{item.gender}, #{item.unionid},#{item.birthday},
#{item.corpName},#{item.position},#{item.isOpenChat}, #{item.createTime}, #{item.corpName},#{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.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod},#{item.delFlag},
#{item.state}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
...@@ -226,7 +236,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -226,7 +236,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
address=IF(we_customer.address != null, VALUES(address), we_customer.address), address=IF(we_customer.address != null, VALUES(address), we_customer.address),
phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone), phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone),
add_method=IF(we_customer.add_method != null, we_customer.add_method, VALUES(add_method)), add_method=IF(we_customer.add_method != null, we_customer.add_method, VALUES(add_method)),
del_flag=IF(we_customer.del_flag != null, we_customer.del_flag, VALUES(del_flag)); del_flag=IF(we_customer.del_flag != null, we_customer.del_flag, VALUES(del_flag)),
state=IF(we_customer.state != null and we_customer.state !='',we_customer.state, VALUES(state));
</insert> </insert>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<select id="followUpRecord" resultType="com.linkwechat.wecom.domain.WeCustomerTrajectory"> <select id="followUpRecord" resultType="com.linkwechat.wecom.domain.WeCustomerTrajectory">
SELECT SELECT
wct.content as trackContent, wct.content as trackContent,
wct.content,
wu.user_id, wu.user_id,
wu.user_name, wu.user_name,
wct.track_time, wct.track_time,
......
...@@ -194,15 +194,15 @@ ...@@ -194,15 +194,15 @@
<select id="findWeUserByCutomerId" resultType="com.linkwechat.wecom.domain.WeCustomerAddUser"> <select id="findWeUserByCutomerId" resultType="com.linkwechat.wecom.domain.WeCustomerAddUser">
SELECT SELECT
wu.user_name, wu.user_name,
wu.user_id, wu.user_id,
wu.head_image_url, wu.head_image_url,
wfcr.create_time wc.first_add_time as createTime
FROM FROM
`we_flower_customer_rel` wfcr we_customer wc
INNER JOIN we_user wu ON wfcr.user_id = wu.user_id INNER JOIN we_user wu ON wc.first_user_id = wu.user_id
WHERE wfcr.external_userid=#{externalUserid} WHERE wc.external_userid=#{externalUserid}
</select> </select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!