Commit 665dcfaa by YaoYuHang

推送消息时agentId不存在则显式抛出异常、标签建群目标客户添加时间改为可以不填

1 parent 46805e8c
......@@ -74,10 +74,10 @@
<version>5.6.24</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
......
......@@ -3,7 +3,7 @@ package com.linkwechat.web.controller.wecom;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils;
//import com.alibaba.nacos.common.utils.CollectionUtils;
import com.google.common.collect.Lists;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.config.CosConfig;
......@@ -268,7 +268,7 @@ public class WeTaskFissionController extends BaseController {
List<WeTaskFissionTotalProgressVO> list = Lists.newArrayList();
if (weTaskFission != null) {
List<WeCustomer> customers = weTaskFissionService.getCustomerListById(null, String.valueOf(id));
if (CollectionUtils.isNotEmpty(customers)) {
if (StringUtils.isNotEmpty(customers)) {
customers.stream().filter(Objects::nonNull).forEach(customer -> {
WeTaskFissionTotalProgressVO vo = new WeTaskFissionTotalProgressVO();
vo.setCustomer(customer);
......
......@@ -124,7 +124,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// .antMatchers("/common/uploadFile2Cos").anonymous()
.antMatchers("/wecom/material/temporaryMaterialMediaId").anonymous()
.antMatchers("/wecom/portrait/**").anonymous()
.antMatchers("/wecom/fission/poster", "/wecom/fission/*/progress/*").anonymous()
// 获取实际群活码和社群运营H5页面不需要登录
.antMatchers("/wecom/groupCode/getActualCode/**").anonymous()
.antMatchers("/wecom/community/h5/**").anonymous()
......
......@@ -4,6 +4,7 @@ package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -12,11 +13,13 @@ import lombok.EqualsAndHashCode;
@TableName("we_pres_tag_group")
public class WePresTagGroupTask extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*主键ID
*/
@TableId
private Long taskId;
private Long taskId = SnowFlakeUtil.nextId();;
/**
* 任务名称
......
......@@ -15,6 +15,19 @@ import java.util.List;
public interface WePresTagGroupTaskMapper extends BaseMapper<WePresTagGroupTask> {
/**
* 添加新任务
* @param task 老客标签建群任务
* @return 结果
*/
int insertTask(WePresTagGroupTask task);
/**
* 更新任务
* @param task 建群任务信息
* @return 结果
*/
int updateTask(WePresTagGroupTask task);
/**
* 获取老客户标签建群任务
*
* @param taskId 任务id
......
......@@ -3,6 +3,7 @@ package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.enums.CommunityTaskType;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.*;
......@@ -326,9 +327,12 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
String toUser = groupList.stream().map(WeGroup::getOwner).collect(Collectors.joining("|"));
pushDto.setTouser(toUser);
// 设置agentId
// 获取agentId
WeCorpAccount validWeCorpAccount = corpAccountService.findValidWeCorpAccount();
String agentId = validWeCorpAccount.getAgentId();
if (StringUtils.isEmpty(agentId)) {
throw new WeComException("当前agentId不可用或不存在");
}
pushDto.setAgentid(Integer.valueOf(agentId));
// 设置消息内容
......
......@@ -86,6 +86,7 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
* @return 数据库新增行数
*/
@Override
@Transactional
public int add(WePresTagGroupTaskDto taskDto) {
// 创建WeCommunityOldGroup对象进行存储
......@@ -94,7 +95,7 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
BeanUtils.copyProperties(taskDto, task);
task.setCreateBy(SecurityUtils.getUsername());
int res = 0;
if (this.save(task)) {
if (taskMapper.insertTask(task) > 0) {
// 保存标签对象
List<String> tagIdList = taskDto.getTagList();
if (CollectionUtil.isNotEmpty(tagIdList)) {
......@@ -200,7 +201,7 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
BeanUtils.copyProperties(wePresTagGroupTaskDto, wePresTagGroupTask);
wePresTagGroupTask.setTaskId(taskId);
wePresTagGroupTask.setUpdateBy(SecurityUtils.getUsername());
if (taskMapper.updateById(wePresTagGroupTask) == 1) {
if (taskMapper.updateTask(wePresTagGroupTask) > 0) {
// 更新标签
// 先删除旧标签
QueryWrapper<WePresTagGroupTaskTag> taskTagQueryWrapper = new QueryWrapper<>();
......@@ -422,6 +423,9 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
// 获取agentId
WeCorpAccount validWeCorpAccount = corpAccountService.findValidWeCorpAccount();
String agentId = validWeCorpAccount.getAgentId();
if (StringUtils.isEmpty(agentId)) {
throw new WeComException("当前agentId不可用或不存在");
}
pushDto.setAgentid(Integer.valueOf(agentId));
// 设置文本消息
......
......@@ -88,4 +88,53 @@
AND wptg.send_type = 1;
</select>
<insert id="insertTask" parameterType="WePresTagGroupTask">
INSERT INTO we_pres_tag_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="taskName != null">task_name,</if>
<if test="sendType != null">send_type,</if>
<if test="groupCodeId != null">group_code_id,</if>
<if test="welcomeMsg != null">welcome_msg,</if>
<if test="sendScope != null">send_scope,</if>
<if test="sendGender != null">send_gender,</if>
<if test="cusBeginTime != null and cusBeginTime !=''">cus_begin_time,</if>
<if test="cusEndTime != null and cusEndTime !=''">cus_end_time,</if>
<if test="msgid != null">msgid,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
<if test="taskName != null">#{taskName},</if>
<if test="sendType != null">#{sendType},</if>
<if test="groupCodeId != null">#{groupCodeId},</if>
<if test="welcomeMsg != null">#{welcomeMsg},</if>
<if test="sendScope != null">#{sendScope},</if>
<if test="sendGender != null">#{sendGender},</if>
<if test="cusBeginTime != null and cusBeginTime !=''">#{cusBeginTime},</if>
<if test="cusEndTime != null and cusEndTime !=''">#{cusEndTime},</if>
<if test="msgid != null">#{msgid},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
</trim>
</insert>
<update id="updateTask" parameterType="WePresTagGroupTask">
UPDATE we_pres_tag_group
<trim prefix="SET" suffixOverrides=",">
<if test="taskName != null">task_name = #{taskName},</if>
<if test="sendType != null">send_type = #{sendType},</if>
<if test="groupCodeId != null">group_code_id = #{groupCodeId},</if>
<if test="welcomeMsg != null">welcome_msg = #{welcomeMsg},</if>
<if test="sendScope != null">send_scope = #{sendScope},</if>
<if test="sendGender != null">send_gender = #{sendGender},</if>
<if test="cusBeginTime != null and cusBeginTime !=''">cus_begin_time = #{cusBeginTime},</if>
<if test="cusEndTime != null and cusEndTime !=''">cus_end_time = #{cusEndTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
WHERE task_id = #{taskId}
</update>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!