修复组织架构删除,群发所有客户的bug

1 parent 2031c7c8
...@@ -12,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen; ...@@ -12,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen;
* @author: HaoN * @author: HaoN
* @create: 2020-08-27 16:42 * @create: 2020-08-27 16:42
**/ **/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAccessTokenInterceptor.class) @BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeCommonAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class) @Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeUserClient { public interface WeUserClient {
......
...@@ -171,6 +171,11 @@ public class WeCustomer extends BaseEntity { ...@@ -171,6 +171,11 @@ public class WeCustomer extends BaseEntity {
private String updateBy; private String updateBy;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过创建「联系我」方式指定 */
private String state;
/** /**
...@@ -195,7 +200,7 @@ public class WeCustomer extends BaseEntity { ...@@ -195,7 +200,7 @@ public class WeCustomer extends BaseEntity {
/** /**
* 0:正常;1:删除 * 0:正常;1:删除
*/ */
@TableLogic // @TableLogic
private Integer delFlag; private Integer delFlag;
//添加方式 //添加方式
......
...@@ -68,6 +68,8 @@ public class WeCustomerList { ...@@ -68,6 +68,8 @@ public class WeCustomerList {
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
private Date birthday; private Date birthday;
......
...@@ -93,6 +93,9 @@ public class ExternalUserDetail extends WeResultDto { ...@@ -93,6 +93,9 @@ public class ExternalUserDetail extends WeResultDto {
private String oper_userid; private String oper_userid;
/**标签**/ /**标签**/
private String[] tag_id; private String[] tag_id;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过创建「联系我」方式指定 */
private String state;
} }
} }
...@@ -28,4 +28,35 @@ public class WeAllocateCustomersVo extends BaseEntity { ...@@ -28,4 +28,35 @@ public class WeAllocateCustomersVo extends BaseEntity {
/**原拥有着*/ /**原拥有着*/
private String handoverUserId; private String handoverUserId;
private String avatar;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthday;
//0-未知 1-男性 2-女性
private Integer gender;
//查询标签id
private String tagIds;
//标签名称,使用逗号隔开
private String tagNames;
//跟进人名称
private String userName;
//添加时间
@JsonFormat(pattern = "yyyy-MM-dd")
private Date firstAddTime;
} }
...@@ -203,23 +203,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -203,23 +203,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
*/ */
public List<WeCustomerList> externalUserIds(String pushRange, String staffId, String department, String tag) { public List<WeCustomerList> externalUserIds(String pushRange, String staffId, String department, String tag) {
if (pushRange.equals(WeConstans.SEND_MESSAGE_CUSTOMER_ALL)) { if (pushRange.equals(WeConstans.SEND_MESSAGE_CUSTOMER_ALL)) {
//从redis中读取数据
// List<WeCustomer> customers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
// if (CollectionUtils.isEmpty(customers)) {
// WeCustomer weCustomer = new WeCustomer();
// weCustomer.setUserIds(staffId);
// weCustomer.setDepartmentIds(department);
// customers = weCustomerService.selectWeCustomerAllList(weCustomer);
// redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
// redisCache.expire(WeConstans.WECUSTOMERS_KEY,2 * 60L);
// }else{
// return customers;
// }
//
// WeCustomer weCustomer = new WeCustomer();
// weCustomer.setUserIds(staffId);
// weCustomer.setDepartmentIds(department);
// return weCustomerService.selectWeCustomerListNoRel(weCustomer);
return weCustomerService.findWeCustomerList(WeCustomerList.builder() return weCustomerService.findWeCustomerList(WeCustomerList.builder()
...@@ -227,7 +211,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -227,7 +211,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
.departmentIds(department) .departmentIds(department)
.build()); .build());
} else { } else {
//按条件查询客户 //按条件查询客户
...@@ -240,14 +223,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -240,14 +223,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
.departmentIds(department) .departmentIds(department)
.build()); .build());
// WeCustomer weCustomer = new WeCustomer();
// weCustomer.setUserIds(staffId);
// weCustomer.setTagIds(tag);
// weCustomer.setDepartmentIds(department);
//
//
//
// return weCustomerService.selectWeCustomerListNoRel(weCustomer);
} }
} }
......
...@@ -96,6 +96,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -96,6 +96,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
@Override @Override
public void sendMessgae(CustomerMessagePushDto customerMessagePushDto, long messageId, List<WeCustomerList> customers, List<WeGroup> groups) throws JsonProcessingException { public void sendMessgae(CustomerMessagePushDto customerMessagePushDto, long messageId, List<WeCustomerList> customers, List<WeGroup> groups) throws JsonProcessingException {
List<String> msgid = new ArrayList<>(); List<String> msgid = new ArrayList<>();
//发给客户 //发给客户
...@@ -118,10 +119,17 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -118,10 +119,17 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
messagePushDto.setSender(customerMessagePushDto.getStaffId()); messagePushDto.setSender(customerMessagePushDto.getStaffId());
childMessage(messagePushDto, customerMessagePushDto); childMessage(messagePushDto, customerMessagePushDto);
try {
SendMessageResultDto sendMessageResultDto = weCustomerMessagePushClient.sendCustomerMessageToUser(messagePushDto); SendMessageResultDto sendMessageResultDto = weCustomerMessagePushClient.sendCustomerMessageToUser(messagePushDto);
if (WeConstans.WE_SUCCESS_CODE.equals(sendMessageResultDto.getErrcode())) { if (WeConstans.WE_SUCCESS_CODE.equals(sendMessageResultDto.getErrcode())) {
msgid.add(sendMessageResultDto.getMsgid()); msgid.add(sendMessageResultDto.getMsgid());
} }
}catch (Exception e){
log.error("消息发送失败:"+e.getMessage());
}
} }
}); });
} }
......
...@@ -57,7 +57,7 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe ...@@ -57,7 +57,7 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
customerMessgaeResult.setSendTime(null); customerMessgaeResult.setSendTime(null);
customerMessgaeResult.setSendType(customerMessgaeResult.getSettingTime() == null ? customerMessagePushDto.getPushType() : "2"); customerMessgaeResult.setSendType(customerMessgaeResult.getSettingTime() == null ? customerMessagePushDto.getPushType() : "2");
customerMessgaeResult.setExternalUserid(customer.getExternalUserid()); customerMessgaeResult.setExternalUserid(customer.getExternalUserid());
customerMessgaeResult.setExternalName(customer.getName()); customerMessgaeResult.setExternalName(customer.getCustomerName());
customerMessgaeResult.setUserid(customer.getFirstUserId()); customerMessgaeResult.setUserid(customer.getFirstUserId());
customerMessgaeResult.setUserName(customer.getUserName()); customerMessgaeResult.setUserName(customer.getUserName());
customerMessgaeResult.setStatus("0"); customerMessgaeResult.setStatus("0");
......
...@@ -170,6 +170,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -170,6 +170,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setFirstUserId(followInfo.getUserid()); weCustomer.setFirstUserId(followInfo.getUserid());
weCustomer.setFirstAddTime(new Date(followInfo.getCreatetime() * 1000L)); weCustomer.setFirstAddTime(new Date(followInfo.getCreatetime() * 1000L));
weCustomer.setAddMethod(followInfo.getAdd_way()); weCustomer.setAddMethod(followInfo.getAdd_way());
weCustomer.setState(followInfo.getState());
weCustomer.setDelFlag(new Integer(0));
weCustomerList.add(weCustomer); weCustomerList.add(weCustomer);
List<String> tags = Stream.of(followInfo.getTag_id()).collect(Collectors.toList()); List<String> tags = Stream.of(followInfo.getTag_id()).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(tags)) { if (CollectionUtil.isNotEmpty(tags)) {
...@@ -303,10 +305,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -303,10 +305,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
); );
if(CollectionUtil.isNotEmpty(weTagList)){ if(CollectionUtil.isNotEmpty(weTagList)){
if(addTag.size()!=weTagList.size()){ if(addTag.size()!=weTagList.size()){
new WeComException("部门标签不存在"); throw new WeComException("部门标签不存在");
} }
}else{ }else{
new WeComException("部门标签不存在"); throw new WeComException("部门标签不存在");
} }
...@@ -374,6 +376,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -374,6 +376,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
} }
} }
} }
} }
...@@ -417,7 +423,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -417,7 +423,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
if(null != followUser){ if(null != followUser){
weCustomer.setFirstAddTime(new Date(followUser.getCreatetime() * 1000L)); weCustomer.setFirstAddTime(new Date(followUser.getCreatetime() * 1000L));
weCustomer.setState(followUser.getState());
weCustomer.setAddMethod(followUser.getAddWay());
weCustomer.setDelFlag(new Integer(0));
this.baseMapper.batchAddOrUpdate( this.baseMapper.batchAddOrUpdate(
ListUtil.toList(weCustomer) ListUtil.toList(weCustomer)
); );
......
...@@ -315,16 +315,21 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W ...@@ -315,16 +315,21 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
}); });
} }
} else { } else {
// WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
// .selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId); .selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
// Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在")); Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
// List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
// .eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
// List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream() List<WeCustomer> weCustomers = weCustomerService.list(new LambdaQueryWrapper<WeCustomer>()
// .map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList()); .eq(WeCustomer::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
// if (CollectionUtil.isNotEmpty(eidList)) {
// customerList.addAll(weCustomerService.listByIds(eidList));
// } List<String> eidList = Optional.ofNullable(weCustomers).orElseGet(ArrayList::new).stream()
.map(WeCustomer::getExternalUserid).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eidList)) {
customerList.addAll(weCustomerService.listByIds(eidList));
}
} }
return customerList; return customerList;
} }
......
...@@ -610,12 +610,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -610,12 +610,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
email, email,
address, address,
phone, phone,
add_method add_method,
del_flag
) values ) values
<foreach collection="weCustomers" item="item" index="index" separator=","> <foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday}, (#{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.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},
#{item.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod} #{item.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod},
#{item.delFlag}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
...@@ -635,7 +637,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -635,7 +637,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
email=IF(we_customer.email != null, VALUES(email), we_customer.email), email=IF(we_customer.email != null, VALUES(email), we_customer.email),
address=IF(we_customer.address != null, VALUES(address), we_customer.address), address=IF(we_customer.address != null, VALUES(address), we_customer.address),
phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone), phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone),
add_method=IF(we_customer.add_method != null, VALUES(add_method), we_customer.add_method); add_method=IF(we_customer.add_method != null, VALUES(add_method), we_customer.add_method),
del_flag=IF(we_customer.del_flag != null, VALUES(del_flag), we_customer.del_flag);
</insert> </insert>
......
...@@ -72,11 +72,14 @@ ...@@ -72,11 +72,14 @@
<select id="customerMessagePushs" resultType="com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo"> <select id="customerMessagePushs" resultType="com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo">
SELECT SELECT
user_name, user_name,
GROUP_CONCAT(IFNULL(external_name,chat_name) SEPARATOR '、') customers GROUP_CONCAT(IFNULL(external_name,chat_name)) customers
FROM FROM
we_customer_messgaeResult we_customer_messgaeResult
<where> <where>
message_id=#{messageId} <if test="messageId !=null">
AND message_id=#{messageId}
</if>
<if test="status!=null"> <if test="status!=null">
AND `status`=#{status} AND `status`=#{status}
</if> </if>
......
...@@ -85,7 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -85,7 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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),
create_time=IF(we_flower_customer_tag_rel.create_time != null, VALUES(create_time), we_flower_customer_tag_rel.create_time);
</insert> </insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -156,11 +156,20 @@ ...@@ -156,11 +156,20 @@
wc.`name` as customerName, wc.`name` as customerName,
wu.user_name as takeUserName, wu.user_name as takeUserName,
wac.allocate_time, wac.allocate_time,
(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 in (wu.department)) as department,
wc.avatar,
wc.birthday,
wc.gender,
GROUP_CONCAT(wt.`tag_id`) as tagIds,
GROUP_CONCAT(wt.`name`) as tagNames,
wu.user_name,
wc.first_add_time
FROM FROM
we_allocate_customer wac we_allocate_customer wac
LEFT JOIN we_customer wc ON wac.external_userid=wc.external_userid LEFT JOIN we_customer wc ON wac.external_userid=wc.external_userid and wac.takeover_userid=wc.first_user_id
LEFT JOIN we_user wu ON wu.user_id=wac.takeover_userid LEFT JOIN we_user wu ON wu.user_id=wac.takeover_userid
LEFT JOIN we_flower_customer_tag_rel wfctr ON wfctr.del_flag=0 AND wfctr.external_userid=wc.external_userid AND wfctr.user_id=wc.first_user_id
LEFT JOIN we_tag wt ON wt.tag_id=wfctr.tag_id
<where> <where>
<if test="handoverUserId != null and handoverUserId !=''">and wac.handover_userid=#{handoverUserId}</if> <if test="handoverUserId != null and handoverUserId !=''">and wac.handover_userid=#{handoverUserId}</if>
<if test="beginTime != null and beginTime !='' and endTime != null and endTime !=''"> <if test="beginTime != null and beginTime !='' and endTime != null and endTime !=''">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!