Commit 5e36081d by 18356073052

群发优化

1 parent 0e22a451
...@@ -45,4 +45,13 @@ public interface WeCustomerMessgaeResultMapper extends BaseMapper<WeCustomerMess ...@@ -45,4 +45,13 @@ public interface WeCustomerMessgaeResultMapper extends BaseMapper<WeCustomerMess
* @return 已发送消息数 * @return 已发送消息数
*/ */
int checkSendStatus(@Param("messageId") Long messageId); int checkSendStatus(@Param("messageId") Long messageId);
/**
* 批量保存映射关系
*
* @param weCustomerMessgaeResults 映射关系列表信息
* @return int 结果
*/
int batchInsert(@Param("customers") List<WeCustomerMessgaeResult> weCustomerMessgaeResults);
} }
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeCustomerMessgaeResult; import com.linkwechat.wecom.domain.WeCustomerMessgaeResult;
...@@ -39,9 +40,12 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe ...@@ -39,9 +40,12 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
int size = 0; int size = 0;
// 0 发给客户 // 0 发给客户
if (customerMessagePushDto.getPushType().equals("0")) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)) {
if (CollectionUtils.isNotEmpty(customers)) { if (CollectionUtils.isNotEmpty(customers)) {
List<WeCustomerMessgaeResult> weCustomerMessgaeResults=Lists.newArrayList();
size = customers.size(); size = customers.size();
customers.forEach(customer -> { customers.forEach(customer -> {
//微信消息发送结果、保存员工客户关系映射关系数据 //微信消息发送结果、保存员工客户关系映射关系数据
...@@ -58,15 +62,17 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe ...@@ -58,15 +62,17 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
customerMessgaeResult.setStatus("0"); customerMessgaeResult.setStatus("0");
customerMessgaeResult.setSettingTime(customerMessagePushDto.getSettingTime()); customerMessgaeResult.setSettingTime(customerMessagePushDto.getSettingTime());
customerMessgaeResult.setDelFlag(0); customerMessgaeResult.setDelFlag(0);
this.save(customerMessgaeResult); weCustomerMessgaeResults.add(customerMessgaeResult);
}); });
customerMessgaeResultMapper.batchInsert(weCustomerMessgaeResults);
} }
} }
// 1 发给客户群 // 1 发给客户群
if (customerMessagePushDto.getPushType().equals("1")) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_GROUP)) {
if (CollectionUtils.isNotEmpty(groups)) { if (CollectionUtils.isNotEmpty(groups)) {
List<WeCustomerMessgaeResult> weCustomerMessgaeResults=Lists.newArrayList();
size = groups.size(); size = groups.size();
groups.forEach(group -> { groups.forEach(group -> {
//微信消息发送结果、保存员工客户关系映射关系数据 //微信消息发送结果、保存员工客户关系映射关系数据
...@@ -84,8 +90,9 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe ...@@ -84,8 +90,9 @@ public class WeCustomerMessgaeResultServiceImpl extends ServiceImpl<WeCustomerMe
//群管理员名称 //群管理员名称
customerMessgaeResult.setUserName(group.getGroupLeaderName()); customerMessgaeResult.setUserName(group.getGroupLeaderName());
customerMessgaeResult.setDelFlag(0); customerMessgaeResult.setDelFlag(0);
this.save(customerMessgaeResult); weCustomerMessgaeResults.add(customerMessgaeResult);
}); });
customerMessgaeResultMapper.batchInsert(weCustomerMessgaeResults);
} }
} }
......
...@@ -3,6 +3,49 @@ ...@@ -3,6 +3,49 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper">
<insert id="batchInsert">
INSERT INTO we_customer_messgaeResult (
messgae_result_id,
message_id,
external_userid,
chat_id,
userid,
`status`,
send_time,
external_name,
user_name,
send_type,
setting_time,
create_by,
create_time,
update_by,
update_time,
del_flag,
chat_name
)
VALUES
<foreach collection="list" item="item" separator="," index="index" >
(#{item.messgaeResultId},
#{item.messageId},
#{item.externalUserid},
#{item.chatId},
#{item.userid},
#{item.status},
#{item.sendTime},
#{item.externalName},
#{item.userName},
#{item.sendType},
#{item.settingTime},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
#{item.delFlag},
#{item.chatName})
</foreach>
</insert>
<update id="updateWeCustomerMessgaeResult"> <update id="updateWeCustomerMessgaeResult">
UPDATE we_customer_messgaeResult UPDATE we_customer_messgaeResult
<set> <set>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!