Pārlūkot izejas kodu

Merge branch 'dev-xym-send_time' of Server/we-com-manage into master

xueyiming 7 mēneši atpakaļ
vecāks
revīzija
033fe692c1
33 mainītis faili ar 3982 papildinājumiem un 136 dzēšanām
  1. 24 0
      we-com-server/pom.xml
  2. 8 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java
  3. 8 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/OtherServerURL.java
  4. 2 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/TimeConstant.java
  5. 42 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/SendMessageMapper.java
  6. 30 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/StaffMapper.java
  7. 35 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/StaffWithUserMapper.java
  8. 114 34
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java
  9. 309 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob2.java
  10. 95 29
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java
  11. 37 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/AdPutFlowParam.java
  12. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/VideoDetail.java
  13. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachment.java
  14. 60 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachmentExample.java
  15. 114 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SendMessage.java
  16. 753 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SendMessageExample.java
  17. 92 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/Staff.java
  18. 662 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffExample.java
  19. 70 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffWithUser.java
  20. 512 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffWithUserExample.java
  21. 1 7
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MiniprogramVo.java
  22. 113 23
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java
  23. 5 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java
  24. 4 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java
  25. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java
  26. 4 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java
  27. 0 5
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpPoolClient.java
  28. 20 5
      we-com-server/src/main/resources/mapper/MessageAttachmentMapper.xml
  29. 322 0
      we-com-server/src/main/resources/mapper/SendMessageMapper.xml
  30. 246 0
      we-com-server/src/main/resources/mapper/StaffMapper.xml
  31. 239 0
      we-com-server/src/main/resources/mapper/StaffWithUserMapper.xml
  32. 32 29
      we-com-server/src/main/resources/mapper/UserMapper.xml
  33. 6 2
      we-com-server/src/main/resources/mybatis-generator-config.xml

+ 24 - 0
we-com-server/pom.xml

@@ -20,4 +20,28 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
 
