客户回调bug修复

1 parent 2ed49e8b
...@@ -24,6 +24,9 @@ public class WeCustomerList { ...@@ -24,6 +24,9 @@ public class WeCustomerList {
//标签名称,使用逗号隔开 //标签名称,使用逗号隔开
private String tagNames; private String tagNames;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthday;
// private List<WeFlowerCustomerRel> weFlowerCustomerRels; // private List<WeFlowerCustomerRel> weFlowerCustomerRels;
......
...@@ -41,6 +41,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -41,6 +41,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService; private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired @Autowired
private IWeMaterialService weMaterialService; private IWeMaterialService weMaterialService;
@Autowired @Autowired
...@@ -154,7 +155,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -154,7 +155,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
); );
}); });
if(weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels)){ weFlowerCustomerTagRelService.batchAddOrUpdate(weFlowerCustomerTagRels);
//标签同步到企业微信端 //标签同步到企业微信端
weCustomerClient.makeCustomerLabel(CutomerTagEdit.builder() weCustomerClient.makeCustomerLabel(CutomerTagEdit.builder()
.external_userid(externalUserId) .external_userid(externalUserId)
...@@ -162,7 +164,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -162,7 +164,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
.add_tag(weFlowerCustomerTagRels.stream() .add_tag(weFlowerCustomerTagRels.stream()
.map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new)) .map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new))
.build()); .build());
}
} }
......
...@@ -41,6 +41,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -41,6 +41,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService; private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired @Autowired
private IWeMaterialService weMaterialService; private IWeMaterialService weMaterialService;
...@@ -73,7 +74,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -73,7 +74,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
); );
}); });
weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels); weFlowerCustomerTagRelService.batchAddOrUpdate(weFlowerCustomerTagRels);
} }
......
...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component; ...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
@Slf4j @Slf4j
@Component("transfer_fail") @Component("transfer_fail")
public class WeCallbackTransferFailImpl extends WeEventStrategy { public class WeCallbackTransferFailImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeAllocateCustomerService iWeAllocateCustomerService; private IWeAllocateCustomerService iWeAllocateCustomerService;
...@@ -31,4 +32,5 @@ public class WeCallbackTransferFailImpl extends WeEventStrategy { ...@@ -31,4 +32,5 @@ public class WeCallbackTransferFailImpl extends WeEventStrategy {
iWeAllocateCustomerService.update(weAllocateCustomer,new LambdaQueryWrapper<WeAllocateCustomer>().eq(WeAllocateCustomer::getTakeoverUserid,userId) iWeAllocateCustomerService.update(weAllocateCustomer,new LambdaQueryWrapper<WeAllocateCustomer>().eq(WeAllocateCustomer::getTakeoverUserid,userId)
.eq(WeAllocateCustomer::getExternalUserid,externalUserId)); .eq(WeAllocateCustomer::getExternalUserid,externalUserId));
} }
} }
...@@ -25,10 +25,7 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -25,10 +25,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -102,7 +99,8 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -102,7 +99,8 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
//发给客户 //发给客户
if(CollectionUtils.isNotEmpty(customers)){ if(CollectionUtils.isNotEmpty(customers)){
customers.stream().collect(Collectors.groupingBy(WeCustomer::getUserId)).forEach((k,v)->{
customers.stream().collect(Collectors.groupingBy(WeCustomer::getFirstUserId)).forEach((k,v)->{
customerMessagePushDto.setStaffId(k); customerMessagePushDto.setStaffId(k);
//发送群发消息 //发送群发消息
......
...@@ -56,11 +56,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -56,11 +56,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
@Autowired
private WeCropTagClient weCropTagClient;
@Autowired
private IWeTagService iWeTagService;
@Autowired @Autowired
...@@ -331,13 +326,12 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -331,13 +326,12 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
); );
}); });
if(iWeFlowerCustomerTagRelService.saveBatch(newTagRels)){ iWeFlowerCustomerTagRelService.batchAddOrUpdate(newTagRels);
weCustomerClient.makeCustomerLabel( weCustomerClient.makeCustomerLabel(
cutomerTagEdit cutomerTagEdit
); );
}
}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())
......
...@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="position" column="position" /> <result property="position" column="position" />
<result property="userName" column="user_name" /> <result property="userName" column="user_name" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="firstUserId" column="first_user_id"></result>
<result property="isOpenChat" column="is_open_chat" jdbcType="INTEGER" /> <result property="isOpenChat" column="is_open_chat" jdbcType="INTEGER" />
</resultMap> </resultMap>
...@@ -32,26 +33,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -32,26 +33,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wc.unionid, wc.unionid,
wc.birthday, wc.birthday,
wc.corp_name, wc.corp_name,
wc.first_user_id,
wc.corp_full_name, wc.corp_full_name,
wc.position, wc.position,
wc.is_open_chat, wc.is_open_chat,
wfcr.id as wfcrId,
wfcr.user_id,
wfcr.remark,
wfcr.description,
wfcr.create_time,
wfcr.remark_corp_name,
wfcr.oper_userid,
wfcr.add_way,
wfcr.state,
wfcr.status,
wu.user_name, wu.user_name,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department
FROM FROM
we_customer wc we_customer wc
LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid LEFT JOIN we_user wu ON wc.first_user_id=wu.user_id
LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.external_userid = wc.external_userid
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id
LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
<where> <where>
<if test="name != null and name !=''"> <if test="name != null and name !=''">
...@@ -59,21 +50,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -59,21 +50,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
<if test="userIds != null and userIds !=''"> <if test="userIds != null and userIds !=''">
<if test="userIds.indexOf(',') != -1"> <if test="userIds.indexOf(',') != -1">
AND wfcr.user_id in AND wu.user_id in
<foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")"> <foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="userIds.indexOf(',') == -1"> <if test="userIds.indexOf(',') == -1">
AND wfcr.user_id=#{userIds} AND wu.user_id=#{userIds}
</if> </if>
</if> </if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 --> <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') AND date_format(wc.first_add_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if> </if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 --> <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') AND date_format(wc.first_add_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="tagIds != null and tagIds !=''"> <if test="tagIds != null and tagIds !=''">
<if test="tagIds.indexOf(',') != -1"> <if test="tagIds.indexOf(',') != -1">
...@@ -98,13 +89,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -98,13 +89,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</if> </if>
<if test="status !=null and status !=''"> <if test="status !=null and status !=''">
AND wfcr.status=#{status} AND wc.del_flag=#{status}
</if> </if>
<if test="isOpenChat !=null "> <if test="isOpenChat !=null ">
AND wc.is_open_chat=#{isOpenChat} AND wc.is_open_chat=#{isOpenChat}
</if> </if>
</where> </where>
ORDER BY wfcr.create_time DESC ORDER BY wc.first_add_time DESC
</select> </select>
...@@ -199,23 +190,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -199,23 +190,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wc.corp_full_name, wc.corp_full_name,
wc.position, wc.position,
wc.is_open_chat, wc.is_open_chat,
wfcr.id as wfcrId,
wfcr.user_id,
wfcr.remark,
wfcr.description,
wfcr.create_time,
wfcr.remark_corp_name,
wfcr.oper_userid,
wfcr.add_way,
wfcr.state,
wfcr.status,
wu.user_name, wu.user_name,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department
FROM FROM
we_customer wc we_customer wc
LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid LEFT JOIN we_user wu ON wu.user_id=wc.first_user_id
LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.external_userid = wc.external_userid
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id
LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
<where> <where>
<if test="name != null and name !=''"> <if test="name != null and name !=''">
...@@ -223,21 +203,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -223,21 +203,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
<if test="userIds != null and userIds !=''"> <if test="userIds != null and userIds !=''">
<if test="userIds.indexOf(',') != -1"> <if test="userIds.indexOf(',') != -1">
AND wfcr.user_id in AND wc.user_id in
<foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")"> <foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="userIds.indexOf(',') == -1"> <if test="userIds.indexOf(',') == -1">
AND wfcr.user_id=#{userIds} AND wc.user_id=#{userIds}
</if> </if>
</if> </if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 --> <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') AND date_format(wc.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if> </if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 --> <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') AND date_format(wc.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="tagIds != null and tagIds !=''"> <if test="tagIds != null and tagIds !=''">
<if test="tagIds.indexOf(',') != -1"> <if test="tagIds.indexOf(',') != -1">
...@@ -262,13 +242,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -262,13 +242,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</if> </if>
<if test="status !=null and status !=''"> <if test="status !=null and status !=''">
AND wfcr.status=#{status} AND wc.del_flag=#{status}
</if> </if>
<if test="isOpenChat !=null "> <if test="isOpenChat !=null ">
AND wc.is_open_chat=#{isOpenChat} AND wc.is_open_chat=#{isOpenChat}
</if> </if>
</where> </where>
ORDER BY wfcr.create_time DESC ORDER BY wc.first_add_time DESC
</select> </select>
...@@ -294,7 +274,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -294,7 +274,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wu.user_name, wu.user_name,
wc.first_add_time, wc.first_add_time,
GROUP_CONCAT(wt.`name`) as tagNames, GROUP_CONCAT(wt.`name`) as tagNames,
GROUP_CONCAT(wt.`tag_id`) as tagIds GROUP_CONCAT(wt.`tag_id`) as tagIds,
wc.birthday
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
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!