Commit 8dfa375c by 田超

Merge branch 'feature/listQrcode' into 'master'

feat: [1004546] 编辑端展示图书下所有二维码

See merge request rays/pcloud-book!1257
parents 8fcc5149 3336bc5f
...@@ -31,6 +31,7 @@ import com.pcloud.book.book.vo.PcloudAdviserBookVO; ...@@ -31,6 +31,7 @@ import com.pcloud.book.book.vo.PcloudAdviserBookVO;
import com.pcloud.book.book.vo.QrCodeVO; import com.pcloud.book.book.vo.QrCodeVO;
import com.pcloud.book.group.dto.BookAppletSceneDTO; import com.pcloud.book.group.dto.BookAppletSceneDTO;
import com.pcloud.book.group.dto.BookServeDTO; import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -390,4 +391,9 @@ public interface BookAdviserBiz { ...@@ -390,4 +391,9 @@ public interface BookAdviserBiz {
* 小睿书下面的书刊权益数量 * 小睿书下面的书刊权益数量
*/ */
Map<Long,Integer> rightsCountByBookIds(List<Long> bookIds); Map<Long,Integer> rightsCountByBookIds(List<Long> bookIds);
/**
* 编辑端 - 分页获取图书下二维码列表
*/
PageBeanNew<BookQrcodeVO> qrList4AdviserBookNew(Long bookId, Long channelId, Long adviserId, String sceneName, Integer currentPage, Integer numPerPage);
} }
package com.pcloud.book.book.biz.impl; package com.pcloud.book.book.biz.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
...@@ -79,8 +78,10 @@ import com.pcloud.book.group.dto.BookGroupDTO; ...@@ -79,8 +78,10 @@ import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO; import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookServeDTO; import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.BookServeLabelDTO; import com.pcloud.book.group.dto.BookServeLabelDTO;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.enums.AppAndProductTypeEnum; import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.enums.JoinGroupTypeEnum; import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant; import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO; import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
...@@ -91,13 +92,17 @@ import com.pcloud.book.rightsSetting.entity.RightsSetting; ...@@ -91,13 +92,17 @@ import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingNow; import com.pcloud.book.rightsSetting.entity.RightsSettingNow;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle; import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.base.constants.MessageFromTypeEnum;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException; import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO; import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO;
import com.pcloud.channelcenter.qrcode.dto.QrcodeLocationDto;
import com.pcloud.channelcenter.qrcode.dto.QrcodeMessageDTO; import com.pcloud.channelcenter.qrcode.dto.QrcodeMessageDTO;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto; import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.MessageDto;
import com.pcloud.common.constant.CacheConstant; import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.RedisKeyConstant;
import com.pcloud.common.core.constant.ProductTypeConstant; import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.core.constant.SceneCode; import com.pcloud.common.core.constant.SceneCode;
import com.pcloud.common.core.constant.SendType; import com.pcloud.common.core.constant.SendType;
...@@ -109,6 +114,7 @@ import com.pcloud.common.page.PageParam; ...@@ -109,6 +114,7 @@ import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils; import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil; import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.ServeLinkUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.facade.tradecenter.dto.Amount4BookAdviserDto; import com.pcloud.facade.tradecenter.dto.Amount4BookAdviserDto;
...@@ -124,7 +130,6 @@ import com.pcloud.wechatgroup.group.dto.GroupUserCountDTO; ...@@ -124,7 +130,6 @@ import com.pcloud.wechatgroup.group.dto.GroupUserCountDTO;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -138,9 +143,9 @@ import java.math.BigDecimal; ...@@ -138,9 +143,9 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -2796,4 +2801,256 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -2796,4 +2801,256 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
Map<Long, Integer> result = CollUtil.isEmpty(bookRightsCountsDtos) ? new HashMap<>() : bookRightsCountsDtos.stream().collect(Collectors.toMap(a -> a.getBookId(), a -> a.getCount(), (k1, k2) -> k2)); Map<Long, Integer> result = CollUtil.isEmpty(bookRightsCountsDtos) ? new HashMap<>() : bookRightsCountsDtos.stream().collect(Collectors.toMap(a -> a.getBookId(), a -> a.getCount(), (k1, k2) -> k2));
return result; return result;
} }
@Override
public PageBeanNew<BookQrcodeVO> qrList4AdviserBookNew(Long bookId, Long channelId, Long adviserId, String sceneName, Integer currentPage, Integer numPerPage) {
// 获取 book_group 二维码列表
CompletableFuture<List<BookQrcodeVO>> bookGroupIdFuture = CompletableFuture.supplyAsync(() -> {
List<Long> locationIds = null;
if (StrUtil.isNotBlank(sceneName)) {
// 模糊匹配印码位置
locationIds = qrcodeSceneConsr.getLocationIds4Name(sceneName);
}
if (CollUtil.isEmpty(locationIds)) locationIds = null;
return Optional.ofNullable(bookGroupDao.listBookQrcodes(bookId, channelId, adviserId, sceneName, locationIds)).orElse(new ArrayList<>());
}, ThreadPoolUtils.OTHER_POOL);
// 获取 qrcode_scene 二维码列表
CompletableFuture<List<BookQrcodeVO>> qrcodeSceneFuture = CompletableFuture.supplyAsync(
() -> Optional.ofNullable(qrcodeSceneConsr.qrList4AdviserBookNew(bookId, channelId, adviserId, sceneName)).orElse(new ArrayList<>()));
try {
// 等待查询结果
CompletableFuture.allOf(bookGroupIdFuture, qrcodeSceneFuture).get();
List<BookQrcodeVO> bookQrcodeList = bookGroupIdFuture.get();
List<BookQrcodeVO> qrcodeSceneList = qrcodeSceneFuture.get();
bookQrcodeList.addAll(qrcodeSceneList);
int totalCount = bookQrcodeList.size();
// 对结果进行排序
// TODO 是否对结果进行缓存?
bookQrcodeList.sort(Comparator.nullsFirst(Comparator.comparing(BookQrcodeVO::getLastModifiedDate).reversed()));
// 手动分页
List<BookQrcodeVO> pageList = CollUtil.page(currentPage, numPerPage, bookQrcodeList);
fillPageList(currentPage, numPerPage, pageList);
return new PageBeanNew<>(currentPage, numPerPage, totalCount, pageList);
} catch (InterruptedException | ExecutionException e) {
LOGGER.warn("获取图书二维码,异步任务失败!", e);
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
}
/**
* 填充手动分页结果
*/
private void fillPageList(Integer currentPage, Integer numPerPage, List<BookQrcodeVO> pageList) {
// 分组
Map<String, List<Long>> map = CollUtil.page(currentPage, numPerPage, pageList).stream().collect(
Collectors.groupingBy(BookQrcodeVO::getSource, Collectors.mapping(BookQrcodeVO::getSceneId, Collectors.toList())));
// 二维码标签 二维码印码位置 二维码类型 二维码ID 二维码地址 服务
// TODO 分组填充信息
List<Long> bookGroupIds = Optional.ofNullable(map).map(x -> x.get("bookGroup")).orElse(new ArrayList<>());
List<Long> qrcodeSceneIds = Optional.ofNullable(map).map(x -> x.get("qrcodeScene")).orElse(new ArrayList<>());
CompletableFuture<Map<Long, BookQrcodeVO>> qrcodeSceneFuture = CompletableFuture.supplyAsync(() ->
Optional.ofNullable(channelConsr.getQrList4SceneIds(qrcodeSceneIds))
.map(x -> x.stream().filter(Objects::nonNull).collect(Collectors.toMap(BookQrcodeVO::getSceneId, Function.identity())))
.orElse(new HashMap<>()));
if (CollUtil.isEmpty(bookGroupIds)){
Map<Long, BookQrcodeVO> qrcodeVOMap = null;
try {
qrcodeVOMap = Optional.ofNullable(qrcodeSceneFuture.get()).orElse(new HashMap<>());
} catch (InterruptedException | ExecutionException e) {
LOGGER.warn("[fillPageList] 异步获取信息失败");
return;
}
for (BookQrcodeVO bookQrcodeVO : pageList) {
if (Objects.isNull(bookQrcodeVO) || Objects.isNull(bookQrcodeVO.getSceneId())) continue;
if (Objects.nonNull(qrcodeVOMap.get(bookQrcodeVO.getSceneId())))
BeanUtils.copyProperties(qrcodeVOMap.get(bookQrcodeVO.getSceneId()), bookQrcodeVO);
}
return;
}
// 查询 book_group 码信息
CompletableFuture<List<BookQrcodeVO>> bookGroupFuture = CompletableFuture.completedFuture(bookGroupDao.listBookQrcodeVOByIds(bookGroupIds));
CompletableFuture<Map<Long, BookQrcodeVO>> bookGroupMapFuture = bookGroupFuture.thenApplyAsync(list ->
Optional.ofNullable(list).map(x -> x.stream().filter(Objects::nonNull).collect(Collectors.toMap(BookQrcodeVO::getSceneId, Function.identity()))).orElse(new HashMap<>()));
CompletableFuture<Map<Long, AccountSettingDto>> accountSettingMapFuture = bookGroupMapFuture.thenApplyAsync(it -> {
if (CollUtil.isEmpty(it) || CollUtil.isEmpty(it.values())) return new HashMap<>();
List<Long> channelIds = it.values().stream().filter(Objects::nonNull).map(BookQrcodeVO::getChannelPartyId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
return Optional.ofNullable(channelConsr.listWechat(channelIds)).orElse(new HashMap<>());
});
// 获取标签名称信息
CompletableFuture<Map<Long, String>> bookGroupLabelMapFuture = bookGroupFuture.thenApplyAsync(list -> {
List<Long> labelIds = list.parallelStream().filter(Objects::nonNull).map(bookQrcodeVO ->
CollUtil.toList(bookQrcodeVO.getProLabelId(), bookQrcodeVO.getPurLabelId(), bookQrcodeVO.getDepLabelId()))
.flatMap(List::stream).filter(Objects::nonNull).distinct().collect(Collectors.toList());
return labelConsr.getLabelName(labelIds);
}, ThreadPoolUtils.OTHER_POOL);
// 获取印码位置信息
CompletableFuture<Map<Long, String>> bookGroupLocationMapFuture = bookGroupFuture.thenApplyAsync(list -> {
List<Long> locationIds = list.parallelStream().filter(Objects::nonNull).map(vos ->
Optional.ofNullable(vos.getQrcodeLocations()).map(x -> x.stream().filter(Objects::nonNull)
.map(QrcodeLocationDto::getLocationId).distinct().collect(Collectors.toList()))
.orElse(new ArrayList<>())
).flatMap(List::stream).filter(Objects::nonNull).distinct().collect(Collectors.toList());
return channelConsr.listLocationNames(locationIds);
}, ThreadPoolUtils.OTHER_POOL);
// 填充配置的服务信息
// 查询 book_group_serve
CompletableFuture<List<BookGroupServe>> bookGroupServeFuture = CompletableFuture.completedFuture(
Optional.ofNullable(bookGroupServeDao.getListByBookGroupIds(bookGroupIds)).orElse(new ArrayList<>()));
// 查询 book_group_serve 作品信息
// 查询作品ID
CompletableFuture<List<Long>> bookGroupProductIdFuture = bookGroupServeFuture.thenApplyAsync(bookGroupServes ->
bookGroupServes.stream().filter(x -> Objects.nonNull(x) && Objects.nonNull(x.getServeId())
&& Objects.equals(AppAndProductTypeEnum.PRODUCT.value, x.getServeType())).map(BookGroupServe::getServeId)
.collect(Collectors.toList()), ThreadPoolUtils.OTHER_POOL);
// 查询作品信息
CompletableFuture<Map<Long, ProductDto>> bookGroupServeProductMapFuture = bookGroupProductIdFuture.thenApplyAsync(productIds ->
productConsr.getProBasesByIds(productIds), ThreadPoolUtils.OTHER_POOL);
// 查询是否超级作者作品
CompletableFuture<Map<Long, Boolean>> isSuperMapFuture = bookGroupProductIdFuture.thenApplyAsync(productIds ->
Optional.ofNullable(productConsr.getIsSuperByProductIdList(productIds)).orElse(new HashMap<>()));
// 查询 book_group_serve 应用信息
CompletableFuture<Map<Long, AppDto>> bookGroupServesAppMapFuture = bookGroupServeFuture.thenApplyAsync(bookGroupServes -> {
// 作品ID 列表
List<Long> appIds = bookGroupServes.stream().filter(x -> Objects.nonNull(x) && Objects.nonNull(x.getServeId())
&& Objects.equals(AppAndProductTypeEnum.APP.value, x.getServeType())).map(BookGroupServe::getServeId).collect(Collectors.toList());
return appConsr.mapByIds(appIds);
}, ThreadPoolUtils.OTHER_POOL);
// 查询统计信息
CompletableFuture<Map<Long, GroupUserCountDTO>> bookGroupStatsMapFuture = CompletableFuture.supplyAsync(() ->
Optional.ofNullable(wechatGroupConsr.getScanCountByGroup(bookGroupIds)).orElse(new HashMap<>()));
try {
CompletableFuture.allOf(qrcodeSceneFuture, bookGroupFuture, bookGroupLabelMapFuture, bookGroupLocationMapFuture,
bookGroupServeFuture, bookGroupProductIdFuture, bookGroupServeProductMapFuture, isSuperMapFuture,
bookGroupServesAppMapFuture, bookGroupStatsMapFuture, accountSettingMapFuture).get();
Map<Long, BookQrcodeVO> bookGroupMap = Optional.ofNullable(bookGroupMapFuture.get()).orElse(new HashMap<>());
Map<Long, BookQrcodeVO> qrcodeVOMap = Optional.ofNullable(qrcodeSceneFuture.get()).orElse(new HashMap<>());
Map<Long, String> labelNameMap = Optional.ofNullable(bookGroupLabelMapFuture.get()).orElse(new HashMap<>());
Map<Long, GroupUserCountDTO> bookGroupStatsMap = Optional.ofNullable(bookGroupStatsMapFuture.get()).orElse(new HashMap<>());
Map<Long, List<BookGroupServe>> bookGroupServeMap = Optional.ofNullable(bookGroupServeFuture.get()).map(x -> x.stream()
.filter(Objects::nonNull).collect(Collectors.groupingBy(BookGroupServe::getBookGroupId))).orElse(new HashMap<>());
Map<Long, String> bookGroupLocationMap = Optional.ofNullable(bookGroupLocationMapFuture.get()).orElse(new HashMap<>());
Map<Long, AppDto> bookGroupAppMap = Optional.ofNullable(bookGroupServesAppMapFuture.get()).orElse(new HashMap<>());
Map<Long, Boolean> isSuperMap = Optional.ofNullable(isSuperMapFuture.get()).orElse(new HashMap<>());
Map<Long, ProductDto> bookGroupProductMap = Optional.ofNullable(bookGroupServeProductMapFuture.get()).orElse(new HashMap<>());
Map<Long, AccountSettingDto> accountSettingDtoMap = Optional.ofNullable(accountSettingMapFuture.get()).orElse(new HashMap<>());
for (BookQrcodeVO bookQrcodeVO : pageList) {
if (Objects.isNull(bookQrcodeVO) || Objects.isNull(bookQrcodeVO.getSceneId())) continue;
if (Objects.equals(bookQrcodeVO.getSource(), "qrcodeScene")) {
if (Objects.nonNull(qrcodeVOMap.get(bookQrcodeVO.getSceneId())))
BeanUtils.copyProperties(qrcodeVOMap.get(bookQrcodeVO.getSceneId()), bookQrcodeVO);
} else if (Objects.equals(bookQrcodeVO.getSource(), "bookGroup")) {
BookQrcodeVO qrcodeVO = Optional.ofNullable(bookGroupMap.get(bookQrcodeVO.getSceneId())).orElse(new BookQrcodeVO());
BeanUtils.copyProperties(qrcodeVO,bookQrcodeVO);
// 填充标签名称
bookQrcodeVO.setProLabelName(Optional.ofNullable(bookQrcodeVO.getProLabelId()).map(labelNameMap::get).orElse(""));
bookQrcodeVO.setPurLabelName(Optional.ofNullable(bookQrcodeVO.getPurLabelId()).map(labelNameMap::get).orElse(""));
bookQrcodeVO.setDepLabelName(Optional.ofNullable(bookQrcodeVO.getDepLabelId()).map(labelNameMap::get).orElse(""));
// 填充统计信息
bookQrcodeVO.setCounts(Optional.ofNullable(bookQrcodeVO.getSceneId()).map(bookGroupStatsMap::get).map(GroupUserCountDTO::getCount).map(Long::valueOf).orElse(0L));
bookQrcodeVO.setBrowseCounts(Optional.ofNullable(bookQrcodeVO.getSceneId()).map(bookGroupStatsMap::get).map(GroupUserCountDTO::getCount).map(Long::valueOf).orElse(0L));
bookQrcodeVO.setBrowserCounts(Optional.ofNullable(bookQrcodeVO.getSceneId()).map(bookGroupStatsMap::get).map(GroupUserCountDTO::getUserCount).map(Long::valueOf).orElse(0L));
// 填充印码位置信息
List<QrcodeLocationDto> qrcodeLocations = bookQrcodeVO.getQrcodeLocations();
if (CollUtil.isEmpty(qrcodeLocations)) {
bookQrcodeVO.setQrcodeLocations(new ArrayList<>());
} else {
qrcodeLocations.forEach(it -> {
if (Objects.nonNull(it) && Objects.nonNull(it.getLocationId())) {
it.setLocationName(Optional.ofNullable(bookGroupLocationMap.get(it.getLocationId())).orElse(""));
}
});
}
// 填充资源列表
if (CollUtil.isEmpty(bookGroupServeMap) || CollUtil.isEmpty(bookGroupServeMap.get(bookQrcodeVO.getSceneId()))){
bookQrcodeVO.setMessages(new ArrayList<>());
continue;
}
// 填充资源明细
List<BookGroupServe> bookGroupServes = bookGroupServeMap.get(bookQrcodeVO.getSceneId());
List<MessageDto> messageDtos = new ArrayList<>(bookGroupServes.size());
for (BookGroupServe bookGroupServe : bookGroupServes) {
MessageDto messageDto = new MessageDto();
messageDto.setFromId(bookGroupServe.getServeId());
messageDto.setTypeCode(bookGroupServe.getServeType());
messageDto.setUrl(bookGroupServe.getServeUrl());
messageDto.setFromType(bookGroupServe.getTypeCode());
if(Objects.equals(bookGroupServe.getServeType(), MessageFromTypeEnum.PRODUCT.value)){
ProductDto productDto = Optional.ofNullable(bookGroupServe.getServeId()).map(bookGroupProductMap::get).orElse(new ProductDto());
messageDto.setPicUrl(Optional.ofNullable(productDto.getCoverImg()).orElse(""));
messageDto.setPosterPicUrl(Optional.ofNullable(productDto.getCoverImg()).orElse(""));
messageDto.setServiceLead(Optional.ofNullable(productDto.getProductName()).orElse(""));
messageDto.setTitle(Optional.ofNullable(productDto.getProductName()).orElse(""));
messageDto.setTypeCodeName(Optional.ofNullable(productDto.getProductTypeDto()).map(ProductTypeDto::getTypeName).orElse(""));
messageDto.setShortTitle(Optional.ofNullable(messageDto.getTypeCodeName()).orElse(""));
messageDto.setCoverImg(Optional.ofNullable(productDto.getCoverImg()).orElse(""));
messageDto.setSuper(Optional.ofNullable(messageDto.getFromId()).map(isSuperMap::get).orElse(false));
String serveLink = ServeLinkUtils.getServeLink(bookGroupServe.getServeType(), productDto.getProductTypeCode(),
String.valueOf(bookGroupServe.getServeId()), null, String.valueOf(qrcodeVO.getChannelPartyId()),
String.valueOf(qrcodeVO.getAdviserId()), null);
messageDto.setUrl(serveLink);
}else if (Objects.equals(bookGroupServe.getServeType(), MessageFromTypeEnum.APP.value)){
AppDto appDto = Optional.ofNullable(bookGroupServe.getServeId()).map(bookGroupAppMap::get).orElse(new AppDto());
messageDto.setPicUrl(Optional.ofNullable(appDto.getTransverseImg()).orElse(""));
messageDto.setPosterPicUrl(Optional.ofNullable(appDto.getTransverseImg()).orElse(""));
messageDto.setServiceLead(Optional.ofNullable(appDto.getTitle()).orElse(""));
messageDto.setShortTitle(Optional.ofNullable(appDto.getTypeName()).orElse(""));
messageDto.setTitle(Optional.ofNullable(appDto.getTitle()).orElse(""));
messageDto.setTypeCodeName(Optional.ofNullable(appDto.getTypeName()).orElse(""));
messageDto.setCoverImg(Optional.ofNullable(appDto.getSquareImg()).orElse(""));
String serveLink = ServeLinkUtils.getServeLink(bookGroupServe.getServeType(), appDto.getTypeCode(),
String.valueOf(bookGroupServe.getServeId()), null, String.valueOf(qrcodeVO.getChannelPartyId()),
String.valueOf(qrcodeVO.getAdviserId()), null);
messageDto.setUrl(serveLink);
}
messageDtos.add(messageDto);
}
bookQrcodeVO.setMessages(messageDtos);
}
}
} catch (InterruptedException | ExecutionException e) {
LOGGER.warn("[fillPageList] 异步获取信息失败");
}
}
} }
...@@ -24,7 +24,7 @@ import com.pcloud.book.book.vo.AgentBookStatsDetailVO; ...@@ -24,7 +24,7 @@ import com.pcloud.book.book.vo.AgentBookStatsDetailVO;
import com.pcloud.book.book.vo.BookServeInfo; import com.pcloud.book.book.vo.BookServeInfo;
import com.pcloud.book.book.vo.PcloudAdviserBookVO; import com.pcloud.book.book.vo.PcloudAdviserBookVO;
import com.pcloud.book.book.vo.QrCodeVO; import com.pcloud.book.book.vo.QrCodeVO;
import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto; import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -49,7 +49,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -49,7 +49,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -408,4 +407,18 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -408,4 +407,18 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
public ResponseDto<Map<String, BookStatisticsResultDto>> getBookRightsCount(@RequestBody List<BookRequestVO> requestVOS) { public ResponseDto<Map<String, BookStatisticsResultDto>> getBookRightsCount(@RequestBody List<BookRequestVO> requestVOS) {
return new ResponseDto<>(bookAdviserBiz.getBookRightsCount(requestVOS)); return new ResponseDto<>(bookAdviserBiz.getBookRightsCount(requestVOS));
} }
@ApiOperation("获取图书下二维码列表")
@GetMapping("qrList4AdviserBookNew")
public ResponseDto<PageBeanNew<BookQrcodeVO>> qrList4AdviserBookNew(
@RequestHeader("token") String token,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage,
@RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "sceneName", required = false) String sceneName) {
ParamChecker.checkPageParamIsAbsent(currentPage, numPerPage, "分页参数错误!");
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(bookAdviserBiz.qrList4AdviserBookNew(bookId,channelId,adviserId,sceneName,currentPage,numPerPage));
}
} }
...@@ -3,15 +3,19 @@ ...@@ -3,15 +3,19 @@
*/ */
package com.pcloud.book.consumer.channel; package com.pcloud.book.consumer.channel;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.channelcenter.qrcode.dto.BookDto; import com.pcloud.channelcenter.qrcode.dto.BookDto;
import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO; import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto; import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.qrcode.entity.QrcodeScene; import com.pcloud.channelcenter.qrcode.entity.QrcodeScene;
import com.pcloud.channelcenter.qrcode.service.QrcodeLocationAssocService;
import com.pcloud.channelcenter.qrcode.service.QrcodeSceneService; import com.pcloud.channelcenter.qrcode.service.QrcodeSceneService;
import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrAskVO; import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrAskVO;
import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrVO; import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrVO;
import com.pcloud.channelcenter.qrcode.vo.BookAssocQRcountRequestVO; import com.pcloud.channelcenter.qrcode.vo.BookAssocQRcountRequestVO;
import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumReqDTO; import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumReqDTO;
import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumRespDTO; import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumRespDTO;
...@@ -40,6 +44,7 @@ import java.util.ArrayList; ...@@ -40,6 +44,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
/** /**
* @描述:二维码中间件 * @描述:二维码中间件
...@@ -60,6 +65,8 @@ public class QrcodeSceneConsr { ...@@ -60,6 +65,8 @@ public class QrcodeSceneConsr {
private MessageService messageService; private MessageService messageService;
@Autowired @Autowired
private AccountSettingService accountSettingService; private AccountSettingService accountSettingService;
@Autowired
private QrcodeLocationAssocService qrcodeLocationAssocService;
...@@ -491,4 +498,33 @@ public class QrcodeSceneConsr { ...@@ -491,4 +498,33 @@ public class QrcodeSceneConsr {
} }
return list; return list;
} }
/**
* 模糊匹配印码位置
*/
public List<Long> getLocationIds4Name(String name) {
if (StrUtil.isBlank(name)) {
return new ArrayList<>();
}
try {
return Optional.ofNullable(ResponseHandleUtil.parseList(qrcodeLocationAssocService.getLocationIds4Name(name), Long.class)).orElse(new ArrayList<>());
} catch (Exception e) {
LOGGER.warn("【模糊匹配印码位置】 请求失败,<ERROR>.[getLocationIds4Name]:{}", e.getMessage(), e);
return new ArrayList<>();
}
}
/**
* 渠道查询图书二维码
*/
public List<BookQrcodeVO> qrList4AdviserBookNew(Long bookId, Long channelId, Long adviserId, String sceneName) {
if (ObjectUtil.hasEmpty(bookId, channelId, adviserId)) return new ArrayList<>();
try {
return Optional.ofNullable(ResponseHandleUtil.parseList(qrcodeSceneService.qrList4AdviserBookNew(bookId, channelId, adviserId, sceneName), BookQrcodeVO.class)).orElse(new ArrayList<>());
} catch (Exception e) {
LOGGER.warn("【渠道查询图书二维码】 请求失败,<ERROR>.[qrList4AdviserBookNew]:{}", e.getMessage(), e);
return new ArrayList<>();
}
}
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
package com.pcloud.book.consumer.user; package com.pcloud.book.consumer.user;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException; import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO; import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO;
...@@ -11,6 +12,8 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeMessageDTO; ...@@ -11,6 +12,8 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeMessageDTO;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto; import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.qrcode.service.QrcodeLocationAssocService; import com.pcloud.channelcenter.qrcode.service.QrcodeLocationAssocService;
import com.pcloud.channelcenter.qrcode.service.QrcodeSceneService; import com.pcloud.channelcenter.qrcode.service.QrcodeSceneService;
import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.qrcode.vo.ServeIdTypeVO; import com.pcloud.channelcenter.qrcode.vo.ServeIdTypeVO;
import com.pcloud.channelcenter.wechat.entity.AccountSetting; import com.pcloud.channelcenter.wechat.entity.AccountSetting;
import com.pcloud.channelcenter.wechat.service.AccountSettingService; import com.pcloud.channelcenter.wechat.service.AccountSettingService;
...@@ -289,6 +292,26 @@ public class ChannelConsr { ...@@ -289,6 +292,26 @@ public class ChannelConsr {
} }
} }
public List<BookQrcodeVO> getQrList4SceneIds(List<Long> qrcodeSceneIds) {
if (CollUtil.isEmpty(qrcodeSceneIds)) return new ArrayList<>();
try {
return ResponseHandleUtil.parseList(qrcodeSceneService.getQrList4SceneIds(qrcodeSceneIds), BookQrcodeVO.class);
} catch (Exception e) {
LOGGER.warn("获取二维码信息失败!ERR:" + e.getMessage(), e);
return new ArrayList<>();
}
}
public Map<Long, AccountSettingDto> listWechat(List<Long> channelIds){
if (CollUtil.isEmpty(channelIds)) return new HashMap<>();
try {
return ResponseHandleUtil.parseMap(accountSettingService.listWechat(channelIds), Long.class, AccountSettingDto.class);
} catch (BizException e) {
LOGGER.warn("根据渠道id获取微信信息失败!ERR:" + e.getMessage(), e);
return new HashMap<>();
}
}
/** /**
* 查询图书下配置的资源ID和资源类型 * 查询图书下配置的资源ID和资源类型
*/ */
......
...@@ -880,4 +880,16 @@ public class WechatGroupConsr { ...@@ -880,4 +880,16 @@ public class WechatGroupConsr {
return new ArrayList<>(); return new ArrayList<>();
} }
} }
public Map<Long, GroupUserCountDTO> getScanCountByGroup(List<Long> bookGroupIds) {
if (CollUtil.isEmpty(bookGroupIds)) return new HashMap<>();
try {
return ResponseHandleUtil.parseMap(groupMemberService.getScanCountByGroup(bookGroupIds, null), Long.class, GroupUserCountDTO.class);
} catch (Exception e) {
log.warn("[getScanCountByGroup] 批量获取社群码扫码人数/次数 失败" + e.getMessage(), e);
return new HashMap<>();
}
}
} }
...@@ -10,6 +10,7 @@ import com.pcloud.book.group.dto.TopAgentBookGroupDTO; ...@@ -10,6 +10,7 @@ import com.pcloud.book.group.dto.TopAgentBookGroupDTO;
import com.pcloud.book.group.entity.BookGroup; import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.QrChangeRecord; import com.pcloud.book.group.entity.QrChangeRecord;
import com.pcloud.book.group.vo.BookGroupAnalysisVO; import com.pcloud.book.group.vo.BookGroupAnalysisVO;
import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO; import com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
...@@ -388,5 +389,9 @@ public interface BookGroupDao extends BaseDao<BookGroup> { ...@@ -388,5 +389,9 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
List<BookGroupDTO> getDTOByBookIdList(Long bookId, Long channelId, Long adviserId); List<BookGroupDTO> getDTOByBookIdList(Long bookId, Long channelId, Long adviserId);
List<BookQrcodeVO> listBookQrcodes(Long bookId, Long channelId, Long adviserId, String sceneName, List<Long> locationIds);
List<BookQrcodeVO> listBookQrcodeVOByIds(List<Long> bookGroupIds);
List<ServeIdTypeDTO> listServeIdAndType4Book(Long bookId, Long channelId, Long adviserId); List<ServeIdTypeDTO> listServeIdAndType4Book(Long bookId, Long channelId, Long adviserId);
} }
package com.pcloud.book.group.dao.impl; package com.pcloud.book.group.dao.impl;
import cn.hutool.core.map.MapUtil;
import com.pcloud.book.group.dao.BookGroupDao; import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.AgentStatisticsInfoDTO; import com.pcloud.book.group.dto.AgentStatisticsInfoDTO;
import com.pcloud.book.group.dto.BookGroupDTO; import com.pcloud.book.group.dto.BookGroupDTO;
...@@ -11,6 +12,7 @@ import com.pcloud.book.group.dto.TopAgentBookGroupDTO; ...@@ -11,6 +12,7 @@ import com.pcloud.book.group.dto.TopAgentBookGroupDTO;
import com.pcloud.book.group.entity.BookGroup; import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.QrChangeRecord; import com.pcloud.book.group.entity.QrChangeRecord;
import com.pcloud.book.group.vo.BookGroupAnalysisVO; import com.pcloud.book.group.vo.BookGroupAnalysisVO;
import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO; import com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
...@@ -525,6 +527,21 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou ...@@ -525,6 +527,21 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
} }
@Override @Override
public List<BookQrcodeVO> listBookQrcodes(Long bookId, Long channelId, Long adviserId, String sceneName, List<Long> locationIds) {
Map<String, Object> paramMap = MapUtil.of("bookId", bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
paramMap.put("sceneName", sceneName);
paramMap.put("locationIds", locationIds);
return getSqlSession().selectList(getStatement("listBookQrcodes"), paramMap);
}
@Override
public List<BookQrcodeVO> listBookQrcodeVOByIds(List<Long> bookGroupIds) {
return getSqlSession().selectList(getStatement("listBookQrcodeVOByIds"), MapUtil.of("bookGroupIds", bookGroupIds));
}
@Override
public List<ServeIdTypeDTO> listServeIdAndType4Book(Long bookId, Long channelId, Long adviserId) { public List<ServeIdTypeDTO> listServeIdAndType4Book(Long bookId, Long channelId, Long adviserId) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId", bookId); paramMap.put("bookId", bookId);
......
...@@ -1298,6 +1298,64 @@ ...@@ -1298,6 +1298,64 @@
</foreach> </foreach>
</select> </select>
<select id="listBookQrcodes" resultType="com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO" parameterType="map">
SELECT id sceneId, update_time lastModifiedDate, 'bookGroup' source
FROM book_group
WHERE
book_id = ${bookId}
AND is_delete = 0
AND create_user = ${adviserId}
AND channel_id = ${channelId}
<if test="sceneName != null">
AND (group_qrcode_name LIKE CONCAT('%', #{sceneName}, '%')
<if test="locationIds != null">
OR group_qrcode_location_id IN <foreach collection="locationIds" open="(" item="it" separator="," close=")"> ${it} </foreach>
</if>
)
</if>
</select>
<resultMap id="BookQrcodeVO" type="com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO">
<id column="id" property="sceneId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelPartyId" jdbcType="BIGINT"/>
<result column="group_qrcode_url" property="qrcodeUrl" jdbcType="VARCHAR"/>
<result column="group_qrcode_name" property="qrcodeName" jdbcType="VARCHAR"/>
<result column="pro_label_id" property="proLabelId" jdbcType="BIGINT"/>
<result column="dep_label_id" property="depLabelId" jdbcType="BIGINT"/>
<result column="pur_label_id" property="purLabelId" jdbcType="BIGINT"/>
<result column="create_user" property="adviserId" jdbcType="BIGINT"/>
<result column="create_time" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="update_time" property="lastModifiedDate" jdbcType="TIMESTAMP"/>
<result column="join_group_type" property="joinGroupType" jdbcType="INTEGER"/>
<result column="jump_type" property="jumpType" jdbcType="INTEGER"/>
<result column="source" property="source" jdbcType="VARCHAR"/>
<collection property="qrcodeLocations" ofType="com.pcloud.channelcenter.qrcode.dto.QrcodeLocationDto">
<id column="group_qrcode_location_id" property="locationId" jdbcType="BIGINT"/>
</collection>
</resultMap>
<select id="listBookQrcodeVOByIds" resultMap="BookQrcodeVO" parameterType="map">
SELECT id,
book_id,
channel_id,
group_qrcode_url,
group_qrcode_name,
pro_label_id,
dep_label_id,
pur_label_id,
create_user,
create_time,
update_time,
join_group_type,
jump_type,
group_qrcode_location_id,
'bookGroup' source
FROM book_group
WHERE id IN <foreach collection="bookGroupIds" open="(" item="it" separator="," close=")"> ${it} </foreach>
</select>
<select id="listServeIdAndType4Book" resultType="com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO" parameterType="map"> <select id="listServeIdAndType4Book" resultType="com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO" parameterType="map">
select serve_id serveId, serve_type serveType, type_code typeCode, a.create_time createTime select serve_id serveId, serve_type serveType, type_code typeCode, a.create_time createTime
from book_group_serve a from book_group_serve a
......
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
select t.serve_id serveId, select t.serve_id serveId,
t.book_group_id bookGroupId, t.book_group_id bookGroupId,
t.serve_type serveType, t.serve_type serveType,
t.type_code typeCode,
t.serve_url serveUrl t.serve_url serveUrl
from book_group_serve t from book_group_serve t
where book_group_id in where book_group_id in
......
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