修复朋友圈等bug

1 parent 3aeee9fa
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.wecom.domain.WeCustomerPortrait;
import com.linkwechat.wecom.domain.WeCustomerTrajectory;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.service.*;
import org.aspectj.weaver.loadtime.Aj;
......@@ -36,6 +35,10 @@ public class WeCustomerPortraitController extends BaseController {
@Autowired
private IWeTagService iWeTagService;
@Autowired
private IWeUserService iWeUserService;
......@@ -81,24 +84,66 @@ public class WeCustomerPortraitController extends BaseController {
/**
* 获取当前系统所有可用标签
* @param groupTagType 标签分组类型(1:客户标签;2:群标签)
* @param userId 员工id
* @return
*/
@GetMapping(value = "/findAllTags")
public AjaxResult findAllTags(){
public AjaxResult findAllTags(Integer groupTagType,String userId){
return AjaxResult.success(
weTagGroupService.selectWeTagGroupList(
WeTagGroup.builder()
.groupTagType(groupTagType)
.owner(userId)
.build()
)
);
}
/**
* 客户画像个人标签库新增
* @param weTagGroup
* @return
*/
@PostMapping("/addOrUpdatePersonTags")
public AjaxResult addOrUpdatePersonTags(@RequestBody WeTagGroup weTagGroup){
if(weTagGroupService.saveOrUpdate(weTagGroup)){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
weTags.stream().forEach(k->{
k.setGroupId(weTagGroup.getGroupId());
k.setTagType(new Integer(3));
});
iWeTagService.saveOrUpdateBatch(weTags);
}
}
return AjaxResult.success();
}
/**
* 个人标签删除
* @param ids
* @return
*/
@DeleteMapping("/deletePersonTag/{ids}")
public AjaxResult deletePersonTag(@PathVariable String[] ids){
iWeTagService.removeByIds(CollectionUtil.newArrayList(ids));
return AjaxResult.success();
}
/**
* 更新客户画像标签
* @param weMakeCustomerTag
* @return
......
......@@ -32,6 +32,7 @@ public class WeMetaObjectHandler implements MetaObjectHandler {
String userName = getUserName();
this.setFieldValByName(CREATE_BY, userName, metaObject);
this.setFieldValByName(UPDATE_BY, userName, metaObject);
}
@Override
......@@ -43,6 +44,7 @@ public class WeMetaObjectHandler implements MetaObjectHandler {
}
private String getUserName() {
String userName;
try {
userName = SecurityUtils.getUsername();
......
......@@ -57,4 +57,17 @@ public class WeCustomerPortrait {
private String tagIds;
//个人标签名
private String personTagNames;
//个人标签id
private String personTagIds;
//当前跟进状态:1:待跟进;2:跟进中;3:已成交;4:无意向;5:已流失
private Integer trackState;
//客户类型 1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户
private Integer customerType;
}
......@@ -53,4 +53,7 @@ public class WeFlowerCustomerTagRel
@TableLogic
private Integer delFlag;
//是否是企业标签:1:是;0:否
private Boolean isCompanyTag;
}
......@@ -44,6 +44,9 @@ public class WeTag implements Serializable
private Integer delFlag;
private Integer tagType;
......
......@@ -54,12 +54,12 @@ public class WeTagGroup extends BaseEntity
private Integer delFlag;
/**标签分组类型(1:客户标签;2:群标签)*/
/**标签分组类型(1:企业客户标签;2:群标签;3:个人标签)*/
private Integer groupTagType;
/**所属人*/
private String owner;
......
......@@ -21,5 +21,7 @@ public class WeMakeCustomerTag {
private String externalUserid;
private String userId;
private List<WeTag> addTag;
//是否是企业标签true是;false:不是
private Boolean isCompanyTag=true;
}
......@@ -433,6 +433,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
List<WeFlowerCustomerTagRel> tagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
.eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId())
.eq(WeFlowerCustomerTagRel::getIsCompanyTag,weMakeCustomerTag.getIsCompanyTag())
.eq(WeFlowerCustomerTagRel::getDelFlag,WeConstans.WE_SUCCESS_CODE)
.notIn(WeFlowerCustomerTagRel::getTagId, addTag.stream().map(WeTag::getTagId).collect(Collectors.toList()))
);
if(CollectionUtil.isNotEmpty(tagRels)){
......@@ -441,6 +443,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
.eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId())
.eq(WeFlowerCustomerTagRel::getIsCompanyTag,weMakeCustomerTag.getIsCompanyTag())
.notIn(WeFlowerCustomerTagRel::getTagId, addTag.stream().map(WeTag::getTagId).collect(Collectors.toList())
))){
cutomerTagEdit.setRemove_tag(
......@@ -454,17 +457,21 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
newTagRels.add(
WeFlowerCustomerTagRel.builder()
.userId(weMakeCustomerTag.getUserId())
.isCompanyTag(weMakeCustomerTag.getIsCompanyTag())
.externalUserid(weMakeCustomerTag.getExternalUserid())
.tagId(k.getTagId())
.delFlag(WeConstans.WE_SUCCESS_CODE)
.build()
);
});
iWeFlowerCustomerTagRelService.batchAddOrUpdate(newTagRels);
weCustomerClient.makeCustomerLabel(
cutomerTagEdit
);
if(weMakeCustomerTag.getIsCompanyTag()){
weCustomerClient.makeCustomerLabel(
cutomerTagEdit
);
}
}else{//为空,取消当前客户所有标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
......@@ -475,14 +482,17 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
.eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId()))){
//同步企业微信端
weCustomerClient.makeCustomerLabel(
CutomerTagEdit.builder()
.external_userid(weMakeCustomerTag.getExternalUserid())
.userid(weMakeCustomerTag.getUserId())
.remove_tag(ArrayUtil.toArray(weFlowerCustomerTagRels.stream().map(WeFlowerCustomerTagRel::getTagId).collect(Collectors.toList()), String.class))
.build()
);
if(weMakeCustomerTag.getIsCompanyTag()){
//同步企业微信端
weCustomerClient.makeCustomerLabel(
CutomerTagEdit.builder()
.external_userid(weMakeCustomerTag.getExternalUserid())
.userid(weMakeCustomerTag.getUserId())
.remove_tag(ArrayUtil.toArray(weFlowerCustomerTagRels.stream().map(WeFlowerCustomerTagRel::getTagId).collect(Collectors.toList()), String.class))
.build()
);
}
}
}
}
......@@ -524,6 +534,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setFirstUserId(userId);
weCustomer.setCustomerName(externalUserDetail.getExternal_contact().getName());
weCustomer.setCustomerType(externalUserDetail.getExternal_contact().getType());
weCustomer.setAddMethod(externalUserDetail.getFollow_info().getAdd_way());
List<ExternalUserDetail.FollowUser> follow_user = externalUserDetail.getFollow_user();
if(CollectionUtil.isNotEmpty(follow_user)){
ExternalUserDetail.FollowUser followUser = follow_user.stream().filter(e -> e.getUserid().equals(userId)).findFirst().get();
......@@ -611,6 +622,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setPhone(weCustomerPortrait.getRemarkMobiles());
weCustomer.setCorpName(weCustomerPortrait.getRemarkCorpName());
weCustomer.setFirstUserId(weCustomerPortrait.getUserId());
weCustomer.setOtherDescr(weCustomerPortrait.getDescription());
this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
......@@ -695,14 +707,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomerList.stream().forEach(k->{
iWeCustomerTrajectoryService.list(new LambdaQueryWrapper<WeCustomerTrajectory>()
.eq(WeCustomerTrajectory::getExternalUserid,k.getExternalUserid())
.eq(WeCustomerTrajectory::getUserId,k.getFirstUserId()));
trackStates.add(WeCustomerDetail.TrackStates
.builder()
.userName(k.getUserName())
.trackStateList(iWeCustomerTrajectoryService.list(new LambdaQueryWrapper<WeCustomerTrajectory>()
.eq(WeCustomerTrajectory::getExternalUserid, k.getExternalUserid())
.eq(WeCustomerTrajectory::getUserId, k.getFirstUserId())))
.build());
trackUsers.add(
......@@ -714,21 +725,27 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.build()
);
companyTags.add(
WeCustomerDetail.CompanyOrPersonTag.builder()
.tagIds(k.getTagIds())
.tagsNames(k.getTagNames())
.userName(k.getUserName())
.build()
);
if(StringUtils.isNotEmpty(k.getTagIds()) && StringUtils.isNotEmpty(k.getTagNames())){
companyTags.add(
WeCustomerDetail.CompanyOrPersonTag.builder()
.tagIds(k.getTagIds())
.tagsNames(k.getTagNames())
.userName(k.getUserName())
.build()
);
}
if(StringUtils.isNotEmpty(k.getPersonTagIds()) && StringUtils.isNotEmpty(k.getPersonTagNames())){
personTags.add(
WeCustomerDetail.CompanyOrPersonTag.builder()
.tagIds(k.getPersonTagIds())
.tagsNames(k.getPersonTagNames())
.userName(k.getUserName())
.build()
);
}
personTags.add(
WeCustomerDetail.CompanyOrPersonTag.builder()
.tagIds(k.getPersonTagIds())
.tagsNames(k.getPersonTagNames())
.userName(k.getUserName())
.build()
);
});
......
......@@ -81,7 +81,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
k.setGroupId(weTagGroup.getGroupId());
});
//客户标签
//客户企业标签
if(weTagGroup.getGroupTagType().equals(new Integer(1))){
weTagGroup.setAddWeTags(
weTags
......@@ -90,7 +90,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
this.batchSaveOrUpdateTagGroupAndTag(ListUtil.toList(weCropGropTagDtlDto.getTag_group()), false);
}
}else{
}else{//群标签或者个人标签
iWeTagService.saveBatch(weTags);
}
......@@ -99,13 +99,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
}
}
// if (CollectionUtil.isEmpty(weTags)) {
// this.save(weTagGroup);
// } else {
//
//
//
// }
......@@ -326,7 +320,9 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (isSync) {
List<WeTagGroup> noExist
= this.list(new LambdaQueryWrapper<WeTagGroup>().notIn(WeTagGroup::getGroupId, weTagGroups.stream().map(WeTagGroup::getGroupId).collect(Collectors.toList())));
= this.list(new LambdaQueryWrapper<WeTagGroup>()
.eq(WeTagGroup::getGroupTagType,new Integer(1))
.notIn(WeTagGroup::getGroupId, weTagGroups.stream().map(WeTagGroup::getGroupId).collect(Collectors.toList())));
//企业微信端删除得标签
if (CollectionUtil.isNotEmpty(noExist)) {
this.removeByIds(noExist.stream().map(WeTagGroup::getGroupId).collect(Collectors.toList()));
......@@ -344,7 +340,9 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (isSync) {
List<WeTag> noExistWeTags
= iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId, weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())));
= iWeTagService.list(new LambdaQueryWrapper<WeTag>()
.eq(WeTag::getTagType,new Integer(1))
.notIn(WeTag::getTagId, weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())));
if (CollectionUtil.isNotEmpty(noExistWeTags)) {
iWeTagService.removeByIds(
noExistWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList())
......
......@@ -9,10 +9,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wc.avatar,
wc.`name` as customerName,
wc.customer_type as customerType,
if(wt.tag_type=1,GROUP_CONCAT(wt.`tag_id`),null ) as tagIds,
if(wt.tag_type=1,GROUP_CONCAT(wt.`name`),null ) as tagNames,
if(wt.tag_type=3,GROUP_CONCAT(wt.`tag_id`),null ) as personTagIds,
if(wt.tag_type=3,GROUP_CONCAT(wt.`name`),null ) as personTagNames,
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=3,wt.`tag_id`,null )) as personTagIds,
GROUP_CONCAT(if(wt.tag_type=3,wt.`name`,null )) as personTagNames,
wu.user_name,
wc.external_userid,
wc.first_user_id,
......@@ -109,20 +109,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT
wc.`name`,
wc.other_descr as remark,
wc.phone as remark_mobiles,
wc.phone as remarkMobiles,
wc.birthday,
wc.email,
wc.address,
wc.qq,
wc.position,
wc.corp_name as remark_corp_name,
wc.corp_name as remarkCorpName,
wc.other_descr as description,
wc.first_user_id as user_id,
wc.avatar,
wc.external_userid,
wc.gender,
GROUP_CONCAT(wt.`name`) as tagNames,
GROUP_CONCAT(wt.`tag_id`) as tagIds
wc.track_state,
wc.customer_type,
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=3,wt.`tag_id`,null )) as personTagIds,
GROUP_CONCAT(if(wt.tag_type=3,wt.`name`,null )) as personTagNames
FROM
we_customer wc
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.user_id = wc.first_user_id AND wfcrf.del_flag=0
......
......@@ -77,15 +77,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
user_id,
external_userid,
tag_id,
create_time
create_time,
is_company_tag,
del_flag
) values
<foreach collection="tagRels" item="item" index="index" separator=",">
(#{item.userId},#{item.externalUserid},#{item.tagId},NOW())
(#{item.userId},#{item.externalUserid},#{item.tagId},NOW(),#{item.isCompanyTag},#{item.delFlag})
</foreach>
ON DUPLICATE KEY UPDATE
user_id=IF(we_flower_customer_tag_rel.user_id != null, VALUES(user_id), we_flower_customer_tag_rel.user_id),
external_userid=IF(we_flower_customer_tag_rel.external_userid != null, VALUES(external_userid), we_flower_customer_tag_rel.external_userid),
tag_id=IF(we_flower_customer_tag_rel.tag_id != null, VALUES(tag_id), we_flower_customer_tag_rel.tag_id);
tag_id=IF(we_flower_customer_tag_rel.tag_id != null, VALUES(tag_id), we_flower_customer_tag_rel.tag_id),
del_flag=IF(we_flower_customer_tag_rel.del_flag != null, we_flower_customer_tag_rel.del_flag, VALUES(del_flag));
</insert>
</mapper>
\ No newline at end of file
......@@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where
wtg.del_flag=0
<if test="groupTagType != null">and wtg.group_tag_type=#{groupTagType}</if>
<if test="owner !=null and owner !=''">and wtg.owner=#{owner}</if>
ORDER BY wtg.create_time DESC
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!