Commit 5b4a7cb3 by 郑勇

feat: [1004401] ERP关联RAYS书刊信息展示、配置资源跳转交互优化

parent 4b4fb3f4
......@@ -786,6 +786,19 @@ public class BookDto extends BaseDto {
*/
private Integer isSendMiniUrl;
/**
*是否小睿教育书
*/
private Boolean xiaoRuiEducation;
public Boolean getXiaoRuiEducation() {
return xiaoRuiEducation;
}
public void setXiaoRuiEducation(Boolean xiaoRuiEducation) {
this.xiaoRuiEducation = xiaoRuiEducation;
}
public Integer getIsSendMiniUrl() {
return isSendMiniUrl;
}
......
......@@ -15,4 +15,24 @@ public class QrcodeStatisticsDTO {
private Long browserCounts;
/**
* 二维码类型
*/
private String codeType;
/**
* 二维码下面资源数量
*/
private Integer serveCount;
/**
* 二维码下面企业微信数量和资源数量总和
*/
private Integer totalCount;
/**
* 是否小睿教育书
*/
private Boolean xiaoRuiEducation;
}
......@@ -245,7 +245,7 @@ public interface BookAdviserBiz {
*/
BookAdviserDto getOneMainBook(Long bookId);
PageBeanNew<QrCodeVO> getQrList(Long bookId, Long adviserId, Long channelId, Integer currentPage, Integer numPerPage);
PageBeanNew<QrCodeVO> getQrList(Long bookId, Long adviserId, Long channelId,Integer type, Integer currentPage, Integer numPerPage);
/**
* 获取书下资源总数(包括现代纸书、1V1、小睿、社群码)
......
......@@ -69,6 +69,7 @@ import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.dao.BookAppletSceneDao;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.BookGroupServeDao;
import com.pcloud.book.group.dto.BookAppletSceneDTO;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
......@@ -230,6 +231,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
private LabelConsr labelConsr;
@Autowired
private BookLabelBiz bookLabelBiz;
@Autowired
private BookGroupServeDao bookGroupServeDao;
@Override
public List<BookDto> listByAdviserId(Long adviserId) {
......@@ -1083,13 +1086,66 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
@Override
@ParamLog("获取某本书关联的二维码")
public PageBeanNew<QrCodeVO> getQrList(Long bookId, Long adviserId, Long channelId, Integer currentPage, Integer numPerPage) {
public PageBeanNew<QrCodeVO> getQrList(Long bookId, Long adviserId, Long channelId,Integer type, Integer currentPage, Integer numPerPage) {
if (null == bookId || null == adviserId || null == channelId || null == currentPage || null == numPerPage ){
throw new BookBizException(BookBizException.ERROR, "参数为空");
}
//type 代表的是过滤二维码。如果是0,展示所有的二维码。如果是1(展示没有资源的码。但是要过滤小睿教育的书的非公众号二维码)
List<Long> xiaoRuiEducation = channelConsr.isXiaoRuiEducation(Lists.newArrayList(bookId));
//BookAdviserDto bookAdviserDto = bookAdviserDao.getBase(bookId, channelId, adviserId);
//现在一本书下面可以配多个跳小睿的码
List<BookGroupDTO> bookGroupDTOList=bookGroupDao.getDTOByBookIdList(bookId, channelId, adviserId);
//群二维码
List<Long> groupQrcodeList =CollUtil.isEmpty(bookGroupDTOList) ? new ArrayList<>() : bookGroupDTOList.stream().filter(a -> null != a.getJoinGroupType() && JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
//客服机器人
List<Long> robotList =CollUtil.isEmpty(bookGroupDTOList) ? new ArrayList<>() : bookGroupDTOList.stream().filter(a -> null != a.getJoinGroupType() && JoinGroupTypeEnum.ROBOT.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
//(**不包括群二维码)小睿二维码下资源数量
List<Long> xiaoruiList =CollUtil.isEmpty(bookGroupDTOList) ? new ArrayList<>() : bookGroupDTOList.stream().filter(a -> null != a.getJoinGroupType() && !JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
//分开查3种类型的资源数量
//群二维码下资源数量
Map<Long, BookGroupServeCountDTO> groupQrCodeMap =CollUtil.isEmpty(groupQrcodeList) ? new HashMap<>() : bookGroupServeDao.mapGroupQrcodeServeCount(groupQrcodeList);
//客服机器人码下资源数量
Map<Long, BookGroupServeCountDTO> robotMap =CollUtil.isEmpty(robotList) ? new HashMap<>() : bookGroupServeDao.mapGroupQrcodeServeCount(robotList);
//(**不包括群二维码)小睿二维码下资源数量
Map<Long, BookGroupServeCountDTO> xiaoruiMap =CollUtil.isEmpty(xiaoruiList) ? new HashMap<>() : bookGroupServeDao.mapXiaoRuiGroupQrcodeServeCount(xiaoruiList);
List<QrCodeVO> qrCodeVOS = new ArrayList<>();
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId, channelId, adviserId);
QrCodeVO qrCodeVO;
for (BookGroupDTO bookGroupDTO : bookGroupDTOList) {
qrCodeVO = new QrCodeVO();
qrCodeVO.setQrCodeName(bookGroupDTO.getGroupQrcodeName());
qrCodeVO.setQrCodeUrl(bookGroupDTO.getGroupQrcodeUrl());
qrCodeVO.setServeCount(0);
qrCodeVO.setRightsCount(0);
qrCodeVO.setSceneId(bookGroupDTO.getId());
qrCodeVO.setJoinGroupType(bookGroupDTO.getJoinGroupType());
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(bookGroupDTO.getJoinGroupType())){
if(CollUtil.isNotEmpty(groupQrCodeMap) && groupQrCodeMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = groupQrCodeMap.get(bookGroupDTO.getId());
qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount());
}
}else{
if(CollUtil.isNotEmpty(xiaoruiMap) && xiaoruiMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = xiaoruiMap.get(bookGroupDTO.getId());
qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount());
}
if(JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
if(CollUtil.isNotEmpty(robotMap) && robotMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = robotMap.get(bookGroupDTO.getId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()) {
qrCodeVO.setServeCount((null == qrCodeVO.getServeCount() ? 0 : qrCodeVO.getServeCount()) + bookGroupServeCountDTO.getServeCount());
}
}
}
}
qrCodeVO.setCodeType("group");
qrCodeVO.setXiaoRuiEducation(false);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(bookId)){
qrCodeVO.setXiaoRuiEducation(true);
}
qrCodeVOS.add(qrCodeVO);
}
/*BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId, channelId, adviserId);
if (null != bookGroupDTO) {
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount;
Map<String, BookGroupServeCountDTO> mapBookGroupRobotServeCount = null;
......@@ -1130,20 +1186,32 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupRobotServeCount.get("" + bookId + "_" + channelId + "_" + adviserId);
qrCodeVO.setServeCount(qrCodeVO.getServeCount() + bookGroupServeCountDTO.getServeCount());
}
qrCodeVO.setCodeType("group");
qrCodeVO.setXiaoRuiEducation(false);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(bookId)){
qrCodeVO.setXiaoRuiEducation(true);
}
qrCodeVOS.add(qrCodeVO);
}
}*/
List<QrcodeSceneDto> qrcodeSceneDtos = qrcodeSceneConsr.getQrCodeList(bookId, adviserId, channelId);
if (!ListUtils.isEmpty(qrcodeSceneDtos)) {
List<Long> sceneIds = qrcodeSceneDtos.stream().map(x -> x.getSceneId()).collect(Collectors.toList());
// 企业微信群资源数
Map<Long, BookGroupServeCountDTO> bookQrcodeWxworkMap = bookQrcodeWxworkBiz.mapWxWorkServeCount4SceneIds(sceneIds, BookQrcodeType.OFFICIAL_ACCOUNTS.getCode());
for (QrcodeSceneDto e : qrcodeSceneDtos) {
QrCodeVO qrCodeVO = new QrCodeVO();
qrCodeVO.setQrCodeName(e.getSceneName());
qrCodeVO.setQrCodeUrl(e.getQrcodeUrl());
QrCodeVO qrCodeVO1 = new QrCodeVO();
qrCodeVO1.setQrCodeName(e.getSceneName());
qrCodeVO1.setQrCodeUrl(e.getQrcodeUrl());
BookGroupServeCountDTO serveCountDTO = bookQrcodeWxworkMap.get(e.getSceneId());
qrCodeVO.setServeCount((ListUtils.isEmpty(e.getMessages()) ? 0 : e.getMessages().size()) + (serveCountDTO == null ? 0 : serveCountDTO.getServeCount()));
qrCodeVOS.add(qrCodeVO);
qrCodeVO1.setServeCount((ListUtils.isEmpty(e.getMessages()) ? 0 : e.getMessages().size()) + ((serveCountDTO == null || null==serveCountDTO.getServeCount()) ? 0 : serveCountDTO.getServeCount()));
//设置二维码类型和书刊是否是小睿教育的书
qrCodeVO1.setCodeType(e.getQrcodeType());
qrCodeVO1.setXiaoRuiEducation(false);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(bookId)){
qrCodeVO1.setXiaoRuiEducation(true);
}
qrCodeVO1.setSceneId(e.getSceneId());
qrCodeVOS.add(qrCodeVO1);
}
}
if (ListUtils.isEmpty(qrCodeVOS)){
......@@ -1151,9 +1219,20 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
List<QrCodeVO> record = new ArrayList<>();
if (qrCodeVOS.size() > (currentPage + 1) * numPerPage){
record = qrCodeVOS.subList(currentPage * numPerPage,(currentPage + 1) * numPerPage);
//type 代表的是过滤二维码。如果是0,展示所有的二维码。如果是1(展示没有资源的码。但是要过滤小睿教育的书的非公众号二维码)
if(null!=type && 1==type){
qrCodeVOS = qrCodeVOS.stream().filter(a -> (null == a.getServeCount() || 0 == a.getServeCount()) && !(null != a.getXiaoRuiEducation() && a.getXiaoRuiEducation() && !"wechat".equalsIgnoreCase(a.getCodeType()))).collect(Collectors.toList());
record = qrCodeVOS.subList(currentPage * numPerPage,(currentPage + 1) * numPerPage);
}else{
record = qrCodeVOS.subList(currentPage * numPerPage,(currentPage + 1) * numPerPage);
}
} else {
record = qrCodeVOS.subList(currentPage * numPerPage, qrCodeVOS.size());
if(null!=type && 1==type){
qrCodeVOS = qrCodeVOS.stream().filter(a -> (null == a.getServeCount() || 0 == a.getServeCount()) && !(null != a.getXiaoRuiEducation() && a.getXiaoRuiEducation() && !"wechat".equalsIgnoreCase(a.getCodeType()))).collect(Collectors.toList());
record = qrCodeVOS.subList(currentPage * numPerPage, qrCodeVOS.size());
}else{
record = qrCodeVOS.subList(currentPage * numPerPage, qrCodeVOS.size());
}
}
return new PageBeanNew<>(currentPage, numPerPage,qrCodeVOS.size(), record);
}
......@@ -1436,15 +1515,31 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
public Map<String, BookQrcodeStatisticsDTO> mapBookQrcodeStatistics(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
Map<String, BookQrcodeStatisticsDTO> resultMap = new HashMap<>();
BookQrcodeStatisticsDTO bookQrcodeStatisticsDTO;
//是否小睿教育的书
List<Long> xiaoRuiEducation =CollUtil.isEmpty(bookIds) ? new ArrayList<>() : channelConsr.isXiaoRuiEducation(bookIds);
// 社群书统计
List<BookGroupDTO> bookGroupList = bookGroupDao.getDTOByBookIdsAdviserIdsChannelIds(bookIds, adviserIds, channelIds);
//计算每个二维码下面的资源数量
//群二维码
List<Long> groupQrcodeList =CollUtil.isEmpty(bookGroupList) ? new ArrayList<>() : bookGroupList.stream().filter(a -> null != a.getJoinGroupType() && JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
//客服机器人
List<Long> robotList =CollUtil.isEmpty(bookGroupList) ? new ArrayList<>() : bookGroupList.stream().filter(a -> null != a.getJoinGroupType() && JoinGroupTypeEnum.ROBOT.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
//(**不包括群二维码)小睿二维码下资源数量
List<Long> xiaoruiList =CollUtil.isEmpty(bookGroupList) ? new ArrayList<>() : bookGroupList.stream().filter(a -> null != a.getJoinGroupType() && !JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
//分开查3种类型的资源数量
//群二维码下资源数量
Map<Long, BookGroupServeCountDTO> groupQrCodeMap =CollUtil.isEmpty(groupQrcodeList) ? new HashMap<>() : bookGroupServeDao.mapGroupQrcodeServeCount(groupQrcodeList);
//客服机器人码下资源数量
Map<Long, BookGroupServeCountDTO> robotMap =CollUtil.isEmpty(robotList) ? new HashMap<>() : bookGroupServeDao.mapGroupQrcodeServeCount(robotList);
//(**不包括群二维码)小睿二维码下资源数量
Map<Long, BookGroupServeCountDTO> xiaoruiMap =CollUtil.isEmpty(xiaoruiList) ? new HashMap<>() : bookGroupServeDao.mapXiaoRuiGroupQrcodeServeCount(xiaoruiList);
if(!CollectionUtils.isEmpty(bookGroupList)){
List<Long> bookGroupIds = bookGroupList.stream().map(x -> x.getId()).collect(Collectors.toList());
Map<Long, GroupUserCountDTO> scanCountByGroup = wechatGroupConsr.getScanCountByGroup(bookGroupIds, null);
for (BookGroupDTO bookGroupDTO : bookGroupList) {
GroupUserCountDTO groupUserCountDTO = scanCountByGroup.get(bookGroupDTO.getId());
String bookAdviserId = bookGroupDTO.getBookId() + "_" + bookGroupDTO.getChannelId() + "_" + bookGroupDTO.getCreateUser();
bookQrcodeStatisticsDTO = new BookQrcodeStatisticsDTO();
bookQrcodeStatisticsDTO.setBookChannelAdviserId(bookGroupDTO.getBookId()+"_"+bookGroupDTO.getChannelId()+"_"+bookGroupDTO.getCreateUser());
bookQrcodeStatisticsDTO.setAdviserId(bookGroupDTO.getCreateUser());
......@@ -1457,12 +1552,47 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrcodeStatisticsDTO.setQrcodeUrl(bookGroupDTO.getGroupQrcodeUrl());
qrcodeStatisticsDTO.setCounts(0L);
qrcodeStatisticsDTO.setBrowserCounts(0L);
qrcodeStatisticsDTO.setServeCount(0);
qrcodeStatisticsDTO.setCodeType("group");
qrcodeStatisticsDTO.setXiaoRuiEducation(false);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(bookGroupDTO.getBookId())){
qrcodeStatisticsDTO.setXiaoRuiEducation(true);
}
if(groupUserCountDTO != null){
qrcodeStatisticsDTO.setCounts(groupUserCountDTO.getCount().longValue());
qrcodeStatisticsDTO.setBrowserCounts(groupUserCountDTO.getUserCount().longValue());
}
bookQrcodeStatisticsDTO.getQrcodeSceneDtoList().add(qrcodeStatisticsDTO);
resultMap.put(bookQrcodeStatisticsDTO.getBookChannelAdviserId(), bookQrcodeStatisticsDTO);
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(bookGroupDTO.getJoinGroupType())){
if(CollUtil.isNotEmpty(groupQrCodeMap) && groupQrCodeMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = groupQrCodeMap.get(bookGroupDTO.getId());
qrcodeStatisticsDTO.setServeCount(bookGroupServeCountDTO.getServeCount());
}
}else{
if(CollUtil.isNotEmpty(xiaoruiMap) && xiaoruiMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = xiaoruiMap.get(bookGroupDTO.getId());
qrcodeStatisticsDTO.setServeCount(bookGroupServeCountDTO.getServeCount());
}
if(JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
if(CollUtil.isNotEmpty(robotMap) && robotMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = robotMap.get(bookGroupDTO.getId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()) {
qrcodeStatisticsDTO.setServeCount((null == qrcodeStatisticsDTO.getServeCount() ? 0 : qrcodeStatisticsDTO.getServeCount()) + bookGroupServeCountDTO.getServeCount());
}
}
}
}
qrcodeStatisticsDTO.setTotalCount(qrcodeStatisticsDTO.getServeCount());
bookQrcodeStatisticsDTO.getQrcodeSceneDtoList().add(qrcodeStatisticsDTO);
bookQrcodeStatisticsDTO.setQrcodeSceneDtoList(Lists.newArrayList(qrcodeStatisticsDTO));
if(resultMap.containsKey(bookQrcodeStatisticsDTO.getBookChannelAdviserId())){
BookQrcodeStatisticsDTO bookQrcodeStatisticsDTO1 = resultMap.get(bookQrcodeStatisticsDTO.getBookChannelAdviserId());
if(null!=bookQrcodeStatisticsDTO1 && CollUtil.isNotEmpty(bookQrcodeStatisticsDTO1.getQrcodeSceneDtoList())){
List<QrcodeStatisticsDTO> qrcodeSceneDtoList = bookQrcodeStatisticsDTO1.getQrcodeSceneDtoList();
qrcodeSceneDtoList.add(qrcodeStatisticsDTO);
bookQrcodeStatisticsDTO.setQrcodeSceneDtoList(qrcodeSceneDtoList);
}
}
resultMap.put(bookQrcodeStatisticsDTO.getBookChannelAdviserId(), bookQrcodeStatisticsDTO);
}
}
......@@ -1471,6 +1601,9 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
if(CollectionUtils.isEmpty(qrcodeSceneDtos)){
qrcodeSceneDtos = Lists.newArrayList();
}
List<Long> sceneIds =CollUtil.isEmpty(qrcodeSceneDtos) ? new ArrayList<>() : qrcodeSceneDtos.stream().map(x -> x.getSceneId()).collect(Collectors.toList());
// 企业微信群资源数
Map<Long, BookGroupServeCountDTO> bookQrcodeWxworkMap =CollUtil.isEmpty(sceneIds) ? new HashMap<>() : bookQrcodeWxworkBiz.mapWxWorkServeCount4SceneIds(sceneIds, BookQrcodeType.OFFICIAL_ACCOUNTS.getCode());
String bookChannelAdviserId;
for (QrcodeSceneDto qrcodeSceneDto : qrcodeSceneDtos) {
bookChannelAdviserId = qrcodeSceneDto.getAdviserBookId() + "_" + qrcodeSceneDto.getChannelPartyId() + "_" + qrcodeSceneDto.getAdviserId();
......@@ -1489,11 +1622,25 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrcodeStatisticsDTO.setQrcodeUrl(qrcodeSceneDto.getQrcodeUrl());
qrcodeStatisticsDTO.setCounts(qrcodeSceneDto.getCounts());
qrcodeStatisticsDTO.setBrowserCounts(qrcodeSceneDto.getBrowserCounts());
//设置二维码类型和二维码下面配置的资源数量。一般资源和企业微信数量
qrcodeStatisticsDTO.setCodeType(qrcodeSceneDto.getQrcodeType());
qrcodeStatisticsDTO.setServeCount(qrcodeSceneDto.getServeCount());
qrcodeStatisticsDTO.setTotalCount(qrcodeSceneDto.getServeCount());
//计算二维码下面的资源数(包括普通资源和配置的企业微信数量)
if(CollUtil.isNotEmpty(bookQrcodeWxworkMap) && bookQrcodeWxworkMap.containsKey(qrcodeSceneDto.getSceneId())){
BookGroupServeCountDTO bookGroupServeCountDTO = bookQrcodeWxworkMap.get(qrcodeSceneDto.getSceneId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()){
qrcodeStatisticsDTO.setServeCount((null==qrcodeSceneDto.getServeCount() ? 0 : qrcodeSceneDto.getServeCount()) + bookGroupServeCountDTO.getServeCount());
}
}
qrcodeStatisticsDTO.setXiaoRuiEducation(false);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(qrcodeSceneDto.getAdviserBookId())){
qrcodeStatisticsDTO.setXiaoRuiEducation(true);
}
bookQrcodeStatisticsDTO.getQrcodeSceneDtoList().add(qrcodeStatisticsDTO);
}
// 筛选出疑似未印刷的二维码(扫码人数<=20 || 扫码次数<=40)
Iterator<BookQrcodeStatisticsDTO> iterator = resultMap.values().iterator();
/*Iterator<BookQrcodeStatisticsDTO> iterator = resultMap.values().iterator();
while(iterator.hasNext()) {
BookQrcodeStatisticsDTO item = iterator.next();
for (int i = item.getQrcodeSceneDtoList().size() - 1; i >= 0; i--) {
......@@ -1507,7 +1654,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
resultMap.remove(item);
}
}
}
}*/
return resultMap;
}
......
......@@ -773,9 +773,14 @@ public class BookBizImpl implements BookBiz {
paramMap.put("channelIds", bookDetailDTO.getChannelIds());
paramMap.put("adviserIds", bookDetailDTO.getAdviserIds());
List<BookDto> bookDtos = bookDao.listBookGroupByBookIds(bookDetailDTO.getBookIds(), bookDetailDTO.getChannelIds(),bookDetailDTO.getAdviserIds());
List<Long> xiaoRuiEducation = channelConsr.isXiaoRuiEducation(bookDetailDTO.getBookIds());
if (!ListUtils.isEmpty(bookDtos)) {
for (BookDto bookDto : bookDtos) {
bookDto.setXiaoRuiEducation(false);
bookMap.put(bookDto.getBookId() + "_" + bookDto.getChannelId() + "_" + bookDto.getAdviserId(), bookDto);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(bookDto.getBookId())){
bookDto.setXiaoRuiEducation(true);
}
}
}
}
......
......@@ -249,9 +249,10 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
public ResponseDto<PageBeanNew<QrCodeVO>> getQrList(@RequestParam(value = "bookId") Long bookId,
@RequestParam(value = "adviserId") Long adviserId,
@RequestParam(value = "channelId") Long channelId,
@RequestParam(value = "type") Integer type,
@RequestParam(value = "currentPage") Integer currentPage,
@RequestParam(value = "numPerPage") Integer numPerPage) throws BizException {
PageBeanNew<QrCodeVO> qrCodeVOPageBeanNew = bookAdviserBiz.getQrList(bookId, adviserId, channelId, currentPage, numPerPage);
PageBeanNew<QrCodeVO> qrCodeVOPageBeanNew = bookAdviserBiz.getQrList(bookId, adviserId, channelId,type, currentPage, numPerPage);
return new ResponseDto<>(qrCodeVOPageBeanNew);
}
......
......@@ -18,4 +18,13 @@ public class QrCodeVO {
@ApiModelProperty("权益数")
private Integer rightsCount;
@ApiModelProperty("二维码类型")
private String codeType;
@ApiModelProperty("是否小睿教育书")
private Boolean xiaoRuiEducation;
@ApiModelProperty("公众号码id")
private Long sceneId;
}
......@@ -271,4 +271,19 @@ public class ChannelConsr {
}
return new HashMap<>();
}
/**
* 是否小睿教育书
*/
public List<Long> isXiaoRuiEducation(List<Long> bookIds) {
if(CollectionUtils.isEmpty(bookIds)){
return new ArrayList<>();
}
try {
return ResponseHandleUtil.parseList(qrcodeSceneService.isXiaoRuiEducation(bookIds), Long.class);
} catch (Exception e) {
LOGGER.error("是否小睿教育书 " + e.getMessage(), e);
throw new ChannelBizException(ChannelBizException.PARAM_IS_NULL, "获取是否小睿教育书失败");
}
}
}
......@@ -382,4 +382,6 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
List<HotAppDTO> listHotApp();
List<HotAppDTO> listHotAppIncrement();
List<BookGroupDTO> getDTOByBookIdList(Long bookId, Long channelId, Long adviserId);
}
......@@ -82,6 +82,21 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> {
Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds, Integer joinGroupType);
/**
* 批量获取群二维码下资源数量
* @param bookGroupIds
* @return
*/
Map<Long, BookGroupServeCountDTO> mapGroupQrcodeServeCount(List<Long> bookGroupIds);
/**
* 批量获取 除了 群二维码下 其它社区码下资源数量
* @param bookGroupIds
* @return
*/
Map<Long, BookGroupServeCountDTO> mapXiaoRuiGroupQrcodeServeCount(List<Long> bookGroupIds);
/**
* 根据书刊查社群书配置资源
* @author:zhuyajie
* @date:2020/12/14 16:31
......
......@@ -505,4 +505,13 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
public List<HotAppDTO> listHotAppIncrement() {
return getSqlSession().selectList(getStatement("listHotAppIncrement"));
}
@Override
public List<BookGroupDTO> getDTOByBookIdList(Long bookId, Long channelId, Long adviserId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId", bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
return super.getSqlSession().selectList(getStatement("getDTOByBookIdList"), paramMap);
}
}
package com.pcloud.book.group.dao.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import com.pcloud.book.book.vo.BookResourceNumDTO;
import com.pcloud.book.group.dao.BookGroupServeDao;
......@@ -155,6 +156,48 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
}
@Override
public Map<Long, BookGroupServeCountDTO> mapGroupQrcodeServeCount(List<Long> bookGroupIds) {
if (CollUtil.isNotEmpty(bookGroupIds) && bookGroupIds.size() > 500) {
Map<Long, BookGroupServeCountDTO>resultMap = new HashMap<>();
List<List<Long>> lists = ListUtils.groupList(bookGroupIds);
for (List<Long> list : lists) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
Map<Long, BookGroupServeCountDTO> objectObjectMap = getSessionTemplate().selectMap(getStatement("mapGroupQrcodeServeCount"), map, "bookQrcodeId");
if(objectObjectMap!=null){
resultMap.putAll(objectObjectMap);
}
}
return resultMap;
} else {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
return getSessionTemplate().selectMap(getStatement("mapGroupQrcodeServeCount"), map, "bookQrcodeId");
}
}
@Override
public Map<Long, BookGroupServeCountDTO> mapXiaoRuiGroupQrcodeServeCount(List<Long> bookGroupIds) {
if (CollUtil.isNotEmpty(bookGroupIds) && bookGroupIds.size() > 500) {
Map<Long, BookGroupServeCountDTO>resultMap = new HashMap<>();
List<List<Long>> lists = ListUtils.groupList(bookGroupIds);
for (List<Long> list : lists) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
Map<Long, BookGroupServeCountDTO> objectObjectMap = getSessionTemplate().selectMap(getStatement("mapXiaoRuiGroupQrcodeServeCount"), map, "bookQrcodeId");
if(objectObjectMap!=null){
resultMap.putAll(objectObjectMap);
}
}
return resultMap;
} else {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
return getSessionTemplate().selectMap(getStatement("mapXiaoRuiGroupQrcodeServeCount"), map, "bookQrcodeId");
}
}
@Override
public List<BookGroupServe> getServeListByBook(Long bookId, Long channelId, Long adviserId) {
Map<String,Object> map = new HashMap<>();
map.put("adviserId", adviserId);
......
......@@ -358,6 +358,7 @@
<select id="listBookGroupByBookIds" resultMap="bookMap" parameterType="list">
SELECT
b.BOOK_ID,
b.CREATED_DATE,
b.ISBN,
b.BOOK_NAME,
b.COVER_IMG,
......
......@@ -144,6 +144,16 @@
ORDER BY create_time ASC limit 1
</select>
<select id="getDTOByBookIdList" resultMap="BookGroupDTO" parameterType="map">
select
<include refid="Base_Column_List"/>
from book_group
where is_delete = 0
and book_id = #{bookId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and create_user = #{adviserId,jdbcType=BIGINT}
</select>
<select id="getDTOByBookIdsAnsAdviserIds" resultMap="BookGroupDTO" parameterType="map">
select
<include refid="Base_Column_List"/>
......
......@@ -238,6 +238,26 @@
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
<!--客服机器人、1v1、小睿的资源数-->
<!--2021-02-19 企业微信群也算一个资源数-->
<select id="mapXiaoRuiGroupQrcodeServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
bg.id bookQrcodeId,
ifnull(COUNT(DISTINCT bgs.id),0) + (SELECT ifnull(COUNT(1),0) FROM book_qrcode_wxwork bqw WHERE bqw.book_qrcode_type = 2 AND bqw.book_qrcode_id = bg.id) serveCount,
bg.book_id bookId, bg.create_user adviserId, bg.channel_id channelId,COUNT(DISTINCT bg.group_qrcode_url) qrcodeCount,
bg.join_group_type joinGroupType
FROM `book_group` bg
LEFT JOIN book_group_serve bgs ON bg.id = bgs.book_group_id
WHERE
bg.is_delete=0
AND bg.id IN
<foreach collection="bookGroupIds" item="bookGroupId" separator="," open="(" close=")">
${bookGroupId}
</foreach>
AND bg.join_group_type IN (2,3,4)
GROUP BY bg.id
</select>
<!--社群资源数-->
<select id="mapBookGroupQrcodeServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
......@@ -265,6 +285,23 @@
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
<!--群二维码资源数-->
<select id="mapGroupQrcodeServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
bg.id bookQrcodeId,ifnull(COUNT(DISTINCT k.id),0) serveCount
FROM
book_group bg
LEFT JOIN book_keyword bk ON bg.id=bk.book_group_id AND bk.is_delete = 0
LEFT JOIN keyword k ON bk.keyword_id = k.id AND k.is_delete = 0
WHERE
bg.is_delete = 0
AND bg.id IN
<foreach collection="bookGroupIds" item="bookGroupId" separator="," open="(" close=")">
${bookGroupId}
</foreach>
GROUP BY bg.id
</select>
<select id="getServeListByBook" parameterType="map" resultMap="BaseResultMap">
SELECT
s.id,
......
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