Commit a82ed6c7 by 郑勇

feat: [1004412] 加权益数量和销售额

parent 079bba7c
......@@ -81,6 +81,10 @@ import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingQueryDTO;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingNow;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO;
......@@ -1091,7 +1095,8 @@ 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);
//现在一本书下面可以配多个跳小睿的码
......@@ -1109,6 +1114,11 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
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());
Map<Long, BigDecimal> groupListSaleInfoMap = tradeConsr.getGroupListSaleInfo(bookGroupIds);
List<QrCodeVO> qrCodeVOS = new ArrayList<>();
QrCodeVO qrCodeVO;
for (BookGroupDTO bookGroupDTO : bookGroupDTOList) {
......@@ -1119,6 +1129,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrCodeVO.setRightsCount(0);
qrCodeVO.setSceneId(bookGroupDTO.getId());
qrCodeVO.setJoinGroupType(bookGroupDTO.getJoinGroupType());
qrCodeVO.setRightsCount(0);
qrCodeVO.setSaleMoney(new BigDecimal(0));
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(bookGroupDTO.getJoinGroupType())){
if(CollUtil.isNotEmpty(groupQrCodeMap) && groupQrCodeMap.containsKey(bookGroupDTO.getId())){
BookGroupServeCountDTO bookGroupServeCountDTO = groupQrCodeMap.get(bookGroupDTO.getId());
......@@ -1138,6 +1150,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
}
}
//小睿的码才有权益
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupDTO.getJoinGroupType())){
qrCodeVO.setRightsCount(rightsettingCounts);
}
//设置销售额
if(CollUtil.isNotEmpty(groupListSaleInfoMap) && groupListSaleInfoMap.containsKey(bookGroupDTO.getId())){
qrCodeVO.setSaleMoney(groupListSaleInfoMap.get(bookGroupDTO.getId()));
}
qrCodeVO.setCodeType("group");
qrCodeVO.setXiaoRuiEducation(false);
if(CollUtil.isNotEmpty(xiaoRuiEducation) && xiaoRuiEducation.contains(bookId)){
......@@ -1198,6 +1218,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
List<Long> sceneIds = qrcodeSceneDtos.stream().map(x -> x.getSceneId()).collect(Collectors.toList());
// 企业微信群资源数
Map<Long, BookGroupServeCountDTO> bookQrcodeWxworkMap = bookQrcodeWxworkBiz.mapWxWorkServeCount4SceneIds(sceneIds, BookQrcodeType.OFFICIAL_ACCOUNTS.getCode());
//计算码的销售额
Map<Long, BigDecimal> sceneListSaleInfoMap = tradeConsr.getSceneListSaleInfo(sceneIds);
for (QrcodeSceneDto e : qrcodeSceneDtos) {
QrCodeVO qrCodeVO1 = new QrCodeVO();
qrCodeVO1.setQrCodeName(e.getSceneName());
......@@ -1211,6 +1233,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrCodeVO1.setXiaoRuiEducation(true);
}
qrCodeVO1.setSceneId(e.getSceneId());
qrCodeVO1.setSaleMoney(new BigDecimal(0));
if(CollUtil.isNotEmpty(sceneListSaleInfoMap) && sceneListSaleInfoMap.containsKey(e.getSceneId())){
qrCodeVO1.setSaleMoney(sceneListSaleInfoMap.get(e.getSceneId()));
}
qrCodeVOS.add(qrCodeVO1);
}
}
......@@ -1237,6 +1263,33 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return new PageBeanNew<>(currentPage, numPerPage,qrCodeVOS.size(), record);
}
private Integer getRightsettingCounts(Long bookId, Long adviserId, Long channelId) {
Long rightsSettingId = bookGroupBiz.getRightsSettingId4Book(adviserId, channelId, bookId);
int i=0;
if(null!=rightsSettingId){
RightsSettingQueryDTO rightsSettingQueryDTO=new RightsSettingQueryDTO();
rightsSettingQueryDTO.setAdviserId(adviserId);
rightsSettingQueryDTO.setBookId(bookId);
rightsSettingQueryDTO.setChannelId(channelId);
rightsSettingQueryDTO.setRightsSettingTypes(Lists.newArrayList(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19));
rightsSettingQueryDTO.setRightsSettingId(rightsSettingId);
RightsSetting rightsSetting = rightsSettingBiz.getRightsSettingItemsByTypeListNew(rightsSettingQueryDTO);
if(null!=rightsSetting && null!=rightsSetting.getRightsSettingNow()){
RightsSettingNow rightsSettingNow = rightsSetting.getRightsSettingNow();
if(CollUtil.isNotEmpty(rightsSettingNow.getRightsSettingTitles())){
for (RightsSettingTitle rightsSettingTitle : rightsSettingNow.getRightsSettingTitles()) {
if(CollUtil.isEmpty(rightsSettingTitle.getRightsSettingItemList())){
continue;
}
i+=rightsSettingTitle.getRightsSettingItemList().size();
}
}
}
}
return i;
}
@Override
public Map<String, BookResourceStatisticsDTO> mapResourceTotalCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds){
Map<String, BookResourceStatisticsDTO> mapBookResourceStatistics = new HashMap<>();
......
package com.pcloud.book.book.vo;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -27,4 +29,7 @@ public class QrCodeVO {
@ApiModelProperty("公众号码id")
private Long sceneId;
@ApiModelProperty("销售额")
private BigDecimal saleMoney;
}
......@@ -278,4 +278,38 @@ public class TradeConsr {
}
return new ArrayList<>();
}
/**
* 获取rays码销售额
* @param bookGroupIds
* @return
*/
public Map<Long, BigDecimal> getGroupListSaleInfo(List<Long> bookGroupIds) {
if (CollUtil.isEmpty(bookGroupIds)) {
return new HashMap<>();
}
try {
return ResponseHandleUtil.parseMap(orderFormService.getGroupListSaleInfo(bookGroupIds), Long.class,BigDecimal.class);
} catch (Exception e) {
LOGGER.error("查询rays码销售额失败.[getGroupListSaleInfo]:{}", e.getMessage(), e);
}
return new HashMap<>();
}
/**
* 获取二维码销售额
* @param sceneIds
* @return
*/
public Map<Long, BigDecimal> getSceneListSaleInfo(List<Long> sceneIds) {
if (CollUtil.isEmpty(sceneIds)) {
return new HashMap<>();
}
try {
return ResponseHandleUtil.parseMap(orderFormService.getSceneListSaleInfo(sceneIds), Long.class,BigDecimal.class);
} catch (Exception e) {
LOGGER.error("查询二维码销售额失败.[getSceneListSaleInfo]:{}", e.getMessage(), e);
}
return new HashMap<>();
}
}
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