Преглед изворни кода

Merge branch 'master' into dev-xym-addTag

# Conflicts:
#	common-module/src/main/java/com/tzld/piaoquan/growth/common/service/WeComUserService.java
xueyiming пре 3 месеци
родитељ
комит
6d2d5b0827

+ 2 - 1
api-module/src/main/java/com/tzld/piaoquan/api/controller/WeComUserController.java

@@ -5,6 +5,7 @@ import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.model.bo.GroupSendWeComUserParam;
 import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
 import com.tzld.piaoquan.growth.common.service.WeComUserService;
+import com.tzld.piaoquan.growth.common.utils.page.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -32,7 +33,7 @@ public class WeComUserController {
 
 
     @PostMapping("/getGroupSendUsers")
-    public CommonResponse<List<WeComUserVo>> getGroupSendUsers(@RequestBody GroupSendWeComUserParam param) {
+    public CommonResponse<Page<WeComUserVo>> getGroupSendUsers(@RequestBody GroupSendWeComUserParam param) {
         log.info("param={}", param);
         return CommonResponse.success(service.getGroupSendWeComUser(param));
     }

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

@@ -2,6 +2,7 @@ package com.tzld.piaoquan.growth.common.dao.mapper.ext;
 
 import com.tzld.piaoquan.growth.common.model.po.WeComUser;
 import com.tzld.piaoquan.growth.common.model.po.WeComUserExample;
+import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -12,5 +13,17 @@ import java.util.List;
 @Mapper
 @Repository
 public interface WeComUserMapperExt {
-    List<WeComUser> getGroupSendUserByDate(@Param("start") Date start, @Param("end") Date end);
+
+    Integer countGroupSendUserByDate(@Param("start") Date start,
+                                             @Param("end") Date end,
+                                             @Param("preSendDate") String preSendDate,
+                                             @Param("carrierIds") List<String> carrierIds);
+
+    List<WeComUserVo> getGroupSendUserByDate(@Param("start") Date start,
+                                             @Param("end") Date end,
+                                             @Param("preSendDate") String preSendDate,
+                                             @Param("carrierIds") List<String> carrierIds,
+                                             @Param("offset") Integer offset,
+                                             @Param("pageSize") Integer pageSize);
+
 }

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

@@ -2,7 +2,12 @@ package com.tzld.piaoquan.growth.common.model.bo;
 
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class GroupSendWeComUserParam {
     String dateStr;
+    List<String> carrierIds;
+    Integer pageNum = 1;
+    Integer pageSize;
 }

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

@@ -2,6 +2,8 @@ package com.tzld.piaoquan.growth.common.model.vo;
 
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class WeComUserVo {
 
@@ -21,4 +23,10 @@ public class WeComUserVo {
 
     private Integer gender;
 
+    private String carrierId;
+
+    private Integer status;
+
+    private Date sendTime;
+
 }

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

@@ -14,6 +14,7 @@ import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
 import com.tzld.piaoquan.growth.common.service.WeComUserService;
 import com.tzld.piaoquan.growth.common.utils.DateUtil;
 import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
+import com.tzld.piaoquan.growth.common.utils.page.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -254,14 +255,30 @@ public class WeComUserServiceImpl implements WeComUserService {
     }
 
     @Override
-    public List<WeComUserVo> getGroupSendWeComUser(GroupSendWeComUserParam param) {
+    public Page<WeComUserVo> getGroupSendWeComUser(GroupSendWeComUserParam param) {
         Date start = DateUtil.getDaysAgoDate(1);
         Date end = DateUtil.getThatDayDate();
+        String preSendDate = DateUtil.getBeforeDayDateString(1, "yyyy-MM-dd");
         if (Objects.nonNull(param) && StringUtils.isNotEmpty(param.getDateStr())) {
             start = DateUtil.getDate(param.getDateStr());
             end = DateUtil.getDatePlusDays(param.getDateStr(), 1);
+            preSendDate = param.getDateStr();
         }
-        List<WeComUser> list = weComUserMapperExt.getGroupSendUserByDate(start, end);
-        return buildWeComUserVo(list);
+        Page<WeComUserVo> page = new Page<>();
+        page.setCurrentPage(param.getPageNum());
+        Integer totalSize = weComUserMapperExt.countGroupSendUserByDate(start, end, preSendDate, param.getCarrierIds());
+        page.setTotalSize(totalSize);
+        if (totalSize == 0) {
+            return page;
+        }
+        int offset = 0;
+        if (Objects.nonNull(param.getPageSize())) {
+            page.setPageSize(param.getPageSize());
+            offset = (param.getPageNum() - 1) * param.getPageSize();
+        }
+        List<WeComUserVo> list = weComUserMapperExt.getGroupSendUserByDate(start, end, preSendDate, param.getCarrierIds(),
+                offset, param.getPageSize());
+        page.setObjs(list);
+        return page;
     }
 }

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

@@ -1,10 +1,10 @@
 package com.tzld.piaoquan.growth.common.service;
 
-import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.growth.common.model.bo.GroupSendWeComUserParam;
 import com.tzld.piaoquan.growth.common.model.po.Staff;
 import com.tzld.piaoquan.growth.common.model.po.WeComUser;
 import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
+import com.tzld.piaoquan.growth.common.utils.page.Page;
 
 import java.util.List;
 
@@ -25,4 +25,5 @@ public interface WeComUserService {
     List<WeComUserVo> getGroupSendWeComUser(GroupSendWeComUserParam param);
 
     JSONObject getUserDetail(String externalUserId, Long corpId);
+    Page<WeComUserVo> getGroupSendWeComUser(GroupSendWeComUserParam param);
 }

+ 7 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/DateUtil.java

@@ -40,6 +40,13 @@ public class DateUtil {
         return dateFormat.format(yesterday);
     }
 
+    public static String getBeforeDayDateString(int day, String format) {
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(format);
+        LocalDate today = LocalDate.now();
+        LocalDate yesterday = today.minusDays(day);
+        return dateFormat.format(yesterday);
+    }
+
     public static String getBeforeDayDateString1() {
         DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate today = LocalDate.now();

+ 38 - 22
common-module/src/main/resources/mapper/ext/WeComUserMapperExt.xml

@@ -1,30 +1,46 @@
 <?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.growth.common.dao.mapper.ext.WeComUserMapperExt">
-    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.growth.common.model.po.WeComUser">
-        <id column="id" jdbcType="BIGINT" property="id" />
-        <result column="corp_id" jdbcType="BIGINT" property="corpId" />
-        <result column="external_user_id" jdbcType="VARCHAR" property="externalUserId" />
-        <result column="union_id" jdbcType="VARCHAR" property="unionId" />
-        <result column="external_user_id_3rd_party" jdbcType="VARCHAR" property="externalUserId3rdParty" />
-        <result column="type" jdbcType="INTEGER" property="type" />
-        <result column="name" jdbcType="VARCHAR" property="name" />
-        <result column="avatar" jdbcType="VARCHAR" property="avatar" />
-        <result column="gender" jdbcType="INTEGER" property="gender" />
-        <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
-        <result column="group_msg_disabled" jdbcType="TINYINT" property="groupMsgDisabled" />
-        <result column="created_at" jdbcType="BIGINT" property="createdAt" />
-        <result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
-        <result column="deleted_at" jdbcType="BIGINT" property="deletedAt" />
-        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    </resultMap>
 
-    <select id="getGroupSendUserByDate" resultMap="BaseResultMap">
-        select wcu.*
+    <select id="countGroupSendUserByDate" resultType="java.lang.Integer">
+        select count(1)
         from we_com_user wcu
-        join we_com_send_message wcsm on wcsm.user_id = wcu.id
+        join we_com_send_msg_result wcsmr on wcsmr.user_id = wcu.id
+        join we_com_special_send_message wcssm on wcssm.user_id = wcsmr.user_id and wcssm.staff_id = wcsmr.staff_id
+        join we_com_staff wcs on wcs.id = wcssm.staff_id
         where wcu.group_msg_disabled > 0
-        and wcsm.create_time between #{start} and #{end}
+        and wcssm.is_send = 1
+        and wcsmr.create_time between #{start} and #{end}
+        and wcssm.pre_send_date = #{preSendDate}
+        <if test="carrierIds != null and carrierIds.size() > 0">
+            and wcs.carrier_id in
+            <foreach collection="carrierIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getGroupSendUserByDate" resultType="com.tzld.piaoquan.growth.common.model.vo.WeComUserVo">
+        select wcu.corp_id as corpId, wcu.external_user_id as externalUserId, wcu.union_id as unionId,
+        wcu.external_user_id_3rd_party as externalUserId3rdParty, wcu.type as type, wcu.name as name,
+        wcu.avatar as avatar, wcu.gender as gender, wcs.carrier_id as carrierId, wcsmr.status as status,
+        wcsmr.send_time as sendTime
+        from we_com_user wcu
+        join we_com_send_msg_result wcsmr on wcsmr.user_id = wcu.id
+        join we_com_special_send_message wcssm on wcssm.user_id = wcsmr.user_id and wcssm.staff_id = wcsmr.staff_id
+        join we_com_staff wcs on wcs.id = wcssm.staff_id
+        where wcu.group_msg_disabled > 0
+        and wcssm.is_send = 1
+        and wcsmr.create_time between #{start} and #{end}
+        and wcssm.pre_send_date = #{preSendDate}
+        <if test="carrierIds != null and carrierIds.size() > 0">
+            and wcs.carrier_id in
+            <foreach collection="carrierIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="pageSize != null and pageSize > 0">
+            limit #{offset}, #{pageSize}
+        </if>
     </select>
 </mapper>