Browse Source

Merge branch 'master' into dev-xym-update-cgi

xueyiming 3 months ago
parent
commit
e21c855ee9

+ 23 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -112,12 +113,15 @@ public class GhDetailServiceImpl implements GhDetailService {
             if (!CollectionUtils.isEmpty(ghDetailVo.getVideoIds())) {
                 ghDetail.setVideoIds(JSONObject.toJSONString(ghDetailVo.getVideoIds()));
             }
+            if (StringUtils.isEmpty(ghDetail.getContentDetail())) {
+                ghDetail.setContentDetail(null);
+            }
             ghDetailMapper.insertSelective(ghDetail);
             return CommonResponse.success();
         } catch (Exception e) {
             log.error("addGhDetail error", e);
         }
-        return CommonResponse.create(500, "插入失败,可能已经存在该记录");
+        return CommonResponse.create(500, "插入失败");
     }
 
     @Override
@@ -138,10 +142,27 @@ public class GhDetailServiceImpl implements GhDetailService {
             if (StringUtils.isNotEmpty(ghDetailVo.getAccountName())) {
                 ghDetail.setGhName(ghDetailVo.getAccountName());
             }
+            if (StringUtils.isEmpty(ghDetail.getContentDetail())) {
+                ghDetail.setContentDetail(null);
+            }
             ghDetail.setGhId(ghDetailVo.getAccountId());
             ghDetail.setGhName(ghDetailVo.getAccountName());
             ghDetail.setVideoIds(JSONObject.toJSONString(ghDetailVo.getVideoIds()));
             ghDetailMapper.updateByPrimaryKeySelective(ghDetail);
+
+            if (StringUtils.isEmpty(ghDetail.getContentDetail()) || StringUtils.isEmpty(ghDetail.getRate())) {
+                GhDetail updateGhDetail = ghDetailMapper.selectByPrimaryKey(ghDetail.getId());
+                if (StringUtils.isEmpty(ghDetail.getContentDetail())) {
+                    updateGhDetail.setContentDetail(null);
+                }
+                if (StringUtils.isEmpty(ghDetail.getRate())) {
+                    updateGhDetail.setRate(null);
+                }
+                updateGhDetail.setUpdateTime(new Date());
+                ghDetailMapper.updateByPrimaryKey(updateGhDetail);
+            }
+
+
             return CommonResponse.success();
         } catch (Exception e) {
             log.error("updateDetail error", e);
@@ -175,6 +196,7 @@ public class GhDetailServiceImpl implements GhDetailService {
         }
 
         if (StringUtils.isNotEmpty(ghDetailVo.getContentDetail())) {
+            ghDetailVo.setContentDetail(ghDetailVo.getContentDetail().trim());
             if (!JSONObject.isValidObject(ghDetailVo.getContentDetail())) {
                 return CommonResponse.create(500, "文章内容格式错误");
             }

+ 2 - 2
api-module/src/main/resources/mybatis-generator-config.xml

@@ -51,11 +51,11 @@
         </javaClientGenerator>
 
 <!--        <table tableName="we_com_alert_message" domainObjectName="AlertMessage" alias=""/>-->
-        <table tableName="gh_detail" domainObjectName="GhDetail" alias=""/>
+<!--        <table tableName="gh_detail" domainObjectName="GhDetail" alias=""/>-->
 <!--        <table tableName="we_com_guarantees_video" domainObjectName="GuaranteesVideo" alias=""/>-->
 <!--        <table tableName="we_com_staff" domainObjectName="Staff" alias=""/>-->
 <!--        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>-->
-<!--        <table tableName="we_com_special_pre_send_message" domainObjectName="PreSpecialSendMessage" alias=""/>-->
+        <table tableName="we_com_special_pre_send_message" domainObjectName="PreSpecialSendMessage" alias=""/>
 <!--        <table tableName="we_com_send_msg_result" domainObjectName="SendMsgResult" alias=""/>-->
 <!--        <table tableName="we_com_corp" domainObjectName="Corp" alias=""/>-->
 

+ 10 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/common/constant/MessageConstant.java

@@ -1,5 +1,8 @@
 package com.tzld.piaoquan.growth.common.common.constant;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public interface MessageConstant {
 
     //推送保底内容
@@ -7,6 +10,13 @@ public interface MessageConstant {
 
     String morningText = "早安,新的一天,愿你拥有最好的心情去迎接一切美好!爆款视频抢先观看,点击下方精彩不断~";
 
+    String specialText = "亲爱的老友好!温水暖胃勤添衣,养生小视频更新啦!点开小程序看看,精彩不断~";
+
+    List<Long> specialStaffIdList = new ArrayList<Long>() {{
+        add(16L);
+        add(17L);
+    }};
+
     //小程序id
     String appid = "wxbdd2a2e93d9a6e25";
 

+ 20 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/PreSpecialStatusEnum.java

@@ -0,0 +1,20 @@
+package com.tzld.piaoquan.growth.common.common.enums;
+
+
+import lombok.Getter;
+
+@Getter
+public enum PreSpecialStatusEnum {
+
+    DEFAULT(0, "默认"),
+    TAG(1, "标签"),
+    GENDER(2, "性别");
+
+    private final Integer status;
+    private final String desc;
+
+    PreSpecialStatusEnum(Integer status, String desc) {
+        this.status = status;
+        this.desc = desc;
+    }
+}

+ 5 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/WeComUserMapper.java

@@ -45,4 +45,9 @@ public interface WeComUserMapper {
 
     List<WeComUser> selectByTagUserList(@Param("tagId") Long tagId);
 
+    List<WeComUser> selectByGenderUserList(@Param("staffId") Long staffId,
+                                           @Param("groupMsgDisabled") byte groupMsgDisabled,
+                                           @Param("filterTagIdList") List<Long> filterTagIdList,
+                                           @Param("gender") Integer gender);
+
 }

+ 22 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/PreSpecialSendMessage.java

@@ -9,6 +9,8 @@ public class PreSpecialSendMessage {
 
     private Long staffId;
 
+    private Integer status;
+
     private String content;
 
     private String attachmentIds;
@@ -21,6 +23,8 @@ public class PreSpecialSendMessage {
 
     private Long tagId;
 
+    private Integer gender;
+
     private Date createTime;
 
     private Date updateTime;
@@ -49,6 +53,14 @@ public class PreSpecialSendMessage {
         this.staffId = staffId;
     }
 
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
     public String getContent() {
         return content;
     }
@@ -97,6 +109,14 @@ public class PreSpecialSendMessage {
         this.tagId = tagId;
     }
 
+    public Integer getGender() {
+        return gender;
+    }
+
+    public void setGender(Integer gender) {
+        this.gender = gender;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }
@@ -122,12 +142,14 @@ public class PreSpecialSendMessage {
         sb.append(", id=").append(id);
         sb.append(", preSendDate=").append(preSendDate);
         sb.append(", staffId=").append(staffId);
+        sb.append(", status=").append(status);
         sb.append(", content=").append(content);
         sb.append(", attachmentIds=").append(attachmentIds);
         sb.append(", groupMsgDisabled=").append(groupMsgDisabled);
         sb.append(", pageNum=").append(pageNum);
         sb.append(", pageSize=").append(pageSize);
         sb.append(", tagId=").append(tagId);
+        sb.append(", gender=").append(gender);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);
         sb.append("]");

+ 120 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/PreSpecialSendMessageExample.java

@@ -307,6 +307,66 @@ public class PreSpecialSendMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andStatusIsNull() {
+            addCriterion("`status` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIsNotNull() {
+            addCriterion("`status` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusEqualTo(Integer value) {
+            addCriterion("`status` =", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotEqualTo(Integer value) {
+            addCriterion("`status` <>", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThan(Integer value) {
+            addCriterion("`status` >", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
+            addCriterion("`status` >=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThan(Integer value) {
+            addCriterion("`status` <", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThanOrEqualTo(Integer value) {
+            addCriterion("`status` <=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIn(List<Integer> values) {
+            addCriterion("`status` in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotIn(List<Integer> values) {
+            addCriterion("`status` not in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusBetween(Integer value1, Integer value2) {
+            addCriterion("`status` between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotBetween(Integer value1, Integer value2) {
+            addCriterion("`status` not between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
         public Criteria andContentIsNull() {
             addCriterion("content is null");
             return (Criteria) this;
@@ -687,6 +747,66 @@ public class PreSpecialSendMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andGenderIsNull() {
+            addCriterion("gender is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderIsNotNull() {
+            addCriterion("gender is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderEqualTo(Integer value) {
+            addCriterion("gender =", value, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderNotEqualTo(Integer value) {
+            addCriterion("gender <>", value, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderGreaterThan(Integer value) {
+            addCriterion("gender >", value, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderGreaterThanOrEqualTo(Integer value) {
+            addCriterion("gender >=", value, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderLessThan(Integer value) {
+            addCriterion("gender <", value, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderLessThanOrEqualTo(Integer value) {
+            addCriterion("gender <=", value, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderIn(List<Integer> values) {
+            addCriterion("gender in", values, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderNotIn(List<Integer> values) {
+            addCriterion("gender not in", values, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderBetween(Integer value1, Integer value2) {
+            addCriterion("gender between", value1, value2, "gender");
+            return (Criteria) this;
+        }
+
+        public Criteria andGenderNotBetween(Integer value1, Integer value2) {
+            addCriterion("gender not between", value1, value2, "gender");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateTimeIsNull() {
             addCriterion("create_time is null");
             return (Criteria) this;

+ 7 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageServiceImpl.java

@@ -18,8 +18,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
+import static com.tzld.piaoquan.growth.common.common.constant.MessageConstant.specialStaffIdList;
 import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.POST_WE_COM_ADD_MSG_TEMPLATE;
 
 
@@ -36,6 +38,7 @@ public class MessageServiceImpl implements MessageService {
     @Autowired
     private PreSpecialSendMessageMapper preSpecialSendMessageMapper;
 
+
     @Override
     public boolean pushWeComMessage(JSONObject jsonObject, Long corpId) {
         try {
@@ -59,7 +62,10 @@ public class MessageServiceImpl implements MessageService {
 
 
     @Override
-    public String getMessageText() {
+    public String getMessageText(Long staffId) {
+        if (specialStaffIdList.contains(staffId)) {
+            return MessageConstant.specialText;
+        }
         Integer hour = DateUtil.getHourOfDay();
         if (hour < 12) {
             return MessageConstant.morningText;

+ 1 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/WeComUserServiceImpl.java

@@ -316,7 +316,7 @@ public class WeComUserServiceImpl implements WeComUserService {
     @Override
     public List<Staff> getStaffByUserId(Long userId) {
         StaffWithUserExample example = new StaffWithUserExample();
-        example.createCriteria().andUserIdEqualTo(userId);
+        example.createCriteria().andUserIdEqualTo(userId).andIsDeleteEqualTo(0);
         List<StaffWithUser> staffWithUsers = staffWithUserMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(staffWithUsers)) {
             return null;

+ 1 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageService.java

@@ -10,7 +10,7 @@ public interface MessageService {
 
     boolean pushWeComMessage(JSONObject jsonObject, Long corpId);
 
-    String getMessageText();
+    String getMessageText(Long staffId);
 
     CommonResponse<Void> createPreSpecialAssembleSendMessage(List<PreSpecialSendMessage> preSpecialSendMessages);
 }

+ 40 - 8
common-module/src/main/resources/mapper/PreSpecialSendMessageMapper.xml

@@ -5,12 +5,14 @@
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="pre_send_date" jdbcType="VARCHAR" property="preSendDate" />
     <result column="staff_id" jdbcType="BIGINT" property="staffId" />
+    <result column="status" jdbcType="INTEGER" property="status" />
     <result column="content" jdbcType="VARCHAR" property="content" />
     <result column="attachment_ids" jdbcType="VARCHAR" property="attachmentIds" />
     <result column="group_msg_disabled" jdbcType="INTEGER" property="groupMsgDisabled" />
     <result column="page_num" jdbcType="INTEGER" property="pageNum" />
     <result column="page_size" jdbcType="INTEGER" property="pageSize" />
     <result column="tag_id" jdbcType="BIGINT" property="tagId" />
+    <result column="gender" jdbcType="INTEGER" property="gender" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
@@ -73,8 +75,8 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, pre_send_date, staff_id, content, attachment_ids, group_msg_disabled, page_num, 
-    page_size, tag_id, create_time, update_time
+    id, pre_send_date, staff_id, `status`, content, attachment_ids, group_msg_disabled, 
+    page_num, page_size, tag_id, gender, create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessageExample" resultMap="BaseResultMap">
     select
@@ -111,13 +113,15 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessage">
     insert into we_com_special_pre_send_message (id, pre_send_date, staff_id, 
-      content, attachment_ids, group_msg_disabled, 
-      page_num, page_size, tag_id, 
-      create_time, update_time)
+      `status`, content, attachment_ids, 
+      group_msg_disabled, page_num, page_size, 
+      tag_id, gender, create_time, 
+      update_time)
     values (#{id,jdbcType=BIGINT}, #{preSendDate,jdbcType=VARCHAR}, #{staffId,jdbcType=BIGINT}, 
-      #{content,jdbcType=VARCHAR}, #{attachmentIds,jdbcType=VARCHAR}, #{groupMsgDisabled,jdbcType=INTEGER}, 
-      #{pageNum,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}, #{tagId,jdbcType=BIGINT}, 
-      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+      #{status,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, #{attachmentIds,jdbcType=VARCHAR}, 
+      #{groupMsgDisabled,jdbcType=INTEGER}, #{pageNum,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}, 
+      #{tagId,jdbcType=BIGINT}, #{gender,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessage">
     insert into we_com_special_pre_send_message
@@ -131,6 +135,9 @@
       <if test="staffId != null">
         staff_id,
       </if>
+      <if test="status != null">
+        `status`,
+      </if>
       <if test="content != null">
         content,
       </if>
@@ -149,6 +156,9 @@
       <if test="tagId != null">
         tag_id,
       </if>
+      <if test="gender != null">
+        gender,
+      </if>
       <if test="createTime != null">
         create_time,
       </if>
@@ -166,6 +176,9 @@
       <if test="staffId != null">
         #{staffId,jdbcType=BIGINT},
       </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
       <if test="content != null">
         #{content,jdbcType=VARCHAR},
       </if>
@@ -184,6 +197,9 @@
       <if test="tagId != null">
         #{tagId,jdbcType=BIGINT},
       </if>
+      <if test="gender != null">
+        #{gender,jdbcType=INTEGER},
+      </if>
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -210,6 +226,9 @@
       <if test="record.staffId != null">
         staff_id = #{record.staffId,jdbcType=BIGINT},
       </if>
+      <if test="record.status != null">
+        `status` = #{record.status,jdbcType=INTEGER},
+      </if>
       <if test="record.content != null">
         content = #{record.content,jdbcType=VARCHAR},
       </if>
@@ -228,6 +247,9 @@
       <if test="record.tagId != null">
         tag_id = #{record.tagId,jdbcType=BIGINT},
       </if>
+      <if test="record.gender != null">
+        gender = #{record.gender,jdbcType=INTEGER},
+      </if>
       <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
       </if>
@@ -244,12 +266,14 @@
     set id = #{record.id,jdbcType=BIGINT},
       pre_send_date = #{record.preSendDate,jdbcType=VARCHAR},
       staff_id = #{record.staffId,jdbcType=BIGINT},
+      `status` = #{record.status,jdbcType=INTEGER},
       content = #{record.content,jdbcType=VARCHAR},
       attachment_ids = #{record.attachmentIds,jdbcType=VARCHAR},
       group_msg_disabled = #{record.groupMsgDisabled,jdbcType=INTEGER},
       page_num = #{record.pageNum,jdbcType=INTEGER},
       page_size = #{record.pageSize,jdbcType=INTEGER},
       tag_id = #{record.tagId,jdbcType=BIGINT},
+      gender = #{record.gender,jdbcType=INTEGER},
       create_time = #{record.createTime,jdbcType=TIMESTAMP},
       update_time = #{record.updateTime,jdbcType=TIMESTAMP}
     <if test="_parameter != null">
@@ -265,6 +289,9 @@
       <if test="staffId != null">
         staff_id = #{staffId,jdbcType=BIGINT},
       </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
       <if test="content != null">
         content = #{content,jdbcType=VARCHAR},
       </if>
@@ -283,6 +310,9 @@
       <if test="tagId != null">
         tag_id = #{tagId,jdbcType=BIGINT},
       </if>
+      <if test="gender != null">
+        gender = #{gender,jdbcType=INTEGER},
+      </if>
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -296,12 +326,14 @@
     update we_com_special_pre_send_message
     set pre_send_date = #{preSendDate,jdbcType=VARCHAR},
       staff_id = #{staffId,jdbcType=BIGINT},
+      `status` = #{status,jdbcType=INTEGER},
       content = #{content,jdbcType=VARCHAR},
       attachment_ids = #{attachmentIds,jdbcType=VARCHAR},
       group_msg_disabled = #{groupMsgDisabled,jdbcType=INTEGER},
       page_num = #{pageNum,jdbcType=INTEGER},
       page_size = #{pageSize,jdbcType=INTEGER},
       tag_id = #{tagId,jdbcType=BIGINT},
+      gender = #{gender,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}

+ 22 - 0
common-module/src/main/resources/mapper/WeComUserMapper.xml

@@ -473,4 +473,26 @@
                  join we_com_user_with_tag t2 on t1.id = t2.user_id
         where t2.tag_id = #{tagId,jdbcType=BIGINT}
     </select>
+
+    <select id="selectByGenderUserList" resultType="com.tzld.piaoquan.growth.common.model.po.WeComUser">
+        select t1.*
+        from we_com_user t1
+        left join we_com_staff_with_user t2 on t1.id = t2.user_id
+        where t1.group_msg_disabled = #{groupMsgDisabled,jdbcType=TINYINT}
+        and t2.staff_id = #{staffId,jdbcType=BIGINT}
+        and t2.is_delete = 0
+        and t1.gender = #{gender,jdbcType=INTEGER}
+        <if test="filterTagIdList != null and filterTagIdList.size() > 0">
+            and t1.id not in (
+            select t2.id
+            from we_com_user_with_tag t1
+            join we_com_user t2 on t1.user_id = t2.id
+            where t1.tag_id in
+            <foreach item="item" index="index" collection="filterTagIdList"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            )
+        </if>
+    </select>
 </mapper>

+ 10 - 2
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -3,6 +3,7 @@ package com.tzld.piaoquan.offline.job;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
+import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
 import com.tzld.piaoquan.growth.common.common.constant.TimeConstant;
 import com.tzld.piaoquan.growth.common.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
@@ -35,6 +36,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static com.tzld.piaoquan.growth.common.common.constant.MessageConstant.MAX_VIDEO_NUM;
+import static com.tzld.piaoquan.growth.common.common.constant.MessageConstant.specialStaffIdList;
 import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.*;
 import static com.tzld.piaoquan.growth.common.common.enums.SourceEnum.HISTORICAL_TOP;
 import static com.tzld.piaoquan.growth.common.common.enums.SourceEnum.MANUAL;
@@ -90,12 +92,18 @@ public class WeComHistoryDataJob {
     @XxlJob("saveHistoryMessageJob1")
     public ReturnT<String> saveHistoryMessageJob1(String param) {
         Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(START_TIME_KEY);
+        Long dayStartTime = DateUtil.getBeforeDayStart(0);
         Long startTime;
         if (startTimeVal == null) {
             startTime = DateUtil.getBeforeDayStart(0);
         } else {
-            startTime = (long) startTimeVal;
+            if (dayStartTime > startTimeVal) {
+                startTime = dayStartTime;
+            } else {
+                startTime = (long) startTimeVal;
+            }
         }
+
         Long endTime = System.currentTimeMillis() / 1000;
         CorpExample example = new CorpExample();
         List<Corp> corps = corpMapper.selectByExample(example);
@@ -149,7 +157,7 @@ public class WeComHistoryDataJob {
             long count = sendCountList.get(0) + sendCountList.get(1) + sendCountList.get(2) + sendCountList.get(3);
             allCount += count;
             notSend += sendCountList.get(0);
-            if (count != 0 && sendCountList.get(0) > 0) {
+            if (count != 0 && sendCountList.get(0) > 0 && !specialStaffIdList.contains(sendDetail.getStaffId())) {
                 LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 if (sendDetail.getStaffId() == 3) {
                     LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");

+ 2 - 2
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComMessageDataJob.java

@@ -244,7 +244,7 @@ public class WeComMessageDataJob {
         for (Corp corp : corps) {
             WeComUserExample weComUserExample = new WeComUserExample();
             WeComUserExample.Criteria criteria = weComUserExample.createCriteria().andExternalUserIdIsNotNull().andCorpIdEqualTo(corp.getId())
-                    .andGroupMsgDisabledNotEqualTo((byte) 2);
+                    .andGroupMsgDisabledEqualTo((byte) 0);
             if (xxlJobParam.getUserId() != null) {
                 criteria.andIdEqualTo(xxlJobParam.getUserId());
             }
@@ -509,7 +509,7 @@ public class WeComMessageDataJob {
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("chat_type", "single");
         JSONObject text = new JSONObject();
-        String content = messageService.getMessageText();
+        String content = messageService.getMessageText(staff.getId());
         text.put("content", content);
         jsonObject.put("text", text);
         jsonObject.put("sender", staff.getCarrierId());

+ 48 - 13
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComSpecialDataJob.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
 import com.tzld.piaoquan.growth.common.common.enums.MessageAttachmentTypeEnum;
+import com.tzld.piaoquan.growth.common.common.enums.PreSpecialStatusEnum;
 import com.tzld.piaoquan.growth.common.dao.mapper.PreSpecialSendMessageMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.SpecialSendMessageMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.StaffMapper;
@@ -63,30 +64,43 @@ public class WeComSpecialDataJob {
         PreSpecialSendMessageExample example = new PreSpecialSendMessageExample();
         example.createCriteria().andPreSendDateEqualTo(thatDayDateString);
         List<PreSpecialSendMessage> preSpecialSendMessages = preSpecialSendMessageMapper.selectByExample(example);
-        List<PreSpecialSendMessage> notHasTagPreSpecialSendMessage = preSpecialSendMessages.stream().filter(e -> e.getTagId() == null).collect(Collectors.toList());
-        if (!CollectionUtils.isEmpty(notHasTagPreSpecialSendMessage)) {
-            for (PreSpecialSendMessage preSpecialSendMessage : notHasTagPreSpecialSendMessage) {
-                notHasTagSpecialAssembleSendMessage(preSpecialSendMessage.getId(), preSpecialSendMessage.getStaffId(),
+        List<PreSpecialSendMessage> defaultPreSpecialSendMessage = preSpecialSendMessages.stream()
+                .filter(e -> Objects.equals(e.getStatus(), PreSpecialStatusEnum.DEFAULT.getStatus())).collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(defaultPreSpecialSendMessage)) {
+            for (PreSpecialSendMessage preSpecialSendMessage : defaultPreSpecialSendMessage) {
+                defaultSpecialAssembleSendMessage(preSpecialSendMessage.getId(), preSpecialSendMessage.getStaffId(),
                         preSpecialSendMessage.getPageNum(), preSpecialSendMessage.getPageSize(),
                         preSpecialSendMessage.getGroupMsgDisabled().byteValue(), preSpecialSendMessage.getAttachmentIds(),
                         preSpecialSendMessage.getContent(), preSpecialSendMessage.getPreSendDate());
             }
         }
-        List<PreSpecialSendMessage> hasTagPreSpecialSendMessage = preSpecialSendMessages.stream().filter(e -> e.getTagId() != null).collect(Collectors.toList());
-        if (!CollectionUtils.isEmpty(hasTagPreSpecialSendMessage)) {
-            for (PreSpecialSendMessage preSpecialSendMessage : hasTagPreSpecialSendMessage) {
-                hasTagSpecialAssembleSendMessage(preSpecialSendMessage.getId(), preSpecialSendMessage.getStaffId(), preSpecialSendMessage.getAttachmentIds(),
+        List<PreSpecialSendMessage> tagPreSpecialSendMessage = preSpecialSendMessages.stream()
+                .filter(e -> Objects.equals(e.getStatus(), PreSpecialStatusEnum.TAG.getStatus())).collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(tagPreSpecialSendMessage)) {
+            for (PreSpecialSendMessage preSpecialSendMessage : tagPreSpecialSendMessage) {
+                tagSpecialAssembleSendMessage(preSpecialSendMessage.getId(), preSpecialSendMessage.getStaffId(), preSpecialSendMessage.getAttachmentIds(),
                         preSpecialSendMessage.getContent(), preSpecialSendMessage.getPreSendDate(), preSpecialSendMessage.getTagId());
             }
         }
+
+        List<PreSpecialSendMessage> genderPreSpecialSendMessage = preSpecialSendMessages.stream()
+                .filter(e -> Objects.equals(e.getStatus(), PreSpecialStatusEnum.GENDER.getStatus())).collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(genderPreSpecialSendMessage)) {
+            for (PreSpecialSendMessage preSpecialSendMessage : genderPreSpecialSendMessage) {
+                genderSpecialAssembleSendMessage(preSpecialSendMessage.getId(), preSpecialSendMessage.getStaffId(),
+                        preSpecialSendMessage.getGroupMsgDisabled().byteValue(), preSpecialSendMessage.getAttachmentIds(),
+                        preSpecialSendMessage.getContent(), preSpecialSendMessage.getPreSendDate(), preSpecialSendMessage.getGender());
+            }
+        }
+
         //发送拼装好的消息
         sendSpecialPushMessage();
         return ReturnT.SUCCESS;
     }
 
 
-    public void notHasTagSpecialAssembleSendMessage(Long preId, Long staffId, Integer pageNum, Integer pageSize,
-                                                    byte groupMsgDisabled, String attachmentIds, String content, String date) {
+    public void defaultSpecialAssembleSendMessage(Long preId, Long staffId, Integer pageNum, Integer pageSize,
+                                                  byte groupMsgDisabled, String attachmentIds, String content, String date) {
         List<Long> filterTagId = weComUserService.getFilterTagId();
         List<WeComUser> weComUserList = weComUserMapper.selectUserList(staffId, groupMsgDisabled, filterTagId, (pageNum - 1) * pageSize, pageSize);
         //落库逻辑
@@ -102,7 +116,7 @@ public class WeComSpecialDataJob {
         }
     }
 
-    public void hasTagSpecialAssembleSendMessage(Long preId, Long staffId, String attachmentIds, String content, String date, Long tagId) {
+    public void tagSpecialAssembleSendMessage(Long preId, Long staffId, String attachmentIds, String content, String date, Long tagId) {
         List<WeComUser> weComUsers = weComUserMapper.selectByTagUserList(tagId);
         if (CollectionUtils.isEmpty(weComUsers)) {
             return;
@@ -129,6 +143,23 @@ public class WeComSpecialDataJob {
         }
     }
 
+    public void genderSpecialAssembleSendMessage(Long preId, Long staffId, byte groupMsgDisabled, String attachmentIds,
+                                                 String content, String date, Integer gender) {
+        List<Long> filterTagId = weComUserService.getFilterTagId();
+        List<WeComUser> weComUserList = weComUserMapper.selectByGenderUserList(staffId, groupMsgDisabled, filterTagId, gender);
+        //落库逻辑
+        for (WeComUser weComUser : weComUserList) {
+            SpecialSendMessage specialSendMessage = new SpecialSendMessage();
+            specialSendMessage.setStaffId(staffId);
+            specialSendMessage.setUserId(weComUser.getId());
+            specialSendMessage.setGroup(preId.intValue());
+            specialSendMessage.setAttachmentIds(attachmentIds);
+            specialSendMessage.setContent(content);
+            specialSendMessage.setPreSendDate(date);
+            specialSendMessageMapper.insertSelective(specialSendMessage);
+        }
+    }
+
 
     public void sendSpecialPushMessage() {
         String thatDayDateString = DateUtil.getThatDayDateString();
@@ -166,7 +197,7 @@ public class WeComSpecialDataJob {
         if (StringUtils.isNotEmpty(specialSendMessage.getContent())) {
             text.put("content", specialSendMessage.getContent());
         } else {
-            text.put("content", messageService.getMessageText());
+            text.put("content", messageService.getMessageText(staff.getId()));
         }
         jsonObject.put("text", text);
         jsonObject.put("sender", staff.getCarrierId());
@@ -182,7 +213,11 @@ public class WeComSpecialDataJob {
                         if (Objects.equals(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode(), type)) {
                             JSONObject miniprogramAttachment = new JSONObject();
                             JSONObject miniprogram = new JSONObject();
-                            miniprogram.put("appid", MessageConstant.appid);
+                            if(StringUtils.isNotEmpty(messageAttachment.getAppid())){
+                                miniprogram.put("appid", messageAttachment.getAppid());
+                            }else {
+                                miniprogram.put("appid", MessageConstant.appid);
+                            }
                             String title = messageAttachment.getTitle();
                             if (title.getBytes(StandardCharsets.UTF_8).length > MAX_BYTES) {
                                 title = ToolUtils.truncateString(title, MAX_BYTES - 3) + "...";