Explorar el Código

Merge branch 'master' into 20250408-wyp-contentPlatform

wangyunpeng hace 1 semana
padre
commit
bb00574107
Se han modificado 30 ficheros con 2006 adiciones y 76 borrados
  1. 7 1
      api-module/src/main/java/com/tzld/piaoquan/api/controller/TencentWeComController.java
  2. 35 0
      api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/AutoReplyMsgSendRecordMapper.java
  3. 145 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/po/AutoReplyMsgSendRecord.java
  4. 992 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/po/AutoReplyMsgSendRecordExample.java
  5. 6 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/WeComAutoReply.java
  6. 2 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/WeComService.java
  7. 175 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComAutoReplyImpl.java
  8. 58 4
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComServiceImpl.java
  9. 20 13
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java
  10. 19 13
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java
  11. 19 13
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java
  12. 326 0
      api-module/src/main/resources/mapper/AutoReplyMsgSendRecordMapper.xml
  13. 3 1
      api-module/src/main/resources/mybatis-api-generator-config.xml
  14. 3 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/common/constant/WeComConstant.java
  15. 2 2
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/SpecialSendMessageMapper.java
  16. 2 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/ext/WeComUserMapperExt.java
  17. 13 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/MsgResult.java
  18. 39 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/WeComUserBo.java
  19. 7 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/vo/WeComUserVo.java
  20. 14 8
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java
  21. 27 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageServiceImpl.java
  22. 34 7
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/WeComUserServiceImpl.java
  23. 3 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageService.java
  24. 2 2
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/WeComUserService.java
  25. 2 1
      common-module/src/main/resources/mapper/SpecialSendMessageMapper.xml
  26. 4 2
      common-module/src/main/resources/mapper/ext/WeComUserMapperExt.xml
  27. 4 1
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java
  28. 2 3
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComMessageDataJob.java
  29. 13 2
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComSpecialDataJob.java
  30. 28 2
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComUserDataJob.java

+ 7 - 1
api-module/src/main/java/com/tzld/piaoquan/api/controller/TencentWeComController.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.api.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.service.WeComAutoReply;
 import com.tzld.piaoquan.growth.common.common.constant.WeComServerConstant;
 import com.tzld.piaoquan.growth.common.service.WeComUserService;
 import com.tzld.piaoquan.growth.common.utils.wecom.WXBizMsgCrypt;
@@ -32,6 +33,9 @@ public class TencentWeComController {
     @Autowired
     private WeComUserService weComUserService;
 
+    @Autowired
+    private WeComAutoReply weComAutoReply;
+
     @GetMapping("/verify")
     public void verifyGet(HttpServletRequest request, HttpServletResponse response) {
         try {
@@ -104,15 +108,17 @@ public class TencentWeComController {
                 if (StringUtils.isNotEmpty(changeType) && changeType.equals("add_external_contact")) {
                     String userId = (String) suiteMap.get("UserID");
                     String externalUserId = (String) suiteMap.get("ExternalUserID");
+                    String welcomeCode = (String) suiteMap.get("WelcomeCode");
                     log.info("addStaffWithUser userId={} externalUserId={}", userId, externalUserId);
                     weComUserService.addStaffWithUser(externalUserId, userId, HNWQ.getId());
+                    weComAutoReply.AutoReplyMessage(welcomeCode, externalUserId, userId, HNWQ.getId());
                 }
 
                 if (StringUtils.isNotEmpty(changeType) && changeType.equals("del_follow_user")) {
                     String userId = (String) suiteMap.get("UserID");
                     String externalUserId = (String) suiteMap.get("ExternalUserID");
                     log.info("delStaffWithUser userId={} externalUserId={}", userId, externalUserId);
-                    weComUserService.delStaffWithUser(externalUserId, userId, System.currentTimeMillis());
+                    weComUserService.delStaffWithUser(externalUserId, userId, HNWQ.getId(), System.currentTimeMillis());
                 }
             }
         } catch (Exception e) {

+ 35 - 0
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/AutoReplyMsgSendRecordMapper.java

@@ -0,0 +1,35 @@
+package com.tzld.piaoquan.api.dao.mapper;
+
+import com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord;
+import com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecordExample;
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface AutoReplyMsgSendRecordMapper {
+    long countByExample(AutoReplyMsgSendRecordExample example);
+
+    int deleteByExample(AutoReplyMsgSendRecordExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(AutoReplyMsgSendRecord record);
+
+    int insertSelective(AutoReplyMsgSendRecord record);
+
+    List<AutoReplyMsgSendRecord> selectByExample(AutoReplyMsgSendRecordExample example);
+
+    AutoReplyMsgSendRecord selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") AutoReplyMsgSendRecord record, @Param("example") AutoReplyMsgSendRecordExample example);
+
+    int updateByExample(@Param("record") AutoReplyMsgSendRecord record, @Param("example") AutoReplyMsgSendRecordExample example);
+
+    int updateByPrimaryKeySelective(AutoReplyMsgSendRecord record);
+
+    int updateByPrimaryKey(AutoReplyMsgSendRecord record);
+}

+ 145 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/AutoReplyMsgSendRecord.java

@@ -0,0 +1,145 @@
+package com.tzld.piaoquan.api.model.po;
+
+public class AutoReplyMsgSendRecord {
+    private Long id;
+
+    private Long msgId;
+
+    private Integer msgType;
+
+    private String corpId;
+
+    private String userId;
+
+    private String groupId;
+
+    private String externalUserId;
+
+    private Long miniVideoId;
+
+    private String newsPublishContentId;
+
+    private Integer status;
+
+    private String errorMsg;
+
+    private Long sendTimestamp;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getMsgId() {
+        return msgId;
+    }
+
+    public void setMsgId(Long msgId) {
+        this.msgId = msgId;
+    }
+
+    public Integer getMsgType() {
+        return msgType;
+    }
+
+    public void setMsgType(Integer msgType) {
+        this.msgType = msgType;
+    }
+
+    public String getCorpId() {
+        return corpId;
+    }
+
+    public void setCorpId(String corpId) {
+        this.corpId = corpId;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getExternalUserId() {
+        return externalUserId;
+    }
+
+    public void setExternalUserId(String externalUserId) {
+        this.externalUserId = externalUserId;
+    }
+
+    public Long getMiniVideoId() {
+        return miniVideoId;
+    }
+
+    public void setMiniVideoId(Long miniVideoId) {
+        this.miniVideoId = miniVideoId;
+    }
+
+    public String getNewsPublishContentId() {
+        return newsPublishContentId;
+    }
+
+    public void setNewsPublishContentId(String newsPublishContentId) {
+        this.newsPublishContentId = newsPublishContentId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
+
+    public Long getSendTimestamp() {
+        return sendTimestamp;
+    }
+
+    public void setSendTimestamp(Long sendTimestamp) {
+        this.sendTimestamp = sendTimestamp;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", msgId=").append(msgId);
+        sb.append(", msgType=").append(msgType);
+        sb.append(", corpId=").append(corpId);
+        sb.append(", userId=").append(userId);
+        sb.append(", groupId=").append(groupId);
+        sb.append(", externalUserId=").append(externalUserId);
+        sb.append(", miniVideoId=").append(miniVideoId);
+        sb.append(", newsPublishContentId=").append(newsPublishContentId);
+        sb.append(", status=").append(status);
+        sb.append(", errorMsg=").append(errorMsg);
+        sb.append(", sendTimestamp=").append(sendTimestamp);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 992 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/AutoReplyMsgSendRecordExample.java

@@ -0,0 +1,992 @@
+package com.tzld.piaoquan.api.model.po;
+
+import com.tzld.piaoquan.growth.common.utils.page.Page;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AutoReplyMsgSendRecordExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public AutoReplyMsgSendRecordExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    public void setPage(Page page) {
+        this.page=page;
+    }
+
+    public Page getPage() {
+        return page;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Long value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Long value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Long value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Long value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Long> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Long> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Long value1, Long value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Long value1, Long value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdIsNull() {
+            addCriterion("msg_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdIsNotNull() {
+            addCriterion("msg_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdEqualTo(Long value) {
+            addCriterion("msg_id =", value, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdNotEqualTo(Long value) {
+            addCriterion("msg_id <>", value, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdGreaterThan(Long value) {
+            addCriterion("msg_id >", value, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("msg_id >=", value, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdLessThan(Long value) {
+            addCriterion("msg_id <", value, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdLessThanOrEqualTo(Long value) {
+            addCriterion("msg_id <=", value, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdIn(List<Long> values) {
+            addCriterion("msg_id in", values, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdNotIn(List<Long> values) {
+            addCriterion("msg_id not in", values, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdBetween(Long value1, Long value2) {
+            addCriterion("msg_id between", value1, value2, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgIdNotBetween(Long value1, Long value2) {
+            addCriterion("msg_id not between", value1, value2, "msgId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeIsNull() {
+            addCriterion("msg_type is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeIsNotNull() {
+            addCriterion("msg_type is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeEqualTo(Integer value) {
+            addCriterion("msg_type =", value, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeNotEqualTo(Integer value) {
+            addCriterion("msg_type <>", value, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeGreaterThan(Integer value) {
+            addCriterion("msg_type >", value, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeGreaterThanOrEqualTo(Integer value) {
+            addCriterion("msg_type >=", value, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeLessThan(Integer value) {
+            addCriterion("msg_type <", value, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeLessThanOrEqualTo(Integer value) {
+            addCriterion("msg_type <=", value, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeIn(List<Integer> values) {
+            addCriterion("msg_type in", values, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeNotIn(List<Integer> values) {
+            addCriterion("msg_type not in", values, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeBetween(Integer value1, Integer value2) {
+            addCriterion("msg_type between", value1, value2, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgTypeNotBetween(Integer value1, Integer value2) {
+            addCriterion("msg_type not between", value1, value2, "msgType");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdIsNull() {
+            addCriterion("corp_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdIsNotNull() {
+            addCriterion("corp_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdEqualTo(String value) {
+            addCriterion("corp_id =", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdNotEqualTo(String value) {
+            addCriterion("corp_id <>", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdGreaterThan(String value) {
+            addCriterion("corp_id >", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdGreaterThanOrEqualTo(String value) {
+            addCriterion("corp_id >=", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdLessThan(String value) {
+            addCriterion("corp_id <", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdLessThanOrEqualTo(String value) {
+            addCriterion("corp_id <=", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdLike(String value) {
+            addCriterion("corp_id like", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdNotLike(String value) {
+            addCriterion("corp_id not like", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdIn(List<String> values) {
+            addCriterion("corp_id in", values, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdNotIn(List<String> values) {
+            addCriterion("corp_id not in", values, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdBetween(String value1, String value2) {
+            addCriterion("corp_id between", value1, value2, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdNotBetween(String value1, String value2) {
+            addCriterion("corp_id not between", value1, value2, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIsNull() {
+            addCriterion("user_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIsNotNull() {
+            addCriterion("user_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdEqualTo(String value) {
+            addCriterion("user_id =", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotEqualTo(String value) {
+            addCriterion("user_id <>", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThan(String value) {
+            addCriterion("user_id >", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThanOrEqualTo(String value) {
+            addCriterion("user_id >=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThan(String value) {
+            addCriterion("user_id <", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThanOrEqualTo(String value) {
+            addCriterion("user_id <=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLike(String value) {
+            addCriterion("user_id like", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotLike(String value) {
+            addCriterion("user_id not like", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIn(List<String> values) {
+            addCriterion("user_id in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotIn(List<String> values) {
+            addCriterion("user_id not in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdBetween(String value1, String value2) {
+            addCriterion("user_id between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotBetween(String value1, String value2) {
+            addCriterion("user_id not between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdIsNull() {
+            addCriterion("group_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdIsNotNull() {
+            addCriterion("group_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdEqualTo(String value) {
+            addCriterion("group_id =", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdNotEqualTo(String value) {
+            addCriterion("group_id <>", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdGreaterThan(String value) {
+            addCriterion("group_id >", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdGreaterThanOrEqualTo(String value) {
+            addCriterion("group_id >=", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdLessThan(String value) {
+            addCriterion("group_id <", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdLessThanOrEqualTo(String value) {
+            addCriterion("group_id <=", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdLike(String value) {
+            addCriterion("group_id like", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdNotLike(String value) {
+            addCriterion("group_id not like", value, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdIn(List<String> values) {
+            addCriterion("group_id in", values, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdNotIn(List<String> values) {
+            addCriterion("group_id not in", values, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdBetween(String value1, String value2) {
+            addCriterion("group_id between", value1, value2, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGroupIdNotBetween(String value1, String value2) {
+            addCriterion("group_id not between", value1, value2, "groupId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdIsNull() {
+            addCriterion("external_user_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdIsNotNull() {
+            addCriterion("external_user_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdEqualTo(String value) {
+            addCriterion("external_user_id =", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdNotEqualTo(String value) {
+            addCriterion("external_user_id <>", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdGreaterThan(String value) {
+            addCriterion("external_user_id >", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdGreaterThanOrEqualTo(String value) {
+            addCriterion("external_user_id >=", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdLessThan(String value) {
+            addCriterion("external_user_id <", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdLessThanOrEqualTo(String value) {
+            addCriterion("external_user_id <=", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdLike(String value) {
+            addCriterion("external_user_id like", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdNotLike(String value) {
+            addCriterion("external_user_id not like", value, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdIn(List<String> values) {
+            addCriterion("external_user_id in", values, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdNotIn(List<String> values) {
+            addCriterion("external_user_id not in", values, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdBetween(String value1, String value2) {
+            addCriterion("external_user_id between", value1, value2, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExternalUserIdNotBetween(String value1, String value2) {
+            addCriterion("external_user_id not between", value1, value2, "externalUserId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdIsNull() {
+            addCriterion("mini_video_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdIsNotNull() {
+            addCriterion("mini_video_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdEqualTo(Long value) {
+            addCriterion("mini_video_id =", value, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdNotEqualTo(Long value) {
+            addCriterion("mini_video_id <>", value, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdGreaterThan(Long value) {
+            addCriterion("mini_video_id >", value, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("mini_video_id >=", value, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdLessThan(Long value) {
+            addCriterion("mini_video_id <", value, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdLessThanOrEqualTo(Long value) {
+            addCriterion("mini_video_id <=", value, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdIn(List<Long> values) {
+            addCriterion("mini_video_id in", values, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdNotIn(List<Long> values) {
+            addCriterion("mini_video_id not in", values, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdBetween(Long value1, Long value2) {
+            addCriterion("mini_video_id between", value1, value2, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniVideoIdNotBetween(Long value1, Long value2) {
+            addCriterion("mini_video_id not between", value1, value2, "miniVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdIsNull() {
+            addCriterion("news_publish_content_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdIsNotNull() {
+            addCriterion("news_publish_content_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdEqualTo(String value) {
+            addCriterion("news_publish_content_id =", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdNotEqualTo(String value) {
+            addCriterion("news_publish_content_id <>", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdGreaterThan(String value) {
+            addCriterion("news_publish_content_id >", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdGreaterThanOrEqualTo(String value) {
+            addCriterion("news_publish_content_id >=", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdLessThan(String value) {
+            addCriterion("news_publish_content_id <", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdLessThanOrEqualTo(String value) {
+            addCriterion("news_publish_content_id <=", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdLike(String value) {
+            addCriterion("news_publish_content_id like", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdNotLike(String value) {
+            addCriterion("news_publish_content_id not like", value, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdIn(List<String> values) {
+            addCriterion("news_publish_content_id in", values, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdNotIn(List<String> values) {
+            addCriterion("news_publish_content_id not in", values, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdBetween(String value1, String value2) {
+            addCriterion("news_publish_content_id between", value1, value2, "newsPublishContentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewsPublishContentIdNotBetween(String value1, String value2) {
+            addCriterion("news_publish_content_id not between", value1, value2, "newsPublishContentId");
+            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 andErrorMsgIsNull() {
+            addCriterion("error_msg is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgIsNotNull() {
+            addCriterion("error_msg is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgEqualTo(String value) {
+            addCriterion("error_msg =", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgNotEqualTo(String value) {
+            addCriterion("error_msg <>", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgGreaterThan(String value) {
+            addCriterion("error_msg >", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgGreaterThanOrEqualTo(String value) {
+            addCriterion("error_msg >=", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgLessThan(String value) {
+            addCriterion("error_msg <", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgLessThanOrEqualTo(String value) {
+            addCriterion("error_msg <=", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgLike(String value) {
+            addCriterion("error_msg like", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgNotLike(String value) {
+            addCriterion("error_msg not like", value, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgIn(List<String> values) {
+            addCriterion("error_msg in", values, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgNotIn(List<String> values) {
+            addCriterion("error_msg not in", values, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgBetween(String value1, String value2) {
+            addCriterion("error_msg between", value1, value2, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andErrorMsgNotBetween(String value1, String value2) {
+            addCriterion("error_msg not between", value1, value2, "errorMsg");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampIsNull() {
+            addCriterion("send_timestamp is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampIsNotNull() {
+            addCriterion("send_timestamp is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampEqualTo(Long value) {
+            addCriterion("send_timestamp =", value, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampNotEqualTo(Long value) {
+            addCriterion("send_timestamp <>", value, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampGreaterThan(Long value) {
+            addCriterion("send_timestamp >", value, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampGreaterThanOrEqualTo(Long value) {
+            addCriterion("send_timestamp >=", value, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampLessThan(Long value) {
+            addCriterion("send_timestamp <", value, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampLessThanOrEqualTo(Long value) {
+            addCriterion("send_timestamp <=", value, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampIn(List<Long> values) {
+            addCriterion("send_timestamp in", values, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampNotIn(List<Long> values) {
+            addCriterion("send_timestamp not in", values, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampBetween(Long value1, Long value2) {
+            addCriterion("send_timestamp between", value1, value2, "sendTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimestampNotBetween(Long value1, Long value2) {
+            addCriterion("send_timestamp not between", value1, value2, "sendTimestamp");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 6 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/WeComAutoReply.java

@@ -0,0 +1,6 @@
+package com.tzld.piaoquan.api.service;
+
+public interface WeComAutoReply {
+
+    void AutoReplyMessage(String welcomeCode, String externalUserId, String userId, Long corpId);
+}

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/WeComService.java

@@ -11,4 +11,6 @@ import java.util.List;
 public interface WeComService {
 
     CommonResponse<List<WeComPushMessageVo>> getPushMessage(WeComPushMessageParam param);
+
+    List<WeComPushMessageVo> getPushMessageByUserId(String userId);
 }

+ 175 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComAutoReplyImpl.java

@@ -0,0 +1,175 @@
+package com.tzld.piaoquan.api.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.dao.mapper.AutoReplyMsgSendRecordMapper;
+import com.tzld.piaoquan.api.model.bo.MsgData;
+import com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord;
+import com.tzld.piaoquan.api.model.vo.WeComPushMessageVo;
+import com.tzld.piaoquan.api.service.WeComAutoReply;
+import com.tzld.piaoquan.api.service.WeComService;
+import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
+import com.tzld.piaoquan.growth.common.dao.mapper.CorpMapper;
+import com.tzld.piaoquan.growth.common.model.bo.MsgResult;
+import com.tzld.piaoquan.growth.common.model.po.Corp;
+import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
+import com.tzld.piaoquan.growth.common.service.MessageService;
+import com.tzld.piaoquan.growth.common.service.WeComUserService;
+import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Random;
+
+@Slf4j
+@Service
+public class WeComAutoReplyImpl implements WeComAutoReply {
+
+    @Autowired
+    private WeComService weComService;
+
+    @Autowired
+    private MessageAttachmentService messageAttachmentService;
+
+    @Autowired
+    private MessageService messageService;
+
+    @Autowired
+    private CorpMapper corpMapper;
+
+    @Autowired
+    private WeComUserService weComUserService;
+
+    @Autowired
+    private HttpPoolClient httpPoolClient;
+
+    @Autowired
+    private AutoReplyMsgSendRecordMapper autoReplyMsgSendRecordMapper;
+
+    @Override
+    public void AutoReplyMessage(String welcomeCode, String externalUserId, String userId, Long corpId) {
+        Corp corp = corpMapper.selectByPrimaryKey(corpId);
+        String corpCorpId = corp.getCorpId();
+        List<WeComPushMessageVo> weComPushMessageVoList = weComService.getPushMessageByUserId(userId);
+        WeComPushMessageVo weComPushMessageVo = getRandomElement(weComPushMessageVoList);
+        if (weComPushMessageVo == null) {
+            LarkRobotUtil.sendMessage("自动回复消息获取失败,userId=" + userId);
+            log.error("自动回复消息获取失败,userId=" + userId);
+            return;
+        }
+        List<MsgData> msgDataList = weComPushMessageVo.getMsgDataList();
+        if (CollectionUtils.isEmpty(msgDataList)) {
+            LarkRobotUtil.sendMessage("自动回复分组内容为空,userId=" + userId);
+            log.error("自动回复分组内容为空,userId=" + userId);
+            return;
+        }
+
+        List<AutoReplyMsgSendRecord> autoReplyMsgSendRecords = new ArrayList<>();
+        JSONObject param = new JSONObject();
+        param.put("welcome_code", welcomeCode);
+        JSONArray attachments = new JSONArray();
+        for (MsgData msgData : msgDataList) {
+            //小程序
+            if (msgData.getMsgType() == 1) {
+                JSONObject attachment = new JSONObject();
+                attachment.put("msgtype", "miniprogram");
+                JSONObject miniprogram = new JSONObject();
+                String picMediaId = messageAttachmentService.getPicMediaId(msgData.getCoverUrl(), corpId);
+                miniprogram.put("title", msgData.getTitle());
+                miniprogram.put("pic_media_id", picMediaId);
+                miniprogram.put("appid", msgData.getMiniAppId());
+                miniprogram.put("page", msgData.getMiniPagePath());
+                attachment.put("miniprogram", miniprogram);
+                attachments.add(attachment);
+            }
+            if (msgData.getMsgType() == 2) {
+                JSONObject attachment = new JSONObject();
+                attachment.put("msgtype", "link");
+                JSONObject link = new JSONObject();
+                link.put("title", msgData.getTitle());
+                link.put("picurl", msgData.getCoverUrl());
+                link.put("desc", msgData.getNewsDescription());
+                link.put("url", msgData.getNewsUrl());
+                attachment.put("link", link);
+                attachments.add(attachment);
+            }
+            if (msgData.getMsgType() == 3) {
+                JSONObject text = new JSONObject();
+//                String name = getName(externalUserId, corpId);
+//                if (StringUtils.hasText(name)) {
+//                    text.put("content", name + "," + msgData.getTitle());
+//                } else {
+//                    text.put("content", msgData.getTitle());
+//                }
+                text.put("content", msgData.getTitle());
+                param.put("text", text);
+            }
+            AutoReplyMsgSendRecord autoReplyMsgSendRecord = new AutoReplyMsgSendRecord();
+            autoReplyMsgSendRecord.setMsgType(msgData.getMsgType());
+            autoReplyMsgSendRecord.setCorpId(corpCorpId);
+            autoReplyMsgSendRecord.setUserId(userId);
+            autoReplyMsgSendRecord.setGroupId(String.valueOf(weComPushMessageVo.getGroupIndex()));
+            autoReplyMsgSendRecord.setExternalUserId(externalUserId);
+            autoReplyMsgSendRecord.setMiniVideoId(msgData.getMiniVideoId());
+            autoReplyMsgSendRecord.setNewsPublishContentId(msgData.getNewsPublishContentId());
+            autoReplyMsgSendRecords.add(autoReplyMsgSendRecord);
+        }
+        if (!CollectionUtils.isEmpty(attachments)) {
+            param.put("attachments", attachments);
+        }
+        MsgResult msgResult = messageService.sendAutoReplyMessage(param, corpId);
+        long resultTime = System.currentTimeMillis();
+        for (AutoReplyMsgSendRecord autoReplyMsgSendRecord : autoReplyMsgSendRecords) {
+            try {
+                autoReplyMsgSendRecord.setMsgId(0L);
+                if (msgResult.getErrcode() == 0) {
+                    autoReplyMsgSendRecord.setStatus(1);
+                } else {
+                    autoReplyMsgSendRecord.setStatus(2);
+                    autoReplyMsgSendRecord.setErrorMsg(msgResult.getErrmsg());
+                }
+                autoReplyMsgSendRecord.setSendTimestamp(resultTime);
+                autoReplyMsgSendRecordMapper.insertSelective(autoReplyMsgSendRecord);
+                sendResult(autoReplyMsgSendRecord);
+            } catch (Exception e) {
+                log.error("saveAutoReplyMsgSendRecord error", e);
+            }
+        }
+    }
+
+
+    private WeComPushMessageVo getRandomElement(List<WeComPushMessageVo> weComPushMessageVoList) {
+        if (CollectionUtils.isEmpty(weComPushMessageVoList)) {
+            return null;
+        }
+        Random random = new Random();
+        int randomIndex = random.nextInt(weComPushMessageVoList.size());
+        return weComPushMessageVoList.get(randomIndex);
+    }
+
+    private String getName(String externalUserId, Long cropId) {
+        try {
+            JSONObject userDetail = weComUserService.getUserDetail(externalUserId, cropId);
+            return userDetail.getJSONObject("external_contact").getString("name");
+        } catch (Exception e) {
+            log.error("WeComAutoReplyImpl getName error", e);
+        }
+        return null;
+    }
+
+    private void sendResult(AutoReplyMsgSendRecord autoReplyMsgSendRecord) {
+        try {
+            String url = "http://aigc-api.cybertogether.net//aigc/publish/api/saveWorkWxAutoReplyMsgSendRecords";
+            String res = httpPoolClient.post(url, JSONObject.toJSONString(autoReplyMsgSendRecord));
+            log.info("WeComAutoReplyImpl sendResult res={}", res);
+        } catch (Exception e) {
+            log.error("sendResult error", e);
+        }
+    }
+}

+ 58 - 4
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComServiceImpl.java

@@ -53,6 +53,7 @@ public class WeComServiceImpl implements WeComService {
         strategyServiceMap = applicationContext.getBeansOfType(ReplyStrategyService.class);
     }
 
+    //TODO 后续自动回复迁移完成可以下掉
     @Override
     public CommonResponse<List<WeComPushMessageVo>> getPushMessage(WeComPushMessageParam param) {
         if (param == null || StringUtils.isEmpty(param.getCorpId()) || !CORP_ID.equals(param.getCorpId()) || StringUtils.isEmpty(param.getUserId())) {
@@ -67,12 +68,12 @@ public class WeComServiceImpl implements WeComService {
         }
         ReplyStaff replyStaff = replyStaffs.get(0);
         List<WeComPushMessageVo> res = new ArrayList<>();
-        ReplyBucketData replyBucketData = getPushMessageData(param, replyStaff.getVideoIds());
+        ReplyBucketData replyBucketData = getPushMessageData(replyStaff.getUserId(), replyStaff.getVideoIds());
         if (replyBucketData == null) {
             return CommonResponse.create(500, "数据异常");
         }
         List<GroupData> groupList = replyBucketData.getGroupList();
-        log.info("groupList={}", groupList);
+        log.info("getPushMessage groupList={}", groupList);
         if (CollectionUtils.isEmpty(groupList)) {
             return CommonResponse.create(500, "数据异常");
         }
@@ -110,14 +111,67 @@ public class WeComServiceImpl implements WeComService {
         return CommonResponse.success(res);
     }
 
-    private ReplyBucketData getPushMessageData(WeComPushMessageParam param, String videoIds) {
+    @Override
+    public List<WeComPushMessageVo> getPushMessageByUserId(String userId) {
+        ReplyStaffExample example = new ReplyStaffExample();
+        example.createCriteria().andUserIdEqualTo(userId).andIsDeleteEqualTo(0);
+        List<ReplyStaff> replyStaffs = replyStaffMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(replyStaffs)) {
+            return null;
+        }
+        ReplyStaff replyStaff = replyStaffs.get(0);
+        List<WeComPushMessageVo> res = new ArrayList<>();
+        ReplyBucketData replyBucketData = getPushMessageData(replyStaff.getUserId(), replyStaff.getVideoIds());
+        if (replyBucketData == null) {
+            return null;
+        }
+        List<GroupData> groupList = replyBucketData.getGroupList();
+        log.info("getPushMessageByUserId groupList={}", groupList);
+        if (CollectionUtils.isEmpty(groupList)) {
+            return null;
+        }
+        String name = replyStaff.getName();
+        for (GroupData groupData : groupList) {
+            if (CollectionUtils.isEmpty(groupData.getMsgDataList())) {
+                continue;
+            }
+            WeComPushMessageVo weComPushMessageVo = new WeComPushMessageVo();
+            weComPushMessageVo.setGroupIndex(groupData.getGroupIndex());
+            List<MsgData> msgDataList = groupData.getMsgDataList();
+            for (MsgData msgData : msgDataList) {
+                if (msgData.getTitle().getBytes(StandardCharsets.UTF_8).length > MAX_BYTES) {
+                    String s = truncateString(msgData.getTitle(), MAX_BYTES - 3) + "...";
+                    msgData.setTitle(s);
+                }
+            }
+            MsgData msgData = new MsgData();
+            msgData.setMsgType(3);
+            if (replyStaff.getId() == 1) {
+                msgData.setTitle("你好呀~我是智能助手芳华,专门陪您唠唠嗑、解解闷的!\uD83C\uDF39\n" +
+                        "刚发现好多有趣视频想分享给您!偷偷告诉我——您平时最爱看【健康养生】、【历史故事】这类知识干货,还是【人生智慧】【怀旧经典】这些暖心内容呀?\n" +
+                        "(悄悄加个选项\uD83D\uDC49【祝福音乐】\uD83C\uDFB5,马上帮您找!)");
+            } else if (replyStaff.getId() == 3) {
+                msgData.setTitle(String.format("很高兴认识您!我是%s,每天给您推荐精彩视频~", name));
+            } else {
+                msgData.setTitle("叔叔阿姨好,我是健康小助手,每天会为您定制全网热点视频,感谢您的关注,手动转发支持哦~");
+            }
+
+            msgDataList.add(0, msgData);
+            weComPushMessageVo.setMsgDataList(msgDataList);
+            res.add(weComPushMessageVo);
+        }
+        log.info("getPushMessageByUserId res={}", res);
+        return res;
+    }
+
+    private ReplyBucketData getPushMessageData(String userId, String videoIds) {
         log.info("strategyServiceMap={}", JSON.toJSONString(strategyServiceMap));
         for (Map.Entry<String, ReplyStrategyService> stringReplyStrategyServiceEntry : strategyServiceMap.entrySet()) {
             ReplyStrategyService replyStrategyService = stringReplyStrategyServiceEntry.getValue();
             // 使用策略层
             if (replyStrategyService.support(ReplyStrategyServiceEnum.WE_COM_PUSH_MESSAGE_STRATEGY_V1)) {
                 BucketDataParam bucketDataParam = new BucketDataParam();
-                bucketDataParam.setGhId(param.getUserId());
+                bucketDataParam.setGhId(userId);
                 if (StringUtils.isNotEmpty(videoIds)) {
                     bucketDataParam.setStrategyStatus(StrategyStatusEnum.DEFAULT.status);
                     bucketDataParam.setVideos(JSONArray.parseArray(videoIds, Long.class));

+ 20 - 13
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java

@@ -352,20 +352,27 @@ public class BuckStrategyV1 implements ReplyStrategyService {
         if (CollectionUtils.isEmpty(bucketDataParam.getVideos())) {
             return result;
         }
-        int existNum = 0;
-        for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
-            int sort = i + 1;
-            Long videoId = bucketDataParam.getVideos().get(i);
-            CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
-            cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
-                    .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
-            long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
-            if (count > 0) {
-                existNum++;
+
+        CgiReplyBucketDataExample countExample = new CgiReplyBucketDataExample();
+        countExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
+                .andGhIdEqualTo(bucketDataParam.getGhId());
+        long allCount = cgiReplyBucketDataMapper.countByExample(countExample);
+        if (allCount == bucketDataParam.getVideos().size()) {
+            int existNum = 0;
+            for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
+                int sort = i + 1;
+                Long videoId = bucketDataParam.getVideos().get(i);
+                CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+                cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
+                        .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
+                long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
+                if (count > 0) {
+                    existNum++;
+                }
+            }
+            if (existNum == bucketDataParam.getVideos().size()) {
+                return null;
             }
-        }
-        if (existNum == bucketDataParam.getVideos().size()) {
-            return null;
         }
         for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
             int sort = i + 1;

+ 19 - 13
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java

@@ -225,20 +225,26 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
                 if (CollectionUtils.isEmpty(bucketDataParam.getVideos())) {
                     return null;
                 }
-                int existNum = 0;
-                for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
-                    int sort = i + 1;
-                    Long videoId = bucketDataParam.getVideos().get(i);
-                    CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
-                    cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
-                            .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
-                    long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
-                    if (count > 0) {
-                        existNum++;
+                CgiReplyBucketDataExample countExample = new CgiReplyBucketDataExample();
+                countExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
+                        .andGhIdEqualTo(bucketDataParam.getGhId());
+                long allCount = cgiReplyBucketDataMapper.countByExample(countExample);
+                if (allCount == bucketDataParam.getVideos().size()) {
+                    int existNum = 0;
+                    for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
+                        int sort = i + 1;
+                        Long videoId = bucketDataParam.getVideos().get(i);
+                        CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+                        cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
+                                .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
+                        long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
+                        if (count > 0) {
+                            existNum++;
+                        }
+                    }
+                    if (existNum == bucketDataParam.getVideos().size()) {
+                        continue;
                     }
-                }
-                if (existNum == bucketDataParam.getVideos().size()) {
-                    continue;
                 }
                 Map<Long, VideoDetail> videoDetailMap = touLiuHttpClient.getVideoDetailRequest(bucketDataParam.getVideos());
                 List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = contentPlatformPlanService.getGzhPlanVideoListByCooperateAccountId(bucketDataParam.getGhId());

+ 19 - 13
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java

@@ -219,20 +219,26 @@ public class WeComPushMessageStrategyV1 implements ReplyStrategyService {
                 if (CollectionUtils.isEmpty(bucketDataParam.getVideos())) {
                     return null;
                 }
-                int existNum = 0;
-                for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
-                    int sort = i + 1;
-                    Long videoId = bucketDataParam.getVideos().get(i);
-                    CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
-                    cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
-                            .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
-                    long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
-                    if (count > 0) {
-                        existNum++;
+                CgiReplyBucketDataExample countExample = new CgiReplyBucketDataExample();
+                countExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
+                        .andGhIdEqualTo(bucketDataParam.getGhId());
+                long allCount = cgiReplyBucketDataMapper.countByExample(countExample);
+                if (allCount == bucketDataParam.getVideos().size()) {
+                    int existNum = 0;
+                    for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
+                        int sort = i + 1;
+                        Long videoId = bucketDataParam.getVideos().get(i);
+                        CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+                        cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
+                                .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
+                        long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
+                        if (count > 0) {
+                            existNum++;
+                        }
+                    }
+                    if (existNum == bucketDataParam.getVideos().size()) {
+                        continue;
                     }
-                }
-                if (existNum == bucketDataParam.getVideos().size()) {
-                    continue;
                 }
                 Map<Long, VideoDetail> videoDetailMap = touLiuHttpClient.getVideoDetailRequest(bucketDataParam.getVideos());
                 for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {

+ 326 - 0
api-module/src/main/resources/mapper/AutoReplyMsgSendRecordMapper.xml

@@ -0,0 +1,326 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.piaoquan.api.dao.mapper.AutoReplyMsgSendRecordMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="msg_id" jdbcType="BIGINT" property="msgId" />
+    <result column="msg_type" jdbcType="INTEGER" property="msgType" />
+    <result column="corp_id" jdbcType="VARCHAR" property="corpId" />
+    <result column="user_id" jdbcType="VARCHAR" property="userId" />
+    <result column="group_id" jdbcType="VARCHAR" property="groupId" />
+    <result column="external_user_id" jdbcType="VARCHAR" property="externalUserId" />
+    <result column="mini_video_id" jdbcType="BIGINT" property="miniVideoId" />
+    <result column="news_publish_content_id" jdbcType="VARCHAR" property="newsPublishContentId" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
+    <result column="send_timestamp" jdbcType="BIGINT" property="sendTimestamp" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, msg_id, msg_type, corp_id, user_id, group_id, external_user_id, mini_video_id, 
+    news_publish_content_id, `status`, error_msg, send_timestamp
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecordExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from workwx_auto_reply_msg_send_record
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+    <if test="page != null">
+      limit #{page.offset} , #{page.pageSize}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from workwx_auto_reply_msg_send_record
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from workwx_auto_reply_msg_send_record
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecordExample">
+    delete from workwx_auto_reply_msg_send_record
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord">
+    insert into workwx_auto_reply_msg_send_record (id, msg_id, msg_type, 
+      corp_id, user_id, group_id, 
+      external_user_id, mini_video_id, news_publish_content_id, 
+      `status`, error_msg, send_timestamp
+      )
+    values (#{id,jdbcType=BIGINT}, #{msgId,jdbcType=BIGINT}, #{msgType,jdbcType=INTEGER}, 
+      #{corpId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR}, 
+      #{externalUserId,jdbcType=VARCHAR}, #{miniVideoId,jdbcType=BIGINT}, #{newsPublishContentId,jdbcType=VARCHAR}, 
+      #{status,jdbcType=INTEGER}, #{errorMsg,jdbcType=VARCHAR}, #{sendTimestamp,jdbcType=BIGINT}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord">
+    insert into workwx_auto_reply_msg_send_record
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="msgId != null">
+        msg_id,
+      </if>
+      <if test="msgType != null">
+        msg_type,
+      </if>
+      <if test="corpId != null">
+        corp_id,
+      </if>
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="groupId != null">
+        group_id,
+      </if>
+      <if test="externalUserId != null">
+        external_user_id,
+      </if>
+      <if test="miniVideoId != null">
+        mini_video_id,
+      </if>
+      <if test="newsPublishContentId != null">
+        news_publish_content_id,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="errorMsg != null">
+        error_msg,
+      </if>
+      <if test="sendTimestamp != null">
+        send_timestamp,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="msgId != null">
+        #{msgId,jdbcType=BIGINT},
+      </if>
+      <if test="msgType != null">
+        #{msgType,jdbcType=INTEGER},
+      </if>
+      <if test="corpId != null">
+        #{corpId,jdbcType=VARCHAR},
+      </if>
+      <if test="userId != null">
+        #{userId,jdbcType=VARCHAR},
+      </if>
+      <if test="groupId != null">
+        #{groupId,jdbcType=VARCHAR},
+      </if>
+      <if test="externalUserId != null">
+        #{externalUserId,jdbcType=VARCHAR},
+      </if>
+      <if test="miniVideoId != null">
+        #{miniVideoId,jdbcType=BIGINT},
+      </if>
+      <if test="newsPublishContentId != null">
+        #{newsPublishContentId,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="errorMsg != null">
+        #{errorMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="sendTimestamp != null">
+        #{sendTimestamp,jdbcType=BIGINT},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecordExample" resultType="java.lang.Long">
+    select count(*) from workwx_auto_reply_msg_send_record
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update workwx_auto_reply_msg_send_record
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.msgId != null">
+        msg_id = #{record.msgId,jdbcType=BIGINT},
+      </if>
+      <if test="record.msgType != null">
+        msg_type = #{record.msgType,jdbcType=INTEGER},
+      </if>
+      <if test="record.corpId != null">
+        corp_id = #{record.corpId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.userId != null">
+        user_id = #{record.userId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.groupId != null">
+        group_id = #{record.groupId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.externalUserId != null">
+        external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.miniVideoId != null">
+        mini_video_id = #{record.miniVideoId,jdbcType=BIGINT},
+      </if>
+      <if test="record.newsPublishContentId != null">
+        news_publish_content_id = #{record.newsPublishContentId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.status != null">
+        `status` = #{record.status,jdbcType=INTEGER},
+      </if>
+      <if test="record.errorMsg != null">
+        error_msg = #{record.errorMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="record.sendTimestamp != null">
+        send_timestamp = #{record.sendTimestamp,jdbcType=BIGINT},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update workwx_auto_reply_msg_send_record
+    set id = #{record.id,jdbcType=BIGINT},
+      msg_id = #{record.msgId,jdbcType=BIGINT},
+      msg_type = #{record.msgType,jdbcType=INTEGER},
+      corp_id = #{record.corpId,jdbcType=VARCHAR},
+      user_id = #{record.userId,jdbcType=VARCHAR},
+      group_id = #{record.groupId,jdbcType=VARCHAR},
+      external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
+      mini_video_id = #{record.miniVideoId,jdbcType=BIGINT},
+      news_publish_content_id = #{record.newsPublishContentId,jdbcType=VARCHAR},
+      `status` = #{record.status,jdbcType=INTEGER},
+      error_msg = #{record.errorMsg,jdbcType=VARCHAR},
+      send_timestamp = #{record.sendTimestamp,jdbcType=BIGINT}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord">
+    update workwx_auto_reply_msg_send_record
+    <set>
+      <if test="msgId != null">
+        msg_id = #{msgId,jdbcType=BIGINT},
+      </if>
+      <if test="msgType != null">
+        msg_type = #{msgType,jdbcType=INTEGER},
+      </if>
+      <if test="corpId != null">
+        corp_id = #{corpId,jdbcType=VARCHAR},
+      </if>
+      <if test="userId != null">
+        user_id = #{userId,jdbcType=VARCHAR},
+      </if>
+      <if test="groupId != null">
+        group_id = #{groupId,jdbcType=VARCHAR},
+      </if>
+      <if test="externalUserId != null">
+        external_user_id = #{externalUserId,jdbcType=VARCHAR},
+      </if>
+      <if test="miniVideoId != null">
+        mini_video_id = #{miniVideoId,jdbcType=BIGINT},
+      </if>
+      <if test="newsPublishContentId != null">
+        news_publish_content_id = #{newsPublishContentId,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="errorMsg != null">
+        error_msg = #{errorMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="sendTimestamp != null">
+        send_timestamp = #{sendTimestamp,jdbcType=BIGINT},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.api.model.po.AutoReplyMsgSendRecord">
+    update workwx_auto_reply_msg_send_record
+    set msg_id = #{msgId,jdbcType=BIGINT},
+      msg_type = #{msgType,jdbcType=INTEGER},
+      corp_id = #{corpId,jdbcType=VARCHAR},
+      user_id = #{userId,jdbcType=VARCHAR},
+      group_id = #{groupId,jdbcType=VARCHAR},
+      external_user_id = #{externalUserId,jdbcType=VARCHAR},
+      mini_video_id = #{miniVideoId,jdbcType=BIGINT},
+      news_publish_content_id = #{newsPublishContentId,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      error_msg = #{errorMsg,jdbcType=VARCHAR},
+      send_timestamp = #{sendTimestamp,jdbcType=BIGINT}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

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

@@ -55,9 +55,11 @@
 <!--        <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="reply_staff" domainObjectName="ReplyStaff" alias=""/>
+<!--        <table tableName="reply_staff" domainObjectName="ReplyStaff" alias=""/>-->
 <!--        <table tableName="we_com_send_msg_result" domainObjectName="SendMsgResult" alias=""/>-->
 <!--        <table tableName="we_com_corp" domainObjectName="Corp" alias=""/>-->
+        <table tableName="workwx_auto_reply_msg_send_record" domainObjectName="AutoReplyMsgSendRecord" alias=""/>
+
 
     </context>
 

+ 3 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/common/constant/WeComConstant.java

@@ -34,4 +34,7 @@ public interface WeComConstant {
 
     //获取企业客户标签详情
     String POST_CORP_TAG_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_corp_tag_list";
+
+    //发送新客户欢迎语
+    String POST_WE_COM_SEND_WELCOME_MSG = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/send_welcome_msg";
 }

+ 2 - 2
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/SpecialSendMessageMapper.java

@@ -36,6 +36,6 @@ public interface SpecialSendMessageMapper {
 
     List<SpecialSendMessage> getGroupList(@Param("preSendDate") String preSendDate);
 
-    List<String> selectExternalUserId(@Param("staffId") Long staffId, @Param("group") Integer group,
-                                      @Param("preSendDate") String preSendDate);
+    List<String> selectExternalUserId(@Param("staffId") Long staffId, @Param("content") String content,
+                                      @Param("group") Integer group, @Param("preSendDate") String preSendDate);
 }

+ 2 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/ext/WeComUserMapperExt.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.growth.common.dao.mapper.ext;
 
+import com.tzld.piaoquan.growth.common.model.bo.WeComUserBo;
 import com.tzld.piaoquan.growth.common.model.po.WeComUser;
 import com.tzld.piaoquan.growth.common.model.po.WeComUserExample;
 import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
@@ -19,7 +20,7 @@ public interface WeComUserMapperExt {
                                              @Param("preSendDate") String preSendDate,
                                              @Param("carrierIds") List<String> carrierIds);
 
-    List<WeComUserVo> getGroupSendUserByDate(@Param("start") Date start,
+    List<WeComUserBo> getGroupSendUserByDate(@Param("start") Date start,
                                              @Param("end") Date end,
                                              @Param("preSendDate") String preSendDate,
                                              @Param("carrierIds") List<String> carrierIds,

+ 13 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/MsgResult.java

@@ -0,0 +1,13 @@
+package com.tzld.piaoquan.growth.common.model.bo;
+
+import lombok.Data;
+import lombok.ToString;
+
+@Data
+@ToString
+public class MsgResult {
+
+    private Integer errcode;
+
+    private String errmsg;
+}

+ 39 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/WeComUserBo.java

@@ -0,0 +1,39 @@
+package com.tzld.piaoquan.growth.common.model.bo;
+
+import lombok.Data;
+import lombok.ToString;
+
+@Data
+@ToString
+public class WeComUserBo {
+    private Long corpId;
+
+    private String externalUserId;
+
+    private String unionId;
+
+    private String externalUserId3rdParty;
+
+    private Integer type;
+
+    private String name;
+
+    private String avatar;
+
+    private Integer gender;
+
+    private String carrierId;
+
+    private Integer status;
+
+    private Long sendTime;
+
+    private Long sendMsgResultId;
+
+    private Integer strategyStatus;
+
+    private String content;
+
+    private Integer sendGender;
+
+}

+ 7 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/vo/WeComUserVo.java

@@ -29,4 +29,11 @@ public class WeComUserVo {
 
     private Long sendTime;
 
+    private Long sendMsgResultId;
+
+    // 100000 单向 普通  200000 多日 普通
+    // 100001 单向 性别  200001 多日 性别
+    // 100002 单向 昵称  200002 多日 昵称
+    private Integer strategy;
+
 }

+ 14 - 8
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -131,10 +131,12 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         if (isInvalidGuaranteedParam(guaranteedParam)) {
             return CommonResponse.create(500, "参数错误");
         }
-
         Set<Long> videoIds = new HashSet<>();
         for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
-            processVideoParam(videoParam, guaranteedParam.getDate(), videoIds);
+            CommonResponse<Void> voidCommonResponse = processVideoParam(videoParam, guaranteedParam.getDate(), videoIds);
+            if (voidCommonResponse != null) {
+                return voidCommonResponse;
+            }
         }
 
         Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);
@@ -156,9 +158,9 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
 
-    private void processVideoParam(VideoParam videoParam, String date, Set<Long> videoIds) {
+    private CommonResponse<Void> processVideoParam(VideoParam videoParam, String date, Set<Long> videoIds) {
         if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
-            LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + date);
+            return CommonResponse.create(500, "保底视频数量异常,请查看" + date);
         }
         List<Long> staffIds = Optional.ofNullable(videoParam.getStaffIds()).orElseGet(() -> {
             List<Long> newStaffIds = new ArrayList<>();
@@ -168,12 +170,16 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             return newStaffIds;
         });
         for (Long staffId : staffIds) {
-            checkVideoSendTime(videoParam, staffId);
+            CommonResponse<Void> voidCommonResponse = checkVideoSendTime(videoParam, staffId);
+            if (voidCommonResponse != null) {
+                return voidCommonResponse;
+            }
             videoIds.addAll(videoParam.getVideoIds());
         }
+        return null;
     }
 
-    private void checkVideoSendTime(VideoParam videoParam, Long staffId) {
+    private CommonResponse<Void> checkVideoSendTime(VideoParam videoParam, Long staffId) {
         for (Long videoId : videoParam.getVideoIds()) {
             MessageAttachmentExample example = new MessageAttachmentExample();
             example.createCriteria().andMiniprogramVideoIdEqualTo(videoId).andStaffIdEqualTo(staffId);
@@ -184,10 +190,10 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             MessageAttachment messageAttachment = messageAttachmentList.get(0);
             if (messageAttachment.getSendTime() != null &&
                     DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 30 * MILLISECOND_DAY) {
-                LarkRobotUtil.sendMessage("保底视频90天内已发送,请查看videoId=" + videoId);
-                throw new RuntimeException("保底视频90天内已发送,请查看videoId=" + videoId);
+                return CommonResponse.create(500, "保底视频30天内已发送,请查看videoId=" + videoId);
             }
         }
+        return null;
     }
 
     private Map<Long, MessageAttachment> createMessageAttachmentMap(Set<Long> videoIds, Map<Long, VideoDetail> coverMap) {

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

@@ -5,6 +5,7 @@ import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
 import com.tzld.piaoquan.growth.common.dao.mapper.PreSpecialSendMessageMapper;
+import com.tzld.piaoquan.growth.common.model.bo.MsgResult;
 import com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessage;
 import com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessageExample;
 import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
@@ -23,6 +24,7 @@ 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;
+import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.POST_WE_COM_SEND_WELCOME_MSG;
 
 
 @Slf4j
@@ -82,5 +84,30 @@ public class MessageServiceImpl implements MessageService {
         return CommonResponse.success();
     }
 
+    @Override
+    public MsgResult sendAutoReplyMessage(JSONObject jsonObject, Long corpId) {
+        MsgResult msgResult = new MsgResult();
+        try {
+            String accessToken = weComAccessTokenService.getWeComAccessToken(corpId);
+            String url = POST_WE_COM_SEND_WELCOME_MSG
+                    + "?access_token=" + accessToken;
+            String s = httpPoolClient.post(url, jsonObject.toJSONString());
+            JSONObject res = JSONObject.parseObject(s);
+            log.info("sendAutoReplyMessage res={}", res);
+            Integer code = res.getInteger("errcode");
+            msgResult.setErrcode(code);
+            if (code != 0) {
+                msgResult.setErrmsg(res.getString("errmsg"));
+                LarkRobotUtil.sendMessage("sendAutoReplyMessage error" + "res:" + res.toJSONString());
+            }
+        } catch (IOException e) {
+            msgResult.setErrcode(-1);
+            msgResult.setErrmsg(e.getMessage());
+            LarkRobotUtil.sendMessage("sendAutoReplyMessage error" + e.getMessage());
+            log.error("sendAutoReplyMessage error", e);
+        }
+        return msgResult;
+    }
+
 
 }

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

@@ -2,6 +2,7 @@ package com.tzld.piaoquan.growth.common.service.Impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.growth.common.common.enums.PreSpecialStatusEnum;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
 import com.tzld.piaoquan.growth.common.dao.mapper.StaffMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.StaffWithUserMapper;
@@ -9,6 +10,7 @@ import com.tzld.piaoquan.growth.common.dao.mapper.UserWithTagMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.WeComUserMapper;
 import com.tzld.piaoquan.growth.common.dao.mapper.ext.WeComUserMapperExt;
 import com.tzld.piaoquan.growth.common.model.bo.GroupSendWeComUserParam;
+import com.tzld.piaoquan.growth.common.model.bo.WeComUserBo;
 import com.tzld.piaoquan.growth.common.model.po.*;
 import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
 import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
@@ -64,7 +66,7 @@ public class WeComUserServiceImpl implements WeComUserService {
         if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(carrierId)) {
             return;
         }
-        Staff staff = getStaff(carrierId);
+        Staff staff = getStaff(carrierId, corpId);
         insertStaffWithUser(externalUserId, staff, corpId);
     }
 
@@ -157,11 +159,11 @@ public class WeComUserServiceImpl implements WeComUserService {
     }
 
     @Override
-    public void delStaffWithUser(String externalUserId, String carrierId, Long deleteTime) {
+    public void delStaffWithUser(String externalUserId, String carrierId, Long corpId, Long deleteTime) {
         if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(carrierId)) {
             return;
         }
-        Staff staff = getStaff(carrierId);
+        Staff staff = getStaff(carrierId, corpId);
         if (staff == null) {
             return;
         }
@@ -201,9 +203,9 @@ public class WeComUserServiceImpl implements WeComUserService {
     }
 
 
-    private Staff getStaff(String carrierId) {
+    private Staff getStaff(String carrierId, Long corpId) {
         StaffExample example = new StaffExample();
-        example.createCriteria().andCarrierIdEqualTo(carrierId);
+        example.createCriteria().andCarrierIdEqualTo(carrierId).andCorpIdEqualTo(corpId);
         List<Staff> staffList = staffMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(staffList)) {
             log.error("getStaff staff empty carrierId={}", carrierId);
@@ -284,9 +286,34 @@ public class WeComUserServiceImpl implements WeComUserService {
             page.setPageSize(param.getPageSize());
             offset = (param.getPageNum() - 1) * param.getPageSize();
         }
-        List<WeComUserVo> list = weComUserMapperExt.getGroupSendUserByDate(start, end, preSendDate, param.getCarrierIds(),
+        List<WeComUserBo> list = weComUserMapperExt.getGroupSendUserByDate(start, end, preSendDate, param.getCarrierIds(),
                 offset, param.getPageSize());
-        page.setObjs(list);
+        List<WeComUserVo> weComUserVoList = new ArrayList<>();
+        for (WeComUserBo weComUserBo : list) {
+            WeComUserVo weComUserVo = new WeComUserVo();
+            BeanUtils.copyProperties(weComUserBo, weComUserVo);
+            int strategy;
+            if (Objects.equals(weComUserBo.getStrategyStatus(), PreSpecialStatusEnum.TAG.getStatus())) {
+                if (weComUserBo.getSendGender() != null) {
+                    strategy = 200001;
+                } else if (StringUtils.isNotEmpty(weComUserBo.getContent()) && weComUserBo.getContent().contains("${name}")) {
+                    strategy = 200002;
+                } else {
+                    strategy = 200000;
+                }
+            } else {
+                if (weComUserBo.getSendGender() != null) {
+                    strategy = 100001;
+                } else if (StringUtils.isNotEmpty(weComUserBo.getContent()) && weComUserBo.getContent().contains("${name}")) {
+                    strategy = 100002;
+                } else {
+                    strategy = 100000;
+                }
+            }
+            weComUserVo.setStrategy(strategy);
+            weComUserVoList.add(weComUserVo);
+        }
+        page.setObjs(weComUserVoList);
         return page;
     }
 

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

@@ -2,6 +2,7 @@ package com.tzld.piaoquan.growth.common.service;
 
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
+import com.tzld.piaoquan.growth.common.model.bo.MsgResult;
 import com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessage;
 
 import java.util.List;
@@ -13,4 +14,6 @@ public interface MessageService {
     String getMessageText(Long staffId);
 
     CommonResponse<Void> createPreSpecialAssembleSendMessage(List<PreSpecialSendMessage> preSpecialSendMessages);
+
+    MsgResult sendAutoReplyMessage(JSONObject jsonObject, Long corpId);
 }

+ 2 - 2
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/WeComUserService.java

@@ -13,11 +13,11 @@ import java.util.List;
 public interface WeComUserService {
 
 
-    void addStaffWithUser(String externalUserId, String staffUserId, Long corpId);
+    void addStaffWithUser(String externalUserId, String carrierId, Long corpId);
 
     void insertStaffWithUser(String externalUserId, Staff staff, Long corpId);
 
-    void delStaffWithUser(String externalUserId, String carrierId, Long deleteTime);
+    void delStaffWithUser(String externalUserId, String carrierId, Long corpId, Long deleteTime);
 
     void delStaffWithUser(Long userId, Long staffId, Long deleteTime);
 

+ 2 - 1
common-module/src/main/resources/mapper/SpecialSendMessageMapper.xml

@@ -311,7 +311,8 @@
         from we_com_special_send_message t1
         left join we_com_user t2 on t1.user_id = t2.id
         where t1.staff_id = #{staffId,jdbcType=BIGINT}
-        and t1.group = #{group,jdbcType=INTEGER}
+        and t1.content = #{content,jdbcType=INTEGER}
+        and t1.group = #{group,jdbcType=VARCHAR}
         and t1.pre_send_date = #{preSendDate,jdbcType=VARCHAR}
         and t1.is_send = 0
     </select>

+ 4 - 2
common-module/src/main/resources/mapper/ext/WeComUserMapperExt.xml

@@ -20,15 +20,17 @@
         </if>
     </select>
 
-    <select id="getGroupSendUserByDate" resultType="com.tzld.piaoquan.growth.common.model.vo.WeComUserVo">
+    <select id="getGroupSendUserByDate" resultType="com.tzld.piaoquan.growth.common.model.bo.WeComUserBo">
         select wcu.corp_id as corpId, wcu.external_user_id as externalUserId, wcu.union_id as unionId,
         wcu.external_user_id_3rd_party as externalUserId3rdParty, wcu.type as type, wcu.name as name,
         wcu.avatar as avatar, wcu.gender as gender, wcs.carrier_id as carrierId, wcsmr.status as status,
-        UNIX_TIMESTAMP(wcsmr.send_time) * 1000 as sendTime
+        UNIX_TIMESTAMP(wcsmr.send_time) * 1000 as sendTime, wcsmr.id as sendMsgResultId, wcspsm.status as strategyStatus,
+        wcspsm.content as content, wcspsm.gender as sendGender
         from we_com_user wcu
         join we_com_send_msg_result wcsmr on wcsmr.user_id = wcu.id
         join we_com_special_send_message wcssm on wcssm.user_id = wcsmr.user_id and wcssm.staff_id = wcsmr.staff_id
         join we_com_staff wcs on wcs.id = wcssm.staff_id
+        join we_com_special_pre_send_message wcspsm on wcssm.group = wcspsm.id
         where wcssm.is_send = 1
         and wcsmr.create_time between #{start} and #{end}
         and wcssm.pre_send_date = #{preSendDate}

+ 4 - 1
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -162,7 +162,10 @@ public class WeComHistoryDataJob {
                 if (sendDetail.getStaffId() == 3) {
                     LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 } else {
-                    LarkRobotUtil.sendNotPushMessage("<at user_id=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
+                    //8点前报警
+                    if(DateUtil.getHourOfDay() < 8){
+                        LarkRobotUtil.sendNotPushMessage("<at user_id=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
+                    }
                 }
             }
             stringBuilder.append("总发送数量:").append(count).append("   ");

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

@@ -166,7 +166,7 @@ public class WeComMessageDataJob {
             }
             if (CollectionUtils.isEmpty(videoParam.getVideoIds()) || videoParam.getVideoIds().size() < MAX_VIDEO_NUM) {
                 LarkRobotUtil.sendMessage("保底视频数量异常,请查看" + guaranteedParam.getDate() + videoParam.getStaffId());
-                throw new RuntimeException();
+                continue;
             }
             for (Long videoId : videoParam.getVideoIds()) {
                 MessageAttachmentExample example = new MessageAttachmentExample();
@@ -179,7 +179,7 @@ public class WeComMessageDataJob {
                 MessageAttachment messageAttachment = messageAttachmentList.get(0);
                 if (messageAttachment.getSendTime() != null
                         && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 30 * MILLISECOND_DAY) {
-                    LarkRobotUtil.sendMessage("保底视频90天内已发送,请查看videoId=" + videoId);
+                    LarkRobotUtil.sendMessage("保底视频30天内已发送,请查看videoId=" + videoId);
                 }
             }
             //重新组合视频id
@@ -187,7 +187,6 @@ public class WeComMessageDataJob {
         }
         if (!videoMap.containsKey(0L)) {
             LarkRobotUtil.sendMessage("保底视频没有默认组,请查看" + guaranteedParam.getDate());
-            throw new RuntimeException();
         }
         log.info("保底数据获取,videoMap={}", videoMap);
         this.guaranteedVideoMap = videoMap;

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

@@ -116,7 +116,11 @@ public class WeComSpecialDataJob {
             specialSendMessage.setUserId(weComUser.getId());
             specialSendMessage.setGroup(preId.intValue());
             specialSendMessage.setAttachmentIds(attachmentIds);
-            specialSendMessage.setContent(content);
+            if (content.contains("${name}")) {
+                specialSendMessage.setContent(content.replace("${name}", weComUser.getName()));
+            } else {
+                specialSendMessage.setContent(content);
+            }
             specialSendMessage.setPreSendDate(date);
             specialSendMessageMapper.insertSelective(specialSendMessage);
         }
@@ -144,6 +148,9 @@ public class WeComSpecialDataJob {
                 specialSendMessage.setUserId(weComUser.getId());
                 specialSendMessage.setGroup(preId.intValue());
                 specialSendMessage.setAttachmentIds(attachmentIds);
+                if (content.contains("${name}")) {
+                    content = content.replace("${name}", weComUser.getName());
+                }
                 specialSendMessage.setContent(content);
                 specialSendMessage.setPreSendDate(date);
                 specialSendMessageMapper.insertSelective(specialSendMessage);
@@ -163,6 +170,9 @@ public class WeComSpecialDataJob {
             specialSendMessage.setUserId(weComUser.getId());
             specialSendMessage.setGroup(preId.intValue());
             specialSendMessage.setAttachmentIds(attachmentIds);
+            if (content.contains("${name}")) {
+                content = content.replace("${name}", weComUser.getName());
+            }
             specialSendMessage.setContent(content);
             specialSendMessage.setPreSendDate(date);
             specialSendMessageMapper.insertSelective(specialSendMessage);
@@ -175,7 +185,8 @@ public class WeComSpecialDataJob {
         List<SpecialSendMessage> groupList = specialSendMessageMapper.getGroupList(thatDayDateString);
         for (SpecialSendMessage specialSendMessage : groupList) {
             List<String> externalUserIds = specialSendMessageMapper.selectExternalUserId(specialSendMessage.getStaffId(),
-                    specialSendMessage.getGroup(), thatDayDateString);
+                    specialSendMessage.getContent(), specialSendMessage.getGroup(), thatDayDateString);
+            System.out.println(externalUserIds);
             boolean flag = specialPushMessage(externalUserIds, specialSendMessage);
             if (flag) {
                 SpecialSendMessage updateSpecialSendMessage = new SpecialSendMessage();

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

@@ -212,7 +212,8 @@ public class WeComUserDataJob {
                     }
                     if (!CollectionUtils.isEmpty(allExternalUserIds)) {
                         for (String delExternalUserId : allExternalUserIds) {
-                            weComUserService.delStaffWithUser(delExternalUserId, staff.getCarrierId(), System.currentTimeMillis());
+                            weComUserService.delStaffWithUser(delExternalUserId, staff.getCarrierId(), corp.getId(),
+                                    System.currentTimeMillis());
                         }
                     }
                     if (CollectionUtils.isEmpty(existExternalUserIds)) {
@@ -245,7 +246,7 @@ public class WeComUserDataJob {
     }
 
     @XxlJob("statisticsUserCountJob")
-    public ReturnT<String> statisticsUserCount(String param) throws IOException {
+    public ReturnT<String> statisticsUserCount(String param) {
         StaffExample staffExample = new StaffExample();
         List<Staff> staffList = staffMapper.selectByExample(staffExample);
         String date;
@@ -309,6 +310,22 @@ public class WeComUserDataJob {
                     count++;
                     Long userId = weComUserMapper.selectIdByExternalUserId(externalUserId);
                     userId = addAndUpdateUser(externalContact, corpId, externalUserId, createAt, staff.getId(), userId);
+                    JSONArray tagIds = followInfo.getJSONArray("tag_id");
+                    if (!CollectionUtils.isEmpty(tagIds)) {
+                        List<String> tagIdList = tagIds.toJavaList(String.class);
+                        for (String tagId : tagIdList) {
+                            TagExample example = new TagExample();
+                            example.createCriteria().andTagIdEqualTo(tagId);
+                            List<Tag> tags = tagMapper.selectByExample(example);
+                            if (!CollectionUtils.isEmpty(tags)) {
+                                Tag tag = tags.get(0);
+                                UserWithTag userWithTag = new UserWithTag();
+                                userWithTag.setUserId(userId);
+                                userWithTag.setTagId(tag.getId());
+                                addUserWithTag(userWithTag);
+                            }
+                        }
+                    }
                 }
                 String nextCursor = jsonObject.getString("next_cursor");
                 if (cursor.equals(nextCursor)) {
@@ -488,6 +505,15 @@ public class WeComUserDataJob {
             weComUser.setGender(gender);
             weComUser.setAvatar(avatar);
             weComUserMapper.updateByPrimaryKeySelective(weComUser);
+            StaffWithUserExample example = new StaffWithUserExample();
+            example.createCriteria().andStaffIdEqualTo(staffId).andUserIdEqualTo(userId);
+            List<StaffWithUser> staffWithUsers = staffWithUserMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(staffWithUsers)) {
+                StaffWithUser staffWithUser = new StaffWithUser();
+                staffWithUser.setStaffId(staffId);
+                staffWithUser.setUserId(userId);
+                staffWithUserMapper.insertSelective(staffWithUser);
+            }
         }
         return userId;
     }