Commit aec0b13e by 郑勇

bug: [1029330] erp多个码对应rays一个码

parent d6a130d5
......@@ -184,6 +184,10 @@ public interface BookAdviserService {
@ApiOperation("erp获取二维码下面配置了企业微信的二维码")
ResponseEntity<ResponseDto<List<Long>>> getHasWxWorkCode(@RequestBody List<Long> sceneIds);
@PostMapping("getHasResourceCode")
@ApiOperation("erp获取配置了资源的Rays码")
ResponseEntity<ResponseDto<List<Long>>> getHasResourceCode(@RequestBody List<Long> sceneIds);
@GetMapping("getBookIdsByAgentId")
@ApiOperation("根据agentId获取书籍id")
void getBookIdsByAgentId(@RequestParam("agentId") Long agentId);
......
......@@ -44,6 +44,10 @@ public class BookGroupServeCountDTO extends BaseDto {
@ApiModelProperty("公众号sceneid/RAYS码bookgroupid")
private Long bookQrcodeId;
@ApiModelProperty("sceneId")
private Long sceneId;
@ApiModelProperty("sceneId数组")
private String sceneIdStr;
......
......@@ -379,6 +379,15 @@ public interface BookAdviserBiz {
List<Long> getHasWxWorkCode(List<Long> sceneIds);
/**
* erp获取rays自有码下面是否配置了资源
* @param sceneIds
* @return
*/
List<Long> getHasResourceCode4Erp(List<Long> sceneIds);
/**
* 根据agentId获取书籍id
* @param agentId
*/
......
......@@ -75,6 +75,7 @@ import com.pcloud.book.group.biz.ResourcePageBiz;
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.dao.ResourcePageItemDao;
import com.pcloud.book.group.dto.BookAppletSceneDTO;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
......@@ -149,8 +150,10 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
......@@ -256,6 +259,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
private ResourcePageBiz resourcePageBiz;
@Autowired
private UpdateSuperSearchProducer searchProducer;
@Autowired
private ResourcePageItemDao resourcePageItemDao;
@Override
public List<BookDto> listByAdviserId(Long adviserId) {
......@@ -1154,31 +1159,42 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
throw new BookBizException(BookBizException.ERROR, "参数为空");
}
//type 代表的是过滤二维码。如果是0,展示所有的二维码。如果是1(展示没有资源的码。但是要过滤小睿教育的书的非公众号二维码)
//获取rays码的权益书。一本书的权益书都一样
Integer rightsettingCounts = getRightsettingCounts(bookId, adviserId, channelId);
List<Long> xiaoRuiEducation = channelConsr.isXiaoRuiEducation(Lists.newArrayList(bookId));
//BookAdviserDto bookAdviserDto = bookAdviserDao.getBase(bookId, channelId, adviserId);
//现在一本书下面可以配多个跳小睿的码
//JoinGroupTypeEnum.XIAORUI的码迁到渠道了。不走这里查)
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());
Set<Long> groupQrcodeSet=new HashSet<>();
Set<Long> xiaoruiSet=new HashSet<>();
List<QrCodeVO> qrCodeVOS = new ArrayList<>();
if(CollUtil.isNotEmpty(bookGroupDTOList)){
for (BookGroupDTO bookGroupDTO : bookGroupDTOList) {
Integer joinGroupType = bookGroupDTO.getJoinGroupType();
if(null!=joinGroupType){
//群二维码和客服机器人
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(joinGroupType) || JoinGroupTypeEnum.ROBOT.getCode().equals(joinGroupType)){
groupQrcodeSet.add(bookGroupDTO.getId());
}
//(**不包括群二维码,小睿)资源数量
if(!JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(joinGroupType)){
xiaoruiSet.add(bookGroupDTO.getId());
}
}
}
List<Long> groupQrcodeList = new ArrayList<>(groupQrcodeSet);
List<Long> xiaoruiList = new ArrayList<>(xiaoruiSet);
//分开查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<Long> bookGroupIds =CollUtil.isEmpty(bookGroupDTOList) ? new ArrayList<>() : bookGroupDTOList.stream().filter(a -> null != a.getId()).map(a -> a.getId()).distinct().collect(Collectors.toList());
List<Long> bookGroupIds =CollUtil.isEmpty(bookGroupDTOList) ? new ArrayList<>() : bookGroupDTOList.stream().filter(a -> null != a.getId() && null!=a.getJoinGroupType()
&& !JoinGroupTypeEnum.XIAORUI.getCode().equals(a.getJoinGroupType())).map(a -> a.getId()).distinct().collect(Collectors.toList());
Map<Long, BigDecimal> groupListSaleInfoMap = tradeConsr.getGroupListSaleInfo(bookGroupIds);
//小睿的销售额 要用sceneId查
List<QrCodeVO> qrCodeVOS = new ArrayList<>();
QrCodeVO qrCodeVO;
for (BookGroupDTO bookGroupDTO : bookGroupDTOList) {
qrCodeVO = new QrCodeVO();
......@@ -1201,18 +1217,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
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(CollUtil.isNotEmpty(groupQrCodeMap) && groupQrCodeMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = groupQrCodeMap.get(bookGroupDTO.getId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()) {
qrCodeVO.setServeCount((null == qrCodeVO.getServeCount() ? 0 : qrCodeVO.getServeCount()) + bookGroupServeCountDTO.getServeCount());
}
}
}
}
//小睿的码才有权益
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupDTO.getJoinGroupType())){
qrCodeVO.setRightsCount(rightsettingCounts);
}
//设置销售额
if(CollUtil.isNotEmpty(groupListSaleInfoMap) && groupListSaleInfoMap.containsKey(bookGroupDTO.getId())){
qrCodeVO.setSaleMoney(groupListSaleInfoMap.get(bookGroupDTO.getId()));
......@@ -1224,57 +1236,15 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
qrCodeVOS.add(qrCodeVO);
}
/*BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId, channelId, adviserId);
if (null != bookGroupDTO) {
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount;
Map<String, BookGroupServeCountDTO> mapBookGroupRobotServeCount = null;
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(bookGroupDTO.getJoinGroupType())){
mapBookGroupServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId), JoinGroupTypeEnum.GROUP_QRCODE.getCode());
} else {
mapBookGroupServeCount = bookGroupBiz.mapBookGroupServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId));
// 获取 1V1 关键词回复数量
if(JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
mapBookGroupRobotServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId), JoinGroupTypeEnum.ROBOT.getCode());
}
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupDTO.getJoinGroupType())){
// 小睿权益数量
List<RightsSettingDto> rightsSettingDtos = rightsSettingDAO.listByBookId(bookId);
if(!CollectionUtils.isEmpty(rightsSettingDtos) && mapBookGroupServeCount != null && !mapBookGroupServeCount.isEmpty()){
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.values().stream().findFirst().get();
if(bookGroupServeCountDTO!=null){
bookGroupServeCountDTO.setRightsCount(rightsSettingDtos.get(0).getCount());
}
}
}
}
QrCodeVO qrCodeVO = new QrCodeVO();
qrCodeVO.setQrCodeName(bookGroupDTO.getGroupQrcodeName());
qrCodeVO.setQrCodeUrl(bookGroupDTO.getGroupQrcodeUrl());
qrCodeVO.setServeCount(0);
qrCodeVO.setRightsCount(0);
qrCodeVO.setJoinGroupType(bookGroupDTO.getJoinGroupType());
if(mapBookGroupServeCount!=null && !mapBookGroupServeCount.isEmpty()) {
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get("" + bookId + "_" + channelId + "_" + adviserId);
qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount());
// 如果是小睿码
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())){
qrCodeVO.setRightsCount(null == bookGroupServeCountDTO.getRightsCount() ? 0 : bookGroupServeCountDTO.getRightsCount());
}
}
if(mapBookGroupRobotServeCount!=null && !mapBookGroupRobotServeCount.isEmpty()){
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());
List<Long> qrcodeSceneIds = qrcodeSceneDtos.stream().filter(a->null!=a.getQrcodeType() && "wechat".equalsIgnoreCase(a.getQrcodeType())).map(x -> x.getSceneId()).collect(Collectors.toList());
//之前小睿的码。现在叫rays码
List<Long> ruiList = qrcodeSceneDtos.stream().filter(a->null!=a.getQrcodeType() && ("ali".equalsIgnoreCase(a.getQrcodeType()) || "own".equalsIgnoreCase(a.getQrcodeType()))).map(x -> x.getSceneId()).collect(Collectors.toList());
//小睿的资源数量。要在resource_page_item查
Map<Long, BookGroupServeCountDTO> ruiMap=resourcePageItemDao.mapQrServeCount(ruiList);
// 企业微信群资源数
Map<Long, BookGroupServeCountDTO> bookQrcodeWxworkMap = bookQrcodeWxworkBiz.mapWxWorkServeCount4SceneIds(sceneIds, BookQrcodeType.OFFICIAL_ACCOUNTS.getCode());
//计算码的销售额
......@@ -1284,7 +1254,17 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrCodeVO1.setQrCodeName(e.getSceneName());
qrCodeVO1.setQrCodeUrl(e.getQrcodeUrl());
BookGroupServeCountDTO serveCountDTO = bookQrcodeWxworkMap.get(e.getSceneId());
qrCodeVO1.setServeCount(0);
//公众号二维码才算渠道原来的资源
if(CollUtil.isNotEmpty(qrcodeSceneIds) && qrcodeSceneIds.contains(e.getSceneId())){
qrCodeVO1.setServeCount((ListUtils.isEmpty(e.getMessages()) ? 0 : e.getMessages().size()) + ((serveCountDTO == null || null==serveCountDTO.getServeCount()) ? 0 : serveCountDTO.getServeCount()));
}
if(CollUtil.isNotEmpty(ruiMap) && ruiMap.containsKey(e.getSceneId())){
BookGroupServeCountDTO bookGroupServeCountDTO = ruiMap.get(e.getSceneId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()){
qrCodeVO1.setServeCount(bookGroupServeCountDTO.getServeCount());
}
}
//设置二维码类型和书刊是否是小睿教育的书
qrCodeVO1.setCodeType(e.getQrcodeType());
qrCodeVO1.setXiaoRuiEducation(false);
......@@ -1348,22 +1328,35 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
if(CollectionUtils.isEmpty(adviserIds) || CollectionUtils.isEmpty(bookIds) || CollectionUtils.isEmpty(channelIds)){
throw new ChannelBizException(ChannelBizException.FILED_NULL, "adviserIds、bookIds、channelIds 参数为空!");
}
Future<Map<String, QrcodeMessageDTO>> mapQrcodeMessageSubmit = ThreadPoolUtils.OTHER_POOL.submit(() -> channelConsr.mapResourceCount(adviserIds, bookIds, channelIds));
//公众号二维码
Future<Map<String, QrcodeMessageDTO>> mapQrcodeMessageSubmit = ThreadPoolUtils.OTHER_POOL.submit(() -> channelConsr.mapResourceCount(adviserIds, bookIds, channelIds,1));
//Rays二维码
Future<Map<String, QrcodeMessageDTO>> mapRaysCodeMessageSubmit = ThreadPoolUtils.OTHER_POOL.submit(() -> channelConsr.mapResourceCount(adviserIds, bookIds, channelIds,2));
Future<Map<String, BookGroupServeCountDTO>> mapBookGroupServeCountSubmit = ThreadPoolUtils.OTHER_POOL.submit(() -> bookGroupBiz.mapBookGroupServeCount(adviserIds, bookIds, channelIds));
Future<Map<String, BookGroupServeCountDTO>> mapBookGroupQrcodeSubmit = ThreadPoolUtils.OTHER_POOL.submit(() -> bookGroupBiz.mapBookGroupQrcodeServeCount(adviserIds, bookIds, channelIds, JoinGroupTypeEnum.GROUP_QRCODE.getCode()));
Future<Map<String, BookGroupServeCountDTO>> mapBookGroupRobotServeCountSubmit = ThreadPoolUtils.OTHER_POOL.submit(()-> bookGroupBiz.mapBookGroupQrcodeServeCount(adviserIds, bookIds, channelIds, JoinGroupTypeEnum.ROBOT.getCode()));
// Future<Map<Long, Integer>> rightsMapSubmit = ThreadPoolUtils.OTHER_POOL.submit(()-> bookAdviserBiz.rightsCountByBookIds(bookIds));
//rays码的资源数量
Future<Map<String, BookGroupServeCountDTO>> raysCodeServeCountSubmit = ThreadPoolUtils.OTHER_POOL.submit(()-> resourcePageBiz.mapRaysCodeServeCount(adviserIds, bookIds, channelIds));
Future<Map<Long, Integer>> rightsMapSubmit = ThreadPoolUtils.OTHER_POOL.submit(()-> bookAdviserBiz.rightsCountByBookIds(bookIds));
Map<String, QrcodeMessageDTO> mapQrcodeMessage =new HashMap<>();
Map<String, QrcodeMessageDTO> mapRaysCodeMessage =new HashMap<>();
Map<String, BookGroupServeCountDTO> mapWxworkServeCount =new HashMap<>();
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount = new HashMap<>();
Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount = new HashMap<>();
Map<String, BookGroupServeCountDTO> mapBookGroupRobotServeCount =new HashMap<>();
Map<Long, Integer> rightsMap=new HashMap<>();
Map<String, BookGroupServeCountDTO> raysCodeServeCount =new HashMap<>();
/* Map<Long, Integer> rightsMap=new HashMap<>();*/
try {
mapQrcodeMessage = mapQrcodeMessageSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("获取二维码信息错误: {}==", e);
}
try {
mapRaysCodeMessage = mapRaysCodeMessageSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("获取Rays二维码信息错误: {}==", e);
}
if(CollUtil.isNotEmpty(mapQrcodeMessage)){
// 只查询公众号二维码中未被删除的sceneId对应的企业微信资源数
String strSceneIds = mapQrcodeMessage.values().stream().map(x -> x.getSceneIdStr()).collect(Collectors.joining(","));
......@@ -1385,10 +1378,15 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
LOGGER.error("批量获取书下的资源数小睿错误: {}==", e);
}
try {
raysCodeServeCount = raysCodeServeCountSubmit.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("批量获取rays码下的资源数量错误: {}==", e);
}
/*try {
rightsMap = rightsMapSubmit.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("获取权益数量错误: {}==", e);
}
}*/
if(mapQrcodeMessage == null || mapQrcodeMessage.isEmpty()){
mapQrcodeMessage = new HashMap<>();
}
......@@ -1402,14 +1400,27 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
mapBookGroupRobotServeCount = new HashMap<>();
}
List<String> bookChannelAdviserIds = mapQrcodeMessage.keySet().stream().collect(Collectors.toList());
bookChannelAdviserIds.addAll(mapRaysCodeMessage.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds.addAll(mapBookGroupServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds.addAll(mapBookGroupQrcodeServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds.addAll(mapBookGroupRobotServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds = bookChannelAdviserIds.stream().distinct().collect(Collectors.toList());
//处理渠道查询二维码rays码的资源数量,从book出数量
if(CollUtil.isNotEmpty(mapRaysCodeMessage)){
for (Entry<String, QrcodeMessageDTO> entry : mapRaysCodeMessage.entrySet()) {
if(CollUtil.isNotEmpty(raysCodeServeCount) && raysCodeServeCount.containsKey(entry.getKey())){
//book这边rays码的资源
BookGroupServeCountDTO bookGroupServeCountDTO = raysCodeServeCount.get(entry.getKey());
if (null != bookGroupServeCountDTO) {
entry.getValue().setServeCount(null!=bookGroupServeCountDTO.getServeCount() ? bookGroupServeCountDTO.getServeCount() : 0);
}
}
}
}
// 处理权益数
if(rightsMap!=null && !rightsMap.isEmpty()){
/* if(rightsMap!=null && !rightsMap.isEmpty()){
for (BookGroupServeCountDTO bookGroupServeCountDTO : mapBookGroupServeCount.values()) {
if(!JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())){
continue;
......@@ -1418,7 +1429,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
Integer count = rightsMap.get(bookGroupServeCountDTO.getBookId());
bookGroupServeCountDTO.setRightsCount(count);
}
}
}*/
BookResourceStatisticsDTO bookResourceStatisticsDTO;
for (String bookChannelAdviserId : bookChannelAdviserIds) {
......@@ -1429,6 +1440,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
bookResourceStatisticsDTO = new BookResourceStatisticsDTO();
QrcodeMessageDTO qrcodeMessageDTO = mapQrcodeMessage.get(bookChannelAdviserId);
QrcodeMessageDTO raysCodeMessageDTO = mapRaysCodeMessage.get(bookChannelAdviserId);
BookGroupServeCountDTO bookQrcodeWxwork = mapWxworkServeCount.get(bookChannelAdviserId);
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get(bookChannelAdviserId);
BookGroupServeCountDTO bookGroupQrcodeServeCountDTO = mapBookGroupQrcodeServeCount.get(bookChannelAdviserId);
......@@ -1446,6 +1458,15 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + qrcodeMessageDTO.getServeCount());
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + qrcodeMessageDTO.getQrcodeCount());
}
if(raysCodeMessageDTO != null){
if(StringUtil.isEmpty(bookResourceStatisticsDTO.getBookChannelAdviserId())){
BeanUtils.copyProperties(raysCodeMessageDTO, bookResourceStatisticsDTO);
bookResourceStatisticsDTO.setQrcodeCount(0);
bookResourceStatisticsDTO.setServeCount(0);
}
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + raysCodeMessageDTO.getServeCount());
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + raysCodeMessageDTO.getQrcodeCount());
}
if(bookGroupServeCountDTO != null){
if(StringUtil.isEmpty(bookResourceStatisticsDTO.getBookChannelAdviserId())){
BeanUtils.copyProperties(bookGroupServeCountDTO, bookResourceStatisticsDTO);
......@@ -1481,12 +1502,13 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
// 设置默认值
int rightsCount = 0;
if(bookGroupServeCountDTO != null && JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())) {
if(bookGroupServeCountDTO != null && null!=bookGroupServeCountDTO.getJoinGroupType() && JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())) {
// 如果是小睿码,则设置权益数
rightsCount = null == bookGroupServeCountDTO.getRightsCount() ? 0 : bookGroupServeCountDTO.getRightsCount();
// rightsCount = null == bookGroupServeCountDTO.getRightsCount() ? 0 : bookGroupServeCountDTO.getRightsCount();
}
bookResourceStatisticsDTO.setRightsCount(rightsCount);
bookResourceStatisticsDTO.setServeTotalCount(bookResourceStatisticsDTO.getServeCount() + rightsCount);
bookResourceStatisticsDTO.setServeTotalCount(bookResourceStatisticsDTO.getServeCount());
mapBookResourceStatistics.put(bookChannelAdviserId, bookResourceStatisticsDTO);
}
return mapBookResourceStatistics;
......@@ -1630,21 +1652,39 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
//是否小睿教育的书
List<Long> xiaoRuiEducation =CollUtil.isEmpty(bookIds) ? new ArrayList<>() : channelConsr.isXiaoRuiEducation(bookIds);
// 社群书统计
//JoinGroupTypeEnum.XIAORUI的码迁到渠道了。不走这里查)
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());
Map<Long, BookGroupServeCountDTO> groupQrCodeMap=new HashMap<>();
Map<Long, BookGroupServeCountDTO> xiaoruiMap=new HashMap<>();
Set<Long> groupQrcodeSet=new HashSet<>();
Set<Long> xiaoruiSet=new HashSet<>();
List<QrCodeVO> qrCodeVOS = new ArrayList<>();
if(CollUtil.isNotEmpty(bookGroupList)){
for (BookGroupDTO bookGroupDTO : bookGroupList) {
Integer joinGroupType = bookGroupDTO.getJoinGroupType();
if(null!=joinGroupType){
//群二维码和客服机器人
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(joinGroupType) || JoinGroupTypeEnum.ROBOT.getCode().equals(joinGroupType)){
groupQrcodeSet.add(bookGroupDTO.getId());
}
//(**不包括群二维码,小睿)资源数量
if(!JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(joinGroupType)){
xiaoruiSet.add(bookGroupDTO.getId());
}
}
}
List<Long> groupQrcodeList = new ArrayList<>(groupQrcodeSet);
List<Long> xiaoruiList = new ArrayList<>(xiaoruiSet);
//分开查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);
//群二维码和客服机器人
groupQrCodeMap =CollUtil.isEmpty(groupQrcodeList) ? new HashMap<>() : bookGroupServeDao.mapGroupQrcodeServeCount(groupQrcodeList);
//(**不包括群二维码,小睿)资源数量
xiaoruiMap =CollUtil.isEmpty(xiaoruiList) ? new HashMap<>() : bookGroupServeDao.mapXiaoRuiGroupQrcodeServeCount(xiaoruiList);
}
if(CollUtil.isNotEmpty(bookGroupList)){
bookGroupList = bookGroupList.stream().filter(a -> null != a.getJoinGroupType() && !JoinGroupTypeEnum.XIAORUI.getCode().equals(a.getJoinGroupType())).collect(Collectors.toList());
}
if(!CollectionUtils.isEmpty(bookGroupList)){
List<Long> bookGroupIds = bookGroupList.stream().map(x -> x.getId()).collect(Collectors.toList());
Map<Long, GroupUserCountDTO> scanCountByGroup = wechatGroupConsr.getScanCountByGroup(bookGroupIds, null);
......@@ -1685,8 +1725,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
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(CollUtil.isNotEmpty(groupQrCodeMap) && groupQrCodeMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = groupQrCodeMap.get(bookGroupDTO.getId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()) {
qrcodeStatisticsDTO.setServeCount((null == qrcodeStatisticsDTO.getServeCount() ? 0 : qrcodeStatisticsDTO.getServeCount()) + bookGroupServeCountDTO.getServeCount());
}
......@@ -1714,6 +1754,15 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrcodeSceneDtos = Lists.newArrayList();
}
List<Long> sceneIds =CollUtil.isEmpty(qrcodeSceneDtos) ? new ArrayList<>() : qrcodeSceneDtos.stream().map(x -> x.getSceneId()).collect(Collectors.toList());
//公众号二维码
List<Long> qrCodeSceneIds =CollUtil.isEmpty(qrcodeSceneDtos) ? new ArrayList<>() : qrcodeSceneDtos.stream().filter(a->null!=a.getQrcodeType()
&& "wechat".equalsIgnoreCase(a.getQrcodeType())).map(x -> x.getSceneId()).collect(Collectors.toList());
//之前小睿的码。现在叫rays码
List<Long> ruiList =CollUtil.isEmpty(qrcodeSceneDtos) ? new ArrayList<>() : qrcodeSceneDtos.stream().filter(a->null!=a.getQrcodeType()
&& ("ali".equalsIgnoreCase(a.getQrcodeType()) || "own".equalsIgnoreCase(a.getQrcodeType()))
).map(x -> x.getSceneId()).collect(Collectors.toList());
//小睿的资源数量。要在resource_page_item查
Map<Long, BookGroupServeCountDTO> ruiMap=CollUtil.isNotEmpty(ruiList) ? resourcePageItemDao.mapQrServeCount(ruiList) : new HashMap<>();
// 企业微信群资源数
Map<Long, BookGroupServeCountDTO> bookQrcodeWxworkMap =CollUtil.isEmpty(sceneIds) ? new HashMap<>() : bookQrcodeWxworkBiz.mapWxWorkServeCount4SceneIds(sceneIds, BookQrcodeType.OFFICIAL_ACCOUNTS.getCode());
// 查询图书是否开启小睿流程
......@@ -1744,18 +1793,27 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
//设置二维码类型和二维码下面配置的资源数量。一般资源和企业微信数量
qrcodeStatisticsDTO.setCodeType(qrcodeSceneDto.getQrcodeType());
qrcodeStatisticsDTO.setServeCount(qrcodeSceneDto.getServeCount());
qrcodeStatisticsDTO.setTotalCount(qrcodeSceneDto.getServeCount());
//计算二维码下面的资源数(包括普通资源和配置的企业微信数量)
if(CollUtil.isNotEmpty(ruiMap) && ruiMap.containsKey(qrcodeSceneDto.getSceneId())){
BookGroupServeCountDTO bookGroupServeCountDTO = ruiMap.get(qrcodeSceneDto.getSceneId());
if(null!=bookGroupServeCountDTO && null!=bookGroupServeCountDTO.getServeCount()){
qrcodeStatisticsDTO.setServeCount(bookGroupServeCountDTO.getServeCount());
}
}
//计算公众号二维码下面的资源数(包括普通资源和配置的企业微信数量)
if(CollUtil.isNotEmpty(qrCodeSceneIds) && qrCodeSceneIds.contains(qrcodeSceneDto.getSceneId())){
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);
}
qrcodeStatisticsDTO.setTotalCount(qrcodeStatisticsDTO.getServeCount());
bookQrcodeStatisticsDTO.getQrcodeSceneDtoList().add(qrcodeStatisticsDTO);
}
// 筛选出疑似未印刷的二维码(扫码人数<=20 || 扫码次数<=40)
......@@ -2531,6 +2589,20 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return bookQrcodeWxworkBiz.getHasWxWorkCode(sceneIds);
}
/**
* erp获取rays自有码下面是否配置了资源
* @param sceneIds
* @return
*/
@Override
public List<Long> getHasResourceCode4Erp(List<Long> sceneIds) {
if(CollUtil.isEmpty(sceneIds)){
return new ArrayList<>();
}
List<Long> result=resourcePageItemDao.getHasResourceCode4Erp(sceneIds);
return result;
}
@Override
@ParamLog("根据agentId获取书籍id")
public void getBookIdsByAgentId(Long agentId) {
......
......@@ -3103,7 +3103,8 @@ public class BookBizImpl implements BookBiz {
qrcodeSceneDtos = Lists.newArrayList();
}
// 获取所有的社群码
List<BookGroupDTO> bookGroupList = bookGroupDao.getDTOByBookIdsAdviserIdsChannelIds(Lists.newArrayList(bookId), Lists.newArrayList(adviserId), Lists.newArrayList(channelId));
//List<BookGroupDTO> bookGroupList = bookGroupDao.getDTOByBookIdsAdviserIdsChannelIds(Lists.newArrayList(bookId), Lists.newArrayList(adviserId), Lists.newArrayList(channelId));
List<BookGroupDTO> bookGroupList = bookGroupDao.getNotXiaoRui(Lists.newArrayList(bookId), Lists.newArrayList(adviserId), Lists.newArrayList(channelId));
if(CollectionUtils.isEmpty(bookGroupList)){
bookGroupList = Lists.newArrayList();
}
......
......@@ -385,6 +385,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
return new ResponseDto<>(bookAdviserBiz.getHasWxWorkCode(sceneIds));
}
@ApiOperation("erp获取rays自有码下面是否配置了资源")
@PostMapping("getHasResourceCode4Erp")
public ResponseDto<?> getHasResourceCode4Erp(@RequestBody List<Long> sceneIds) {
return new ResponseDto<>(bookAdviserBiz.getHasResourceCode4Erp(sceneIds));
}
@PostMapping("getBooksByAgentToken")
public ResponseDto<List<Long>>getBooksByAgentToken(@RequestParam(value = "token") String token,@RequestParam(value = "index") int index,@RequestParam(value = "month" ,required = false) Integer month){
Long agentId = (Long)SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
......
......@@ -207,6 +207,12 @@ public class BookAdviserServiceImpl implements BookAdviserService {
}
@Override
@PostMapping("getHasResourceCode")
public ResponseEntity<ResponseDto<List<Long>>> getHasResourceCode(@RequestBody List<Long> sceneIds) {
return ResponseHandleUtil.toResponse(bookAdviserBiz.getHasResourceCode4Erp(sceneIds));
}
@Override
public void getBookIdsByAgentId(Long agentId) {
bookAdviserBiz.getBookIdsByAgentId(agentId);
}
......
......@@ -177,11 +177,12 @@ public class ChannelConsr {
}
}
public Map<String, QrcodeMessageDTO> mapResourceCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
public Map<String, QrcodeMessageDTO> mapResourceCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds,Integer codeType) {
MapResourceCountDTO mapResourceCountDTO = new MapResourceCountDTO();
mapResourceCountDTO.setAdviserIds(adviserIds);
mapResourceCountDTO.setBookIds(bookIds);
mapResourceCountDTO.setChannelIds(channelIds);
mapResourceCountDTO.setCodeType(codeType);
Map<String, QrcodeMessageDTO> mapQrcodeMessage = ResponseHandleUtil.parseMap(qrcodeSceneService.mapResourceCount(mapResourceCountDTO), String.class, QrcodeMessageDTO.class);
return mapQrcodeMessage;
}
......
......@@ -2,6 +2,7 @@ package com.pcloud.book.group.biz;
import com.pcloud.book.book.dto.RaysSceneCatalogDto;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageCourseDTO;
......@@ -329,4 +330,12 @@ public interface ResourcePageBiz {
List<String> mapCatalogBook(List<Long> bookIds, Long adviserId);
List<RaysSceneCatalogDto> listRaysSceneCatalogDto(List<Long> sceneIds);
/**
* rays码下面资源数量
* @param adviserIds
* @param bookIds
* @param channelIds
*/
Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds);
}
......@@ -46,6 +46,7 @@ import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.dao.ResourcePageToolDao;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageCourseDTO;
......@@ -97,6 +98,7 @@ import com.pcloud.message.common.enums.YesNoEnums;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -1694,4 +1696,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return Optional.ofNullable(bookGroupDao.listRaysSceneCatalogDto(sceneIds)).orElse(new ArrayList<>());
}
@Override
public Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
if(CollectionUtils.isEmpty(adviserIds) || CollectionUtils.isEmpty(bookIds) || CollectionUtils.isEmpty(channelIds)){
return new HashMap<>();
}
return resourcePageDao.mapRaysCodeServeCount(adviserIds, bookIds, channelIds);
}
}
......@@ -15,6 +15,7 @@ import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -401,4 +402,6 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
List<Long> mapCatalogBook(List<Long> bookIds, Long adviserId);
List<RaysSceneCatalogDto> listRaysSceneCatalogDto(List<Long> sceneIds);
List<BookGroupDTO> getNotXiaoRui(List<Long> bookIds, List<Long> adviserIds, List<Long> channelIds);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.ResourcePage;
import com.pcloud.common.core.dao.BaseDao;
......@@ -105,4 +106,6 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
* * @param null
*/
Boolean isOpenRaysBook(Long bookId, Long channelId, Long adviserId);
Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds);
}
\ No newline at end of file
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageUrlDTO;
......@@ -9,6 +10,7 @@ import com.pcloud.book.group.vo.ResourcePageItemVO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* 自有码H5页面栏目资源详情(ResourcePageItem)表数据库访问层
......@@ -90,4 +92,18 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{
List<ResourcePageUrlDTO> getServeUrl4Update(List<Long> sceneIdList);
void batchUpdateServeUrlById(List<ResourcePageUrlDTO> list);
/**
* 算码下面的资源
* @param ruiList
* @return
*/
Map<Long, BookGroupServeCountDTO> mapQrServeCount(List<Long> ruiList);
/**
* 过滤有资源的rays码
* @param sceneIds
* @return
*/
List<Long> getHasResourceCode4Erp(List<Long> sceneIds);
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import com.pcloud.common.utils.ListForInSQL;
import com.pcloud.common.utils.ListUtils;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -569,4 +570,13 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
public List<RaysSceneCatalogDto> listRaysSceneCatalogDto(List<Long> sceneIds) {
return getSessionTemplate().selectList(getStatement("listRaysSceneCatalogDto"), MapUtil.of("sceneIds", sceneIds));
}
@Override
public List<BookGroupDTO> getNotXiaoRui(List<Long> bookIds, List<Long> adviserIds, List<Long> channelIds) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookIds",bookIds);
paramMap.put("adviserIds",adviserIds);
paramMap.put("channelIds",channelIds);
return super.getSqlSession().selectList(getStatement("getNotXiaoRui"),paramMap);
}
}
......@@ -2,8 +2,10 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.ResourcePageDao;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.ResourcePage;
import com.pcloud.common.core.dao.BaseDaoImpl;
import com.pcloud.common.utils.ListUtils;
import org.springframework.stereotype.Component;
......@@ -97,4 +99,29 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
map.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("isOpenRaysBook"), map);
}
@Override
public Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
if (bookIds != null && bookIds.size() > 500) {
Map<String, BookGroupServeCountDTO>resultMap = new HashMap<>();
List<List<Long>> lists = ListUtils.groupList(bookIds);
for (List<Long> list : lists) {
Map<String, Object> map = new HashMap<>();
map.put("adviserIds", adviserIds);
map.put("bookIds", list);
map.put("channelIds", channelIds);
Map<String, BookGroupServeCountDTO> objectObjectMap = getSessionTemplate().selectMap(getStatement("mapRaysCodeServeCount"), map, "bookChannelAdviserId");
if(objectObjectMap!=null){
resultMap.putAll(objectObjectMap);
}
}
return resultMap;
} else {
Map<String, Object> map = new HashMap<>();
map.put("adviserIds", adviserIds);
map.put("bookIds", bookIds);
map.put("channelIds", channelIds);
return getSessionTemplate().selectMap(getStatement("mapRaysCodeServeCount"), map, "bookChannelAdviserId");
}
}
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageUrlDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.ResourcePageItem;
import com.pcloud.book.group.vo.ResourcePageItemVO;
......@@ -93,4 +94,18 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple
public void batchUpdateServeUrlById(List<ResourcePageUrlDTO> list) {
getSessionTemplate().update(getStatement("batchUpdateServeUrlById"), list);
}
@Override
public Map<Long, BookGroupServeCountDTO> mapQrServeCount(List<Long> ruiList) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("sceneIds", ruiList);
return getSessionTemplate().selectMap(getStatement("mapQrServeCount"), paramMap, "sceneId");
}
@Override
public List<Long> getHasResourceCode4Erp(List<Long> sceneIds) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("sceneIds", sceneIds);
return getSessionTemplate().selectList(getStatement("getHasResourceCode4Erp"), paramMap);
}
}
......@@ -153,6 +153,7 @@
and book_id = #{bookId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and create_user = #{adviserId,jdbcType=BIGINT}
and join_group_type != 4
</select>
<select id="getDTOByBookIdsAnsAdviserIds" resultMap="BookGroupDTO" parameterType="map">
......@@ -1416,4 +1417,23 @@
HAVING
count( b.id ) =1
</select>
<select id="getNotXiaoRui" resultMap="BookGroupDTO" parameterType="map">
select
<include refid="Base_Column_List"/>
from book_group
where is_delete = 0 AND book_id in
<foreach collection="bookIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and create_user in
<foreach collection="adviserIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and channel_id in
<foreach collection="channelIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and join_group_type!=4
</select>
</mapper>
......@@ -235,7 +235,7 @@
<foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")">
${adviserId}
</foreach>
AND bg.join_group_type IN (2,3,4)
AND bg.join_group_type IN (2,3)
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
......@@ -255,7 +255,7 @@
<foreach collection="bookGroupIds" item="bookGroupId" separator="," open="(" close=")">
${bookGroupId}
</foreach>
AND bg.join_group_type IN (2,3,4)
AND bg.join_group_type IN (2,3)
GROUP BY bg.id
</select>
......
......@@ -228,4 +228,27 @@
AND channel_id = #{channelId}
AND open_rays = 1
</select>
<select id="mapRaysCodeServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId,ifnull(COUNT(DISTINCT bk.id),0) serveCount,
bg.book_id bookId,bg.create_user adviserId,bg.channel_id channelId
FROM
resource_page bg
LEFT JOIN resource_page_item bk ON bg.id=bk.resource_page_id
WHERE
bg.book_id IN
<foreach collection="bookIds" item="bookId" separator="," open="(" close=")">
${bookId}
</foreach>
AND bg.channel_id IN
<foreach collection="channelIds" item="channelId" separator="," open="(" close=")">
${channelId}
</foreach>
AND bg.create_user IN
<foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")">
${adviserId}
</foreach>
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
</mapper>
\ No newline at end of file
......@@ -257,4 +257,34 @@
${item.id}
</foreach>
</update>
<select id="mapQrServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
p.book_group_id bookQrcodeId,
p.scene_id sceneId,
ifnull(count(i.id),0) serveCount
FROM
resource_page p
LEFT JOIN resource_page_item i ON i.resource_page_id = p.id
WHERE
p.scene_id in
<foreach collection="sceneIds" index="index" separator="," open="(" close=")" item="item">
#{item}
</foreach>
group by p.scene_id
</select>
<select id="getHasResourceCode4Erp" parameterType="map" resultType="Long">
SELECT
p.scene_id
FROM
resource_page p
LEFT JOIN resource_page_item i ON i.resource_page_id = p.id
WHERE
p.scene_id in
<foreach collection="sceneIds" index="index" separator="," open="(" close=")" item="item">
#{item}
</foreach>
group by p.scene_id having count(i.id)>0
</select>
</mapper>
\ No newline at end of file
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