修复朋友圈等bug

1 parent 3aeee9fa
package com.linkwechat.web.controller.wecom; 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
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;
import com.linkwechat.wecom.domain.WeCustomerPortrait; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.WeCustomerTrajectory;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag; import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.*;
import org.aspectj.weaver.loadtime.Aj; import org.aspectj.weaver.loadtime.Aj;
...@@ -36,6 +35,10 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -36,6 +35,10 @@ public class WeCustomerPortraitController extends BaseController {
@Autowired @Autowired
private IWeTagService iWeTagService;
@Autowired
private IWeUserService iWeUserService; private IWeUserService iWeUserService;
...@@ -81,23 +84,65 @@ public class WeCustomerPortraitController extends BaseController { ...@@ -81,23 +84,65 @@ public class WeCustomerPortraitController extends BaseController {
/** /**
* 获取当前系统所有可用标签 * 获取当前系统所有可用标签
* @param groupTagType 标签分组类型(1:客户标签;2:群标签)
* @param userId 员工id
* @return * @return
*/ */
@GetMapping(value = "/findAllTags") @GetMapping(value = "/findAllTags")
public AjaxResult findAllTags(){ public AjaxResult findAllTags(Integer groupTagType,String userId){
return AjaxResult.success( return AjaxResult.success(
weTagGroupService.selectWeTagGroupList( weTagGroupService.selectWeTagGroupList(
WeTagGroup.builder() WeTagGroup.builder()
.groupTagType(groupTagType)
.owner(userId)
.build() .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 * @param weMakeCustomerTag
......
...@@ -32,6 +32,7 @@ public class WeMetaObjectHandler implements MetaObjectHandler { ...@@ -32,6 +32,7 @@ public class WeMetaObjectHandler implements MetaObjectHandler {
String userName = getUserName(); String userName = getUserName();
this.setFieldValByName(CREATE_BY, userName, metaObject); this.setFieldValByName(CREATE_BY, userName, metaObject);
this.setFieldValByName(UPDATE_BY, userName, metaObject); this.setFieldValByName(UPDATE_BY, userName, metaObject);
} }
@Override @Override
...@@ -43,6 +44,7 @@ public class WeMetaObjectHandler implements MetaObjectHandler { ...@@ -43,6 +44,7 @@ public class WeMetaObjectHandler implements MetaObjectHandler {
} }
private String getUserName() { private String getUserName() {
String userName; String userName;
try { try {
userName = SecurityUtils.getUsername(); userName = SecurityUtils.getUsername();
......
...@@ -57,4 +57,17 @@ public class WeCustomerPortrait { ...@@ -57,4 +57,17 @@ public class WeCustomerPortrait {
private String tagIds; 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 ...@@ -53,4 +53,7 @@ public class WeFlowerCustomerTagRel
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;
//是否是企业标签:1:是;0:否
private Boolean isCompanyTag;
} }
...@@ -44,6 +44,9 @@ public class WeTag implements Serializable ...@@ -44,6 +44,9 @@ public class WeTag implements Serializable
private Integer delFlag; private Integer delFlag;
private Integer tagType;
......
...@@ -54,12 +54,12 @@ public class WeTagGroup extends BaseEntity ...@@ -54,12 +54,12 @@ public class WeTagGroup extends BaseEntity
private Integer delFlag; private Integer delFlag;
/**标签分组类型(1:客户标签;2:群标签)*/ /**标签分组类型(1:企业客户标签;2:群标签;3:个人标签)*/
private Integer groupTagType; private Integer groupTagType;
/**所属人*/
private String owner;
......
...@@ -21,5 +21,7 @@ public class WeMakeCustomerTag { ...@@ -21,5 +21,7 @@ public class WeMakeCustomerTag {
private String externalUserid; private String externalUserid;
private String userId; private String userId;
private List<WeTag> addTag; private List<WeTag> addTag;
//是否是企业标签true是;false:不是
private Boolean isCompanyTag=true;
} }
...@@ -433,6 +433,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -433,6 +433,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
List<WeFlowerCustomerTagRel> tagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>() List<WeFlowerCustomerTagRel> tagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()) .eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
.eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId()) .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())) .notIn(WeFlowerCustomerTagRel::getTagId, addTag.stream().map(WeTag::getTagId).collect(Collectors.toList()))
); );
if(CollectionUtil.isNotEmpty(tagRels)){ if(CollectionUtil.isNotEmpty(tagRels)){
...@@ -441,6 +443,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -441,6 +443,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
new LambdaQueryWrapper<WeFlowerCustomerTagRel>() new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()) .eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
.eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId()) .eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId())
.eq(WeFlowerCustomerTagRel::getIsCompanyTag,weMakeCustomerTag.getIsCompanyTag())
.notIn(WeFlowerCustomerTagRel::getTagId, addTag.stream().map(WeTag::getTagId).collect(Collectors.toList()) .notIn(WeFlowerCustomerTagRel::getTagId, addTag.stream().map(WeTag::getTagId).collect(Collectors.toList())
))){ ))){
cutomerTagEdit.setRemove_tag( cutomerTagEdit.setRemove_tag(
...@@ -454,17 +457,21 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -454,17 +457,21 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
newTagRels.add( newTagRels.add(
WeFlowerCustomerTagRel.builder() WeFlowerCustomerTagRel.builder()
.userId(weMakeCustomerTag.getUserId()) .userId(weMakeCustomerTag.getUserId())
.isCompanyTag(weMakeCustomerTag.getIsCompanyTag())
.externalUserid(weMakeCustomerTag.getExternalUserid()) .externalUserid(weMakeCustomerTag.getExternalUserid())
.tagId(k.getTagId()) .tagId(k.getTagId())
.delFlag(WeConstans.WE_SUCCESS_CODE)
.build() .build()
); );
}); });
iWeFlowerCustomerTagRelService.batchAddOrUpdate(newTagRels); iWeFlowerCustomerTagRelService.batchAddOrUpdate(newTagRels);
if(weMakeCustomerTag.getIsCompanyTag()){
weCustomerClient.makeCustomerLabel( weCustomerClient.makeCustomerLabel(
cutomerTagEdit cutomerTagEdit
); );
}
}else{//为空,取消当前客户所有标签 }else{//为空,取消当前客户所有标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>() List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
...@@ -475,6 +482,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -475,6 +482,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
new LambdaQueryWrapper<WeFlowerCustomerTagRel>() new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()) .eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
.eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId()))){ .eq(WeFlowerCustomerTagRel::getUserId, weMakeCustomerTag.getUserId()))){
if(weMakeCustomerTag.getIsCompanyTag()){
//同步企业微信端 //同步企业微信端
weCustomerClient.makeCustomerLabel( weCustomerClient.makeCustomerLabel(
CutomerTagEdit.builder() CutomerTagEdit.builder()
...@@ -484,6 +492,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -484,6 +492,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.build() .build()
); );
} }
}
} }
} }
} }
...@@ -524,6 +534,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -524,6 +534,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setFirstUserId(userId); weCustomer.setFirstUserId(userId);
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.setAddMethod(externalUserDetail.getFollow_info().getAdd_way());
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();
...@@ -611,6 +622,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -611,6 +622,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setPhone(weCustomerPortrait.getRemarkMobiles()); weCustomer.setPhone(weCustomerPortrait.getRemarkMobiles());
weCustomer.setCorpName(weCustomerPortrait.getRemarkCorpName()); weCustomer.setCorpName(weCustomerPortrait.getRemarkCorpName());
weCustomer.setFirstUserId(weCustomerPortrait.getUserId()); weCustomer.setFirstUserId(weCustomerPortrait.getUserId());
weCustomer.setOtherDescr(weCustomerPortrait.getDescription());
this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>() this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
...@@ -695,14 +707,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -695,14 +707,13 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomerList.stream().forEach(k->{ weCustomerList.stream().forEach(k->{
iWeCustomerTrajectoryService.list(new LambdaQueryWrapper<WeCustomerTrajectory>()
.eq(WeCustomerTrajectory::getExternalUserid,k.getExternalUserid())
.eq(WeCustomerTrajectory::getUserId,k.getFirstUserId()));
trackStates.add(WeCustomerDetail.TrackStates trackStates.add(WeCustomerDetail.TrackStates
.builder() .builder()
.userName(k.getUserName()) .userName(k.getUserName())
.trackStateList(iWeCustomerTrajectoryService.list(new LambdaQueryWrapper<WeCustomerTrajectory>()
.eq(WeCustomerTrajectory::getExternalUserid, k.getExternalUserid())
.eq(WeCustomerTrajectory::getUserId, k.getFirstUserId())))
.build()); .build());
trackUsers.add( trackUsers.add(
...@@ -714,6 +725,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -714,6 +725,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.build() .build()
); );
if(StringUtils.isNotEmpty(k.getTagIds()) && StringUtils.isNotEmpty(k.getTagNames())){
companyTags.add( companyTags.add(
WeCustomerDetail.CompanyOrPersonTag.builder() WeCustomerDetail.CompanyOrPersonTag.builder()
.tagIds(k.getTagIds()) .tagIds(k.getTagIds())
...@@ -721,7 +733,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -721,7 +733,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.userName(k.getUserName()) .userName(k.getUserName())
.build() .build()
); );
}
if(StringUtils.isNotEmpty(k.getPersonTagIds()) && StringUtils.isNotEmpty(k.getPersonTagNames())){
personTags.add( personTags.add(
WeCustomerDetail.CompanyOrPersonTag.builder() WeCustomerDetail.CompanyOrPersonTag.builder()
.tagIds(k.getPersonTagIds()) .tagIds(k.getPersonTagIds())
...@@ -729,6 +744,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -729,6 +744,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.userName(k.getUserName()) .userName(k.getUserName())
.build() .build()
); );
}
}); });
......
...@@ -81,7 +81,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr ...@@ -81,7 +81,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
k.setGroupId(weTagGroup.getGroupId()); k.setGroupId(weTagGroup.getGroupId());
}); });
//客户标签 //客户企业标签
if(weTagGroup.getGroupTagType().equals(new Integer(1))){ if(weTagGroup.getGroupTagType().equals(new Integer(1))){
weTagGroup.setAddWeTags( weTagGroup.setAddWeTags(
weTags weTags
...@@ -90,7 +90,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr ...@@ -90,7 +90,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) { if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
this.batchSaveOrUpdateTagGroupAndTag(ListUtil.toList(weCropGropTagDtlDto.getTag_group()), false); this.batchSaveOrUpdateTagGroupAndTag(ListUtil.toList(weCropGropTagDtlDto.getTag_group()), false);
} }
}else{ }else{//群标签或者个人标签
iWeTagService.saveBatch(weTags); iWeTagService.saveBatch(weTags);
} }
...@@ -99,13 +99,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr ...@@ -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 ...@@ -326,7 +320,9 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (isSync) { if (isSync) {
List<WeTagGroup> noExist 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)) { if (CollectionUtil.isNotEmpty(noExist)) {
this.removeByIds(noExist.stream().map(WeTagGroup::getGroupId).collect(Collectors.toList())); this.removeByIds(noExist.stream().map(WeTagGroup::getGroupId).collect(Collectors.toList()));
...@@ -344,7 +340,9 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr ...@@ -344,7 +340,9 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (isSync) { if (isSync) {
List<WeTag> noExistWeTags 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)) { if (CollectionUtil.isNotEmpty(noExistWeTags)) {
iWeTagService.removeByIds( iWeTagService.removeByIds(
noExistWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()) noExistWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList())
......
...@@ -9,10 +9,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -9,10 +9,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wc.avatar, wc.avatar,
wc.`name` as customerName, wc.`name` as customerName,
wc.customer_type as customerType, wc.customer_type as customerType,
if(wt.tag_type=1,GROUP_CONCAT(wt.`tag_id`),null ) as tagIds, GROUP_CONCAT(if(wt.tag_type=1,wt.`tag_id`,null )) as tagIds,
if(wt.tag_type=1,GROUP_CONCAT(wt.`name`),null ) as tagNames, GROUP_CONCAT(if(wt.tag_type=1,wt.`name`,null )) as tagNames,
if(wt.tag_type=3,GROUP_CONCAT(wt.`tag_id`),null ) as personTagIds, GROUP_CONCAT(if(wt.tag_type=3,wt.`tag_id`,null )) as personTagIds,
if(wt.tag_type=3,GROUP_CONCAT(wt.`name`),null ) as personTagNames, GROUP_CONCAT(if(wt.tag_type=3,wt.`name`,null )) as personTagNames,
wu.user_name, wu.user_name,
wc.external_userid, wc.external_userid,
wc.first_user_id, wc.first_user_id,
...@@ -109,20 +109,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -109,20 +109,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT SELECT
wc.`name`, wc.`name`,
wc.other_descr as remark, wc.other_descr as remark,
wc.phone as remark_mobiles, wc.phone as remarkMobiles,
wc.birthday, wc.birthday,
wc.email, wc.email,
wc.address, wc.address,
wc.qq, wc.qq,
wc.position, wc.position,
wc.corp_name as remark_corp_name, wc.corp_name as remarkCorpName,
wc.other_descr as description, wc.other_descr as description,
wc.first_user_id as user_id, wc.first_user_id as user_id,
wc.avatar, wc.avatar,
wc.external_userid, wc.external_userid,
wc.gender, wc.gender,
GROUP_CONCAT(wt.`name`) as tagNames, wc.track_state,
GROUP_CONCAT(wt.`tag_id`) as tagIds 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 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
......
...@@ -77,15 +77,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -77,15 +77,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
user_id, user_id,
external_userid, external_userid,
tag_id, tag_id,
create_time create_time,
is_company_tag,
del_flag
) values ) values
<foreach collection="tagRels" item="item" index="index" separator=","> <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> </foreach>
ON DUPLICATE KEY UPDATE 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), 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), 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> </insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where where
wtg.del_flag=0 wtg.del_flag=0
<if test="groupTagType != null">and wtg.group_tag_type=#{groupTagType}</if> <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 ORDER BY wtg.create_time DESC
</select> </select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!