Explorar o código

标签查询数据增加用户数属性

zoujiajian %!s(int64=2) %!d(string=hai) anos
pai
achega
4398354548

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserTagMapper.java

@@ -18,4 +18,6 @@ public interface CorpUserTagMapper extends BaseMapper<CorpUserTag> {
 	Page<CorpUserView> selectCorpUserDetailByCondition(@Param("page") Page<CorpUserView> page, @Param("groupId") String groupId, @Param("tagId") String tagId, @Param("wxCorpId") Long wxCorpId);
 
 	List<CorpUserTagExcelData> exportUserTagDetail(@Param("tagIds") String[] tagIds, @Param("groupIds") String[] groupIds, @Param("wxCorpId") Long wxCorpId);
+
+	Integer countTagUser(@Param("tagIdStr") String tagIdStr, @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserOrderDetailView.java

@@ -15,6 +15,8 @@ import java.math.BigDecimal;
 @Getter
 @Setter
 public class UserOrderDetailView {
+	private Integer numOfUser;
+
 	private Integer numOfOrder;
 
 	private BigDecimal orderMoney;

+ 7 - 2
netflix-dao/src/main/resources/mapper/CorpTagMapper.xml

@@ -55,7 +55,12 @@
     </select>
 
     <select id="selectCountOfCustomer" resultType="java.lang.Integer">
-        select count(distinct cufr.corp_user_id) from corp_user_tag cut left join corp_user_follow_relation cufr on cufr.id = cut.relation_id
-        where cufr.wx_corp_id = #{wxCorpId} and cut.tag_id = #{tagId}
+        select count(distinct ca.corp_user_id)
+        from corp_user_tag cut
+                 left join corp_user_follow_relation cufr
+                           on cufr.id = cut.relation_id
+                 left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
+        where cufr.wx_corp_id = #{wxCorpId}
+          and cut.tag_id = #{tagId}
     </select>
 </mapper>

+ 15 - 0
netflix-dao/src/main/resources/mapper/CorpUserTagMapper.xml

@@ -60,4 +60,19 @@
         inner join user u on u.id = cu.user_id
         group by cu.id, cu.unionid)s order by s.tagTime desc, s.userId asc
     </select>
+
+    <select id="countTagUser" resultType="java.lang.Integer">
+        select count(distinct ca.corp_user_id)
+        from (select relation_id
+        from `corp_user_tag` ct
+        where tag_id = #{tagIdStr}
+        <if test="startTime != null">
+            and ct.created_time >= #{startTime}
+        </if>
+        <if test="endTime != null">
+            and ct.created_time &lt; #{endTime}
+        </if>) s
+        left join corp_user_follow_relation cufr on cufr.id = s.relation_id
+        left join corp_user_auth ca on ca.external_userid = cufr.corp_user_id
+    </select>
 </mapper>

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpTagServiceImpl.java

@@ -422,6 +422,8 @@ public class CorpTagServiceImpl implements CorpTagService {
 	public UserOrderDetailView getTagUserData(Integer start, Integer limit, String tagIdStr, String startTime, String endTime) {
 		UserOrderDetailView u = orderDonMapper.getTagUserData(tagIdStr, startTime, endTime);
 
+		u.setNumOfUser(corpUserTagMapper.countTagUser(tagIdStr, startTime, endTime));
+
 		Page<UserOrderDetailView> records = orderDonMapper.getTagUserDataPage(new Page<>(start, limit), tagIdStr, startTime, endTime);
 
 		u.setRecords(records);