Commit 43a46a89 by 水库浪子

修改图文群发;群发记录;客户打标签;离职客户按时间查询报错;群发消息同步等相关BUG

1 parent 8a404209
...@@ -53,9 +53,7 @@ public class WeCustomerMessagePushController extends BaseController { ...@@ -53,9 +53,7 @@ public class WeCustomerMessagePushController extends BaseController {
@PostMapping(value = "add") @PostMapping(value = "add")
public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) { public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) {
try { try {
SecurityContext context = SecurityContextHolder.getContext();
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
SecurityContextHolder.setContext(context);
weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto); weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto);
} catch (JsonProcessingException | ParseException | CloneNotSupportedException e) { } catch (JsonProcessingException | ParseException | CloneNotSupportedException e) {
......
...@@ -27,7 +27,7 @@ public interface WeCustomerMessagePushClient { ...@@ -27,7 +27,7 @@ public interface WeCustomerMessagePushClient {
/** /**
* 获取企业群发消息发送结果 * 获取企业群发消息发送结果
* <a href="https://work.weixin.qq.com/api/doc/90000/90135/92136">API文档地址</a> * <a href="https://work.weixin.qq.com/api/doc/90000/90135/93338#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E7%BE%A4%E5%8F%91%E6%88%90%E5%91%98%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C">API文档地址</a>
* *
* @param queryCustomerMessageStatusResultDataObjectDto{msgid} <a href="https://work.weixin.qq.com/api/doc/90000/90135/92135">添加企业群发消息任务返回的msgid</a> * @param queryCustomerMessageStatusResultDataObjectDto{msgid} <a href="https://work.weixin.qq.com/api/doc/90000/90135/92135">添加企业群发消息任务返回的msgid</a>
*/ */
...@@ -37,4 +37,7 @@ public interface WeCustomerMessagePushClient { ...@@ -37,4 +37,7 @@ public interface WeCustomerMessagePushClient {
QueryCustomerMessageStatusResultDto queryCustomerMessageStatus(@Body QueryCustomerMessageStatusResultDataObjectDto queryCustomerMessageStatusResultDataObjectDto); QueryCustomerMessageStatusResultDto queryCustomerMessageStatus(@Body QueryCustomerMessageStatusResultDataObjectDto queryCustomerMessageStatusResultDataObjectDto);
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
...@@ -34,6 +35,7 @@ public class WeFlowerCustomerRel ...@@ -34,6 +35,7 @@ public class WeFlowerCustomerRel
/** 添加了此外部联系人的企业成员userid */ /** 添加了此外部联系人的企业成员userid */
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String userId; private String userId;
/** 外部联系人名称 */ /** 外部联系人名称 */
......
...@@ -84,7 +84,7 @@ public class CustomerMessagePushDto implements Cloneable{ ...@@ -84,7 +84,7 @@ public class CustomerMessagePushDto implements Cloneable{
public String content() { public String content() {
if (this.getMessageType()!=null) { if (this.getMessageType()!=null) {
// 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息 // 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息 4 图文
if ( this.getMessageType().equals("0")) { if ( this.getMessageType().equals("0")) {
return this.getTextMessage().getContent(); return this.getTextMessage().getContent();
} }
...@@ -103,6 +103,12 @@ public class CustomerMessagePushDto implements Cloneable{ ...@@ -103,6 +103,12 @@ public class CustomerMessagePushDto implements Cloneable{
return this.getMiniprogramMessage().getTitle() + ":" + this.getMiniprogramMessage().getPage(); return this.getMiniprogramMessage().getTitle() + ":" + this.getMiniprogramMessage().getPage();
} }
if(this.getMessageType().equals("4")){
return this.getTextMessage().getContent()+","+this.getImageMessage().getPic_url();
}
} }
return null; return null;
...@@ -115,19 +121,6 @@ public class CustomerMessagePushDto implements Cloneable{ ...@@ -115,19 +121,6 @@ public class CustomerMessagePushDto implements Cloneable{
} }
public List<CustomerMessagePushDto> handleImageAndText() throws CloneNotSupportedException {
List<CustomerMessagePushDto> customerMessagePushDtos=new ArrayList<>();
CustomerMessagePushDto cloneOne = this.clone();
cloneOne.setMessageType("0");
customerMessagePushDtos.add(cloneOne);
CustomerMessagePushDto cloneTwo = this.clone();
cloneTwo.setMessageType("1");
customerMessagePushDtos.add(cloneTwo);
return customerMessagePushDtos;
}
} }
...@@ -8,4 +8,8 @@ public class QueryCustomerMessageStatusResultDataObjectDto { ...@@ -8,4 +8,8 @@ public class QueryCustomerMessageStatusResultDataObjectDto {
* 群发消息的id,通过<a href=“https://work.weixin.qq.com/api/doc/90000/90135/92135”>创建企业群发接口</a>返回 * 群发消息的id,通过<a href=“https://work.weixin.qq.com/api/doc/90000/90135/92135”>创建企业群发接口</a>返回
*/ */
private String msgid; private String msgid;
} }
...@@ -17,6 +17,7 @@ public class QueryCustomerMessageStatusResultDto extends WeResultDto { ...@@ -17,6 +17,7 @@ public class QueryCustomerMessageStatusResultDto extends WeResultDto {
private String check_status; private String check_status;
} }
...@@ -2,8 +2,11 @@ package com.linkwechat.wecom.mapper; ...@@ -2,8 +2,11 @@ package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeCustomerMessage; import com.linkwechat.wecom.domain.WeCustomerMessage;
import com.linkwechat.wecom.domain.dto.message.DetailMessageStatusResultDto;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 群发消息 微信消息表Mapper接口 * 群发消息 微信消息表Mapper接口
* *
...@@ -30,4 +33,6 @@ public interface WeCustomerMessageMapper extends BaseMapper<WeCustomerMessage> { ...@@ -30,4 +33,6 @@ public interface WeCustomerMessageMapper extends BaseMapper<WeCustomerMessage> {
*/ */
int updateWeCustomerMessageCheckStatusById(@Param("messageId") Long messageId,@Param("status") String status); int updateWeCustomerMessageCheckStatusById(@Param("messageId") Long messageId,@Param("status") String status);
} }
...@@ -19,6 +19,7 @@ import com.linkwechat.wecom.service.IWeCustomerMessageOriginalService; ...@@ -19,6 +19,7 @@ import com.linkwechat.wecom.service.IWeCustomerMessageOriginalService;
import com.linkwechat.wecom.service.IWeCustomerMessageService; import com.linkwechat.wecom.service.IWeCustomerMessageService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -131,14 +132,16 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer ...@@ -131,14 +132,16 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
List<DetailMessageStatusResultDto> detailList = queryCustomerMessageStatusResultDto.getDetail_list(); List<DetailMessageStatusResultDto> detailList = queryCustomerMessageStatusResultDto.getDetail_list();
detailList.forEach(d -> {
if (d.getStatus().equals(WeConstans.sendMessageStatusEnum.SEND.getStatus())) {
atomicInteger.incrementAndGet(); detailList.forEach(d -> {
//更新消息发送状态
customerMessageMapper.updateWeCustomerMessageCheckStatusById(messageId,WeConstans.sendMessageStatusEnum.SEND.getStatus()); // if (d.getStatus().equals(WeConstans.sendMessageStatusEnum.SEND.getStatus())) {
} //
// atomicInteger.incrementAndGet();
// //更新消息发送状态
// customerMessageMapper.updateWeCustomerMessageCheckStatusById(messageId,WeConstans.sendMessageStatusEnum.SEND.getStatus());
// }
weCustomerMessgaeResultMapper.updateWeCustomerMessgaeResult(messageId, d.getChat_id(), d.getExternal_userid(), d.getStatus(), d.getSend_time()); weCustomerMessgaeResultMapper.updateWeCustomerMessgaeResult(messageId, d.getChat_id(), d.getExternal_userid(), d.getStatus(), d.getSend_time());
......
...@@ -81,29 +81,16 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -81,29 +81,16 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePush) throws JsonProcessingException, ParseException, CloneNotSupportedException { public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException, ParseException, CloneNotSupportedException {
if(StrUtil.isNotBlank(customerMessagePush.getSettingTime())){ if(StrUtil.isNotBlank(customerMessagePushDto.getSettingTime())){
if(DateUtils.diffTime(new Date(), DateUtil.parse(customerMessagePush.getSettingTime(), "yyyy-MM-dd HH:mm")) > 0){ if(DateUtils.diffTime(new Date(), DateUtil.parse(customerMessagePushDto.getSettingTime(), "yyyy-MM-dd HH:mm")) > 0){
throw new WeComException("发送时间不能小于当前时间"); throw new WeComException("发送时间不能小于当前时间");
} }
} }
List<CustomerMessagePushDto> customerMessagePushDtos=new ArrayList<>();
if(customerMessagePush.getMessageType().equals("4")){ if(customerMessagePushDto.getMessageType().equals("1")){//等于图片或者图文,根据图片URL,获取新的media_id
customerMessagePushDtos=customerMessagePush.handleImageAndText();
}else{
customerMessagePushDtos.add(customerMessagePush);
}
for(CustomerMessagePushDto customerMessagePushDto:customerMessagePushDtos){
if(customerMessagePush.getMessageType().equals("1")){//等于图片或者图文,根据图片URL,获取新的media_id
ImageMessageDto imageMessage = customerMessagePushDto.getImageMessage(); ImageMessageDto imageMessage = customerMessagePushDto.getImageMessage();
...@@ -120,7 +107,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -120,7 +107,6 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
} }
List<WeCustomer> customers = Lists.newArrayList(); List<WeCustomer> customers = Lists.newArrayList();
List<WeGroup> groups = new ArrayList<>(); List<WeGroup> groups = new ArrayList<>();
// 0 发给客户 // 0 发给客户
...@@ -166,13 +152,8 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -166,13 +152,8 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
//保存分类消息信息 //保存分类消息信息
weCustomerSeedMessageService.saveSeedMessage(customerMessagePushDto, messageId); weCustomerSeedMessageService.saveSeedMessage(customerMessagePushDto, messageId);
this.sendMessage(customerMessagePushDto,messageId,customers,groups); this.sendMessage(customerMessagePushDto,messageId,customers,groups);
}
} }
......
...@@ -15,10 +15,7 @@ import com.linkwechat.wecom.domain.WeCustomer; ...@@ -15,10 +15,7 @@ import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeCustomerMessage; import com.linkwechat.wecom.domain.WeCustomerMessage;
import com.linkwechat.wecom.domain.WeGroup; import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; import com.linkwechat.wecom.domain.dto.message.*;
import com.linkwechat.wecom.domain.dto.message.ImageMessageDto;
import com.linkwechat.wecom.domain.dto.message.SendMessageResultDto;
import com.linkwechat.wecom.domain.dto.message.WeCustomerMessagePushDto;
import com.linkwechat.wecom.mapper.WeCustomerMessageMapper; import com.linkwechat.wecom.mapper.WeCustomerMessageMapper;
import com.linkwechat.wecom.service.IWeCustomerMessageService; import com.linkwechat.wecom.service.IWeCustomerMessageService;
import com.linkwechat.wecom.service.IWeMaterialService; import com.linkwechat.wecom.service.IWeMaterialService;
...@@ -89,7 +86,9 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -89,7 +86,9 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
//通过messageId更新msgIds //通过messageId更新msgIds
WeCustomerMessage weCustomerMessage = new WeCustomerMessage(); WeCustomerMessage weCustomerMessage = new WeCustomerMessage();
weCustomerMessage.setMessageId(messageId); weCustomerMessage.setMessageId(messageId);
weCustomerMessage.setMsgid(objectMapper.writeValueAsString(msgIds)); // String result = msgIds.stream().map(String::valueOf).collect(Collectors.joining(","));
weCustomerMessage.setMsgid(msgIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
// weCustomerMessage.setMsgid(objectMapper.writeValueAsString(msgIds));
weCustomerMessageMapper.updateWeCustomerMessageMsgIdById(weCustomerMessage); weCustomerMessageMapper.updateWeCustomerMessageMsgIdById(weCustomerMessage);
} }
...@@ -102,6 +101,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -102,6 +101,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)) {
WeCustomerMessagePushDto messagePushDto = new WeCustomerMessagePushDto(); WeCustomerMessagePushDto messagePushDto = new WeCustomerMessagePushDto();
messagePushDto.setChat_type(ChatType.of(customerMessagePushDto.getPushType()).getName()); messagePushDto.setChat_type(ChatType.of(customerMessagePushDto.getPushType()).getName());
List<String> externalUserIds = customers.stream().map(WeCustomer::getExternalUserid).collect(Collectors.toList()); List<String> externalUserIds = customers.stream().map(WeCustomer::getExternalUserid).collect(Collectors.toList());
...@@ -135,6 +135,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -135,6 +135,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
} }
this.updateMsgId(messageId, msgid); this.updateMsgId(messageId, msgid);
} }
...@@ -182,9 +183,11 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -182,9 +183,11 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
if(customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT_IMAGE.getType())){ if(customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT_IMAGE.getType())){
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("msgtype","text_image"); jsonObject.put("msgtype","image");
jsonObject.put("text_image",customerMessagePushDto.getTextMessage()); jsonObject.put("image",customerMessagePushDto.getImageMessage());
list.add(jsonObject); list.add(jsonObject);
weCustomerMessagePushDto.setText(customerMessagePushDto.getTextMessage());
} }
if(customerMessagePushDto.getMessageType().equals(GroupMessageType.VIDEO.getType())){ if(customerMessagePushDto.getMessageType().equals(GroupMessageType.VIDEO.getType())){
......
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
...@@ -349,10 +350,16 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -349,10 +350,16 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void makeLabel(WeMakeCustomerTag weMakeCustomerTag) { public void makeLabel(WeMakeCustomerTag weMakeCustomerTag) {
LambdaQueryWrapper<WeFlowerCustomerRel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(WeFlowerCustomerRel::getExternalUserid, weMakeCustomerTag.getExternalUserid());
if(StrUtil.isNotBlank(weMakeCustomerTag.getUserId())){
wrapper.eq(WeFlowerCustomerRel::getUserId,weMakeCustomerTag.getUserId());
}
//查询出当前用户对应的 //查询出当前用户对应的
List<WeFlowerCustomerRel> flowerCustomerRels = iWeFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>() List<WeFlowerCustomerRel> flowerCustomerRels = iWeFlowerCustomerRelService.list(
.eq(WeFlowerCustomerRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()) wrapper
.eq(WeFlowerCustomerRel::getUserId,weMakeCustomerTag.getUserId())
); );
if (CollectionUtil.isNotEmpty(flowerCustomerRels)) { if (CollectionUtil.isNotEmpty(flowerCustomerRels)) {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
message_id=#{messageId} message_id=#{messageId}
</where> </where>
</update> </update>
<update id="updateWeCustomerMessageCheckStatusById"> <update id="updateWeCustomerMessageCheckStatusById">
UPDATE we_customer_message UPDATE we_customer_message
<set> <set>
...@@ -31,4 +32,6 @@ ...@@ -31,4 +32,6 @@
</where> </where>
</update> </update>
</mapper> </mapper>
...@@ -65,8 +65,10 @@ ...@@ -65,8 +65,10 @@
AND external_userid=#{externalUserid} AND external_userid=#{externalUserid}
</if> </if>
</where> </where>
</update> </update>
<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,
......
...@@ -237,7 +237,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -237,7 +237,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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 !=''">
DATE_FORMAT(wu.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime} and DATE_FORMAT(wu.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime}
</if> </if>
</where> </where>
</select> </select>
...@@ -258,7 +258,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -258,7 +258,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="oldOwner != null and oldOwner !=''">and wag.old_owner=#{oldOwner}</if> <if test="oldOwner != null and oldOwner !=''">and wag.old_owner=#{oldOwner}</if>
<if test="beginTime != null and beginTime !='' and endTime != null and endTime !=''"> <if test="beginTime != null and beginTime !='' and endTime != null and endTime !=''">
DATE_FORMAT(wu.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime} and DATE_FORMAT(wu.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime}
</if> </if>
</where> </where>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!