Commit 0ea5a396 authored by linkwechat8856@163.com's avatar linkwechat8856@163.com
Browse files

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

Showing with 106 additions and 53 deletions
+106 -53
......@@ -12,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen;
* @author: HaoN
* @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)
public interface WeUserClient {
......
......@@ -171,6 +171,11 @@ public class WeCustomer extends BaseEntity {
private String updateBy;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过创建「联系我」方式指定 */
private String state;
/**
......@@ -195,7 +200,7 @@ public class WeCustomer extends BaseEntity {
/**
* 0:正常;1:删除
*/
@TableLogic
// @TableLogic
private Integer delFlag;
//添加方式
......
......@@ -68,6 +68,8 @@ public class WeCustomerList {
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthday;
......
......@@ -93,6 +93,9 @@ public class ExternalUserDetail extends WeResultDto {
private String oper_userid;
/**标签**/
private String[] tag_id;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过创建「联系我」方式指定 */
private String state;
}
}
......@@ -28,4 +28,35 @@ public class WeAllocateCustomersVo extends BaseEntity {
/**原拥有着*/
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
*/
public List<WeCustomerList> externalUserIds(String pushRange, String staffId, String department, String tag) {
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()
......@@ -227,7 +211,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
.departmentIds(department)
.build());
} else {
//按条件查询客户
......@@ -240,14 +223,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
.departmentIds(department)
.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
@Override
public void sendMessgae(CustomerMessagePushDto customerMessagePushDto, long messageId, List<WeCustomerList> customers, List<WeGroup> groups) throws JsonProcessingException {
List<String> msgid = new ArrayList<>();
//发给客户
......@@ -118,10 +119,17 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
messagePushDto.setSender(customerMessagePushDto.getStaffId());
childMessage(messagePushDto, customerMessagePushDto);
SendMessageResultDto sendMessageResultDto = weCustomerMessagePushClient.sendCustomerMessageToUser(messagePushDto);
if (WeConstans.WE_SUCCESS_CODE.equals(sendMessageResultDto.getErrcode())) {
msgid.add(sendMessageResultDto.getMsgid());
try {
SendMessageResultDto sendMessageResultDto = weCustomerMessagePushClient.sendCustomerMessageToUser(messagePushDto);
if (WeConstans.WE_SUCCESS_CODE.equals(sendMessageResultDto.getErrcode())) {
msgid.add(sendMessageResultDto.getMsgid());
}
}catch (Exception e){
log.error("消息发送失败:"+e.getMessage());
}
}
});
}
......
......@@ -57,7 +57,7 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
customerMessgaeResult.setSendTime(null);
customerMessgaeResult.setSendType(customerMessgaeResult.getSettingTime() == null ? customerMessagePushDto.getPushType() : "2");
customerMessgaeResult.setExternalUserid(customer.getExternalUserid());
customerMessgaeResult.setExternalName(customer.getName());
customerMessgaeResult.setExternalName(customer.getCustomerName());
customerMessgaeResult.setUserid(customer.getFirstUserId());
customerMessgaeResult.setUserName(customer.getUserName());
customerMessgaeResult.setStatus("0");
......
......@@ -170,6 +170,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer.setFirstUserId(followInfo.getUserid());
weCustomer.setFirstAddTime(new Date(followInfo.getCreatetime() * 1000L));
weCustomer.setAddMethod(followInfo.getAdd_way());
weCustomer.setState(followInfo.getState());
weCustomer.setDelFlag(new Integer(0));
weCustomerList.add(weCustomer);
List<String> tags = Stream.of(followInfo.getTag_id()).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(tags)) {
......@@ -303,10 +305,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
);
if(CollectionUtil.isNotEmpty(weTagList)){
if(addTag.size()!=weTagList.size()){
new WeComException("部门标签不存在");
throw new WeComException("部门标签不存在");
}
}else{
new WeComException("部门标签不存在");
throw new WeComException("部门标签不存在");
}
......@@ -374,6 +376,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}
}
}
}
......@@ -417,7 +423,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
if(null != followUser){
weCustomer.setFirstAddTime(new Date(followUser.getCreatetime() * 1000L));
weCustomer.setState(followUser.getState());
weCustomer.setAddMethod(followUser.getAddWay());
weCustomer.setDelFlag(new Integer(0));
this.baseMapper.batchAddOrUpdate(
ListUtil.toList(weCustomer)
);
......
......@@ -315,16 +315,21 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
});
}
} else {
// WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
// .selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
// 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()
// .map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(eidList)) {
// customerList.addAll(weCustomerService.listByIds(eidList));
// }
WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
List<WeCustomer> weCustomers = weCustomerService.list(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
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;
}
......
......@@ -610,12 +610,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
email,
address,
phone,
add_method
add_method,
del_flag
) 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},#{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>
ON DUPLICATE KEY UPDATE
......@@ -635,7 +637,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
email=IF(we_customer.email != null, VALUES(email), we_customer.email),
address=IF(we_customer.address != null, VALUES(address), we_customer.address),
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>
......
......@@ -72,11 +72,14 @@
<select id="customerMessagePushs" resultType="com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo">
SELECT
user_name,
GROUP_CONCAT(IFNULL(external_name,chat_name) SEPARATOR '、') customers
GROUP_CONCAT(IFNULL(external_name,chat_name)) customers
FROM
we_customer_messgaeResult
<where>
message_id=#{messageId}
<if test="messageId !=null">
AND message_id=#{messageId}
</if>
<if test="status!=null">
AND `status`=#{status}
</if>
......
......@@ -85,7 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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),
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>
</mapper>
\ No newline at end of file
......@@ -156,11 +156,20 @@
wc.`name` as customerName,
wu.user_name as takeUserName,
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
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_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>
<if test="handoverUserId != null and handoverUserId !=''">and wac.handover_userid=#{handoverUserId}</if>
<if test="beginTime != null and beginTime !='' and endTime != null and endTime !=''">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment