Commit b9292251 by 朱亚洁

好友数量

parent 71f3d401
......@@ -24,7 +24,6 @@ import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.BookGroupClassifyBiz;
import com.pcloud.book.group.dao.*;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.entity.JoinGroupCipher;
......@@ -36,9 +35,11 @@ import com.pcloud.book.group.vo.StatisticVO;
import com.pcloud.book.group.biz.GroupQrcodeBiz;
import com.pcloud.book.group.dao.AppClickRecordDao;
import com.pcloud.book.group.dao.AppTouchRecordDao;
import com.pcloud.book.group.dao.BookGroupCipherUserDao;
import com.pcloud.book.group.dao.BookGroupClassifyDao;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.BookGroupServeDao;
import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.dao.JoinGroupCipherDao;
import com.pcloud.book.group.dao.TempletRelevanceDao;
import com.pcloud.book.group.dao.WeixinQrcodeDao;
......@@ -232,7 +233,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private BookGroupServeDao bookGroupServeDao;
@Autowired
private GroupQrcodeDao groupQrcodeDao;
@Autowired
private BookGroupCipherUserDao bookGroupCipherUserDao;
@Override
......@@ -610,7 +612,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
bookDto.setTotalIncome(BigDecimal.ZERO);
}
//好友数量
Integer friendsCount = joinGroupCipherDao.getFriendsCountByBookGroup(bookGroupId);
Integer friendsCount = bookGroupCipherUserDao.getFriendsCountByBookGroup(bookGroupId);
bookDto.setFriendsCount(friendsCount);
}
return pageBean;
......@@ -1101,6 +1103,9 @@ public class BookGroupBizImpl implements BookGroupBiz {
qrcodeName = "未命名" + noName;
}
}
if (Integer.valueOf(2).equals(bookDto.getJoinGroupType())) {
qrcodeName = qrcodeName + "(" + bookDto.getBookGroupCipher() + ")";
}
// 加入二维码图片
String[] qrcodePicurl = {qrcodeName, qrcodeUrl};
qrcodePicUrls.add(qrcodePicurl);
......@@ -2053,7 +2058,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
public Map<String, Integer> getBookGroupFriendsCountByDay(Long bookGroupId, String startDate, String endDate) {
String startTime = DateUtils.formatDate(DateUtils.getDayStart(DateUtils.getDateByStr(startDate)), DateUtils.DATE_FORMAT_DATETIME);
String endTime = DateUtils.formatDate(DateUtils.getDayEnd(DateUtils.getDateByStr(endDate)), DateUtils.DATE_FORMAT_DATETIME);
List<DayCountDTO> countDTOS = joinGroupCipherDao.getBookGroupFriendsCountByDay(bookGroupId, startTime, endTime);
List<DayCountDTO> countDTOS = bookGroupCipherUserDao.getBookGroupFriendsCountByDay(bookGroupId, startTime, endTime);
Map<String, Integer> map = new HashMap<>();
if (ListUtils.isEmpty(countDTOS)) {
return map;
......@@ -2068,7 +2073,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
public PageBeanNew<FriendsVO> listPageFriendsStatistic(Long bookGroupId, Integer currentPage, Integer numPerPage) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookGroupId", bookGroupId);
PageBeanNew<FriendsVO> pageBeanNew = joinGroupCipherDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listPageFriendsStatistic");
PageBeanNew<FriendsVO> pageBeanNew = bookGroupCipherUserDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listPageFriendsStatistic");
List<FriendsVO> recordList = pageBeanNew.getRecordList();
if (null == pageBeanNew || ListUtils.isEmpty(recordList)) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
......
......@@ -17,6 +17,7 @@ import com.pcloud.book.group.biz.GroupAnnouncementBiz;
import com.pcloud.book.group.biz.GroupQrcodeBiz;
import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.group.dao.BookClassifyBuyRecordDao;
import com.pcloud.book.group.dao.BookGroupCipherUserDao;
import com.pcloud.book.group.dao.BookGroupClassifyDao;
import com.pcloud.book.group.dao.BookQrcodeUserDao;
import com.pcloud.book.group.dao.JoinGroupCipherDao;
......@@ -160,9 +161,10 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
private LearningReportTouchRecordDao learningReportTouchRecordDao;
@Autowired
private JoinGroupCipherDao joinGroupCipherDao;
@Autowired
private BookAuthUserBiz bookAuthUserBiz;
@Autowired
private BookGroupCipherUserDao bookGroupCipherUserDao;
@Override
......@@ -479,7 +481,7 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
classifyAndGroupCountVO.setClassifyCount(statistic.get(bookGroupId).getClassifyCount());
}
classifyAndGroupCountVO.setGroupCount(groupCount);
Integer friendsCount = joinGroupCipherDao.getFriendsCountByBookGroup(bookGroupId);
Integer friendsCount = bookGroupCipherUserDao.getFriendsCountByBookGroup(bookGroupId);
classifyAndGroupCountVO.setFriendsCount(friendsCount);
return classifyAndGroupCountVO;
}
......
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.DayCountDTO;
import com.pcloud.book.group.entity.BookGroupCipherUser;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
......@@ -12,4 +15,19 @@ public interface BookGroupCipherUserDao extends BaseDao<BookGroupCipherUser> {
Long getBookGroupIdByWxUserId(String wxUserId);
/**
* 社群码好友数量
* @param bookGroupId
* @return
*/
public Integer getFriendsCountByBookGroup(Long bookGroupId);
/**
* 日加好友数量
* @param bookGroupId
* @param startTime
* @param endTime
* @return
*/
List<DayCountDTO> getBookGroupFriendsCountByDay(Long bookGroupId, String startTime, String endTime);
}
......@@ -33,21 +33,7 @@ public interface JoinGroupCipherDao extends BaseDao<JoinGroupCipher> {
List<JoinGroupCipher> getListByAltIdAndWxIdAndType(String robotId, String userWxId, Integer code);
/**
* 社群码好友数量
* @param bookGroupId
* @return
*/
public Integer getFriendsCountByBookGroup(Long bookGroupId);
/**
* 日加好友数量
* @param bookGroupId
* @param startTime
* @param endTime
* @return
*/
List<DayCountDTO> getBookGroupFriendsCountByDay(Long bookGroupId, String startTime, String endTime);
JoinGroupCipher getByWechatUserIdAndQrcodeId(Long wechatUserId, Long qrcodeId, Integer type);
......
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.BookGroupCipherUserDao;
import com.pcloud.book.group.dto.DayCountDTO;
import com.pcloud.book.group.entity.BookGroupCipherUser;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
......@@ -16,4 +21,19 @@ public class BookGroupCipherUserDaoImpl extends BaseDaoImpl<BookGroupCipherUser>
public Long getBookGroupIdByWxUserId(String wxUserId) {
return this.getSqlSession().selectOne(this.getStatement("getBookGroupIdByWxUserId"), wxUserId);
}
@Override
public Integer getFriendsCountByBookGroup(Long bookGroupId) {
return getSessionTemplate().selectOne(getStatement("getFriendsCountByBookGroup"), bookGroupId);
}
@Override
public List<DayCountDTO> getBookGroupFriendsCountByDay(Long bookGroupId, String startTime, String endTime) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
map.put("startTime", startTime);
map.put("endTime", endTime);
return getSessionTemplate().selectList(getStatement("getBookGroupFriendsCountByDay"), map);
}
}
......@@ -89,20 +89,6 @@ public class JoinGroupCipherDaoImpl extends BaseDaoImpl<JoinGroupCipher> impleme
return this.getSqlSession().selectList(this.getStatement("getListByAltIdAndWxIdAndType"), map);
}
@Override
public Integer getFriendsCountByBookGroup(Long bookGroupId) {
return getSessionTemplate().selectOne(getStatement("getFriendsCountByBookGroup"), bookGroupId);
}
@Override
public List<DayCountDTO> getBookGroupFriendsCountByDay(Long bookGroupId, String startTime, String endTime) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
map.put("startTime", startTime);
map.put("endTime", endTime);
return getSessionTemplate().selectList(getStatement("getBookGroupFriendsCountByDay"), map);
}
public JoinGroupCipher getByWechatUserIdAndQrcodeId(Long wechatUserId, Long qrcodeId, Integer type) {
Map<String,Object> map=new HashMap<>();
map.put("wechatUserId",wechatUserId);
......
......@@ -38,4 +38,52 @@
<select id="getBookGroupIdByWxUserId" parameterType="String" resultType="long">
select book_group_id from book_group_cipher_user t where t.wx_user_id=#{wxUserId} order by create_time desc limit 1
</select>
<select id="getFriendsCountByBookGroup" parameterType="long" resultType="integer">
SELECT
COUNT(DISTINCT wx_user_id)
FROM
book_group_cipher_user
WHERE
book_group_id = #{bookGroupId}
</select>
<select id="getBookGroupFriendsCountByDay" parameterType="map" resultType="com.pcloud.book.group.dto.DayCountDTO">
SELECT
COUNT(DISTINCT a.wx_user_id) count,
DATE_FORMAT(a.create_time, "%Y-%m-%d") date
FROM
(
SELECT
wx_user_id,create_time
FROM
book_group_cipher_user
WHERE
book_group_id = #{bookGroupId}
GROUP BY
wx_user_id
) AS a
WHERE
a.create_time >= #{startTime}
AND a.create_time &lt;= #{endTime}
GROUP BY
DATE_FORMAT(a.create_time, "%Y-%m-%d")
</select>
<select id="listPageFriendsStatistic" parameterType="map" resultType="com.pcloud.book.group.vo.FriendsVO">
SELECT
wx_user_id wxUserId,
alt_id robotId,
create_time createTime
FROM
book_group_cipher_user
WHERE
book_group_id = #{bookGroupId}
GROUP BY
wx_user_id,
alt_id
ORDER BY
create_time DESC,id DESC
</select>
</mapper>
\ No newline at end of file
......@@ -128,45 +128,6 @@
type=#{type}
</select>
<select id="getFriendsCountByBookGroup" parameterType="long" resultType="integer">
SELECT
COUNT(DISTINCT wx_id)
FROM
join_group_cipher
WHERE
book_group_id = #{bookGroupId}
AND has_used = 1
</select>
<select id="getBookGroupFriendsCountByDay" parameterType="map" resultType="com.pcloud.book.group.dto.DayCountDTO">
SELECT
COUNT(DISTINCT wx_id) count,
DATE_FORMAT(create_time, "%Y-%m-%d") date
FROM
join_group_cipher
WHERE
book_group_id = #{bookGroupId}
AND has_used = 1
AND create_time >= #{startTime}
AND create_time &lt;= #{endTime}
GROUP BY
DATE_FORMAT(create_time, "%Y-%m-%d")
</select>
<select id="listPageFriendsStatistic" parameterType="map" resultType="com.pcloud.book.group.vo.FriendsVO">
SELECT DISTINCT
wx_id wxUserId,
alt_id robotId,
create_time createTime
FROM
join_group_cipher
WHERE
book_group_id = 655
AND has_used = 1
ORDER BY
create_time DESC,id DESC
</select>
<!--根据用户id和群id获取基本信息-->
<select id="getByWechatUserIdAndQrcodeId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from join_group_cipher
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment