Commit 4d7c9791 by 阮思源

微信群学习报告

parent 11293978
......@@ -50,6 +50,11 @@ public class GroupClassifyQrcodeDTO implements Serializable {
private String qrCodeUrl;
/**
* 是否开启群学习报告
*/
private Boolean hasOpenLearningReport;
public Long getBookId() {
return bookId;
}
......@@ -122,6 +127,14 @@ public class GroupClassifyQrcodeDTO implements Serializable {
this.qrCodeUrl = qrCodeUrl;
}
public Boolean getHasOpenLearningReport() {
return hasOpenLearningReport;
}
public void setHasOpenLearningReport(Boolean hasOpenLearningReport) {
this.hasOpenLearningReport = hasOpenLearningReport;
}
@Override
public String toString() {
return "GroupClassifyQrcodeDTO{" +
......@@ -133,6 +146,8 @@ public class GroupClassifyQrcodeDTO implements Serializable {
", groupQrcodeId=" + groupQrcodeId +
", weixinQrcodeId=" + weixinQrcodeId +
", price=" + price +
", qrCodeUrl='" + qrCodeUrl + '\'' +
", hasOpenLearningReport=" + hasOpenLearningReport +
'}';
}
}
......@@ -176,6 +176,12 @@
</dependency>
<dependency>
<groupId>com.pcloud.facade</groupId>
<artifactId>pcloud-facade-shareimage</artifactId>
<version>${pcloud-facade-shareimage.version}</version>
</dependency>
<dependency>
<groupId>fakepath</groupId>
<artifactId>jbarcode</artifactId>
<version>0.2.8</version>
......
......@@ -188,4 +188,14 @@ public class BookApplication {
public Queue convert2BookQueue(){
return RabbitMQFactory.queueBuilder(MQQueueConstant.CONVERT_TO_BOOK);
}
@Bean
public Queue wxGroupLearningReportQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.WXGROUP_LEARNING_REPORT);
}
@Bean
public Binding wxGroupLearningReportBind() {
return RabbitMQFactory.bindingExchange(wxGroupLearningReportQueue(), MQTopicProducer.WXGROUP_LEARNING_REPORT);
}
}
package com.pcloud.book.consumer.analysisengine;
import com.pcloud.analysisengine.wechatgroupan.dto.GroupBrowseDTO;
import com.pcloud.analysisengine.wechatgroupan.service.WechatGroupAnService;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ResponseHandleUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/25 10:09
**/
@Component("wechatGroupAnConsr")
public class WechatGroupAnConsr {
private static final Logger LOGGER = LoggerFactory.getLogger(WechatGroupAnConsr.class);
@Autowired
private WechatGroupAnService wechatGroupAnService;
@ParamLog(description = "获取微信群浏览集合")
public List<GroupBrowseDTO> getGroupBrowseList(Long qrcodeId) {
List<GroupBrowseDTO> groupBrowseDTOS = new ArrayList<>();
try {
groupBrowseDTOS = ResponseHandleUtil.parseListResponse(wechatGroupAnService.getGroupBrowseList(qrcodeId), GroupBrowseDTO.class);
} catch (BizException e) {
LOGGER.warn("【分析引擎(消)】获取微信群浏览集合.[getGroupBrowseList]:" + e.getMessage(), e);
} catch (Exception e) {
LOGGER.error("【分析引擎(消)】获取微信群浏览集合.[getGroupBrowseList]:" + e.getMessage(), e);
}
if (groupBrowseDTOS == null) {
groupBrowseDTOS = new ArrayList<>();
}
return groupBrowseDTOS;
}
@ParamLog(description = "获取微信群单个浏览")
public GroupBrowseDTO getGroupBrowseForOne(Long qrcodeId, Long wechatUserId) {
GroupBrowseDTO groupBrowseDTO = new GroupBrowseDTO();
try {
groupBrowseDTO = ResponseHandleUtil.parseResponse(wechatGroupAnService.getGroupBrowseForOne(qrcodeId, wechatUserId), GroupBrowseDTO.class);
} catch (BizException e) {
LOGGER.warn("【分析引擎(消)】获取微信群单个浏览.[getGroupBrowseForOne]:" + e.getMessage(), e);
} catch (Exception e) {
LOGGER.error("【分析引擎(消)】获取微信群单个浏览.[getGroupBrowseForOne]:" + e.getMessage(), e);
}
if (groupBrowseDTO == null) {
groupBrowseDTO = new GroupBrowseDTO();
}
return groupBrowseDTO;
}
}
package com.pcloud.book.consumer.trade;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.facade.tradecenter.dto.GroupMoneyDto;
import com.pcloud.facade.tradecenter.dto.QrGroupBuyDetailDto;
import com.pcloud.facade.tradecenter.dto.SpeWechatGroupDto;
import com.pcloud.facade.tradecenter.dto.WechatGroupDto;
import com.pcloud.facade.tradecenter.dto.*;
import com.pcloud.facade.tradecenter.service.OrderFormService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -90,4 +89,41 @@ public class TradeConsr {
}
return map;
}
@ParamLog("根据微信群id查询销售情况")
public List<SaleDetailByQrcodeDto> getSaleDetailByQrcodeId(Long qrcodeId) throws BizException{
List<SaleDetailByQrcodeDto> list=new ArrayList<>();
if (qrcodeId == null) {
return list;
}
try {
ResponseEntity<ResponseDto<List<SaleDetailByQrcodeDto>>> responseEntity = orderFormService.getSaleDetailByQrcodeId(qrcodeId);
list = ResponseHandleUtil.parseListResponse(responseEntity, SaleDetailByQrcodeDto.class);
} catch (Exception e) {
LOGGER.error("根据微信群id查询销售情况:" + e.getMessage(), e);
}
if (list == null) {
list = new ArrayList<>();
}
return list;
}
@ParamLog("根据微信群id和wechatUserId查询销售额")
public BigDecimal getAmountByQrcodeId(Long qrcodeId,Long wechatUserId) throws BizException{
BigDecimal amount=BigDecimal.ZERO;
if (qrcodeId == null) {
return amount;
}
try {
ResponseEntity<ResponseDto<BigDecimal>> responseEntity = orderFormService.getAmountByQrcodeId(qrcodeId,wechatUserId);
amount = ResponseHandleUtil.parseResponse(responseEntity, BigDecimal.class);
} catch (Exception e) {
LOGGER.error("根据微信群id和wechatUserId查询销售额:" + e.getMessage(), e);
}
if (amount == null) {
amount = BigDecimal.ZERO;
}
return amount;
}
}
package com.pcloud.book.group.biz;
import com.pcloud.book.group.dto.BookGroupStatisticDTO;
import com.pcloud.book.group.dto.ClassifyDTO;
import com.pcloud.book.group.dto.GroupClassifyQrcodeDTO;
import com.pcloud.book.group.dto.GroupNameAndMaxSeqDTO;
import com.pcloud.book.group.dto.GroupQrcodeBaseDTO;
import com.pcloud.book.group.dto.ProAssocGroupAndUserNumberDTO;
import com.pcloud.book.group.dto.*;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.vo.*;
import com.pcloud.common.page.PageBeanNew;
......@@ -174,4 +169,14 @@ public interface BookGroupClassifyBiz {
PageBeanNew<ClassifyDTO> listSimpleBookGroupClassify4Adviser(Long adviserId, BookGroupClassify bookGroupClassify, PageParam pageParam);
PageBeanNew<AdviserClassifyVO> listAdviserClassify(Long adviserId, AdviserClassifyParam adviserClassifyParam);
/**
* 更新是否开启微学习报告
*/
void updateHasOpenLearningReport(Long classifyId, Boolean hasOpenLearningReport, Long partyId);
/**
* 获取群分类学习报告相关列表
*/
PageBeanNew<ClassifyLearningReportDto> listClassifyForLearningReport(Integer currentPage, Integer numPerPage, String keyword, Long partyId);
}
package com.pcloud.book.group.biz;
import com.pcloud.book.group.dto.AppClickDTO;
import com.pcloud.book.group.dto.LearningScoreDTO;
import com.pcloud.book.group.dto.UserLearningInfoDTO;
import com.pcloud.book.group.entity.LearningReportBrowseRecord;
import java.util.List;
public interface LearningReportBiz {
Long createLearningReportBrowseRecord(LearningReportBrowseRecord learningReportBrowseRecord);
Long createLearningReportTouchRecord(String wxUserId,String wxGroupId);
List<AppClickDTO> getRecentlyLearning(Long wechatUserId, Long qrcodeId);
List<LearningScoreDTO> getLearningTopFive(Long qrcodeId);
LearningScoreDTO getUserLearningSore(Long qrcodeId,Long wechatUserId);
UserLearningInfoDTO getUserLearningInfo(Long qrcodeId, Long wechatUserId, String qrcodeUrlS);
}
......@@ -45,7 +45,7 @@ public class AppClickRecordBizImpl implements AppClickRecordBiz {
}
GroupQrcode groupQrcode = groupQrcodeDao.getById(appClickRecord.getQrcodeId());
if (groupQrcode != null) {
appClickRecord.setQrcodeId(groupQrcode.getId());
appClickRecord.setWeixinGroupId(groupQrcode.getWeixinGroupId());
}
appClickRecordDao.insert(appClickRecord);
return appClickRecord.getId();
......
......@@ -11,20 +11,14 @@ import com.pcloud.book.consumer.settlement.SettlementConsr;
import com.pcloud.book.consumer.trade.TradeConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.biz.*;
import com.pcloud.book.group.dao.BookClassifyBuyRecordDao;
import com.pcloud.book.group.dao.BookGroupClassifyDao;
import com.pcloud.book.group.dao.BookQrcodeUserDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupStatisticDTO;
import com.pcloud.book.group.dto.ClassifyDTO;
import com.pcloud.book.group.dto.GroupAndUserNumberDTO;
import com.pcloud.book.group.dto.GroupClassifyQrcodeDTO;
import com.pcloud.book.group.dto.GroupNameAndMaxSeqDTO;
import com.pcloud.book.group.dto.GroupQrcodeBaseDTO;
import com.pcloud.book.group.dto.GroupQrcodeInfoDTO;
import com.pcloud.book.group.dto.ProAssocGroupAndUserNumberDTO;
import com.pcloud.book.group.dto.QrcodeNameAndProIdDTO;
import com.pcloud.book.group.dto.WeixinQrcodeDTO;
import com.pcloud.book.group.dao.*;
import com.pcloud.book.group.dto.*;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.BookQrcodeUser;
import com.pcloud.book.group.entity.GroupQrcode;
......@@ -60,9 +54,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -122,6 +118,10 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
private GroupSet groupSet;
@Autowired
private BookGroupClassifyBiz bookGroupClassifyBiz;
@Autowired
private LearningReportBrowseRecordDao learningReportBrowseRecordDao;
@Autowired
private LearningReportTouchRecordDao learningReportTouchRecordDao;
@Override
@ParamLog("新增分类")
......@@ -859,4 +859,86 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
return pageBeanNew;
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("更新是否开启微学习报告")
@Override
public void updateHasOpenLearningReport(Long classifyId, Boolean hasOpenLearningReport, Long partyId) {
bookGroupClassifyDao.updateHasOpenLearningReport(classifyId,hasOpenLearningReport,partyId);
}
@ParamLog("获取群分类学习报告相关列表")
@Override
public PageBeanNew<ClassifyLearningReportDto> listClassifyForLearningReport(Integer currentPage, Integer numPerPage, String keyword, Long partyId) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("keyword", keyword);
paramMap.put("partyId", partyId);
PageBeanNew<ClassifyLearningReportDto> pageBeanNew = bookGroupClassifyDao.listPageNew(pageParam, paramMap, "listClassifyForLearningReport");
if (pageBeanNew == null) {
return new PageBeanNew<>(currentPage, numPerPage, new ArrayList<>());
}
//遍历填充标签
List<ClassifyLearningReportDto> list = pageBeanNew.getRecordList();
if (!ListUtils.isEmpty(list)) {
List<Long> labelIds = new ArrayList<>();
List<Long> classifyIds = new ArrayList<>();
for (ClassifyLearningReportDto classifyLearningReportDto : list) {
classifyIds.add(classifyLearningReportDto.getClassifyId());
if (classifyLearningReportDto.getProLabelId() != null) {
labelIds.add(classifyLearningReportDto.getProLabelId());
}
if (classifyLearningReportDto.getPurLabelId() != null) {
labelIds.add(classifyLearningReportDto.getPurLabelId());
}
if (classifyLearningReportDto.getDepLabelId() != null) {
labelIds.add(classifyLearningReportDto.getDepLabelId());
}
}
Map<Long, Integer> browseCountMap = new HashMap<>();
Map<Long, Integer> touchCountMap = new HashMap<>();
if (!ListUtils.isEmpty(classifyIds)) {
List<ClassifyLearningCountDto> browseCountList = learningReportBrowseRecordDao.getCountGroupByClassifyId(classifyIds);
List<ClassifyLearningCountDto> touchCountList = learningReportTouchRecordDao.getCountGroupByClassifyId(classifyIds);
for (ClassifyLearningCountDto classifyLearningCountDto:browseCountList){
browseCountMap.put(classifyLearningCountDto.getClassifyId(),classifyLearningCountDto.getCount());
}
for (ClassifyLearningCountDto classifyLearningCountDto:touchCountList){
touchCountMap.put(classifyLearningCountDto.getClassifyId(),classifyLearningCountDto.getCount());
}
}
Map<Long, String> labelMap = new HashMap<>();
if (!ListUtils.isEmpty(labelIds)) {
labelMap = ResponseHandleUtil.parseMap(labelService.getLabelName(labelIds), Long.class, String.class);
}
for (ClassifyLearningReportDto classifyLearningReportDto : list) {
if (!MapUtils.isEmpty(labelMap)) {
Long proLabelId = classifyLearningReportDto.getProLabelId();
if (proLabelId != null) {
classifyLearningReportDto.setProLabelName(labelMap.get(proLabelId));
}
Long purLabelId = classifyLearningReportDto.getPurLabelId();
if (purLabelId != null) {
classifyLearningReportDto.setPurLabelName(labelMap.get(purLabelId));
}
Long depLabelId = classifyLearningReportDto.getDepLabelId();
if (depLabelId != null) {
classifyLearningReportDto.setDepLabelName(labelMap.get(depLabelId));
}
}
Integer browseCount = browseCountMap.get(classifyLearningReportDto.getClassifyId());
if (browseCount == null) {
browseCount = 0;
}
Integer touchCount = touchCountMap.get(classifyLearningReportDto.getClassifyId());
if (touchCount == null) {
touchCount = 0;
}
classifyLearningReportDto.setLearningReportBrowseCount(browseCount);
classifyLearningReportDto.setLearningReportTouchCount(touchCount);
}
}
return pageBeanNew;
}
}
package com.pcloud.book.group.biz.impl;
import com.pcloud.analysisengine.wechatgroupan.dto.GroupBrowseDTO;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.analysisengine.WechatGroupAnConsr;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.consumer.trade.TradeConsr;
import com.pcloud.book.group.biz.LearningReportBiz;
import com.pcloud.book.group.dao.*;
import com.pcloud.book.group.dto.AppClickDTO;
import com.pcloud.book.group.dto.ClassifyDTO;
import com.pcloud.book.group.dto.LearningScoreDTO;
import com.pcloud.book.group.dto.UserLearningInfoDTO;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.entity.LearningReportBrowseRecord;
import com.pcloud.book.group.entity.LearningReportTouchRecord;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.facade.tradecenter.dto.SaleDetailByQrcodeDto;
import com.pcloud.readercenter.wechat.entity.WechatUser;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/23 19:49
**/
@Component("learningReportBiz")
public class LearningReportBizImpl implements LearningReportBiz {
@Autowired
private LearningReportBrowseRecordDao learningReportBrowseRecordDao;
@Autowired
private LearningReportTouchRecordDao learningReportTouchRecordDao;
@Autowired
private GroupQrcodeDao groupQrcodeDao;
@Autowired
private BookGroupClassifyDao bookGroupClassifyDao;
@Autowired
private AppClickRecordDao appClickRecordDao;
@Autowired
private AppConsr appConsr;
@Autowired
private ProductConsr productConsr;
@Autowired
private ReaderConsr readerConsr;
@Autowired
private WechatGroupAnConsr wechatGroupAnConsr;
@Autowired
private TradeConsr tradeConsr;
@Transactional(rollbackFor = Exception.class)
@ParamLog("新增学习报告浏览记录")
@Override
public Long createLearningReportBrowseRecord(LearningReportBrowseRecord learningReportBrowseRecord) {
learningReportBrowseRecordDao.insert(learningReportBrowseRecord);
return learningReportBrowseRecord.getId();
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("新增学习触发浏览记录")
@Override
public Long createLearningReportTouchRecord(String wxUserId, String wxGroupId) {
LearningReportTouchRecord learningReportTouchRecord = new LearningReportTouchRecord();
learningReportTouchRecord.setWxUserId(wxUserId);
GroupQrcode groupQrcode = groupQrcodeDao.getGroupQrcodeByGroupId(wxGroupId);
if (groupQrcode != null) {
learningReportTouchRecord.setQrcodeId(groupQrcode.getId());
Long classifyId = groupQrcode.getClassifyId();
learningReportTouchRecord.setClassifyId(classifyId);
if (classifyId != null) {
ClassifyDTO classifyDTO = bookGroupClassifyDao.getById(classifyId);
if (classifyDTO != null) {
learningReportTouchRecord.setBookGroupId(classifyDTO.getBookGroupId());
}
}
}
learningReportTouchRecordDao.insert(learningReportTouchRecord);
return learningReportTouchRecord.getId();
}
@ParamLog("获取最近学习")
@Override
public List<AppClickDTO> getRecentlyLearning(Long wechatUserId, Long qrcodeId) {
if (wechatUserId == null || qrcodeId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误!");
}
List<AppClickDTO> appClickDTOS = appClickRecordDao.getRecentlyClick(wechatUserId, qrcodeId, 2);
if (!ListUtils.isEmpty(appClickDTOS)) {
List<Long> appIds = new ArrayList<>();
List<Long> productIds = new ArrayList<>();
for (AppClickDTO appClickDTO : appClickDTOS) {
if ("APP".equalsIgnoreCase(appClickDTO.getServeType())) {
appIds.add(appClickDTO.getServeId());
}
if ("PRODUCT".equalsIgnoreCase(appClickDTO.getServeType())) {
productIds.add(appClickDTO.getServeId());
}
}
Map<Long, AppDto> appDtoMap = new HashMap<>();
if (!ListUtils.isEmpty(appIds)) {
appDtoMap = appConsr.mapByIds(appIds);
}
Map<Long, ProductDto> productDtoMap = new HashMap<>();
if (!ListUtils.isEmpty(productIds)) {
productDtoMap = productConsr.getProBasesByIds(productIds);
}
for (AppClickDTO appClickDTO : appClickDTOS) {
Long id = appClickDTO.getServeId();
String type = appClickDTO.getServeType();
if ("PRODUCT".equalsIgnoreCase(type)) {
ProductDto productDto = productDtoMap.get(id);
if (productDto != null) {
appClickDTO.setServeName(productDto.getProductName());
appClickDTO.setImage(productDto.getCoverImg());
ProductTypeDto productTypeDto = productDto.getProductTypeDto();
if (productTypeDto != null) {
appClickDTO.setTypeName(productTypeDto.getTypeName());
appClickDTO.setTypeCode(productTypeDto.getTypeCode());
}
}
}
if ("APP".equalsIgnoreCase(type)) {
AppDto appDto = appDtoMap.get(id);
if (appDto != null) {
appClickDTO.setTypeName(appDto.getTypeName());
appClickDTO.setServeName(appDto.getTitle());
appClickDTO.setImage(appDto.getSquareImg());
appClickDTO.setTypeCode(appDto.getTypeCode());
}
}
}
}
return appClickDTOS;
}
@ParamLog("获取学习元气值前五名")
@Override
public List<LearningScoreDTO> getLearningTopFive(Long qrcodeId) {
List<LearningScoreDTO> learningScoreDTOS = getLearningScoreDTOSortList(qrcodeId);
learningScoreDTOS = learningScoreDTOS.stream().limit(5).collect(Collectors.toList());
if (!ListUtils.isEmpty(learningScoreDTOS)) {
List<Long> fiveUserIds = learningScoreDTOS.stream().map(LearningScoreDTO::getWechatUserId).collect(Collectors.toList());
Map<Long, WechatUser> userMap = readerConsr.getUserList(fiveUserIds);
for (LearningScoreDTO learningScoreDTO : learningScoreDTOS) {
Long userId = learningScoreDTO.getWechatUserId();
WechatUser wechatUser = userMap.get(userId);
if (wechatUser != null) {
learningScoreDTO.setNickName(wechatUser.getWechatUserNickname());
learningScoreDTO.setHeadUrl(wechatUser.getWechatUserHeadurl());
}
}
}
return learningScoreDTOS;
}
@ParamLog("获取元气值全部排行")
private List<LearningScoreDTO> getLearningScoreDTOSortList(Long qrcodeId){
//获取浏览记录
List<GroupBrowseDTO> groupBrowseDTOS = wechatGroupAnConsr.getGroupBrowseList(qrcodeId);
Map<Long, Integer> browseMap = new HashMap<>();
for (GroupBrowseDTO groupBrowseDTO : groupBrowseDTOS) {
browseMap.put(groupBrowseDTO.getUserId(), groupBrowseDTO.getAllBrowseTimes());
}
//内部接口根据qrcodeId获取群应用和作品购买情况
List<SaleDetailByQrcodeDto> saleDetailByQrcodeDtos = tradeConsr.getSaleDetailByQrcodeId(qrcodeId);
Map<Long, Double> buyMap = new HashMap<>();
for (SaleDetailByQrcodeDto saleDetailByQrcodeDto:saleDetailByQrcodeDtos){
buyMap.put(saleDetailByQrcodeDto.getWechatUserId(),saleDetailByQrcodeDto.getAmount().doubleValue());
}
//计算
List<Long> userIds = new ArrayList<>();
userIds.addAll(browseMap.keySet());
userIds.addAll(buyMap.keySet());
userIds = userIds.stream().distinct().collect(Collectors.toList());
Map<Long, Integer> scoreMap = new HashMap<>();
for (Long userId : userIds) {
Integer score = 0;
Integer browseTime = browseMap.get(userId);
if (browseTime != null) {
score = score + browseTime / 60;
}
Double buyAmount = buyMap.get(userId);
if (buyAmount != null) {
BigDecimal bd = new BigDecimal(buyAmount).setScale(0, BigDecimal.ROUND_HALF_UP);
score = score + Integer.parseInt(bd.toString());
}
scoreMap.put(userId, score);
}
List<LearningScoreDTO> learningScoreDTOS = new ArrayList<>();
for (Long userId : userIds) {
Integer score = scoreMap.get(userId);
LearningScoreDTO learningScoreDTO = new LearningScoreDTO();
learningScoreDTO.setWechatUserId(userId);
learningScoreDTO.setScore(score);
learningScoreDTOS.add(learningScoreDTO);
}
learningScoreDTOS = learningScoreDTOS.stream().filter(s -> s.getScore() != null && s.getScore() > 0).sorted(Comparator.comparingInt(LearningScoreDTO::getScore).reversed()).collect(Collectors.toList());
return learningScoreDTOS;
}
@ParamLog("获取微信用户元气值")
@Override
public LearningScoreDTO getUserLearningSore(Long qrcodeId, Long wechatUserId) {
//获取浏览记录
GroupBrowseDTO groupBrowseDTO = wechatGroupAnConsr.getGroupBrowseForOne(qrcodeId, wechatUserId);
LearningScoreDTO learningScoreDTO = new LearningScoreDTO();
learningScoreDTO.setWechatUserId(wechatUserId);
//计算
Integer score = 0;
if (groupBrowseDTO != null) {
Integer browseTime = groupBrowseDTO.getAllBrowseTimes();
learningScoreDTO.setAllLearningTime(browseTime);
if (browseTime != null) {
score = score + browseTime / 60;
}
}
//交易内部接口获取购买情况
BigDecimal buyAmount = tradeConsr.getAmountByQrcodeId(qrcodeId,wechatUserId);
if (buyAmount != null) {
BigDecimal bd = buyAmount.setScale(0, BigDecimal.ROUND_HALF_UP);
score = score + Integer.parseInt(bd.toString());
}
learningScoreDTO.setScore(score);
WechatUser wechatUser = readerConsr.getWechatUser(wechatUserId);
if (wechatUser != null) {
learningScoreDTO.setNickName(wechatUser.getWechatUserNickname());
learningScoreDTO.setHeadUrl(wechatUser.getWechatUserHeadurl());
}
return learningScoreDTO;
}
@ParamLog("获取微信用户榜单")
@Override
public UserLearningInfoDTO getUserLearningInfo(Long qrcodeId, Long wechatUserId, String qrcodeUrlS) {
if (wechatUserId == null || qrcodeId == null || StringUtil.isEmpty(qrcodeUrlS)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误!");
}
UserLearningInfoDTO userLearningInfoDTO = new UserLearningInfoDTO();
String qrcodeUrl=QrcodeUtils.create(UrlUtils.getShortUrl4Own(qrcodeUrlS));
userLearningInfoDTO.setQrcodeUrl(qrcodeUrl);
LearningScoreDTO learningScoreDTO = getUserLearningSore(qrcodeId, wechatUserId);
if (learningScoreDTO != null) {
userLearningInfoDTO.setAllLearningTime(learningScoreDTO.getAllLearningTime());
userLearningInfoDTO.setHeadUrl(learningScoreDTO.getHeadUrl());
userLearningInfoDTO.setNickName(learningScoreDTO.getNickName());
userLearningInfoDTO.setScore(learningScoreDTO.getScore());
userLearningInfoDTO.setWechatUserId(wechatUserId);
}
Integer userNum = 0;
GroupQrcode groupQrcode = groupQrcodeDao.getById(qrcodeId);
if (groupQrcode != null) {
userNum = groupQrcode.getUserNumber();
}
List<LearningScoreDTO> learningScoreDTOSortList = getLearningScoreDTOSortList(qrcodeId);
Integer groupSort = learningScoreDTOSortList.size() + 1;
if (!ListUtils.isEmpty(learningScoreDTOSortList)) {
for (int i = 0; i < learningScoreDTOSortList.size(); i++) {
if (wechatUserId.equals(learningScoreDTOSortList.get(i).getWechatUserId())) {
groupSort = i + 1;
}
}
}
userLearningInfoDTO.setGroupSort(groupSort);
Double exceedPercent = 1.00D;
if (userNum != null && userNum > 0) {
exceedPercent = (userNum - groupSort) / userNum.doubleValue();
}
userLearningInfoDTO.setExceedPercent(exceedPercent);
return userLearningInfoDTO;
}
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.AppClickDTO;
import com.pcloud.book.group.dto.AppStatisticsDTO;
import com.pcloud.book.group.entity.AppClickRecord;
import com.pcloud.common.core.dao.BaseDao;
......@@ -11,4 +12,9 @@ public interface AppClickRecordDao extends BaseDao<AppClickRecord> {
* 根据作品或应用id集合获取统计
*/
List<AppStatisticsDTO> getClickStatisticsByServeIds(List<Long> serveIds, Long qrcodeId, Long bookGroupId);
/**
* 获取最近点击
*/
List<AppClickDTO> getRecentlyClick(Long wechatUserId, Long qrcodeId, Integer top);
}
......@@ -230,4 +230,10 @@ public interface BookGroupClassifyDao extends BaseDao<BookGroupClassify> {
List<ClassifyKeywordDTO> getClassifyStatistics(Long bookId);
GroupClassifyQrcodeDTO getClassifyQrcodeInfoByName(String weixinGroupName);
/**
* 更新是否开启学习报告
*/
void updateHasOpenLearningReport(Long classifyId, Boolean hasOpenLearningReport, Long partyId);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.ClassifyLearningCountDto;
import com.pcloud.book.group.entity.LearningReportBrowseRecord;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface LearningReportBrowseRecordDao extends BaseDao<LearningReportBrowseRecord> {
List<ClassifyLearningCountDto> getCountGroupByClassifyId(List<Long> classifyIds);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.ClassifyLearningCountDto;
import com.pcloud.book.group.entity.LearningReportTouchRecord;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface LearningReportTouchRecordDao extends BaseDao<LearningReportTouchRecord> {
List<ClassifyLearningCountDto> getCountGroupByClassifyId(List<Long> classifyIds);
}
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.AppClickRecordDao;
import com.pcloud.book.group.dto.AppClickDTO;
import com.pcloud.book.group.dto.AppStatisticsDTO;
import com.pcloud.book.group.entity.AppClickRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
......@@ -25,4 +26,13 @@ public class AppClickRecordDaoImpl extends BaseDaoImpl<AppClickRecord> implement
map.put("serveIds", serveIds);
return this.getSqlSession().selectList(this.getStatement("getClickStatisticsByServeIds"), map);
}
@Override
public List<AppClickDTO> getRecentlyClick(Long wechatUserId, Long qrcodeId, Integer top) {
Map<String, Object> map = new HashMap<>();
map.put("qrcodeId", qrcodeId);
map.put("wechatUserId", wechatUserId);
map.put("top", top);
return this.getSqlSession().selectList(this.getStatement("getRecentlyClick"), map);
}
}
......@@ -197,4 +197,13 @@ public class BookGroupClassifyDaoImpl extends BaseDaoImpl<BookGroupClassify> imp
public GroupClassifyQrcodeDTO getClassifyQrcodeInfoByName(String weixinGroupName) {
return this.getSessionTemplate().selectOne(getStatement("getClassifyQrcodeInfoByName"), weixinGroupName);
}
@Override
public void updateHasOpenLearningReport(Long classifyId, Boolean hasOpenLearningReport, Long partyId) {
Map<String, Object> paramMap = new HashMap();
paramMap.put("classifyId", classifyId);
paramMap.put("hasOpenLearningReport", hasOpenLearningReport);
paramMap.put("partyId", partyId);
this.getSqlSession().update(this.getStatement("updateHasOpenLearningReport"), paramMap);
}
}
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.LearningReportBrowseRecordDao;
import com.pcloud.book.group.dao.LearningReportTouchRecordDao;
import com.pcloud.book.group.dto.ClassifyLearningCountDto;
import com.pcloud.book.group.entity.LearningReportBrowseRecord;
import com.pcloud.book.group.entity.LearningReportTouchRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("learningReportBrowseRecord")
public class LearningReportBrowseRecordDaoImpl extends BaseDaoImpl<LearningReportBrowseRecord> implements LearningReportBrowseRecordDao {
@Override
public List<ClassifyLearningCountDto> getCountGroupByClassifyId(List<Long> list) {
return this.getSqlSession().selectList(this.getStatement("getCountGroupByClassifyId"), list);
}
}
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.LearningReportTouchRecordDao;
import com.pcloud.book.group.dto.ClassifyLearningCountDto;
import com.pcloud.book.group.entity.LearningReportTouchRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("learningReportTouchRecord")
public class LearningReportTouchRecordDaoImpl extends BaseDaoImpl<LearningReportTouchRecord> implements LearningReportTouchRecordDao {
@Override
public List<ClassifyLearningCountDto> getCountGroupByClassifyId(List<Long> list) {
return this.getSqlSession().selectList(this.getStatement("getCountGroupByClassifyId"), list);
}
}
package com.pcloud.book.group.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/24 17:55
**/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AppClickDTO implements Serializable {
private static final long serialVersionUID = 7389809828237942796L;
@ApiModelProperty("社群书id")
private Long bookGroupId;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("群id")
private Long qrcodeId;
@ApiModelProperty("微信群id")
private String weixinGroupId;
@ApiModelProperty("应用或作品id")
private Long serveId;
@ApiModelProperty("应用或作品名称")
private String serveName;
@ApiModelProperty("类型")
private String serveType;
@ApiModelProperty("应用或作品类型名称")
private String typeName;
@ApiModelProperty("类型code")
private String typeCode;
@ApiModelProperty("应用或作品图片")
private String image;
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public String getWeixinGroupId() {
return weixinGroupId;
}
public void setWeixinGroupId(String weixinGroupId) {
this.weixinGroupId = weixinGroupId;
}
public Long getServeId() {
return serveId;
}
public void setServeId(Long serveId) {
this.serveId = serveId;
}
public String getServeName() {
return serveName;
}
public void setServeName(String serveName) {
this.serveName = serveName;
}
public String getServeType() {
return serveType;
}
public void setServeType(String serveType) {
this.serveType = serveType;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public String getTypeCode() {
return typeCode;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
@Override
public String toString() {
return "AppClickDTO{" +
"bookGroupId=" + bookGroupId +
", classifyId=" + classifyId +
", qrcodeId=" + qrcodeId +
", weixinGroupId='" + weixinGroupId + '\'' +
", serveId=" + serveId +
", serveName='" + serveName + '\'' +
", serveType='" + serveType + '\'' +
", typeName='" + typeName + '\'' +
", typeCode='" + typeCode + '\'' +
", image='" + image + '\'' +
'}';
}
}
package com.pcloud.book.group.dto;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/23 20:10
**/
public class ClassifyLearningCountDto implements Serializable {
private static final long serialVersionUID = -4629088587616450517L;
private Long classifyId;
private Integer count;
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
@Override
public String toString() {
return "ClassifyLearningCountDto{" +
"classifyId=" + classifyId +
", count=" + count +
'}';
}
}
package com.pcloud.book.group.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/23 18:17
**/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ClassifyLearningReportDto implements Serializable {
private static final long serialVersionUID = -5175893581465763555L;
@ApiModelProperty("分类标识")
private Long classifyId;
@ApiModelProperty("图书标识")
private Long bookId;
@ApiModelProperty("图书名称")
private String bookName;
@ApiModelProperty("群分类")
private String classify;
@ApiModelProperty("社群码标识")
private String bookGroupId;
@ApiModelProperty("群二维码名称")
private String groupQrcodeName;
@ApiModelProperty("专业标签ID")
private Long proLabelId;
@ApiModelProperty("深度标签ID")
private Long depLabelId;
@ApiModelProperty("目的标签ID")
private Long purLabelId;
@ApiModelProperty("专业标签名称")
private String proLabelName;
@ApiModelProperty("深度标签名称")
private String depLabelName;
@ApiModelProperty("目的标签名称")
private String purLabelName;
@ApiModelProperty("学习报告触发次数")
private Integer learningReportTouchCount;
@ApiModelProperty("学习报告浏览次数")
private Integer learningReportBrowseCount;
@ApiModelProperty("是否开启学习报告")
private Boolean hasOpenLearningReport;
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
public String getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(String bookGroupId) {
this.bookGroupId = bookGroupId;
}
public String getGroupQrcodeName() {
return groupQrcodeName;
}
public void setGroupQrcodeName(String groupQrcodeName) {
this.groupQrcodeName = groupQrcodeName;
}
public Long getProLabelId() {
return proLabelId;
}
public void setProLabelId(Long proLabelId) {
this.proLabelId = proLabelId;
}
public Long getDepLabelId() {
return depLabelId;
}
public void setDepLabelId(Long depLabelId) {
this.depLabelId = depLabelId;
}
public Long getPurLabelId() {
return purLabelId;
}
public void setPurLabelId(Long purLabelId) {
this.purLabelId = purLabelId;
}
public String getProLabelName() {
return proLabelName;
}
public void setProLabelName(String proLabelName) {
this.proLabelName = proLabelName;
}
public String getDepLabelName() {
return depLabelName;
}
public void setDepLabelName(String depLabelName) {
this.depLabelName = depLabelName;
}
public String getPurLabelName() {
return purLabelName;
}
public void setPurLabelName(String purLabelName) {
this.purLabelName = purLabelName;
}
public Integer getLearningReportTouchCount() {
return learningReportTouchCount;
}
public void setLearningReportTouchCount(Integer learningReportTouchCount) {
this.learningReportTouchCount = learningReportTouchCount;
}
public Integer getLearningReportBrowseCount() {
return learningReportBrowseCount;
}
public void setLearningReportBrowseCount(Integer learningReportBrowseCount) {
this.learningReportBrowseCount = learningReportBrowseCount;
}
public Boolean getHasOpenLearningReport() {
return hasOpenLearningReport;
}
public void setHasOpenLearningReport(Boolean hasOpenLearningReport) {
this.hasOpenLearningReport = hasOpenLearningReport;
}
@Override
public String toString() {
return "ClassifyLearningReportDto{" +
"classifyId=" + classifyId +
", bookId=" + bookId +
", bookName='" + bookName + '\'' +
", classify='" + classify + '\'' +
", bookGroupId='" + bookGroupId + '\'' +
", groupQrcodeName='" + groupQrcodeName + '\'' +
", proLabelId=" + proLabelId +
", depLabelId=" + depLabelId +
", purLabelId=" + purLabelId +
", proLabelName='" + proLabelName + '\'' +
", depLabelName='" + depLabelName + '\'' +
", purLabelName='" + purLabelName + '\'' +
", learningReportTouchCount=" + learningReportTouchCount +
", learningReportBrowseCount=" + learningReportBrowseCount +
", hasOpenLearningReport=" + hasOpenLearningReport +
'}';
}
}
package com.pcloud.book.group.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/24 15:07
**/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LearningScoreDTO implements Serializable {
private static final long serialVersionUID = 3667715938819008003L;
@ApiModelProperty("微信id")
private Long wechatUserId;
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("头像")
private String headUrl;
@ApiModelProperty("元气值")
private Integer score;
@ApiModelProperty("总学习时长")
private Integer allLearningTime;
public Long getWechatUserId() {
return wechatUserId;
}
public void setWechatUserId(Long wechatUserId) {
this.wechatUserId = wechatUserId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getHeadUrl() {
return headUrl;
}
public void setHeadUrl(String headUrl) {
this.headUrl = headUrl;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public Integer getAllLearningTime() {
return allLearningTime;
}
public void setAllLearningTime(Integer allLearningTime) {
this.allLearningTime = allLearningTime;
}
@Override
public String toString() {
return "LearningScoreDTO{" +
"wechatUserId=" + wechatUserId +
", nickName='" + nickName + '\'' +
", headUrl='" + headUrl + '\'' +
", score=" + score +
", allLearningTime=" + allLearningTime +
'}';
}
}
package com.pcloud.book.group.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/25 9:50
**/
@ApiModel("学习报告")
public class UserLearningInfoDTO implements Serializable {
private static final long serialVersionUID = 7734297462091875084L;
@ApiModelProperty("微信id")
private Long wechatUserId;
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("头像")
private String headUrl;
@ApiModelProperty("元气值")
private Integer score;
@ApiModelProperty("总学习时长")
private Integer allLearningTime;
@ApiModelProperty("群排名")
private Integer groupSort;
@ApiModelProperty("超过群成员百分比")
private Double exceedPercent;
@ApiModelProperty("二维码链接")
private String qrcodeUrl;
public Long getWechatUserId() {
return wechatUserId;
}
public void setWechatUserId(Long wechatUserId) {
this.wechatUserId = wechatUserId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getHeadUrl() {
return headUrl;
}
public void setHeadUrl(String headUrl) {
this.headUrl = headUrl;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public Integer getAllLearningTime() {
return allLearningTime;
}
public void setAllLearningTime(Integer allLearningTime) {
this.allLearningTime = allLearningTime;
}
public Integer getGroupSort() {
return groupSort;
}
public void setGroupSort(Integer groupSort) {
this.groupSort = groupSort;
}
public Double getExceedPercent() {
return exceedPercent;
}
public void setExceedPercent(Double exceedPercent) {
this.exceedPercent = exceedPercent;
}
public String getQrcodeUrl() {
return qrcodeUrl;
}
public void setQrcodeUrl(String qrcodeUrl) {
this.qrcodeUrl = qrcodeUrl;
}
@Override
public String toString() {
return "UserLearningInfoDTO{" +
"wechatUserId=" + wechatUserId +
", nickName='" + nickName + '\'' +
", headUrl='" + headUrl + '\'' +
", score=" + score +
", allLearningTime=" + allLearningTime +
", groupSort=" + groupSort +
", exceedPercent=" + exceedPercent +
", qrcodeUrl='" + qrcodeUrl + '\'' +
'}';
}
}
......@@ -29,6 +29,9 @@ public class AppClickRecord extends BaseEntity {
@ApiModelProperty("类型")
private String serveType;
@ApiModelProperty("微信id")
private Long wechatUserId;
public Long getBookGroupId() {
return bookGroupId;
}
......@@ -78,6 +81,14 @@ public class AppClickRecord extends BaseEntity {
this.serveType = serveType;
}
public Long getWechatUserId() {
return wechatUserId;
}
public void setWechatUserId(Long wechatUserId) {
this.wechatUserId = wechatUserId;
}
@Override
public String toString() {
return "AppClickRecord{" +
......@@ -87,6 +98,7 @@ public class AppClickRecord extends BaseEntity {
", weixinGroupId='" + weixinGroupId + '\'' +
", serveId=" + serveId +
", serveType='" + serveType + '\'' +
", wechatUserId=" + wechatUserId +
"} " + super.toString();
}
}
package com.pcloud.book.group.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/5/29 17:32
**/
public class LearningReportBrowseRecord extends BaseEntity {
private static final long serialVersionUID = 8764621621846783953L;
@ApiModelProperty("群id")
private Long qrcodeId;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("创建人")
private Long createUser;
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
@Override
public String toString() {
return "LearningReportBrowseRecord{" +
"qrcodeId=" + qrcodeId +
", classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", createUser=" + createUser +
"} " + super.toString();
}
}
package com.pcloud.book.group.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/5/29 17:32
**/
public class LearningReportTouchRecord extends BaseEntity {
private static final long serialVersionUID = -6649480862036544354L;
@ApiModelProperty("群id")
private Long qrcodeId;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("微信用户id")
private String wxUserId;
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId;
}
@Override
public String toString() {
return "LearningReportTouchRecord{" +
"qrcodeId=" + qrcodeId +
", classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", wxUserId='" + wxUserId + '\'' +
"} " + super.toString();
}
}
......@@ -6,6 +6,7 @@ import com.pcloud.common.exceptions.BizException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -15,6 +16,7 @@ public interface AppClickRecordFacade {
@ApiOperation("新增应用作品点击记录")
@PostMapping("createAppClickRecord")
ResponseDto<?> createAppClickRecord(
@CookieValue("userInfo") String userInfo,
@RequestBody @ApiParam("应用点击记录模型") AppClickRecord appClickRecord
) throws BizException;
......
......@@ -155,4 +155,21 @@ public interface BookGroupClassifyFacade {
@PostMapping("listAdviserClassify")
ResponseDto<PageBeanNew<AdviserClassifyVO>> listAdviserClassify(@RequestHeader("token") String token, @RequestBody AdviserClassifyParam adviserClassifyParam) throws PermissionException;
@ApiOperation("关闭或开启学习报告")
@GetMapping("updateHasOpenLearningReport")
ResponseDto<?> updateHasOpenLearningReport(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("classifyId") @ApiParam("分类id") Long classifyId,
@RequestParam("hasOpenLearningReport") @ApiParam("是否开启学习报告") Boolean hasOpenLearningReport
) throws BizException, PermissionException;
@ApiOperation("获取群分类学习报告相关列表")
@GetMapping("listClassifyForLearningReport")
ResponseDto<?> listClassifyForLearningReport(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage,
@RequestParam(value = "keyword", required = false) @ApiParam("关键词") String keyword
) throws BizException, PermissionException;
}
package com.pcloud.book.group.facade;
import com.pcloud.book.group.entity.LearningReportBrowseRecord;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
@Api(description = "学习报告")
public interface LearningReportFacade {
@ApiOperation("新增学习报告浏览记录")
@PostMapping("createLearningReportBrowseRecord")
ResponseDto<?> createLearningReportBrowseRecord(
@CookieValue("userInfo") String userInfo,
@RequestBody @ApiParam("学习报告浏览记录") LearningReportBrowseRecord learningReportBrowseRecord
) throws BizException, PermissionException;
@ApiOperation("获取最近学习记录")
@GetMapping("getRecentlyLearning")
ResponseDto<?> getRecentlyLearning(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId
) throws BizException, PermissionException;
@ApiOperation("获取学习元气值前五名")
@GetMapping("getLearningTopFive")
ResponseDto<?> getLearningTopFive(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId
) throws BizException, PermissionException;
@ApiOperation("获取微信用户元气值")
@GetMapping("getUserLearningSore")
ResponseDto<?> getUserLearningSore(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId
) throws BizException, PermissionException;
@ApiOperation("获取微信用户榜单")
@GetMapping("getUserLearningInfo")
ResponseDto<?> getUserLearningInfo(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId,
@RequestParam @ApiParam("生成二维码的链接") String qrcodeUrlS
) throws BizException, PermissionException;
}
......@@ -6,13 +6,11 @@ import com.pcloud.book.group.entity.AppClickRecord;
import com.pcloud.book.group.facade.AppClickRecordFacade;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @Description
......@@ -30,11 +28,14 @@ public class AppClickRecordFacadeImpl implements AppClickRecordFacade {
@PostMapping("createAppClickRecord")
@Override
public ResponseDto<?> createAppClickRecord(
@CookieValue("userInfo") String userInfo,
@RequestBody @ApiParam("应用点击记录模型") AppClickRecord appClickRecord
) throws BizException {
if (appClickRecord==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数为空!");
}
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appClickRecord.setWechatUserId(wechatUserId);
return new ResponseDto<>(appClickRecordBiz.createAppClickRecord(appClickRecord));
}
}
......@@ -10,6 +10,7 @@ import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
......@@ -157,4 +158,30 @@ public class BookGroupClassifyFacadeImpl implements BookGroupClassifyFacade {
return new ResponseDto<>(bookGroupClassifyBiz.listAdviserClassify(adviserId, adviserClassifyParam));
}
@ApiOperation("关闭或开启学习报告")
@GetMapping("updateHasOpenLearningReport")
@Override
public ResponseDto<?> updateHasOpenLearningReport(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("classifyId") @ApiParam("分类id") Long classifyId,
@RequestParam("hasOpenLearningReport") @ApiParam("是否开启学习报告") Boolean hasOpenLearningReport
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookGroupClassifyBiz.updateHasOpenLearningReport(classifyId,hasOpenLearningReport,partyId);
return new ResponseDto<>();
}
@ApiOperation("获取群分类学习报告相关列表")
@GetMapping("listClassifyForLearningReport")
@Override
public ResponseDto<?> listClassifyForLearningReport(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage,
@RequestParam(value = "keyword", required = false) @ApiParam("关键词") String keyword
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(bookGroupClassifyBiz.listClassifyForLearningReport(currentPage,numPerPage,keyword,partyId));
}
}
package com.pcloud.book.group.facade.impl;
import com.pcloud.book.group.biz.LearningReportBiz;
import com.pcloud.book.group.entity.LearningReportBrowseRecord;
import com.pcloud.book.group.facade.LearningReportFacade;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController("learningReportFacade")
@RequestMapping("learningReport")
public class LearningReportFacadeImpl implements LearningReportFacade {
@Autowired
private LearningReportBiz learningReportBiz;
@ApiOperation("新增学习报告浏览记录")
@PostMapping("createLearningReportBrowseRecord")
@Override
public ResponseDto<?> createLearningReportBrowseRecord(
@CookieValue("userInfo") String userInfo,
@RequestBody @ApiParam("学习报告浏览记录") LearningReportBrowseRecord learningReportBrowseRecord
) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
learningReportBrowseRecord.setCreateUser(wechatUserId);
return new ResponseDto<>(learningReportBiz.createLearningReportBrowseRecord(learningReportBrowseRecord));
}
@ApiOperation("获取最近学习记录")
@GetMapping("getRecentlyLearning")
@Override
public ResponseDto<?> getRecentlyLearning(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId
) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(learningReportBiz.getRecentlyLearning(wechatUserId,qrcodeId));
}
@ApiOperation("获取学习元气值前五名")
@GetMapping("getLearningTopFive")
@Override
public ResponseDto<?> getLearningTopFive(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId
) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(learningReportBiz.getLearningTopFive(qrcodeId));
}
@ApiOperation("获取微信用户元气值")
@GetMapping("getUserLearningSore")
@Override
public ResponseDto<?> getUserLearningSore(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId
) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(learningReportBiz.getUserLearningSore(qrcodeId, wechatUserId));
}
@ApiOperation("获取微信用户榜单")
@GetMapping("getUserLearningInfo")
@Override
public ResponseDto<?> getUserLearningInfo(
@CookieValue("userInfo") String userInfo,
@RequestParam @ApiParam("群id") Long qrcodeId,
@RequestParam @ApiParam("生成二维码的链接") String qrcodeUrlS
) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(learningReportBiz.getUserLearningInfo(qrcodeId, wechatUserId,qrcodeUrlS));
}
}
......@@ -283,6 +283,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
}
//获取关键词信息(改成10个了)
SendWeixinRequestTools.sendKeywordsInfo(keywords, robotId, weixinGroupId);
//如果设置了群学习报告,加一个群学习报告的关键词
pushLearningReport(classifyQrcodeInfo,robotId, weixinGroupId);
if (bookGuide != null && bookGuide.getIsRecommend() != null && bookGuide.getIsRecommend() == 1) {
//推送公众号消息
SendWeixinRequestTools.sendAccountMessage(weixinGroupId, bookGuide.getRecommendLanguage(), robotId, wechatInfo);
......@@ -314,6 +316,13 @@ public class BookGuideBizImpl implements BookGuideBiz {
}
}
@ParamLog("推关学习报告键词消息")
private void pushLearningReport(GroupClassifyQrcodeDTO classifyQrcodeInfo, String robotId, String weixinGroupId) {
if (classifyQrcodeInfo.getHasOpenLearningReport() != null && classifyQrcodeInfo.getHasOpenLearningReport()) {
SendWeixinRequestTools.sendTextMessage("关键词【学习报告】\n 获取个人专属学习报告,与群成员PK元气值", robotId, weixinGroupId);
}
}
@Override
public Map<String, Object> getGuideMessage(String weixinGroupId, String wexinGroupName) {
Map<String, Object> map = new HashMap<>();
......
......@@ -65,4 +65,9 @@ public class MQTopicConumer {
*/
public static final String PRODUCT_UPDATE = PREFIX + MQTopicProducer.PRODUCT_UPDATE;
/**
* 微信群学习报告
*/
public static final String WXGROUP_LEARNING_REPORT = PREFIX + MQTopicProducer.WXGROUP_LEARNING_REPORT;
}
package com.pcloud.book.mq.topic;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.biz.LearningReportBiz;
import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.group.dao.BookGroupClassifyDao;
import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.dto.BookWxQrcodeDTO;
import com.pcloud.book.group.dto.GroupClassifyQrcodeDTO;
import com.pcloud.book.group.dto.LearningScoreDTO;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.facade.shareimage.dto.HtmlDto;
import com.pcloud.facade.shareimage.facade.Htm2ImgService;
import com.pcloud.wechatgroup.message.dto.GroupLearningReportDTO;
import com.sdk.wxgroup.SendPicMessageVO;
import com.sdk.wxgroup.SendTextMessageVO;
import com.sdk.wxgroup.WxGroupSDK;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Component
@RabbitListener(queues = MQTopicConumer.WXGROUP_LEARNING_REPORT)
public class WXGroupLearningReportListener {
private static final Logger LOGGER = LoggerFactory.getLogger(WXGroupLearningReportListener.class);
@Autowired
private LearningReportBiz learningReportBiz;
@Autowired
private GroupQrcodeDao groupQrcodeDao;
@Autowired
private Htm2ImgService htm2ImgService;
@Autowired
private WechatGroupConsr wechatGroupConsr;
@Autowired
private BookGroupClassifyDao bookGroupClassifyDao;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private WeixinQrcodeBiz weixinQrcodeBiz;
@ParamLog("接收学习报告topic")
@RabbitHandler
public void onMessage(GroupLearningReportDTO groupLearningReportDTO) throws BizException {
try {
if (groupLearningReportDTO == null
|| groupLearningReportDTO.getWechatGroupId() == null
|| groupLearningReportDTO.getWechatUserId() == null)
return;
String wechatUserId = groupLearningReportDTO.getWechatUserId();
String wechatGroupId = groupLearningReportDTO.getWechatGroupId();
//新增触发记录
learningReportBiz.createLearningReportTouchRecord(wechatUserId, wechatGroupId);
//发送报告等
GroupQrcode groupQrcode = groupQrcodeDao.getGroupQrcodeByGroupId(wechatGroupId);
if (groupQrcode == null) {
LOGGER.info("没找到该群" + wechatGroupId);
return;
}
GroupClassifyQrcodeDTO groupClassifyQrcodeDTO = bookGroupClassifyDao.getClassifyQrcodeInfo(wechatGroupId);
if (groupClassifyQrcodeDTO == null) {
LOGGER.info("没找到该分类" + wechatGroupId);
return;
}
if (groupClassifyQrcodeDTO.getHasOpenLearningReport() == null || !groupClassifyQrcodeDTO.getHasOpenLearningReport()) {
LOGGER.info("没找设置学习报告" + wechatGroupId);
return;
}
Long groupQrcodeId = groupQrcode.getId();
List<LearningScoreDTO> learningScoreDTOS = learningReportBiz.getLearningTopFive(groupQrcodeId);
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(groupClassifyQrcodeDTO.getChannelId());
String url = "/other/grouppk?book_group_id=" + groupClassifyQrcodeDTO.getBookGroupId() + "&classify_id=" + groupClassifyQrcodeDTO.getClassifyId() + "&qrcode_id=" + groupQrcodeId;
String resultUrl = accountSettingDto.getProtocol() + accountSettingDto.getDomain() + "/W" + accountSettingDto.getAccountSettingId() + "/C" + groupClassifyQrcodeDTO.getChannelId() + url;
resultUrl=UrlUtils.getShortUrl4Own(resultUrl);
String qrcodeUrl = QrcodeUtils.create(resultUrl);
if (qrcodeUrl.contains("https://oss.5rs.me")) {
qrcodeUrl = qrcodeUrl.replace("https://oss.5rs.me", "https://file.5rs.me");
} else if (qrcodeUrl.contains("http://oss.5rs.me")) {
qrcodeUrl = qrcodeUrl.replace("http://oss.5rs.me", "http://file.5rs.me");
}
String imageUrl = getPic(learningScoreDTOS,qrcodeUrl);
String alt = wechatGroupConsr.getRobotIdByGroupId(wechatGroupId);
if (StringUtil.isEmpty(alt)) {
return;
}
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setGroupId(wechatGroupId);
sendTextMessageVO.setAltId(alt);
sendTextMessageVO.setContent("个人专属学习报告,及群成员元气排行榜。点击获取" + resultUrl);
LOGGER.info("发送文字消息开始"+sendTextMessageVO.toString());
WxGroupSDK.sendTextMessage(sendTextMessageVO);
LOGGER.info("发送文字消息结束"+sendTextMessageVO.toString());
SendPicMessageVO sendPicMessageVO = new SendPicMessageVO();
sendPicMessageVO.setPicUrl(imageUrl);
sendPicMessageVO.setGroupId(wechatGroupId);
sendPicMessageVO.setAltId(alt);
LOGGER.info("发送分享图消息开始"+sendTextMessageVO.toString());
WxGroupSDK.sendPicMessage(sendPicMessageVO);
LOGGER.info("发送分享图消息开始"+sendTextMessageVO.toString());
} catch (Exception e) {
LOGGER.error("接收学习报告topic失败" + e.getMessage(), e);
}
}
@ParamLog("获取图片")
private String getPic(List<LearningScoreDTO> learningScoreDTOS, String qrcodeUrl) {
String list="";
for (LearningScoreDTO learningScoreDTO:learningScoreDTOS){
String headUrl = learningScoreDTO.getHeadUrl();
if (headUrl.contains("https://oss.5rs.me")) {
headUrl = headUrl.replace("https://oss.5rs.me", "https://file.5rs.me");
} else if (headUrl.contains("http://oss.5rs.me")) {
headUrl = headUrl.replace("http://oss.5rs.me", "http://file.5rs.me");
}
String s1 = "{\n" +
" headPic: '" + headUrl + "?x-oss-process=image/auto-orient,0/resize,p_100',\n" +
" nickName: '" + learningScoreDTO.getNickName() + "',\n" +
" strength: " + learningScoreDTO.getScore() + "\n" +
" }";
list = list + "," + s1;
}
String yesterday=DateUtils.getYesterday();
String mo=yesterday.substring(5,7);
String da=yesterday.substring(8,10);
String s3="<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"\n" +
"<head>\n" +
" <meta charset=\"gbk\">\n" +
" <title>Document</title>\n" +
" <style>\n" +
" * {\n" +
" margin: 0;\n" +
" padding: 0;\n" +
" box-sizing: border-box;\n" +
" font-family: '微软雅黑', Arial, Helvetica, sans-serif;\n" +
" }\n" +
" th {\n" +
" font-weight: normal;\n" +
" }\n" +
"\n" +
" .group-rank {\n" +
" position: relative;\n" +
" width: 750px;\n" +
" height: 1334px;\n" +
" padding: 40px 32px 30px;\n" +
" background: #f5f4f4 url(https://file.5rs.me/oss/uploadfe/png/8021a28c21a36b31e2d47cb1cbdf673b.png) top / 750px no-repeat;\n" +
" }\n" +
"\n" +
" .group-rank-header {\n" +
" color: #fff;\n" +
" }\n" +
"\n" +
" .group-rank-header .title {\n" +
" font-size: 125px;\n" +
" }\n" +
"\n" +
" .group-rank-header .tips {\n" +
" font-size: 31px;\n" +
" }\n" +
"\n" +
" .group-rank-list,\n" +
" .group-rank-help {\n" +
" overflow: hidden;\n" +
" border-radius: 16px;\n" +
" margin-top: 50px;\n" +
" background-color: #fffdfb;\n" +
" box-shadow: 0px 14px 70px 0px rgba(26, 21, 15, 0.1);\n" +
" }\n" +
"\n" +
" .group-rank-list {\n" +
" height: 686px;\n" +
" }\n" +
"\n" +
" .group-rank-list table {\n" +
" width: 100%;\n" +
" table-layout: fixed;\n" +
" border-spacing: 0;\n" +
" }\n" +
"\n" +
" .group-rank-list table thead tr {\n" +
" height: 67px;\n" +
" font-size: 24px;\n" +
" color: #a19280;\n" +
" background-color: #fff6ed;\n" +
" }\n" +
"\n" +
" .group-rank-list table tbody tr {\n" +
" height: 120px;\n" +
" text-align: center;\n" +
" }\n" +
"\n" +
" .group-rank-list table tbody tr td .index::after {\n" +
" content: attr(data-index);\n" +
" font-size: 28px;\n" +
" color: #999;\n" +
" }\n" +
"\n" +
" .group-rank-list table tbody tr:nth-child(1) td .index::after {\n" +
" content: url(https://file.5rs.me/oss/uploadfe/png/aa572981a172e47b974b62584cec584f.png?x-oss-process=image/auto-orient,0/resize,p_38);\n" +
" }\n" +
"\n" +
" .group-rank-list table tbody tr:nth-child(2) td .index::after {\n" +
" content: url(https://file.5rs.me/oss/uploadfe/png/24ff8ea2c40a4da97ce6d9f4cce7a599.png?x-oss-process=image/auto-orient,0/resize,p_38);\n" +
" }\n" +
"\n" +
" .group-rank-list table tbody tr:nth-child(3) td .index::after {\n" +
" content: url(https://file.5rs.me/oss/uploadfe/png/1c01dec272bef14c2a4d495042c44cd8.png?x-oss-process=image/auto-orient,0/resize,p_38);\n" +
" }\n" +
"\n" +
" .headPic {\n" +
" border: 1px solid #eee;\n" +
" border-radius: 50%;\n" +
" }\n" +
"\n" +
" .nickName {\n" +
" text-overflow: ellipsis;\n" +
" white-space: nowrap;\n" +
" overflow: hidden;\n" +
" }\n" +
"\n" +
" .nickName,\n" +
" .strength {\n" +
" color: #442d12;\n" +
" font-size: 30px;\n" +
" }\n" +
"\n" +
" .group-rank-help {\n" +
" display: flex;\n" +
" height: 280px;\n" +
" padding: 30px;\n" +
" }\n" +
"\n" +
" .left-content {\n" +
" width: 400px;\n" +
" }\n" +
"\n" +
" .right-content {\n" +
" width: 190px;\n" +
" margin-left: 30px;\n" +
" }\n" +
"\n" +
" .left-content .question {\n" +
" margin-bottom: 35px;\n" +
" font-size: 36px;\n" +
" line-height: 32px;\n" +
" letter-spacing: 1px;\n" +
" color: #442d12;\n" +
" }\n" +
"\n" +
" .left-content .answer {\n" +
" position: relative;\n" +
" padding-left: 30px;\n" +
" font-size: 28px;\n" +
" line-height: 46px;\n" +
" color: #75542f;\n" +
" }\n" +
"\n" +
" .left-content .answer::before {\n" +
" content: '';\n" +
" position: absolute;\n" +
" top: 15px;\n" +
" left: 0;\n" +
" width: 10px;\n" +
" height: 10px;\n" +
" border-radius: 50%;\n" +
" background-color: currentColor;\n" +
" }\n" +
"\n" +
" .right-content .qrcode {\n" +
" width: 172px;\n" +
" height: 176px;\n" +
" padding: 12px 0;\n" +
" text-align: center;\n" +
" background-color: #fffdfb;\n" +
" box-shadow: 0px 14px 70px 0px rgba(26, 21, 15, 0.1);\n" +
" margin: 0 auto;\n" +
" }\n" +
"\n" +
" .right-content .qrcode img {\n" +
" line-height: 176px;\n" +
" }\n" +
"\n" +
" .right-content p {\n" +
" text-align: center;\n" +
" margin-top: 15px;\n" +
" font-size: 22px;\n" +
" line-height: 22px;\n" +
" color: #442d12;\n" +
" }\n" +
" </style>\n" +
"</head>\n" +
"\n" +
"<body>\n" +
" <div class=\"group-rank\">\n" +
" <div class=\"group-rank-header\">\n" +
" <div class=\"title\">排行榜</div>\n" +
" <p class=\"tips\">数据截止于"+mo+"月"+da+"日 24:00</p>\n" +
" </div>\n" +
" <div class=\"group-rank-list\">\n" +
" <table>\n" +
" <colgroup>\n" +
" <col width=\"100\">\n" +
" <col width=\"100\">\n" +
" <col>\n" +
" <col width=\"120\">\n" +
" </colgroup>\n" +
" <thead>\n" +
" <tr>\n" +
" <th>名次</th>\n" +
" <th>头像</th>\n" +
" <th>昵称</th>\n" +
" <th>元气值</th>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" </tbody>\n" +
" </table>\n" +
" </div>\n" +
" <div class=\"group-rank-help\">\n" +
" <div class=\"left-content\">\n" +
" <div class=\"question\">什么是元气值?</div>\n" +
" <p class=\"answer\">元气值是根据群成员每天学习时长、坚持打卡天数、有效发言次数等因素评估得出。</p>\n" +
" </div>\n" +
" <div class=\"right-content\">\n" +
" <div class=\"qrcode\">\n" +
" <img\n" +
" src=\""+qrcodeUrl+"?x-oss-process=image/auto-orient,0/resize,p_100\"\n" +
" alt=\"qrcode\" width=\"153\" height=\"153\">\n" +
" </div>\n" +
" <p>扫码查看个人报告</p>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
"</body>\n" +
"\n" +
"<script>\n" +
" var list = ["+list+
" ];\n" +
"\n" +
" var html = '';\n" +
"\n" +
" list.forEach((item, index) => {\n" +
" html += '<tr><td><span data-index=0' + index + ' class=index></span></td><td><img src=' + item.headPic +\n" +
" ' alt=\"headPic\" class=\"headPic\" width=\"64\" height=\"64\"></td><td class=\"nickName\"><span>' + item.nickName +\n" +
" '</span></td><td><span class=\"strength\">' + item.strength + '</span></td></tr>'\n" +
" });\n" +
"\n" +
" document.querySelector('tbody').innerHTML = html;\n" +
"</script>\n" +
"\n" +
"</html>";
HtmlDto htmlDto=new HtmlDto();
htmlDto.setHeight(1334);
htmlDto.setWidth(750);
htmlDto.setHtmlCode(s3);
htmlDto.setSnapshot(new Long(System.currentTimeMillis()).toString());
String pic = ResponseHandleUtil.parseResponse(htm2ImgService.toJPGByChrome(htmlDto),String.class);
return pic;
}
}
......@@ -9,15 +9,16 @@
<result column="weixin_group_id" property="weixinGroupId" jdbcType="VARCHAR"/>
<result column="serve_id" property="serveId" jdbcType="BIGINT"/>
<result column="serve_type" property="serveType" jdbcType="VARCHAR"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_group_id, classify_id, qrcode_id, weixin_group_id, serve_id, serve_type, create_time
id, book_group_id, classify_id, qrcode_id, weixin_group_id, serve_id, serve_type, wechat_user_id, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.AppTouchRecord" useGeneratedKeys="true"
<insert id="insert" parameterType="com.pcloud.book.group.entity.AppClickRecord" useGeneratedKeys="true"
keyProperty="id">
insert into app_click_record
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -27,6 +28,7 @@
weixin_group_id,
serve_id,
serve_type,
wechat_user_id,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
......@@ -36,6 +38,7 @@
#{weixinGroupId,jdbcType=VARCHAR},
#{serveId,jdbcType=BIGINT},
#{serveType,jdbcType=VARCHAR},
#{wechatUserId,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
......@@ -62,4 +65,20 @@
t.serve_id
</select>
<!--获取最近点击-->
<select id="getRecentlyClick" parameterType="map" resultType="com.pcloud.book.group.dto.AppClickDTO">
select
book_group_id bookGroupId,
classify_id classifyId,
qrcode_id qrcodeId,
weixin_group_id weixinGroupId,
serve_id serveId,
serve_type serveType
from app_click_record
where wechat_user_id=#{wechatUserId}
and qrcode_id=#{qrcodeId}
group by serve_id
order by create_time desc
limit #{top}
</select>
</mapper>
\ No newline at end of file
......@@ -308,6 +308,7 @@
c.book_group_id bookGroupId,
c.price price,
q.id groupQrcodeId,
c.has_open_learning_report hasOpenLearningReport,
q.weixin_qrcode_id weixinQrcodeId,
q.qrcode_url qrCodeUrl
from
......@@ -783,4 +784,43 @@
book_group_classify c join book_group_qrcode q on c.id = q.classify_id
and q.group_name = #{_parameter} limit 1
</select>
<!--更新是否开启学习报告-->
<update id="updateHasOpenLearningReport" parameterType="map">
update book_group_classify set
has_open_learning_report=#{hasOpenLearningReport},
update_user=#{partyId},
update_time=now()
where id=#{classifyId}
</update>
<!--获取群分类学习报告相关列表-->
<select id="listClassifyForLearningReport" parameterType="map" resultType="com.pcloud.book.group.dto.ClassifyLearningReportDto">
SELECT
c.id classifyId,
c.book_id bookId,
b.BOOK_NAME bookName,
c.classify,
c.book_group_id bookGroupId,
bg.group_qrcode_name groupQrcodeName,
bg.pro_label_id proLabelId,
bg.dep_label_id depLabelId,
bg.pur_label_id purLabelId,
c.has_open_learning_report hasOpenLearningReport
FROM book_group_classify c
LEFT JOIN BOOK_GROUP bg on bg.id = c.book_group_id
LEFT JOIN book b ON c.book_id = b.book_id
WHERE c.is_delete = 0
AND bg.is_delete = 0
AND b.is_delete = 0
AND c.create_user = #{partyId}
<if test="keyword != null">
AND (
b.book_name LIKE CONCAT('%', #{keyword},'%')
OR c.classify LIKE CONCAT('%', #{keyword},'%')
OR bg.group_qrcode_name LIKE CONCAT('%', #{keyword},'%')
)
</if>
group by c.id
order by c.id desc
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.LearningReportBrowseRecordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.LearningReportBrowseRecord">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/>
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, qrcode_id, classify_id, book_group_id, create_user, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.LearningReportBrowseRecord" useGeneratedKeys="true"
keyProperty="id">
insert into learning_report_browse_record
<trim prefix="(" suffix=")" suffixOverrides=",">
qrcode_id,
classify_id,
book_group_id,
create_user,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{qrcodeId,jdbcType=BIGINT},
#{classifyId,jdbcType=BIGINT},
#{bookGroupId,jdbcType=BIGINT},
#{createUser,jdbcType=BIGINT},
NOW()
</trim>
</insert>
<select id="getCountGroupByClassifyId" parameterType="list" resultType="com.pcloud.book.group.dto.ClassifyLearningCountDto">
select
classify_id classifyId,
count(1) count
from learning_report_browse_record
where classify_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
group by classify_id
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.LearningReportTouchRecordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.LearningReportTouchRecord">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/>
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="wx_user_id" property="wxUserId" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, qrcode_id, classify_id, book_group_id, create_user, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.LearningReportTouchRecord" useGeneratedKeys="true"
keyProperty="id">
insert into learning_report_touch_record
<trim prefix="(" suffix=")" suffixOverrides=",">
qrcode_id,
classify_id,
book_group_id,
wx_user_id,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{qrcodeId,jdbcType=BIGINT},
#{classifyId,jdbcType=BIGINT},
#{bookGroupId,jdbcType=BIGINT},
#{wxUserId,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<select id="getCountGroupByClassifyId" parameterType="list" resultType="com.pcloud.book.group.dto.ClassifyLearningCountDto">
select
classify_id classifyId,
count(1) count
from learning_report_touch_record
where classify_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
group by classify_id
</select>
</mapper>
\ No newline at end of file
......@@ -128,6 +128,7 @@
<pcloud-facade-audioapp.version>2.1.0-RELEASE</pcloud-facade-audioapp.version>
<pcloud-facade-videolesson.version>2.1.0-RELEASE</pcloud-facade-videolesson.version>
<pcloud-facade-liveapp.version>2.1.0-RELEASE</pcloud-facade-liveapp.version>
<pcloud-facade-shareimage.version>2.1.0-RELEASE</pcloud-facade-shareimage.version>
</properties>
<dependencyManagement>
......
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