+    <build>
+        <!-- 固定包名 避免随着版本变动 -->
+        <finalName>we-com-server</finalName>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.yml</include>
+                    <include>**/*.yaml</include>
+                    <include>**/*.xml</include>
+                    <include>**/*.properties</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+
+    </build>
+
 </project>

+ 8 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java

@@ -1,5 +1,8 @@
 package com.tzld.piaoquan.wecom.common.constant;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public interface MessageConstant {
 
     //推送保底内容
@@ -10,5 +13,10 @@ public interface MessageConstant {
 
     String defaultName = "日常push-%s-推荐官";
 
+    Map<String, String> carrierIdMap = new HashMap<String, String>(){{
+        put("wogizUDQAAzM5HbqIyA4k3KR6D8vKp3w", "songyi");
+        put("wogizUDQAAk5Z_5nLRD-XTAPU9poaRCw", "XinYi");
+    }};
+
 
 }

+ 8 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/OtherServerURL.java

@@ -0,0 +1,8 @@
+package com.tzld.piaoquan.wecom.common.constant;
+
+public interface OtherServerURL {
+
+    String POST_VIDEO_DETAIL_URL = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo";
+
+    String POST_ADD_TENCENT = "https://api.piaoquantv.com/ad/put/flow/add/tencent";
+}

+ 2 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/TimeConstant.java

@@ -6,4 +6,6 @@ public interface TimeConstant {
     Integer HOUR = 60 * 60;
     Integer DAY = 60 * 60 * 24;
 
+    Long MILLISECOND_DAY = (long) DAY * 1000;
+
 }

+ 42 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/SendMessageMapper.java

@@ -0,0 +1,42 @@
+package com.tzld.piaoquan.wecom.dao.mapper;
+
+import com.tzld.piaoquan.wecom.model.po.SendMessage;
+import com.tzld.piaoquan.wecom.model.po.SendMessageExample;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface SendMessageMapper {
+    long countByExample(SendMessageExample example);
+
+    int deleteByExample(SendMessageExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(SendMessage record);
+
+    int insertSelective(SendMessage record);
+
+    List<SendMessage> selectByExample(SendMessageExample example);
+
+    SendMessage selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") SendMessage record, @Param("example") SendMessageExample example);
+
+    int updateByExample(@Param("record") SendMessage record, @Param("example") SendMessageExample example);
+
+    int updateByPrimaryKeySelective(SendMessage record);
+
+    int updateByPrimaryKey(SendMessage record);
+
+    void insertList(@Param("list") List<SendMessage> list);
+
+    List<SendMessage> getGroupList(@Param("createTime") Date createTime, @Param("isSend")Integer isSend);
+
+    List<String> selectExternalUserId3rdParty(@Param("record") SendMessage record);
+
+}

+ 30 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/StaffMapper.java

@@ -0,0 +1,30 @@
+package com.tzld.piaoquan.wecom.dao.mapper;
+
+import com.tzld.piaoquan.wecom.model.po.Staff;
+import com.tzld.piaoquan.wecom.model.po.StaffExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+public interface StaffMapper {
+    long countByExample(StaffExample example);
+
+    int deleteByExample(StaffExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(Staff record);
+
+    int insertSelective(Staff record);
+
+    List<Staff> selectByExample(StaffExample example);
+
+    Staff selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") Staff record, @Param("example") StaffExample example);
+
+    int updateByExample(@Param("record") Staff record, @Param("example") StaffExample example);
+
+    int updateByPrimaryKeySelective(Staff record);
+
+    int updateByPrimaryKey(Staff record);
+}

+ 35 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/StaffWithUserMapper.java

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

+ 114 - 34
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java

@@ -4,27 +4,27 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.google.common.collect.Lists;
-import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
-import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.*;
 import com.tzld.piaoquan.wecom.model.bo.PushMessage;
-import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
-import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
-import com.tzld.piaoquan.wecom.model.po.User;
-import com.tzld.piaoquan.wecom.model.po.UserExample;
+import com.tzld.piaoquan.wecom.model.po.*;
+import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.service.MessageService;
 import com.tzld.piaoquan.wecom.utils.DateUtil;
 import com.tzld.piaoquan.wecom.utils.MessageUtil;
 import com.tzld.piaoquan.wecom.utils.OdpsUtil;
 import com.tzld.piaoquan.wecom.utils.page.Page;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
+import java.io.PrintStream;
 import java.util.*;
 import java.util.stream.Collectors;
 
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
+import static com.tzld.piaoquan.wecom.common.constant.TimeConstant.MILLISECOND_DAY;
 
 @Component
 public class WeComMessageDataJob {
@@ -41,6 +41,15 @@ public class WeComMessageDataJob {
     @Autowired
     private MessageService messageService;
 
+    @Autowired
+    private MessageAttachmentService messageAttachmentService;
+
+    @Autowired
+    private StaffWithUserMapper staffWithUserMapper;
+
+    @Autowired
+    private StaffMapper staffMapper;
+
     private static final int MAX_VIDEO_NUM = 3;
 
     //历史优质视频可推送用户列表
@@ -49,8 +58,14 @@ public class WeComMessageDataJob {
     //保底视频列表
     List<Long> guaranteedVideoIdList = new ArrayList<>();
 
+    //从缓存中获取的保底视频数量
+    int getGuaranteedVideoIdNum = 0;
+
+    Map<String, String> pageMap = new HashMap<>();
+
     //初始化操作
     void init() {
+        //历史优质视频获取
         String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
         List<Record> recordList = OdpsUtil.getOdpsData(sql);
         if (CollectionUtils.isEmpty(recordList)) {
@@ -66,21 +81,35 @@ public class WeComMessageDataJob {
             list.add(pushMessage);
         }
         goodHistoryPushList = list;
-        List<Long> saveVideoIds = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, 2))
+
+        getGuaranteedVideoIdNum = 0;
+        //保底视频获取
+        List<Long> videoIdList = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, -1))
                 .stream().map(o -> (Integer) o).map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(saveVideoIds)) {
+        if (CollectionUtils.isEmpty(videoIdList)) {
             throw new RuntimeException("保底数据为空");
         }
-        MessageAttachmentExample example = new MessageAttachmentExample();
-        example.createCriteria().andMiniprogramVideoIdIn(saveVideoIds);
-        List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
-        if (CollectionUtils.isEmpty(messageAttachmentList) || messageAttachmentList.size() < saveVideoIds.size()) {
-            throw new RuntimeException("保底数据获取失败");
-        }
-        for (MessageAttachment messageAttachment : messageAttachmentList) {
-            if (messageAttachment.getUpdateTime().compareTo(DateUtil.getThatDayDate()) < 0) {
-                throw new RuntimeException("保底数据不是最新的");
+        List<Long> saveVideoIds = new ArrayList<>();
+        for (Long videoId : videoIdList) {
+            getGuaranteedVideoIdNum++;
+            MessageAttachmentExample example = new MessageAttachmentExample();
+            example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
+            List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                continue;
             }
+            MessageAttachment messageAttachment = messageAttachmentList.get(0);
+            if (messageAttachment.getSendTime() != null
+                    && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 180 * MILLISECOND_DAY) {
+                continue;
+            }
+            saveVideoIds.add(videoId);
+            if (saveVideoIds.size() >= MAX_VIDEO_NUM) {
+                break;
+            }
+        }
+        if (saveVideoIds.size() < MAX_VIDEO_NUM) {
+            throw new RuntimeException("保底数据不足");
         }
         guaranteedVideoIdList = saveVideoIds;
     }
@@ -100,17 +129,53 @@ public class WeComMessageDataJob {
                 continue;
             }
             for (User user : userList) {
-                String pushKey = getPushKey(user);
-                if (res.containsKey(pushKey)) {
-                    res.get(pushKey).add(user.getExternalUserId3rdParty());
-                } else {
-                    res.put(pushKey, Lists.newArrayList(user.getExternalUserId3rdParty()));
+                List<String> staffPushKeys = getStaffPushKey(user);
+                if (CollectionUtils.isEmpty(staffPushKeys)) {
+                    continue;
+                }
+                for (String staffPushKey : staffPushKeys) {
+                    if (res.containsKey(staffPushKey)) {
+                        res.get(staffPushKey).add(user.getExternalUserId3rdParty());
+                    } else {
+                        res.put(staffPushKey, Lists.newArrayList(user.getExternalUserId3rdParty()));
+                    }
                 }
             }
         }
         pushMessage(res);
+        saveGuaranteedVideoIdList(guaranteedVideoIdList);
+    }
+
+    public void saveGuaranteedVideoIdList(List<Long> videoIdList) {
+        MessageAttachmentExample example = new MessageAttachmentExample();
+        example.createCriteria().andMiniprogramVideoIdIn(videoIdList);
+        List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+        for (MessageAttachment messageAttachment : messageAttachmentList) {
+            MessageAttachment updateMessageAttachment = new MessageAttachment();
+            updateMessageAttachment.setId(messageAttachment.getId());
+            updateMessageAttachment.setSendTime(new Date());
+            messageAttachmentMapper.updateByPrimaryKeySelective(updateMessageAttachment);
+        }
+        //移除从redis中获取的保底数据
+        for (int i = 0; i < getGuaranteedVideoIdNum; i++) {
+            redisTemplate.opsForList().leftPop(GUARANTEED_MINIPROGRAM_KEY);
+        }
     }
 
+    public List<String> getStaffPushKey(User user) {
+        StaffWithUserExample example = new StaffWithUserExample();
+        example.createCriteria().andUserIdEqualTo(user.getId());
+        List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(staffWithUserList)) {
+            return null;
+        }
+        String pushKey = getPushKey(user);
+        List<String> staffPushKeys = new ArrayList<>();
+        for (StaffWithUser staffWithUser : staffWithUserList) {
+            staffPushKeys.add(staffWithUser.getId() + "&" + pushKey);
+        }
+        return staffPushKeys;
+    }
 
     public String getPushKey(User user) {
         int n = 0;
@@ -148,18 +213,21 @@ public class WeComMessageDataJob {
 
     public void pushMessage(Map<String, List<String>> map) {
         List<JSONObject> pushList = new ArrayList<>();
-        //发送人员  暂时写死 只有两个
-        List<String> staffExtIdList = new ArrayList<>();
-        staffExtIdList.add("wogizUDQAAk5Z_5nLRD-XTAPU9poaRCw");
-        staffExtIdList.add("wogizUDQAAzM5HbqIyA4k3KR6D8vKp3w");
         String text = messageService.getMessageText();
         String name = MessageUtil.getName();
         for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+            String[] split = entry.getKey().split("&");
+            Long staffId = Long.parseLong(split[0]);
+            StaffExample staffExample = new StaffExample();
+            staffExample.createCriteria().andIdEqualTo(staffId);
+            List<Staff> staffList = staffMapper.selectByExample(staffExample);
+            Staff staff = staffList.get(0);
+            String pushKey = split[1];
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("name", name);
             jsonObject.put("text", text);
             JSONArray attachments = new JSONArray();
-            List<Long> videoIdList = Arrays.stream(entry.getKey().split("_")).map(Long::parseLong).collect(Collectors.toList());
+            List<Long> videoIdList = Arrays.stream(pushKey.split("_")).map(Long::parseLong).collect(Collectors.toList());
             for (Long videoId : videoIdList) {
                 JSONObject attachment = new JSONObject();
                 attachment.put("msgtype", "miniprogram");
@@ -173,7 +241,19 @@ public class WeComMessageDataJob {
                 JSONObject miniprogram = new JSONObject();
                 miniprogram.put("appid", messageAttachment.getAppid());
                 miniprogram.put("title", messageAttachment.getTitle());
-                miniprogram.put("page", messageAttachment.getPage());
+
+                String page = "";
+                String key = staff.getStaffExtId() + "_" + videoId;
+                if (pageMap.containsKey(key)) {
+                    page = pageMap.get(key);
+                } else {
+                    page = messageAttachmentService.getPage(staff, videoId);
+                    pageMap.put(key, page);
+                }
+                if (StringUtils.isEmpty(page)) {
+                    throw new RuntimeException("获取page失败");
+                }
+                miniprogram.put("page", page);
                 miniprogram.put("cover", messageAttachment.getCover());
                 attachment.put("miniprogram", miniprogram);
                 attachments.add(attachment);
@@ -184,12 +264,10 @@ public class WeComMessageDataJob {
                 List<JSONObject> staffEuList = new ArrayList<>();
                 JSONObject newJSONObject = new JSONObject();
                 newJSONObject.putAll(jsonObject);
-                for (String staffExtId : staffExtIdList) {
-                    JSONObject staff_eu = new JSONObject();
-                    staff_eu.put("staff_ext_id", staffExtId);
-                    staff_eu.put("eu_ext_ids", list);
-                    staffEuList.add(staff_eu);
-                }
+                JSONObject staff_eu = new JSONObject();
+                staff_eu.put("staff_ext_id", staff.getStaffExtId());
+                staff_eu.put("eu_ext_ids", list);
+                staffEuList.add(staff_eu);
                 newJSONObject.put("staff_eu_list", staffEuList);
                 pushList.add(newJSONObject);
             }
@@ -197,6 +275,8 @@ public class WeComMessageDataJob {
         if (CollectionUtils.isEmpty(pushList)) {
             throw new RuntimeException("推送视频生成失败");
         }
+
+        System.out.println(pushList);
         for (JSONObject jsonObject : pushList) {
             messageService.pushMessage(jsonObject);
         }

+ 309 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob2.java

@@ -0,0 +1,309 @@
+package com.tzld.piaoquan.wecom.job;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.odps.data.Record;
+import com.google.common.collect.Lists;
+import com.tzld.piaoquan.wecom.dao.mapper.*;
+import com.tzld.piaoquan.wecom.model.bo.PushMessage;
+import com.tzld.piaoquan.wecom.model.po.*;
+import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
+import com.tzld.piaoquan.wecom.service.MessageService;
+import com.tzld.piaoquan.wecom.utils.DateUtil;
+import com.tzld.piaoquan.wecom.utils.MessageUtil;
+import com.tzld.piaoquan.wecom.utils.OdpsUtil;
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
+import static com.tzld.piaoquan.wecom.common.constant.TimeConstant.MILLISECOND_DAY;
+
+@Component
+public class WeComMessageDataJob2 {
+
+    @Autowired
+    private UserMapper userMapper;
+
+    @Autowired
+    private MessageAttachmentMapper messageAttachmentMapper;
+
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @Autowired
+    private MessageService messageService;
+
+    @Autowired
+    private MessageAttachmentService messageAttachmentService;
+
+    @Autowired
+    private StaffWithUserMapper staffWithUserMapper;
+
+    @Autowired
+    private StaffMapper staffMapper;
+
+    @Autowired
+    SendMessageMapper sendMessageMapper;
+
+    private static final int MAX_VIDEO_NUM = 3;
+
+    //历史优质视频可推送用户列表
+    List<PushMessage> goodHistoryPushList = new ArrayList<>();
+
+    //保底视频列表
+    List<Long> guaranteedVideoIdList = new ArrayList<>();
+
+    //从缓存中获取的保底视频数量
+    int getGuaranteedVideoIdNum = 0;
+
+    Map<String, String> pageMap = new HashMap<>();
+
+    //初始化操作
+    void init() {
+        //历史优质视频获取
+        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
+        List<Record> recordList = OdpsUtil.getOdpsData(sql);
+        if (CollectionUtils.isEmpty(recordList)) {
+            return;
+        }
+        List<PushMessage> list = new ArrayList<>();
+        for (Record record : recordList) {
+            PushMessage pushMessage = new PushMessage();
+            Long videoId = Long.parseLong((String) record.get(0));
+            Set<Long> userIds = new HashSet<>(JSONObject.parseArray((String) record.get(1), Long.class));
+            pushMessage.setVideoId(videoId);
+            pushMessage.setUserIds(userIds);
+            list.add(pushMessage);
+        }
+        goodHistoryPushList = list;
+
+        getGuaranteedVideoIdNum = 0;
+        //保底视频获取
+        List<Long> videoIdList = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, -1))
+                .stream().map(o -> (Integer) o).map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(videoIdList)) {
+            throw new RuntimeException("保底数据为空");
+        }
+        List<Long> saveVideoIds = new ArrayList<>();
+        for (Long videoId : videoIdList) {
+            getGuaranteedVideoIdNum++;
+            MessageAttachmentExample example = new MessageAttachmentExample();
+            example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
+            List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                continue;
+            }
+            MessageAttachment messageAttachment = messageAttachmentList.get(0);
+//            if (messageAttachment.getSendTime() != null
+//                    && DateUtil.dateDifference(new Date(), messageAttachment.getSendTime()) < 180 * MILLISECOND_DAY) {
+//                continue;
+//            }
+            saveVideoIds.add(videoId);
+            if (saveVideoIds.size() >= MAX_VIDEO_NUM) {
+                break;
+            }
+        }
+        if (saveVideoIds.size() < MAX_VIDEO_NUM) {
+            throw new RuntimeException("保底数据不足");
+        }
+        guaranteedVideoIdList = saveVideoIds;
+    }
+
+    public void assemble() {
+        init();
+        Map<String, List<String>> res = new HashMap<>();
+        UserExample example = new UserExample();
+        List<String> test = new ArrayList<>();
+        test.add("wmgizUDQAAzefmcVLEuJLR5YcHInGcsg");
+        test.add("wmgizUDQAAYdFWt1hts2fU6P2h84fPvQ");
+        example.createCriteria().andExternalUserId3rdPartyIn(test);
+        long count = userMapper.countByExample(example);
+        int page = 1;
+        int pageSize = 1000;
+        long totalPageSize = count / pageSize + 1;
+        for (; page <= totalPageSize; page++) {
+            example.setPage(new Page<>(page, pageSize));
+            List<User> userList = userMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(userList)) {
+                continue;
+            }
+            //落库逻辑
+            List<SendMessage> allSeneMessageList = new ArrayList<>();
+            for (User user : userList) {
+                List<SendMessage> sendMessageList = getSendMessage(user);
+                if (!CollectionUtils.isEmpty(sendMessageList)) {
+                    allSeneMessageList.addAll(sendMessageList);
+                }
+            }
+            if (!CollectionUtils.isEmpty(allSeneMessageList)) {
+                sendMessageMapper.insertList(allSeneMessageList);
+            }
+        }
+//        pushSendMessage();
+//        saveGuaranteedVideoIdList(guaranteedVideoIdList);
+    }
+
+    public void saveGuaranteedVideoIdList(List<Long> videoIdList) {
+        MessageAttachmentExample example = new MessageAttachmentExample();
+        example.createCriteria().andMiniprogramVideoIdIn(videoIdList);
+        List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+        for (MessageAttachment messageAttachment : messageAttachmentList) {
+            MessageAttachment updateMessageAttachment = new MessageAttachment();
+            updateMessageAttachment.setId(messageAttachment.getId());
+            updateMessageAttachment.setSendTime(new Date());
+            messageAttachmentMapper.updateByPrimaryKeySelective(updateMessageAttachment);
+        }
+        //移除从redis中获取的保底数据
+        for (int i = 0; i < getGuaranteedVideoIdNum; i++) {
+            redisTemplate.opsForList().leftPop(GUARANTEED_MINIPROGRAM_KEY);
+        }
+    }
+
+    public List<SendMessage> getSendMessage(User user) {
+        int n = 0;
+        List<SendMessage> sendMessageList = new ArrayList<>();
+        SendMessage sendMessage = new SendMessage();
+        for (PushMessage pushMessage : goodHistoryPushList) {
+            if (pushMessage.getUserIds().contains(user.getId())) {
+                if (n == 0) {
+                    sendMessage.setVideoId1(pushMessage.getVideoId());
+                }
+                if (n == 1) {
+                    sendMessage.setVideoId2(pushMessage.getVideoId());
+                }
+                if (n == 2) {
+                    sendMessage.setVideoId3(pushMessage.getVideoId());
+                }
+                n++;
+                if (n >= MAX_VIDEO_NUM) {
+                    break;
+                }
+            }
+        }
+        //保底数据
+        if (n < MAX_VIDEO_NUM) {
+            for (Long videoId : guaranteedVideoIdList) {
+                if (n == 0) {
+                    sendMessage.setVideoId1(videoId);
+                }
+                if (n == 1) {
+                    sendMessage.setVideoId2(videoId);
+                }
+                if (n == 2) {
+                    sendMessage.setVideoId3(videoId);
+                }
+                n++;
+                if (n >= MAX_VIDEO_NUM) {
+                    break;
+                }
+            }
+        }
+        if (n < MAX_VIDEO_NUM) {
+            throw new RuntimeException("保底数据异常");
+        }
+        StaffWithUserExample example = new StaffWithUserExample();
+        example.createCriteria().andUserIdEqualTo(user.getId());
+        List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(staffWithUserList)) {
+            return null;
+        }
+        for (StaffWithUser staffWithUser : staffWithUserList) {
+            SendMessage newSendMessage = new SendMessage();
+            BeanUtils.copyProperties(sendMessage, newSendMessage);
+            newSendMessage.setStaffId(staffWithUser.getStaffId());
+            newSendMessage.setUserId(staffWithUser.getUserId());
+            sendMessageList.add(newSendMessage);
+        }
+        return sendMessageList;
+    }
+
+
+    public void pushSendMessage() {
+        List<SendMessage> groupList = sendMessageMapper.getGroupList(DateUtil.getThatDayDate(), 0);
+        for (SendMessage sendMessage : groupList) {
+            sendMessage.setIsSend(0);
+            sendMessage.setCreateTime(DateUtil.getThatDayDate());
+            List<String> sendUserList = sendMessageMapper.selectExternalUserId3rdParty(sendMessage);
+            pushMessage(sendUserList, sendMessage);
+        }
+    }
+
+    public void pushMessage(List<String> sendUserList, SendMessage sendMessage) {
+        List<JSONObject> pushList = new ArrayList<>();
+        StaffExample staffExample = new StaffExample();
+        staffExample.createCriteria().andIdEqualTo(sendMessage.getStaffId());
+        List<Staff> staffList = staffMapper.selectByExample(staffExample);
+        Staff staff = staffList.get(0);
+        String text = messageService.getMessageText();
+        String name = MessageUtil.getName();
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("name", name);
+        jsonObject.put("text", text);
+        JSONArray attachments = new JSONArray();
+        List<Long> videoIdList = new ArrayList<>();
+        videoIdList.add(sendMessage.getVideoId1());
+        videoIdList.add(sendMessage.getVideoId2());
+        videoIdList.add(sendMessage.getVideoId3());
+        for (Long videoId : videoIdList) {
+            JSONObject attachment = new JSONObject();
+            attachment.put("msgtype", "miniprogram");
+            MessageAttachmentExample example = new MessageAttachmentExample();
+            example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
+            List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                throw new RuntimeException("附件信息查询异常");
+            }
+            MessageAttachment messageAttachment = messageAttachmentList.get(0);
+            JSONObject miniprogram = new JSONObject();
+            miniprogram.put("appid", messageAttachment.getAppid());
+            miniprogram.put("title", messageAttachment.getTitle());
+            miniprogram.put("cover", messageAttachment.getCover());
+            String page = "";
+            String key = staff.getStaffExtId() + "_" + videoId;
+            if (pageMap.containsKey(key)) {
+                page = pageMap.get(key);
+            } else {
+                page = messageAttachmentService.getPage(staff, videoId);
+                pageMap.put(key, page);
+            }
+            if (StringUtils.isEmpty(page)) {
+                throw new RuntimeException("获取page失败");
+            }
+            miniprogram.put("page", page);
+
+            attachment.put("miniprogram", miniprogram);
+            attachments.add(attachment);
+        }
+        jsonObject.put("attachments", attachments);
+        List<List<String>> lists = Lists.partition(sendUserList, 10000);
+        for (List<String> list : lists) {
+            List<JSONObject> staffEuList = new ArrayList<>();
+            JSONObject newJSONObject = new JSONObject();
+            newJSONObject.putAll(jsonObject);
+            JSONObject staff_eu = new JSONObject();
+            staff_eu.put("staff_ext_id", staff.getStaffExtId());
+            staff_eu.put("eu_ext_ids", list);
+            staffEuList.add(staff_eu);
+            newJSONObject.put("staff_eu_list", staffEuList);
+            pushList.add(newJSONObject);
+        }
+
+        if (CollectionUtils.isEmpty(pushList)) {
+            throw new RuntimeException("推送视频生成失败");
+        }
+        for (JSONObject pushJsonObject : pushList) {
+            messageService.pushMessage(pushJsonObject);
+        }
+
+        //TODO 发送成功更新发送状态
+    }
+}

+ 95 - 29
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java

@@ -2,14 +2,17 @@ package com.tzld.piaoquan.wecom.job;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.StaffWithUserMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
-import com.tzld.piaoquan.wecom.model.po.User;
-import com.tzld.piaoquan.wecom.model.po.UserExample;
+import com.tzld.piaoquan.wecom.model.po.*;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
 import com.tzld.piaoquan.wecom.utils.page.Page;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -33,34 +36,68 @@ public class WeComUserDataJob {
     @Autowired
     private AccessTokenService accessTokenService;
 
+    @Autowired
+    private StaffMapper staffMapper;
+
+    @Autowired
+    private StaffWithUserMapper staffWithUserMapper;
+
+    public void insertStaffWithUser() {
+        long endTime = 1727507085L;
+        long startTime = 1720540800L;
+        StaffExample example = new StaffExample();
+        example.createCriteria().andIdEqualTo(1L);
+        List<Staff> staffList = staffMapper.selectByExample(example);
+        for (Staff staff : staffList) {
+            insertAllUser(startTime, endTime, staff);
+        }
+    }
+
     //初始化用户使用此任务
-    public void insertAllUser() {
+    public void insertAllUser(long startTime, long endTime, Staff staff) {
         try {
-            Long endTime = System.currentTimeMillis() / 1000;
-            Long startTime = 1720540800L;
-            Integer total = getUserTotal(startTime, endTime);
+            Integer total = getUserTotal(startTime, endTime, staff.getStaffExtId());
             if (total == null || total == 0) {
                 return;
             }
             int page = total / size + 1;
             int sum = 0;
             for (int i = 0; i < page; i++) {
-                String res = getUser(size, i * size, 1720540800L, endTime);
+                String res = getUser(size, i * size, startTime, endTime, staff.getStaffExtId());
                 if (ObjectUtils.isEmpty(res)) {
                     continue;
                 }
                 JSONObject jsonObject = JSONObject.parseObject(res);
                 JSONArray jsonArray = jsonObject.getJSONArray("external_user_list");
-                List<User> userList = new ArrayList<>();
+                List<StaffWithUser> insertStaffWithUserList = new ArrayList<>();
                 for (int j = 0; j < jsonArray.size(); j++) {
-                    String id = (String) jsonArray.getJSONObject(j).get("id");
-                    jsonArray.getJSONObject(j).put("id", null);
-                    User user = jsonArray.getJSONObject(j).toJavaObject(User.class);
-                    user.setExternalUserId3rdParty(id);
-                    userList.add(user);
+                    String externalUserId3rdParty = (String) jsonArray.getJSONObject(j).get("id");
+                    Long userId = userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty);
+                    if (userId == null) {
+                        jsonArray.getJSONObject(j).put("id", null);
+                        User user = jsonArray.getJSONObject(j).toJavaObject(User.class);
+                        user.setExternalUserId3rdParty(externalUserId3rdParty);
+                        userMapper.insert(user);
+                        userId = user.getId();
+                    }
+                    if (userId == null) {
+                        System.out.println("插入数据异常:" + jsonArray.getJSONObject(j));
+                        continue;
+                    }
+                    StaffWithUserExample staffWithUserExample = new StaffWithUserExample();
+                    staffWithUserExample.createCriteria().andStaffIdEqualTo(staff.getId()).andUserIdEqualTo(userId);
+                    List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(staffWithUserExample);
+                    if (CollectionUtils.isEmpty(staffWithUserList)) {
+                        StaffWithUser staffWithUser = new StaffWithUser();
+                        staffWithUser.setUserId(userId);
+                        staffWithUser.setStaffId(staff.getId());
+                        insertStaffWithUserList.add(staffWithUser);
+                    }
                     sum++;
                 }
-                userMapper.insertList(userList);
+                if(!CollectionUtils.isEmpty(insertStaffWithUserList)){
+                    staffWithUserMapper.insertList(insertStaffWithUserList);
+                }
                 if (jsonArray.size() < size) {
                     if (total > sum) {
                         System.out.println("插入数量不足");
@@ -73,37 +110,48 @@ public class WeComUserDataJob {
         }
     }
 
-    private Integer getUserTotal(Long startTime, Long endTime) throws IOException {
-        String res = getUser(1, 0, startTime, endTime);
+    private Integer getUserTotal(Long startTime, Long endTime, String staffId) throws IOException {
+        String res = getUser(1, 0, startTime, endTime, staffId);
         JSONObject jsonObject = JSONObject.parseObject(res);
         return jsonObject.getInteger("total");
     }
 
-    private String getUser(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
+    private String getUser(Integer limit, Integer offset, Long startTime, Long endTime, String staffExtId) throws IOException {
         String accessToken = accessTokenService.getAccessToken();
         String url = GET_USER_URL
                 + "?access_token=" + accessToken
                 + "&limit=" + limit + "&offset=" + offset + "&start_time=" + startTime + "&end_time=" + endTime;
+        if (StringUtils.isNotEmpty(staffExtId)) {
+            url = url + "&staff_id=" + staffExtId;
+        }
         return httpPoolClientDefault.get(url);
     }
 
+    public void updateStaffWithUser() {
+        UserExample userExample = new UserExample();
+        userExample.setOrderByClause("create_time desc");
+        userExample.setPage(new Page<>(1, 1));
+        List<User> userList = userMapper.selectByExample(userExample);
+        long startTime = userList.get(0).getCreateTime().getTime() / 1000;
+        long endTime = System.currentTimeMillis() / 1000;
+        StaffExample example = new StaffExample();
+        List<Staff> staffList = staffMapper.selectByExample(example);
+        for (Staff staff : staffList) {
+            updateUser(startTime, endTime, staff);
+        }
+    }
+
 
-    public void updateUser() {
+    public void updateUser(long startTime, long endTime, Staff staff) {
         try {
-            UserExample userExample = new UserExample();
-            userExample.setOrderByClause("create_time desc");
-            userExample.setPage(new Page<>(1, 1));
-            List<User> userList = userMapper.selectByExample(userExample);
-            long startTime = userList.get(0).getCreateTime().getTime() / 1000;
-            Long endTime = System.currentTimeMillis() / 1000;
-            Integer total = getUpdateUserTotal(startTime, endTime);
+            Integer total = getUpdateUserTotal(startTime, endTime, staff.getStaffExtId());
             if (total == null || total == 0) {
                 return;
             }
             int page = total / size + 1;
             int sum = 0;
             for (int i = 0; i < page; i++) {
-                String res = getUpdateUser(size, i * size, startTime, endTime);
+                String res = getUpdateUser(size, i * size, startTime, endTime, staff.getStaffExtId());
                 if (ObjectUtils.isEmpty(res)) {
                     continue;
                 }
@@ -117,13 +165,28 @@ public class WeComUserDataJob {
                     UserExample example = new UserExample();
                     example.createCriteria().andExternalUserId3rdPartyEqualTo(user.getExternalUserId3rdParty());
                     List<User> list = userMapper.selectByExample(example);
+                    Long userId;
                     if (CollectionUtils.isEmpty(list)) {
                         //没有用户,走插入逻辑
                         userMapper.insert(user);
+                        userId = user.getId();
                     } else {
                         User oldUser = list.get(0);
                         user.setId(oldUser.getId());
                         userMapper.updateByPrimaryKeySelective(user);
+                        userId = oldUser.getId();
+                    }
+                    if (userId == null) {
+                        continue;
+                    }
+                    StaffWithUserExample staffWithUserExample = new StaffWithUserExample();
+                    staffWithUserExample.createCriteria().andStaffIdEqualTo(staff.getId()).andUserIdEqualTo(userId);
+                    List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(staffWithUserExample);
+                    if (CollectionUtils.isEmpty(staffWithUserList)) {
+                        StaffWithUser staffWithUser = new StaffWithUser();
+                        staffWithUser.setStaffId(staff.getId());
+                        staffWithUser.setUserId(userId);
+                        staffWithUserMapper.insert(staffWithUser);
                     }
                     sum++;
                 }
@@ -142,18 +205,21 @@ public class WeComUserDataJob {
         }
     }
 
-    private Integer getUpdateUserTotal(Long startTime, Long endTime) throws IOException {
-        String res = getUpdateUser(1, 0, startTime, endTime);
+    private Integer getUpdateUserTotal(Long startTime, Long endTime, String staffExtId) throws IOException {
+        String res = getUpdateUser(1, 0, startTime, endTime, staffExtId);
         JSONObject jsonObject = JSONObject.parseObject(res);
         return jsonObject.getInteger("total");
     }
 
-    private String getUpdateUser(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
+    private String getUpdateUser(Integer limit, Integer offset, Long startTime, Long endTime, String staffExtId) throws IOException {
         String accessToken = accessTokenService.getAccessToken();
         String url = UPDATE_USER_URL
                 + "?access_token=" + accessToken
                 + "&limit=" + limit + "&offset=" + offset + "&start_update_time=" + startTime + "&end_update_time=" + endTime
                 + "&source=external_user";
+        if (StringUtils.isNotEmpty(staffExtId)) {
+            url = url + "&staff_id=" + staffExtId;
+        }
         return httpPoolClientDefault.get(url);
     }
 

+ 37 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/AdPutFlowParam.java

@@ -0,0 +1,37 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class AdPutFlowParam {
+
+    private Long id;
+
+    private Long videoId;
+
+    private String putScene;
+
+    private String channel;
+
+    private String remark;
+
+    private String path;
+
+    private Map<String,String> requestParam;
+
+    private String rootSourceId;
+
+    private String putTypeOne;
+
+    private String putTypeTwo;
+
+    private String putTypeThree;
+
+    private String testId;
+
+    private String putCarrierId;
+
+    private String putStartDate;
+}

+ 11 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/VideoDetail.java

@@ -0,0 +1,11 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+
+@Data
+public class VideoDetail {
+
+    private String cover;
+
+    private String title;
+}

+ 11 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachment.java

@@ -23,6 +23,8 @@ public class MessageAttachment {
 
     private Integer isDelete;
 
+    private Date sendTime;
+
     private Date createTime;
 
     private Date updateTime;
@@ -107,6 +109,14 @@ public class MessageAttachment {
         this.isDelete = isDelete;
     }
 
+    public Date getSendTime() {
+        return sendTime;
+    }
+
+    public void setSendTime(Date sendTime) {
+        this.sendTime = sendTime;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }
@@ -139,6 +149,7 @@ public class MessageAttachment {
         sb.append(", cover=").append(cover);
         sb.append(", miniprogramVideoId=").append(miniprogramVideoId);
         sb.append(", isDelete=").append(isDelete);
+        sb.append(", sendTime=").append(sendTime);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);
         sb.append("]");

+ 60 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachmentExample.java

@@ -776,6 +776,66 @@ public class MessageAttachmentExample {
             return (Criteria) this;
         }
 
+        public Criteria andSendTimeIsNull() {
+            addCriterion("send_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeIsNotNull() {
+            addCriterion("send_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeEqualTo(Date value) {
+            addCriterion("send_time =", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeNotEqualTo(Date value) {
+            addCriterion("send_time <>", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeGreaterThan(Date value) {
+            addCriterion("send_time >", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("send_time >=", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeLessThan(Date value) {
+            addCriterion("send_time <", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeLessThanOrEqualTo(Date value) {
+            addCriterion("send_time <=", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeIn(List<Date> values) {
+            addCriterion("send_time in", values, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeNotIn(List<Date> values) {
+            addCriterion("send_time not in", values, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeBetween(Date value1, Date value2) {
+            addCriterion("send_time between", value1, value2, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeNotBetween(Date value1, Date value2) {
+            addCriterion("send_time not between", value1, value2, "sendTime");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateTimeIsNull() {
             addCriterion("create_time is null");
             return (Criteria) this;

+ 114 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SendMessage.java

@@ -0,0 +1,114 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import java.util.Date;
+
+public class SendMessage {
+    private Long id;
+
+    private Long staffId;
+
+    private Long userId;
+
+    private Long videoId1;
+
+    private Long videoId2;
+
+    private Long videoId3;
+
+    private Integer isSend;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(Long staffId) {
+        this.staffId = staffId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getVideoId1() {
+        return videoId1;
+    }
+
+    public void setVideoId1(Long videoId1) {
+        this.videoId1 = videoId1;
+    }
+
+    public Long getVideoId2() {
+        return videoId2;
+    }
+
+    public void setVideoId2(Long videoId2) {
+        this.videoId2 = videoId2;
+    }
+
+    public Long getVideoId3() {
+        return videoId3;
+    }
+
+    public void setVideoId3(Long videoId3) {
+        this.videoId3 = videoId3;
+    }
+
+    public Integer getIsSend() {
+        return isSend;
+    }
+
+    public void setIsSend(Integer isSend) {
+        this.isSend = isSend;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @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(", staffId=").append(staffId);
+        sb.append(", userId=").append(userId);
+        sb.append(", videoId1=").append(videoId1);
+        sb.append(", videoId2=").append(videoId2);
+        sb.append(", videoId3=").append(videoId3);
+        sb.append(", isSend=").append(isSend);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 753 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SendMessageExample.java

@@ -0,0 +1,753 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import com.tzld.piaoquan.wecom.utils.page.Page;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class SendMessageExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public SendMessageExample() {
+        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 andStaffIdIsNull() {
+            addCriterion("staff_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIsNotNull() {
+            addCriterion("staff_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdEqualTo(Long value) {
+            addCriterion("staff_id =", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotEqualTo(Long value) {
+            addCriterion("staff_id <>", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThan(Long value) {
+            addCriterion("staff_id >", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("staff_id >=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThan(Long value) {
+            addCriterion("staff_id <", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThanOrEqualTo(Long value) {
+            addCriterion("staff_id <=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIn(List<Long> values) {
+            addCriterion("staff_id in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotIn(List<Long> values) {
+            addCriterion("staff_id not in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdBetween(Long value1, Long value2) {
+            addCriterion("staff_id between", value1, value2, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotBetween(Long value1, Long value2) {
+            addCriterion("staff_id not between", value1, value2, "staffId");
+            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(Long value) {
+            addCriterion("user_id =", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotEqualTo(Long value) {
+            addCriterion("user_id <>", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThan(Long value) {
+            addCriterion("user_id >", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("user_id >=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThan(Long value) {
+            addCriterion("user_id <", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThanOrEqualTo(Long value) {
+            addCriterion("user_id <=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIn(List<Long> values) {
+            addCriterion("user_id in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotIn(List<Long> values) {
+            addCriterion("user_id not in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdBetween(Long value1, Long value2) {
+            addCriterion("user_id between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotBetween(Long value1, Long value2) {
+            addCriterion("user_id not between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1IsNull() {
+            addCriterion("video_id_1 is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1IsNotNull() {
+            addCriterion("video_id_1 is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1EqualTo(Long value) {
+            addCriterion("video_id_1 =", value, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1NotEqualTo(Long value) {
+            addCriterion("video_id_1 <>", value, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1GreaterThan(Long value) {
+            addCriterion("video_id_1 >", value, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1GreaterThanOrEqualTo(Long value) {
+            addCriterion("video_id_1 >=", value, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1LessThan(Long value) {
+            addCriterion("video_id_1 <", value, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1LessThanOrEqualTo(Long value) {
+            addCriterion("video_id_1 <=", value, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1In(List<Long> values) {
+            addCriterion("video_id_1 in", values, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1NotIn(List<Long> values) {
+            addCriterion("video_id_1 not in", values, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1Between(Long value1, Long value2) {
+            addCriterion("video_id_1 between", value1, value2, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId1NotBetween(Long value1, Long value2) {
+            addCriterion("video_id_1 not between", value1, value2, "videoId1");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2IsNull() {
+            addCriterion("video_id_2 is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2IsNotNull() {
+            addCriterion("video_id_2 is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2EqualTo(Long value) {
+            addCriterion("video_id_2 =", value, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2NotEqualTo(Long value) {
+            addCriterion("video_id_2 <>", value, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2GreaterThan(Long value) {
+            addCriterion("video_id_2 >", value, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2GreaterThanOrEqualTo(Long value) {
+            addCriterion("video_id_2 >=", value, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2LessThan(Long value) {
+            addCriterion("video_id_2 <", value, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2LessThanOrEqualTo(Long value) {
+            addCriterion("video_id_2 <=", value, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2In(List<Long> values) {
+            addCriterion("video_id_2 in", values, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2NotIn(List<Long> values) {
+            addCriterion("video_id_2 not in", values, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2Between(Long value1, Long value2) {
+            addCriterion("video_id_2 between", value1, value2, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId2NotBetween(Long value1, Long value2) {
+            addCriterion("video_id_2 not between", value1, value2, "videoId2");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3IsNull() {
+            addCriterion("video_id_3 is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3IsNotNull() {
+            addCriterion("video_id_3 is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3EqualTo(Long value) {
+            addCriterion("video_id_3 =", value, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3NotEqualTo(Long value) {
+            addCriterion("video_id_3 <>", value, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3GreaterThan(Long value) {
+            addCriterion("video_id_3 >", value, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3GreaterThanOrEqualTo(Long value) {
+            addCriterion("video_id_3 >=", value, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3LessThan(Long value) {
+            addCriterion("video_id_3 <", value, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3LessThanOrEqualTo(Long value) {
+            addCriterion("video_id_3 <=", value, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3In(List<Long> values) {
+            addCriterion("video_id_3 in", values, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3NotIn(List<Long> values) {
+            addCriterion("video_id_3 not in", values, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3Between(Long value1, Long value2) {
+            addCriterion("video_id_3 between", value1, value2, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoId3NotBetween(Long value1, Long value2) {
+            addCriterion("video_id_3 not between", value1, value2, "videoId3");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendIsNull() {
+            addCriterion("is_send is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendIsNotNull() {
+            addCriterion("is_send is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendEqualTo(Integer value) {
+            addCriterion("is_send =", value, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendNotEqualTo(Integer value) {
+            addCriterion("is_send <>", value, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendGreaterThan(Integer value) {
+            addCriterion("is_send >", value, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_send >=", value, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendLessThan(Integer value) {
+            addCriterion("is_send <", value, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendLessThanOrEqualTo(Integer value) {
+            addCriterion("is_send <=", value, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendIn(List<Integer> values) {
+            addCriterion("is_send in", values, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendNotIn(List<Integer> values) {
+            addCriterion("is_send not in", values, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendBetween(Integer value1, Integer value2) {
+            addCriterion("is_send between", value1, value2, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsSendNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_send not between", value1, value2, "isSend");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            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);
+        }
+    }
+}

+ 92 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/Staff.java

@@ -0,0 +1,92 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import java.util.Date;
+
+public class Staff {
+    private Long id;
+
+    private String staffExtId;
+
+    private String carrierId;
+
+    private String remark;
+
+    private Integer isDelete;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getStaffExtId() {
+        return staffExtId;
+    }
+
+    public void setStaffExtId(String staffExtId) {
+        this.staffExtId = staffExtId;
+    }
+
+    public String getCarrierId() {
+        return carrierId;
+    }
+
+    public void setCarrierId(String carrierId) {
+        this.carrierId = carrierId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @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(", staffExtId=").append(staffExtId);
+        sb.append(", carrierId=").append(carrierId);
+        sb.append(", remark=").append(remark);
+        sb.append(", isDelete=").append(isDelete);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 662 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffExample.java

@@ -0,0 +1,662 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class StaffExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public StaffExample() {
+        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 andStaffExtIdIsNull() {
+            addCriterion("staff_ext_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdIsNotNull() {
+            addCriterion("staff_ext_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdEqualTo(String value) {
+            addCriterion("staff_ext_id =", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdNotEqualTo(String value) {
+            addCriterion("staff_ext_id <>", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdGreaterThan(String value) {
+            addCriterion("staff_ext_id >", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdGreaterThanOrEqualTo(String value) {
+            addCriterion("staff_ext_id >=", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdLessThan(String value) {
+            addCriterion("staff_ext_id <", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdLessThanOrEqualTo(String value) {
+            addCriterion("staff_ext_id <=", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdLike(String value) {
+            addCriterion("staff_ext_id like", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdNotLike(String value) {
+            addCriterion("staff_ext_id not like", value, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdIn(List<String> values) {
+            addCriterion("staff_ext_id in", values, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdNotIn(List<String> values) {
+            addCriterion("staff_ext_id not in", values, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdBetween(String value1, String value2) {
+            addCriterion("staff_ext_id between", value1, value2, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffExtIdNotBetween(String value1, String value2) {
+            addCriterion("staff_ext_id not between", value1, value2, "staffExtId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdIsNull() {
+            addCriterion("carrier_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdIsNotNull() {
+            addCriterion("carrier_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdEqualTo(String value) {
+            addCriterion("carrier_id =", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdNotEqualTo(String value) {
+            addCriterion("carrier_id <>", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdGreaterThan(String value) {
+            addCriterion("carrier_id >", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdGreaterThanOrEqualTo(String value) {
+            addCriterion("carrier_id >=", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdLessThan(String value) {
+            addCriterion("carrier_id <", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdLessThanOrEqualTo(String value) {
+            addCriterion("carrier_id <=", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdLike(String value) {
+            addCriterion("carrier_id like", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdNotLike(String value) {
+            addCriterion("carrier_id not like", value, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdIn(List<String> values) {
+            addCriterion("carrier_id in", values, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdNotIn(List<String> values) {
+            addCriterion("carrier_id not in", values, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdBetween(String value1, String value2) {
+            addCriterion("carrier_id between", value1, value2, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCarrierIdNotBetween(String value1, String value2) {
+            addCriterion("carrier_id not between", value1, value2, "carrierId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkIsNull() {
+            addCriterion("remark is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkIsNotNull() {
+            addCriterion("remark is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkEqualTo(String value) {
+            addCriterion("remark =", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkNotEqualTo(String value) {
+            addCriterion("remark <>", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkGreaterThan(String value) {
+            addCriterion("remark >", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkGreaterThanOrEqualTo(String value) {
+            addCriterion("remark >=", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkLessThan(String value) {
+            addCriterion("remark <", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkLessThanOrEqualTo(String value) {
+            addCriterion("remark <=", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkLike(String value) {
+            addCriterion("remark like", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkNotLike(String value) {
+            addCriterion("remark not like", value, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkIn(List<String> values) {
+            addCriterion("remark in", values, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkNotIn(List<String> values) {
+            addCriterion("remark not in", values, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkBetween(String value1, String value2) {
+            addCriterion("remark between", value1, value2, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andRemarkNotBetween(String value1, String value2) {
+            addCriterion("remark not between", value1, value2, "remark");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNull() {
+            addCriterion("is_delete is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNotNull() {
+            addCriterion("is_delete is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteEqualTo(Integer value) {
+            addCriterion("is_delete =", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotEqualTo(Integer value) {
+            addCriterion("is_delete <>", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThan(Integer value) {
+            addCriterion("is_delete >", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_delete >=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThan(Integer value) {
+            addCriterion("is_delete <", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThanOrEqualTo(Integer value) {
+            addCriterion("is_delete <=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIn(List<Integer> values) {
+            addCriterion("is_delete in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotIn(List<Integer> values) {
+            addCriterion("is_delete not in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete not between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            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);
+        }
+    }
+}

+ 70 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffWithUser.java

@@ -0,0 +1,70 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import java.util.Date;
+
+public class StaffWithUser {
+    private Long id;
+
+    private Long staffId;
+
+    private Long userId;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(Long staffId) {
+        this.staffId = staffId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @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(", staffId=").append(staffId);
+        sb.append(", userId=").append(userId);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 512 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffWithUserExample.java

@@ -0,0 +1,512 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class StaffWithUserExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public StaffWithUserExample() {
+        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 andStaffIdIsNull() {
+            addCriterion("staff_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIsNotNull() {
+            addCriterion("staff_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdEqualTo(Long value) {
+            addCriterion("staff_id =", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotEqualTo(Long value) {
+            addCriterion("staff_id <>", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThan(Long value) {
+            addCriterion("staff_id >", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("staff_id >=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThan(Long value) {
+            addCriterion("staff_id <", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThanOrEqualTo(Long value) {
+            addCriterion("staff_id <=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIn(List<Long> values) {
+            addCriterion("staff_id in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotIn(List<Long> values) {
+            addCriterion("staff_id not in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdBetween(Long value1, Long value2) {
+            addCriterion("staff_id between", value1, value2, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotBetween(Long value1, Long value2) {
+            addCriterion("staff_id not between", value1, value2, "staffId");
+            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(Long value) {
+            addCriterion("user_id =", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotEqualTo(Long value) {
+            addCriterion("user_id <>", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThan(Long value) {
+            addCriterion("user_id >", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("user_id >=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThan(Long value) {
+            addCriterion("user_id <", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThanOrEqualTo(Long value) {
+            addCriterion("user_id <=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIn(List<Long> values) {
+            addCriterion("user_id in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotIn(List<Long> values) {
+            addCriterion("user_id not in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdBetween(Long value1, Long value2) {
+            addCriterion("user_id between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotBetween(Long value1, Long value2) {
+            addCriterion("user_id not between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            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);
+        }
+    }
+}

+ 1 - 7
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MiniprogramVo.java

@@ -7,12 +7,6 @@ import java.util.Date;
 @Data
 public class MiniprogramVo {
 
-    private String title;
-
-    private String appid;
-
-    private String page;
-
-    private String cover;
+    private Long videoId;
 
 }

+ 113 - 23
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java

@@ -1,13 +1,20 @@
 package com.tzld.piaoquan.wecom.service.Impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.wecom.common.exception.CustomizeException;
 import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
+import com.tzld.piaoquan.wecom.model.bo.AdPutFlowParam;
+import com.tzld.piaoquan.wecom.model.bo.VideoDetail;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
+import com.tzld.piaoquan.wecom.model.po.Staff;
 import com.tzld.piaoquan.wecom.model.vo.MiniprogramVo;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
-import com.tzld.piaoquan.wecom.utils.MessageUtil;
+import com.tzld.piaoquan.wecom.utils.DateUtil;
+import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
+import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,11 +22,13 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.io.IOException;
+import java.util.*;
 
 import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.appid;
+import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.carrierIdMap;
+import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_ADD_TENCENT;
+import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_VIDEO_DETAIL_URL;
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
 import static com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum.PARAMS_ERROR;
 
@@ -27,6 +36,7 @@ import static com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum.PARAMS_ERRO
 @Service
 public class MessageAttachmentServiceImpl implements MessageAttachmentService {
 
+    private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
     @Autowired
     private MessageAttachmentMapper messageAttachmentMapper;
@@ -57,34 +67,114 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         List<MessageAttachment> messageAttachmentList = new ArrayList<>();
         List<Long> videoList = new ArrayList<>();
         for (MiniprogramVo miniprogramVo : miniprogramVoList) {
-            if (StringUtils.isEmpty(miniprogramVo.getPage())) {
+            if (miniprogramVo.getVideoId() == null) {
                 throw new CustomizeException(PARAMS_ERROR);
             }
-            if (StringUtils.isEmpty(miniprogramVo.getCover())) {
-                throw new CustomizeException(PARAMS_ERROR);
-            }
-            if (StringUtils.isEmpty(miniprogramVo.getTitle())) {
-                throw new CustomizeException(PARAMS_ERROR);
-            }
-            Long videoId = MessageUtil.getVideoId(miniprogramVo.getPage());
-            if (videoId == null) {
-                throw new CustomizeException(PARAMS_ERROR);
-            }
-            if (StringUtils.isEmpty(miniprogramVo.getAppid())) {
-                miniprogramVo.setAppid(appid);
-            }
             MessageAttachment messageAttachment = new MessageAttachment();
             BeanUtils.copyProperties(miniprogramVo, messageAttachment);
-            messageAttachment.setMiniprogramVideoId(videoId);
+            messageAttachment.setMiniprogramVideoId(miniprogramVo.getVideoId());
             messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
             messageAttachmentList.add(messageAttachment);
-            videoList.add(videoId);
+            videoList.add(miniprogramVo.getVideoId());
+        }
+        Map<Long, VideoDetail> coverMap = getVideoDetail(videoList);
+        for (MessageAttachment messageAttachment : messageAttachmentList) {
+            VideoDetail videoDetail = coverMap.get(messageAttachment.getMiniprogramVideoId());
+            if (videoDetail == null || StringUtils.isEmpty(videoDetail.getCover()) || StringUtils.isEmpty(videoDetail.getTitle())) {
+                throw new RuntimeException("获取视频详情异常");
+            }
+            messageAttachment.setCover(videoDetail.getCover());
+            messageAttachment.setTitle(videoDetail.getTitle());
+            messageAttachment.setAppid(appid);
         }
         addMiniprogram(messageAttachmentList);
-        redisTemplate.delete(GUARANTEED_MINIPROGRAM_KEY);
-        Collections.reverse(videoList);
         for (Long video : videoList) {
-            redisTemplate.opsForList().leftPush(GUARANTEED_MINIPROGRAM_KEY, video);
+            redisTemplate.opsForList().rightPush(GUARANTEED_MINIPROGRAM_KEY, video);
+        }
+    }
+
+    public Map<Long, VideoDetail> getVideoDetail(List<Long> videoIdList) {
+        try {
+            Map<Long, VideoDetail> map = new HashMap<>();
+            JSONObject params = new JSONObject();
+            params.put("videoIdList", videoIdList);
+            String post = httpPoolClientDefault.post(POST_VIDEO_DETAIL_URL, params.toJSONString());
+            JSONObject res = JSONObject.parseObject(post);
+            JSONArray data = res.getJSONArray("data");
+            for (int i = 0; i < data.size(); i++) {
+                VideoDetail videoDetail = new VideoDetail();
+                JSONObject jsonObject = data.getJSONObject(i);
+                Long videoId = jsonObject.getLong("id");
+                String shareImgPath = jsonObject.getString("shareImgPath");
+                String title = jsonObject.getString("title");
+                videoDetail.setCover(shareImgPath);
+                videoDetail.setTitle(title);
+                map.put(videoId, videoDetail);
+            }
+            return map;
+        } catch (IOException e) {
+            throw new RuntimeException("获取详情异常");
+        }
+    }
+
+    @Override
+    public String getPage(Staff staff, Long videoId) {
+        try {
+            if (staff == null || staff.getCarrierId() == null) {
+                return "";
+            }
+            String page = selectPage(staff.getCarrierId(), videoId);
+            if (StringUtils.isNotEmpty(page)) {
+                return page;
+            }
+            return insertPage(staff.getCarrierId(), videoId, staff.getRemark());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private String insertPage(String carrierId, Long videoId, String remark) throws IOException {
+        AdPutFlowParam param = new AdPutFlowParam();
+        param.setChannel("tencentqw");
+        param.setPath("pages/category");
+        param.setPutCarrierId(carrierId);
+        param.setPutScene("touliu");
+        param.setPutStartDate(DateUtil.getDayDateString("yyyy-MM-dd"));
+        param.setPutTypeOne("企微");
+        param.setPutTypeTwo("日常推送");
+        param.setPutTypeThree("位置X");
+        param.setRemark(remark);
+        param.setVideoId(videoId);
+        Map<String, String> requestParam = new HashMap<>();
+        String jumpPage = "pages/user-videos?id=${videoId}&fromGzh=1&rootShareId=${uuid}&shareId=${uuid}&rootSourceId=[rootSourceId]"
+                .replace("${videoId}", "" + videoId)
+                .replace("${uuid}", "" + UUID.randomUUID());
+        requestParam.put("jumpPage", jumpPage);
+        param.setRequestParam(requestParam);
+        String res = httpPoolClientDefault.post(POST_ADD_TENCENT, JSONObject.toJSONString(param));
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        JSONObject data = jsonObject.getJSONObject("data");
+        return data.getString("url");
+    }
+
+    public String selectPage(String carrierId, Long videoId) throws IOException {
+        Map<String, String> map = new HashMap<>();
+        String url = "https://api.piaoquantv.com/ad/put/flow/list/tencent?videoId=${videoId}&putScene=touliu&channel=tencentqw&currentPage=1&pageSize=20"
+                .replace("${videoId}", "" + videoId);
+        String res = httpPoolClientDefault.get(url);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        JSONObject data = jsonObject.getJSONObject("data");
+        JSONArray objs = data.getJSONArray("objs");
+        for (int i = 0; i < objs.size(); i++) {
+            JSONObject obj = objs.getJSONObject(i);
+            String putCarrierId = obj.getString("putCarrierId");
+            String page = obj.getString("url");
+            if (StringUtils.isEmpty(putCarrierId) || StringUtils.isEmpty(page)) {
+                continue;
+            }
+            map.put(putCarrierId, page);
         }
+        return map.get(carrierId);
     }
 }

+ 5 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java

@@ -32,16 +32,20 @@ public class MessageServiceImpl implements MessageService {
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
 
-    public void pushMessage(JSONObject jsonObject) {
+    public boolean pushMessage(JSONObject jsonObject) {
         try {
             String accessToken = accessTokenService.getAccessToken();
             String url = POST_MESSAGE_PUSH_URL
                     + "?access_token=" + accessToken;
             String s = httpPoolClientDefault.post(url, jsonObject.toJSONString());
             System.out.println(s);
+            JSONObject res = JSONObject.parseObject(s);
+            Integer code = res.getInteger("errcode");
+            return code == 0;
         } catch (IOException e) {
             e.printStackTrace();
         }
+        return false;
     }
 
     @Override

+ 4 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java

@@ -1,9 +1,11 @@
 package com.tzld.piaoquan.wecom.service;
 
 import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
+import com.tzld.piaoquan.wecom.model.po.Staff;
 import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
 import com.tzld.piaoquan.wecom.model.vo.MiniprogramVo;
 
+import java.io.IOException;
 import java.util.List;
 
 public interface MessageAttachmentService {
@@ -11,4 +13,6 @@ public interface MessageAttachmentService {
     void addMiniprogram(List<MessageAttachment> messageAttachmentList);
 
     void createGuaranteedMiniprogram(List<MiniprogramVo> miniprogramVoList);
+
+    String getPage(Staff staff, Long videoId);
 }

+ 1 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java

@@ -5,7 +5,7 @@ import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
 
 public interface MessageService {
 
-    void pushMessage(JSONObject jsonObject);
+    boolean pushMessage(JSONObject jsonObject);
 
     void createMessageText(MessageTextVo messageTextVo);
 

+ 4 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java

@@ -31,5 +31,9 @@ public class DateUtil {
         return dateFormat.format(today);
     }
 
+    public static Long dateDifference(Date date1, Date date2) {
+        return Math.abs(date1.getTime() - date2.getTime());
+    }
+
 
 }

+ 0 - 5
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpPoolClient.java

@@ -1,10 +1,8 @@
 package com.tzld.piaoquan.wecom.utils;
 
-import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
-import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpStatus;
@@ -22,7 +20,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.params.HttpParams;
 import org.apache.http.ssl.SSLContexts;
 import org.apache.http.util.EntityUtils;
 import org.slf4j.Logger;
@@ -32,13 +29,11 @@ import org.slf4j.MDC;
 import javax.net.ssl.SSLContext;
 import java.io.IOException;
 import java.net.SocketTimeoutException;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.security.KeyManagementException;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;

+ 20 - 5
we-com-server/src/main/resources/mapper/MessageAttachmentMapper.xml

@@ -12,6 +12,7 @@
     <result column="cover" jdbcType="VARCHAR" property="cover" />
     <result column="miniprogram_video_id" jdbcType="BIGINT" property="miniprogramVideoId" />
     <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
@@ -75,7 +76,7 @@
   </sql>
   <sql id="Base_Column_List">
     id, `type`, url, title, `desc`, appid, page, cover, miniprogram_video_id, is_delete, 
-    create_time, update_time
+    send_time, create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample" resultMap="BaseResultMap">
     select
@@ -114,13 +115,13 @@
     insert into we_com_message_attachment (id, `type`, url, 
       title, `desc`, appid, 
       page, cover, miniprogram_video_id, 
-      create_time, update_time
-      )
+      send_time, create_time,
+      update_time)
     values (#{id,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{url,jdbcType=VARCHAR}, 
       #{title,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR}, 
       #{page,jdbcType=VARCHAR}, #{cover,jdbcType=VARCHAR}, #{miniprogramVideoId,jdbcType=BIGINT}, 
-      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
-      )
+      #{sendTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
+      #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachment">
     insert into we_com_message_attachment
@@ -155,6 +156,9 @@
       <if test="isDelete != null">
         is_delete,
       </if>
+      <if test="sendTime != null">
+        send_time,
+      </if>
       <if test="createTime != null">
         create_time,
       </if>
@@ -193,6 +197,9 @@
       <if test="isDelete != null">
         #{isDelete,jdbcType=INTEGER},
       </if>
+      <if test="sendTime != null">
+        #{sendTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -240,6 +247,9 @@
       <if test="record.isDelete != null">
         is_delete = #{record.isDelete,jdbcType=INTEGER},
       </if>
+      <if test="record.sendTime != null">
+        send_time = #{record.sendTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
       </if>
@@ -263,6 +273,7 @@
       cover = #{record.cover,jdbcType=VARCHAR},
       miniprogram_video_id = #{record.miniprogramVideoId,jdbcType=BIGINT},
       is_delete = #{record.isDelete,jdbcType=INTEGER},
+      send_time = #{record.sendTime,jdbcType=TIMESTAMP},
       create_time = #{record.createTime,jdbcType=TIMESTAMP},
       update_time = #{record.updateTime,jdbcType=TIMESTAMP}
     <if test="_parameter != null">
@@ -299,6 +310,9 @@
       <if test="isDelete != null">
         is_delete = #{isDelete,jdbcType=INTEGER},
       </if>
+      <if test="sendTime != null">
+        send_time = #{sendTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -319,6 +333,7 @@
       cover = #{cover,jdbcType=VARCHAR},
       miniprogram_video_id = #{miniprogramVideoId,jdbcType=BIGINT},
       is_delete = #{isDelete,jdbcType=INTEGER},
+      send_time = #{sendTime,jdbcType=TIMESTAMP},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}

+ 322 - 0
we-com-server/src/main/resources/mapper/SendMessageMapper.xml

@@ -0,0 +1,322 @@
+<?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.wecom.dao.mapper.SendMessageMapper">
+    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.SendMessage">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="staff_id" jdbcType="BIGINT" property="staffId"/>
+        <result column="user_id" jdbcType="BIGINT" property="userId"/>
+        <result column="video_id_1" jdbcType="BIGINT" property="videoId1"/>
+        <result column="video_id_2" jdbcType="BIGINT" property="videoId2"/>
+        <result column="video_id_3" jdbcType="BIGINT" property="videoId3"/>
+        <result column="is_send" jdbcType="INTEGER" property="isSend"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+    </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
+        , staff_id, user_id, video_id_1, video_id_2, video_id_3, is_send, create_time, 
+    update_time
+    </sql>
+    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample"
+            resultMap="BaseResultMap">
+        select
+        <if test="distinct">
+            distinct
+        </if>
+        <include refid="Base_Column_List"/>
+        from we_com_send_message
+        <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 we_com_send_message
+        where id = #{id,jdbcType=BIGINT}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete
+        from we_com_send_message
+        where id = #{id,jdbcType=BIGINT}
+    </delete>
+    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample">
+        delete from we_com_send_message
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </delete>
+    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+        insert into we_com_send_message (id, staff_id, user_id,
+                                         video_id_1, video_id_2, video_id_3,
+                                         create_time, update_time)
+        values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
+                #{videoId1,jdbcType=BIGINT}, #{videoId2,jdbcType=BIGINT}, #{videoId3,jdbcType=BIGINT},
+                #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+    </insert>
+    <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+        insert into we_com_send_message
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="staffId != null">
+                staff_id,
+            </if>
+            <if test="userId != null">
+                user_id,
+            </if>
+            <if test="videoId1 != null">
+                video_id_1,
+            </if>
+            <if test="videoId2 != null">
+                video_id_2,
+            </if>
+            <if test="videoId3 != null">
+                video_id_3,
+            </if>
+            <if test="isSend != null">
+                is_send,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="staffId != null">
+                #{staffId,jdbcType=BIGINT},
+            </if>
+            <if test="userId != null">
+                #{userId,jdbcType=BIGINT},
+            </if>
+            <if test="videoId1 != null">
+                #{videoId1,jdbcType=BIGINT},
+            </if>
+            <if test="videoId2 != null">
+                #{videoId2,jdbcType=BIGINT},
+            </if>
+            <if test="videoId3 != null">
+                #{videoId3,jdbcType=BIGINT},
+            </if>
+            <if test="isSend != null">
+                #{isSend,jdbcType=INTEGER},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+    <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample"
+            resultType="java.lang.Long">
+        select count(*) from we_com_send_message
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </select>
+    <update id="updateByExampleSelective" parameterType="map">
+        update we_com_send_message
+        <set>
+            <if test="record.id != null">
+                id = #{record.id,jdbcType=BIGINT},
+            </if>
+            <if test="record.staffId != null">
+                staff_id = #{record.staffId,jdbcType=BIGINT},
+            </if>
+            <if test="record.userId != null">
+                user_id = #{record.userId,jdbcType=BIGINT},
+            </if>
+            <if test="record.videoId1 != null">
+                video_id_1 = #{record.videoId1,jdbcType=BIGINT},
+            </if>
+            <if test="record.videoId2 != null">
+                video_id_2 = #{record.videoId2,jdbcType=BIGINT},
+            </if>
+            <if test="record.videoId3 != null">
+                video_id_3 = #{record.videoId3,jdbcType=BIGINT},
+            </if>
+            <if test="record.isSend != null">
+                is_send = #{record.isSend,jdbcType=INTEGER},
+            </if>
+            <if test="record.createTime != null">
+                create_time = #{record.createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="record.updateTime != null">
+                update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByExample" parameterType="map">
+        update we_com_send_message
+        set id = #{record.id,jdbcType=BIGINT},
+        staff_id = #{record.staffId,jdbcType=BIGINT},
+        user_id = #{record.userId,jdbcType=BIGINT},
+        video_id_1 = #{record.videoId1,jdbcType=BIGINT},
+        video_id_2 = #{record.videoId2,jdbcType=BIGINT},
+        video_id_3 = #{record.videoId3,jdbcType=BIGINT},
+        is_send = #{record.isSend,jdbcType=INTEGER},
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+        update we_com_send_message
+        <set>
+            <if test="staffId != null">
+                staff_id = #{staffId,jdbcType=BIGINT},
+            </if>
+            <if test="userId != null">
+                user_id = #{userId,jdbcType=BIGINT},
+            </if>
+            <if test="videoId1 != null">
+                video_id_1 = #{videoId1,jdbcType=BIGINT},
+            </if>
+            <if test="videoId2 != null">
+                video_id_2 = #{videoId2,jdbcType=BIGINT},
+            </if>
+            <if test="videoId3 != null">
+                video_id_3 = #{videoId3,jdbcType=BIGINT},
+            </if>
+            <if test="isSend != null">
+                is_send = #{isSend,jdbcType=INTEGER},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+        update we_com_send_message
+        set staff_id    = #{staffId,jdbcType=BIGINT},
+            user_id     = #{userId,jdbcType=BIGINT},
+            video_id_1  = #{videoId1,jdbcType=BIGINT},
+            video_id_2  = #{videoId2,jdbcType=BIGINT},
+            video_id_3  = #{videoId3,jdbcType=BIGINT},
+            is_send     = #{isSend,jdbcType=INTEGER},
+            create_time = #{createTime,jdbcType=TIMESTAMP},
+            update_time = #{updateTime,jdbcType=TIMESTAMP}
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+
+    <insert id="insertList" parameterType="java.util.List">
+        insert into we_com_send_message
+        (
+        staff_id,
+        user_id,
+        video_id_1,
+        video_id_2,
+        video_id_3
+        )
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.staffId,jdbcType=BIGINT},
+            #{item.userId,jdbcType=BIGINT},
+            #{item.videoId1,jdbcType=BIGINT},
+            #{item.videoId2,jdbcType=BIGINT},
+            #{item.videoId3,jdbcType=BIGINT}
+            )
+        </foreach>
+    </insert>
+
+    <select id="getGroupList" resultMap="BaseResultMap">
+        select staff_id, video_id_1, video_id_2, video_id_3
+        from we_com_send_message
+        where create_time >= #{createTime} and is_send = #{isSend}
+    </select>
+
+    <select id="selectExternalUserId3rdParty" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage" resultType="java.lang.String">
+        select
+            t2.external_user_id_3rd_party
+        from we_com_send_message t1 left join we_com_user t2 on t1.user_id = t2.id
+        where t1.staff_id = #{record.staffId}
+          and t1.video_id_1 = #{record.videoId1}
+          and t1.video_id_2 = #{record.videoId2}
+          and t1.video_id_3 = #{record.videoId3}
+          and t1.create_time > #{record.createTime}
+          and t1.is_send = #{record.isSend}
+    </select>
+</mapper>

+ 246 - 0
we-com-server/src/main/resources/mapper/StaffMapper.xml

@@ -0,0 +1,246 @@
+<?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.wecom.dao.mapper.StaffMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.Staff">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="staff_ext_id" jdbcType="VARCHAR" property="staffExtId" />
+    <result column="carrier_id" jdbcType="VARCHAR" property="carrierId" />
+    <result column="remark" jdbcType="VARCHAR" property="remark" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+  </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, staff_ext_id, carrier_id, remark, is_delete, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_staff
+    <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 we_com_staff
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_staff
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffExample">
+    delete from we_com_staff
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
+    insert into we_com_staff (id, staff_ext_id, carrier_id, 
+      remark, is_delete, create_time, 
+      update_time)
+    values (#{id,jdbcType=BIGINT}, #{staffExtId,jdbcType=VARCHAR}, #{carrierId,jdbcType=VARCHAR}, 
+      #{remark,jdbcType=VARCHAR}, #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
+    insert into we_com_staff
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="staffExtId != null">
+        staff_ext_id,
+      </if>
+      <if test="carrierId != null">
+        carrier_id,
+      </if>
+      <if test="remark != null">
+        remark,
+      </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="staffExtId != null">
+        #{staffExtId,jdbcType=VARCHAR},
+      </if>
+      <if test="carrierId != null">
+        #{carrierId,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffExample" resultType="java.lang.Long">
+    select count(*) from we_com_staff
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_staff
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.staffExtId != null">
+        staff_ext_id = #{record.staffExtId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.carrierId != null">
+        carrier_id = #{record.carrierId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.remark != null">
+        remark = #{record.remark,jdbcType=VARCHAR},
+      </if>
+      <if test="record.isDelete != null">
+        is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateTime != null">
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update we_com_staff
+    set id = #{record.id,jdbcType=BIGINT},
+      staff_ext_id = #{record.staffExtId,jdbcType=VARCHAR},
+      carrier_id = #{record.carrierId,jdbcType=VARCHAR},
+      remark = #{record.remark,jdbcType=VARCHAR},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
+    update we_com_staff
+    <set>
+      <if test="staffExtId != null">
+        staff_ext_id = #{staffExtId,jdbcType=VARCHAR},
+      </if>
+      <if test="carrierId != null">
+        carrier_id = #{carrierId,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
+    update we_com_staff
+    set staff_ext_id = #{staffExtId,jdbcType=VARCHAR},
+      carrier_id = #{carrierId,jdbcType=VARCHAR},
+      remark = #{remark,jdbcType=VARCHAR},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 239 - 0
we-com-server/src/main/resources/mapper/StaffWithUserMapper.xml

@@ -0,0 +1,239 @@
+<?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.wecom.dao.mapper.StaffWithUserMapper">
+    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="staff_id" jdbcType="BIGINT" property="staffId"/>
+        <result column="user_id" jdbcType="BIGINT" property="userId"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+    </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
+        , staff_id, user_id, create_time, update_time
+    </sql>
+    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample"
+            resultMap="BaseResultMap">
+        select
+        <if test="distinct">
+            distinct
+        </if>
+        <include refid="Base_Column_List"/>
+        from we_com_staff_with_user
+        <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 we_com_staff_with_user
+        where id = #{id,jdbcType=BIGINT}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete
+        from we_com_staff_with_user
+        where id = #{id,jdbcType=BIGINT}
+    </delete>
+    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample">
+        delete from we_com_staff_with_user
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </delete>
+    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+        insert into we_com_staff_with_user (id, staff_id, user_id,
+                                            create_time, update_time)
+        values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
+                #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+    </insert>
+    <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+        insert into we_com_staff_with_user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="staffId != null">
+                staff_id,
+            </if>
+            <if test="userId != null">
+                user_id,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="staffId != null">
+                #{staffId,jdbcType=BIGINT},
+            </if>
+            <if test="userId != null">
+                #{userId,jdbcType=BIGINT},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+    <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample"
+            resultType="java.lang.Long">
+        select count(*) from we_com_staff_with_user
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </select>
+    <update id="updateByExampleSelective" parameterType="map">
+        update we_com_staff_with_user
+        <set>
+            <if test="record.id != null">
+                id = #{record.id,jdbcType=BIGINT},
+            </if>
+            <if test="record.staffId != null">
+                staff_id = #{record.staffId,jdbcType=BIGINT},
+            </if>
+            <if test="record.userId != null">
+                user_id = #{record.userId,jdbcType=BIGINT},
+            </if>
+            <if test="record.createTime != null">
+                create_time = #{record.createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="record.updateTime != null">
+                update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByExample" parameterType="map">
+        update we_com_staff_with_user
+        set id = #{record.id,jdbcType=BIGINT},
+        staff_id = #{record.staffId,jdbcType=BIGINT},
+        user_id = #{record.userId,jdbcType=BIGINT},
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+        <if test="_parameter != null">
+            <include refid="Update_By_Example_Where_Clause"/>
+        </if>
+    </update>
+    <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+        update we_com_staff_with_user
+        <set>
+            <if test="staffId != null">
+                staff_id = #{staffId,jdbcType=BIGINT},
+            </if>
+            <if test="userId != null">
+                user_id = #{userId,jdbcType=BIGINT},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+        update we_com_staff_with_user
+        set staff_id    = #{staffId,jdbcType=BIGINT},
+            user_id     = #{userId,jdbcType=BIGINT},
+            create_time = #{createTime,jdbcType=TIMESTAMP},
+            update_time = #{updateTime,jdbcType=TIMESTAMP}
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+
+    <insert id="insertList" parameterType="java.util.List">
+        insert into we_com_staff_with_user
+        (
+        staff_id,
+        user_id,
+        create_time,
+        update_time
+        )
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.staffId,jdbcType=BIGINT},
+            #{item.userId,jdbcType=BIGINT},
+            #{item.createTime,jdbcType=TIMESTAMP},
+            #{item.updateTime,jdbcType=TIMESTAMP}
+            )
+        </foreach>
+    </insert>
+</mapper>

+ 32 - 29
we-com-server/src/main/resources/mapper/UserMapper.xml

@@ -111,17 +111,20 @@
       <include refid="Example_Where_Clause" />
     </if>
   </delete>
-  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.User">
-    insert into we_com_user (id, external_user_id, union_id, 
-      external_user_id_3rd_party, `type`, `name`, 
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.User" useGeneratedKeys="true" keyProperty="id">
+      insert into we_com_user (id, external_user_id, union_id,
+      external_user_id_3rd_party, `type`, `name`,
       avatar, gender,
-      created_at, updated_at, create_time, 
+      created_at, updated_at, create_time,
       update_time)
-    values (#{id,jdbcType=BIGINT}, #{externalUserId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR}, 
-      #{externalUserId3rdParty,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
+      values (#{id,jdbcType=BIGINT}, #{externalUserId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR},
+      #{externalUserId3rdParty,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
       #{avatar,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER},
-      #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
       #{updateTime,jdbcType=TIMESTAMP})
+      <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
+          select LAST_INSERT_ID()
+      </selectKey>
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
     insert into we_com_user
@@ -350,32 +353,32 @@
   <insert id="insertList" parameterType="java.util.List">
     insert into we_com_user
     (
-     external_user_id,
-     union_id,
-     external_user_id_3rd_party,
-     `type`,
-     `name`,
-     avatar,
-     gender,
-     created_at,
-     updated_at,
-     create_time,
-     update_time
+    external_user_id,
+    union_id,
+    external_user_id_3rd_party,
+    `type`,
+    `name`,
+    avatar,
+    gender,
+    created_at,
+    updated_at,
+    create_time,
+    update_time
     )
     values
     <foreach collection="list" item="item" separator=",">
       (
-       #{item.externalUserId,jdbcType=VARCHAR},
-       #{item.unionId,jdbcType=VARCHAR},
-       #{item.externalUserId3rdParty,jdbcType=VARCHAR},
-       #{item.type,jdbcType=INTEGER},
-       #{item.name,jdbcType=VARCHAR},
-       #{item.avatar,jdbcType=VARCHAR},
-       #{item.gender,jdbcType=INTEGER},
-       #{item.createdAt,jdbcType=BIGINT},
-       #{item.updatedAt,jdbcType=BIGINT},
-       #{item.createTime,jdbcType=TIMESTAMP},
-       #{item.updateTime,jdbcType=TIMESTAMP}
+      #{item.externalUserId,jdbcType=VARCHAR},
+      #{item.unionId,jdbcType=VARCHAR},
+      #{item.externalUserId3rdParty,jdbcType=VARCHAR},
+      #{item.type,jdbcType=INTEGER},
+      #{item.name,jdbcType=VARCHAR},
+      #{item.avatar,jdbcType=VARCHAR},
+      #{item.gender,jdbcType=INTEGER},
+      #{item.createdAt,jdbcType=BIGINT},
+      #{item.updatedAt,jdbcType=BIGINT},
+      #{item.createTime,jdbcType=TIMESTAMP},
+      #{item.updateTime,jdbcType=TIMESTAMP}
       )
     </foreach>
   </insert>

+ 6 - 2
we-com-server/src/main/resources/mybatis-generator-config.xml

@@ -51,8 +51,12 @@
         </javaClientGenerator>
 
 <!--        <table tableName="we_com_user" domainObjectName="User" alias=""/>-->
-        <table tableName="we_com_history_message" domainObjectName="HistoryMessage" alias=""/>
-        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>
+<!--        <table tableName="we_com_history_message" domainObjectName="HistoryMessage" alias=""/>-->
+<!--        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>-->
+<!--        <table tableName="we_com_staff" domainObjectName="Staff" alias=""/>-->
+<!--        <table tableName="we_com_staff_with_user" domainObjectName="StaffWithUser" alias=""/>-->
+        <table tableName="we_com_send_message" domainObjectName="SendMessage" alias=""/>
+
 
     </context>