离职继承bug修复

1 parent f5af5ead
......@@ -55,6 +55,15 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
*/
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
List<WeCustomer> allocateWeCustomers = this.list(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(allocateWeCustomers)){
if(this.update(WeCustomer.builder()
.firstUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.build(),new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId,weLeaveUserInfoAllocateVo.getHandoverUserid()))){//接手客户
//删除原有的
this.baseMapper.deleteWeCustomerByUserIds(
new String[]{weLeaveUserInfoAllocateVo.getHandoverUserid()}
);
allocateWeCustomers.stream().forEach(k->{
k.setFirstUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
});
//新增
this.baseMapper.batchAddOrUpdate(
allocateWeCustomers
);
//记录接受离职表
List<WeAllocateCustomer> weAllocateCustomers = new ArrayList<>();
allocateWeCustomers.stream().forEach(k->{
......@@ -266,14 +273,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.build());
}
}
}
}
......
......@@ -97,7 +97,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl
if (CollectionUtil.isNotEmpty(weAllocateGroups)) {
if (iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)) {
//同步企业微信端
// //同步企业微信端
weUserClient.allocateGroup(
AllocateWeGroupDto.builder()
.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"
delete from we_customer where external_userid = #{externalUserId}
</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 from we_customer where external_userid in
<foreach item="item" collection="array" open="(" separator="," close=")">
......@@ -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 @@
)
</insert>
<update id="updateTaskSolvedById">
UPDATE we_customer_messageTimeTask set
solved=#{solved},
<if test="exceMsg != null and exceMsg !=''">
exce_msg=#{exceMsg}
</if>
UPDATE we_customer_messageTimeTask
<trim prefix="set" suffixOverrides=",">
<if test="solved !=null">
solved=#{solved},
</if>
<if test="exceMsg != null and exceMsg !=''">
exce_msg=#{exceMsg},
</if>
</trim>
<where>
task_id=#{taskId}
</where>
......
......@@ -123,12 +123,11 @@
<if test="hasTag">
AND customer.external_userid in (
SELECT
t3.external_userid
t2.external_userid
FROM
we_pres_tag_group task
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_rel t3 ON t2.flower_customer_rel_id = t3.id
WHERE
task.task_id = #{taskId}
)
......@@ -137,12 +136,11 @@
<if test="hasScope">
AND customer.external_userid in (
SELECT
t3.external_userid
customer.external_userid
FROM
we_pres_tag_group task
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.external_userid = t3.external_userid
LEFT JOIN we_customer customer ON customer.first_user_id = scope.we_user_id
WHERE
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!