Переглянути джерело

群发任务用户添加时间范围

zoujiajian 2 роки тому
батько
коміт
f96c8c0515

+ 3 - 2
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserFollowRelationMapper.java

@@ -5,6 +5,7 @@ import com.cyksj.model.dto.CorpUserFollowRelationDto;
 import com.cyksj.model.entity.CorpUserFollowRelation;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -15,9 +16,9 @@ public interface CorpUserFollowRelationMapper extends BaseMapper<CorpUserFollowR
 
 	String selectCorpCustomers(@Param("unionid") String unionid, @Param("wxCorpId") Long wxCorpId);
 
-	List<CorpUserFollowRelationDto> selectCorpUserFollowRelationByTagIds(@Param("list") List<String> tagIds, @Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> followIds, @Param("userScope") Integer userScope, @Param("consumerScope") Integer consumerScope);
+	List<CorpUserFollowRelationDto> selectCorpUserFollowRelationByTagIds(@Param("list") List<String> tagIds, @Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> followIds, @Param("userScope") Integer userScope, @Param("consumerScope") Integer consumerScope, @Param("joinStartTime") Date joinStartTime, @Param("joinEndTime") Date joinEndTime);
 
 	List<CorpUserFollowRelationDto> selectCorpUserFollowRelation(@Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> service_follow_ids);
 
-	List<CorpUserFollowRelationDto> selectCorpUserNotUnderTagIds(@Param("list") List<String> tagIds, @Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> followIds, @Param("userScope") Integer userScope, @Param("consumerScope") Integer consumerScope);
+	List<CorpUserFollowRelationDto> selectCorpUserNotUnderTagIds(@Param("list") List<String> tagIds, @Param("wxCorpId") Long wxCorpId, @Param("followIds") List<String> followIds, @Param("userScope") Integer userScope, @Param("consumerScope") Integer consumerScope, @Param("joinStartTime") Date joinStartTime, @Param("joinEndTime") Date joinEndTime);
 }

+ 13 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpMsgBulkTask.java

@@ -148,6 +148,19 @@ public class CorpMsgBulkTask implements Serializable {
 	 */
 	private Integer consumerScope;
 
+
+	/**
+	 * 用户添加客服起始时间
+	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private Date joinStartTime;
+
+	/**
+	 * 用户添加客服结束时间
+	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private Date joinEndTime;
+
 	private Boolean deleted;
 
 	/**

+ 12 - 0
netflix-dao/src/main/resources/mapper/CorpUserFollowRelationMapper.xml

@@ -26,6 +26,12 @@
         left join `corp_user_auth` ca on ca.external_userid = cufr.corp_user_id
         left join `corp_user` cu on cu.id = ca.corp_user_id
         where cufr.wx_corp_id = #{wxCorpId}
+        <if test="joinStartTime != null">
+            and cu.created_time >= #{joinStartTime}
+        </if>
+        <if test="joinEndTime != null">
+            and cu.created_time &lt; #{joinEndTime}
+        </if>
         <choose>
             <when test="userScope == 2">
                 and cu.user_id != 0
@@ -78,6 +84,12 @@
         any_value(cu.user_id) as user_id
         from corp_user cu inner join corp_user_auth ca on ca.corp_user_id = cu.id
         and ca.wx_corp_id = #{wxCorpId}
+        <if test="joinStartTime != null">
+            and cu.created_time >= #{joinStartTime}
+        </if>
+        <if test="joinEndTime != null">
+            and cu.created_time &lt; #{joinEndTime}
+        </if>
         <choose>
             <when test="userScope == 2">
                 and cu.user_id != 0

+ 4 - 2
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpMsgBulkTaskServiceImpl.java

@@ -263,14 +263,16 @@ public class CorpMsgBulkTaskServiceImpl extends ServiceImpl<CorpMsgBulkTaskMappe
 		Integer sendScope = corpMsgBulkTask.getSendScope();
 
 		Integer consumerScope = corpMsgBulkTask.getConsumerScope();
+		Date joinStartTime = corpMsgBulkTask.getJoinStartTime();
+		Date joinEndTime = corpMsgBulkTask.getJoinEndTime();
 
 		List<CorpUserFollowRelationDto> corpUserFollowRelations = null;
 		//全部用户
 		if (sendScope == 1) {
 			//此时tagIds是 需要过滤的用户标签
-			corpUserFollowRelations = corpUserFollowRelationMapper.selectCorpUserNotUnderTagIds(tagIds, wxCorpApp.getId(), service_follow_ids, userScope, consumerScope);
+			corpUserFollowRelations = corpUserFollowRelationMapper.selectCorpUserNotUnderTagIds(tagIds, wxCorpApp.getId(), service_follow_ids, userScope, consumerScope, joinStartTime, joinEndTime);
 		} else {
-			corpUserFollowRelations = corpUserFollowRelationMapper.selectCorpUserFollowRelationByTagIds(tagIds, wxCorpApp.getId(), service_follow_ids, userScope, consumerScope);
+			corpUserFollowRelations = corpUserFollowRelationMapper.selectCorpUserFollowRelationByTagIds(tagIds, wxCorpApp.getId(), service_follow_ids, userScope, consumerScope, joinStartTime, joinEndTime);
 		}
 		//将成员与客户相同关联聚合
 		Map<String, List<CorpUserFollowRelationDto>> userRelationMap = corpUserFollowRelations.stream().collect(Collectors.groupingBy(CorpUserFollowRelationDto::getFollowId));