离职继承bug修复

1 parent f5af5ead
...@@ -55,6 +55,15 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer> ...@@ -55,6 +55,15 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
*/ */
public int deleteWeCustomerById(String externalUserId); public int deleteWeCustomerById(String externalUserId);
/**
* 批量删除企业微信客户
*
* @param userIds 需要删除的数据ID
* @return 结果
*/
public int deleteWeCustomerByUserIds(String[] userIds);
/** /**
* 批量删除企业微信客户 * 批量删除企业微信客户
* *
......
...@@ -237,10 +237,17 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -237,10 +237,17 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
List<WeCustomer> allocateWeCustomers = this.list(new LambdaQueryWrapper<WeCustomer>() List<WeCustomer> allocateWeCustomers = this.list(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId, weLeaveUserInfoAllocateVo.getHandoverUserid())); .eq(WeCustomer::getFirstUserId, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(allocateWeCustomers)){ if(CollectionUtil.isNotEmpty(allocateWeCustomers)){
if(this.update(WeCustomer.builder() //删除原有的
.firstUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid()) this.baseMapper.deleteWeCustomerByUserIds(
.build(),new LambdaQueryWrapper<WeCustomer>() new String[]{weLeaveUserInfoAllocateVo.getHandoverUserid()}
.eq(WeCustomer::getFirstUserId,weLeaveUserInfoAllocateVo.getHandoverUserid()))){//接手客户 );
allocateWeCustomers.stream().forEach(k->{
k.setFirstUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
});
//新增
this.baseMapper.batchAddOrUpdate(
allocateWeCustomers
);
//记录接受离职表 //记录接受离职表
List<WeAllocateCustomer> weAllocateCustomers = new ArrayList<>(); List<WeAllocateCustomer> weAllocateCustomers = new ArrayList<>();
allocateWeCustomers.stream().forEach(k->{ allocateWeCustomers.stream().forEach(k->{
...@@ -266,11 +273,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -266,11 +273,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.build()); .build());
} }
}
} }
......
...@@ -97,7 +97,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl ...@@ -97,7 +97,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl
if (CollectionUtil.isNotEmpty(weAllocateGroups)) { if (CollectionUtil.isNotEmpty(weAllocateGroups)) {
if (iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)) { if (iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)) {
//同步企业微信端 // //同步企业微信端
weUserClient.allocateGroup( weUserClient.allocateGroup(
AllocateWeGroupDto.builder() AllocateWeGroupDto.builder()
.chat_id_list(ArrayUtil.toArray(weAllocateGroups.stream().map(WeAllocateGroup::getChatId).collect(Collectors.toList()), String.class)) .chat_id_list(ArrayUtil.toArray(weAllocateGroups.stream().map(WeAllocateGroup::getChatId).collect(Collectors.toList()), String.class))
......
...@@ -379,6 +379,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -379,6 +379,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from we_customer where external_userid = #{externalUserId} delete from we_customer where external_userid = #{externalUserId}
</delete> </delete>
<delete id="deleteWeCustomerByUserIds">
delete from we_customer where first_user_id in
<foreach item="item" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<delete id="deleteWeCustomerByIds"> <delete id="deleteWeCustomerByIds">
delete from we_customer where external_userid in delete from we_customer where external_userid in
<foreach item="item" collection="array" open="(" separator="," close=")"> <foreach item="item" collection="array" open="(" separator="," close=")">
...@@ -559,6 +567,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -559,6 +567,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchAddOrUpdate">
INSERT INTO we_customer(
external_userid,
NAME,
avatar,
type,
gender,
unionid,
birthday,
corp_name,
corp_full_name,
position,
is_open_chat,
create_time,
create_by,
first_user_id,
first_add_time
) values
<foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday},
#{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},
#{item.createBy},#{item.firstUserId},#{item.firstAddTime}
)
</foreach>
ON DUPLICATE KEY UPDATE
NAME=IF(we_customer.NAME != null, VALUES(NAME), we_customer.NAME),
avatar=IF(we_customer.avatar != null, VALUES(avatar), we_customer.avatar),
type=IF(we_customer.type != null, VALUES(type), we_customer.type),
gender=IF(we_customer.gender != null, VALUES(gender), we_customer.gender),
unionid=IF(we_customer.unionid != null, VALUES(unionid), we_customer.unionid),
birthday=IF(we_customer.birthday != null,VALUES(birthday), we_customer.birthday),
corp_name=IF(we_customer.corp_name != null, VALUES(corp_name), we_customer.corp_name),
corp_full_name=IF(we_customer.corp_full_name != null, VALUES(corp_full_name), we_customer.corp_full_name),
position=IF(we_customer.position != null, VALUES(position), we_customer.position),
is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat),
first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id),
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time);
</insert>
......
...@@ -38,11 +38,15 @@ ...@@ -38,11 +38,15 @@
) )
</insert> </insert>
<update id="updateTaskSolvedById"> <update id="updateTaskSolvedById">
UPDATE we_customer_messageTimeTask set UPDATE we_customer_messageTimeTask
<trim prefix="set" suffixOverrides=",">
<if test="solved !=null">
solved=#{solved}, solved=#{solved},
</if>
<if test="exceMsg != null and exceMsg !=''"> <if test="exceMsg != null and exceMsg !=''">
exce_msg=#{exceMsg} exce_msg=#{exceMsg},
</if> </if>
</trim>
<where> <where>
task_id=#{taskId} task_id=#{taskId}
</where> </where>
......
...@@ -123,12 +123,11 @@ ...@@ -123,12 +123,11 @@
<if test="hasTag"> <if test="hasTag">
AND customer.external_userid in ( AND customer.external_userid in (
SELECT SELECT
t3.external_userid t2.external_userid
FROM FROM
we_pres_tag_group task we_pres_tag_group task
LEFT JOIN we_pres_tag_group_tag t1 ON t1.task_id = task.task_id LEFT JOIN we_pres_tag_group_tag t1 ON t1.task_id = task.task_id
LEFT JOIN we_flower_customer_tag_rel t2 ON t2.tag_id = t1.tag_id LEFT JOIN we_flower_customer_tag_rel t2 ON t2.tag_id = t1.tag_id
LEFT JOIN we_flower_customer_rel t3 ON t2.flower_customer_rel_id = t3.id
WHERE WHERE
task.task_id = #{taskId} task.task_id = #{taskId}
) )
...@@ -137,12 +136,11 @@ ...@@ -137,12 +136,11 @@
<if test="hasScope"> <if test="hasScope">
AND customer.external_userid in ( AND customer.external_userid in (
SELECT SELECT
t3.external_userid customer.external_userid
FROM FROM
we_pres_tag_group task we_pres_tag_group task
LEFT JOIN we_pres_tag_group_scope scope ON scope.task_id = task.task_id LEFT JOIN we_pres_tag_group_scope scope ON scope.task_id = task.task_id
LEFT JOIN we_flower_customer_rel t3 ON t3.user_id = scope.we_user_id LEFT JOIN we_customer customer ON customer.first_user_id = scope.we_user_id
LEFT JOIN we_customer customer ON customer.external_userid = t3.external_userid
WHERE WHERE
task.task_id = #{taskId} task.task_id = #{taskId}
) )
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!