Commit fa403ebc by 裴大威

Merge branch 'feat-zyj-1002754' into 'master'

1002754获取社群码配置资源

See merge request rays/pcloud-book!626
parents e872a769 85d480f0
......@@ -7,9 +7,9 @@ import com.pcloud.book.applet.dto.AppletUserBookcaseDTO;
import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.applet.entity.AppletUserClickRecord;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
......@@ -17,8 +17,6 @@ import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -44,10 +42,12 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@Autowired
private AssistTempletConsr assistTempletConsr;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
private BookGroupBiz bookGroupBiz;
@Override
public void addUserBook(AppletUserBookcase appletUserBookcase) {
//数据库去重
appletUserBookcaseDao.deleteByBookIdUserId(appletUserBookcase);
appletUserBookcaseDao.insert(appletUserBookcase);
Long wechatUserId = appletUserBookcase.getWechatUserId();
String key = "BOOK:APPLET:listByWechatUserId"+wechatUserId;
......@@ -90,21 +90,17 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@Override
public Map<String, Object> getUserClickStatistic(Long wechatUserId, Long bookId, Long channelId, Long adviserId) {
//书刊下所有资源
BookServeParamVO serveParamVO = new BookServeParamVO();
serveParamVO.setBookId(bookId);
serveParamVO.setAdviserId(adviserId);
serveParamVO.setChannelId(channelId);
List<BookServeVO> serveVOList = qrcodeSceneConsr.listBookServeIds(serveParamVO);
if (ListUtils.isEmpty(serveVOList)){
//社群书和现代纸书下资源
List<BookServeDTO> serveDTOList = bookGroupBiz.getBookAndBookGroupServeIds(adviserId,bookId,channelId);
if (ListUtils.isEmpty(serveDTOList)){
return new HashMap<>();
}
Integer clickCount = 0;
String startDate = DateUtils.formatDate(new Date(), DateUtils.DATE_FORMAT_DATEONLY);
List<Long> appIds = serveVOList.stream().filter(s->s.getTypeCode().equalsIgnoreCase("APP")).
map(BookServeVO::getServeId).distinct().collect(Collectors.toList());
List<Long> productIds = serveVOList.stream().filter(s->s.getTypeCode().equalsIgnoreCase("PRODUCT")).
map(BookServeVO::getServeId).distinct().collect(Collectors.toList());
List<Long> appIds = serveDTOList.stream().filter(s->s.getServeType().equalsIgnoreCase("APP")).
map(BookServeDTO::getServeId).distinct().collect(Collectors.toList());
List<Long> productIds = serveDTOList.stream().filter(s->s.getServeType().equalsIgnoreCase("PRODUCT")).
map(BookServeDTO::getServeId).distinct().collect(Collectors.toList());
if (!ListUtils.isEmpty(appIds)){
Integer appCount = appletUserBookcaseDao.getUserClickServerCount(wechatUserId,bookId,channelId,adviserId,appIds,"APP");
if (appCount>0){
......
......@@ -37,4 +37,10 @@ public interface AppletUserBookcaseDao extends BaseDao<AppletUserBookcase> {
* @return
*/
String getMinClickTime (Long wechatUserId, Long bookId, Long channelId, Long adviserId, List<Long> serveIds, String fromType);
/**
* 删除
* @param appletUserBookcase
*/
void deleteByBookIdUserId(AppletUserBookcase appletUserBookcase);
}
......@@ -45,4 +45,9 @@ public class AppletUserBookcaseDaoImpl extends BaseDaoImpl<AppletUserBookcase> i
map.put("fromType", fromType);
return getSessionTemplate().selectOne(getStatement("getMinClickTime"),map);
}
@Override
public void deleteByBookIdUserId(AppletUserBookcase appletUserBookcase) {
getSessionTemplate().delete(getStatement("deleteByBookIdUserId"),appletUserBookcase);
}
}
......@@ -771,4 +771,22 @@ public interface BookGroupBiz {
* @param scene
*/
void getByAppletScene(Long wechatUserId, String scene);
/**
* 获取小睿社群书和现代纸书所配资源
* @param adviserId
* @param bookId
* @param channelId
* @return
*/
PageBeanNew<BookServeDTO> getBookAndBookGroupServeList(Long adviserId, Long bookId, Long channelId);
/**
* 获取小睿社群书和现代纸书所配资源id
* @param adviserId
* @param bookId
* @param channelId
* @return
*/
List<BookServeDTO> getBookAndBookGroupServeIds(Long adviserId, Long bookId, Long channelId);
}
......@@ -86,7 +86,9 @@ import com.pcloud.channelcenter.base.constants.ChannelConstants;
import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.dto.MessageDto;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.core.constant.SystemCode;
......@@ -4501,4 +4503,113 @@ public class BookGroupBizImpl implements BookGroupBiz {
appletUserBookcaseBiz.addUserBook(appletUserBookcase);
}
@Override
public PageBeanNew<BookServeDTO> getBookAndBookGroupServeList(Long adviserId, Long bookId, Long channelId) {
//社群书和现代纸书下资源
List<BookServeDTO> serveDTOList = getBookAndBookGroupServeIds(adviserId,bookId,channelId);
if (ListUtils.isEmpty(serveDTOList)){
return new PageBeanNew<>(0,1,0,new ArrayList<>());
}
//填充资源信息
fillBookServe(serveDTOList);
PageBeanNew<BookServeDTO> pageBeanNew = new PageBeanNew<BookServeDTO>(0,serveDTOList.size(),serveDTOList.size(),serveDTOList);
pageBeanNew.setPageCount(1);
return pageBeanNew;
}
public List<BookServeDTO> getBookAndBookGroupServeIds(Long adviserId, Long bookId, Long channelId){
List<BookServeDTO> serveDTOList = new ArrayList<>();
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId,channelId,adviserId);
List<Long> appIds = new ArrayList<>();
List<Long> productIds = new ArrayList<>();
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
if (null!= bookGroupDTO){//有社群书
//社群书配置资源
List<BookGroupServe> bookGroupServes = bookGroupServeDao.getListByBookGroupId(bookGroupDTO.getId());
if (!ListUtils.isEmpty(bookGroupServes)){
for (BookGroupServe bookGroupServe: bookGroupServes){
BookServeDTO bookServeDTO = new BookServeDTO();
BeanUtils.copyProperties(bookGroupServe,bookServeDTO);
String url = SendWeixinRequestTools.splitUrl(accountSettingDto,bookGroupServe.getServeUrl());
bookServeDTO.setUrl(url);
bookServeDTO.setTypeCode(bookServeDTO.getServeType());
serveDTOList.add(bookServeDTO);
if (AppAndProductTypeEnum.APP.value.equals(bookServeDTO.getServeType())){
appIds.add(bookGroupServe.getServeId());
}else {
productIds.add(bookGroupServe.getServeId());
}
}
}
}
//现代纸书二维码配置资源
BookServeParamVO serveParamVO = new BookServeParamVO();
serveParamVO.setAdviserId(adviserId);
serveParamVO.setBookId(bookId);
serveParamVO.setChannelId(channelId);
List<BookServeVO> bookServeVOS = qrcodeSceneConsr.listBookServeIds(serveParamVO);
if (!ListUtils.isEmpty(bookServeVOS)){
for (BookServeVO bookServeVO: bookServeVOS){
Long serveId = bookServeVO.getServeId();
BookServeDTO bookServeDTO = new BookServeDTO();
bookServeDTO.setTypeCode(bookServeVO.getTypeCode());
String url = SendWeixinRequestTools.splitUrl(accountSettingDto, bookServeVO.getUrl());
if (AppAndProductTypeEnum.APP.value.equals(bookServeVO.getTypeCode()) && !appIds.contains(serveId)){
bookServeDTO.setServeId(serveId);
bookServeDTO.setServeType(bookServeVO.getTypeCode());
bookServeDTO.setUrl(url);
serveDTOList.add(bookServeDTO);
appIds.add(serveId);
}else if (AppAndProductTypeEnum.PRODUCT.value.equals(bookServeVO.getTypeCode()) && !productIds.contains(serveId)){
bookServeDTO.setServeId(serveId);
bookServeDTO.setServeType(bookServeVO.getTypeCode());
bookServeDTO.setUrl(url);
serveDTOList.add(bookServeDTO);
productIds.add(serveId);
}
}
}
return serveDTOList;
}
private void fillBookServe(List<BookServeDTO> serveDTOList) {
if (ListUtils.isEmpty(serveDTOList)){
return;
}
List<Long> appIds = serveDTOList.stream().filter(s->s.getServeType().equals(AppAndProductTypeEnum.APP.value)).map(BookServeDTO::getServeId).collect(Collectors.toList());
List<Long> productIds = serveDTOList.stream().filter(s->s.getServeType().equals(AppAndProductTypeEnum.PRODUCT.value)).map(BookServeDTO::getServeId).collect(Collectors.toList());
Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, AppDto> appDtoMap = new HashMap<>();
if (!ListUtils.isEmpty(productIds)) {
productDtoMap = productConsr.getProBasesByIds(productIds);
}
if (!ListUtils.isEmpty(appIds)) {
appDtoMap = appConsr.mapByIds(appIds);
}
for(BookServeDTO bookServeDTO: serveDTOList){
if (!MapUtils.isEmpty(productDtoMap) && AppAndProductTypeEnum.PRODUCT.value.equals(bookServeDTO.getServeType())) {
ProductDto productDto = productDtoMap.get(bookServeDTO.getServeId());
if (productDto != null) {
bookServeDTO.setServeName(productDto.getProductName());
bookServeDTO.setCoverImg(productDto.getCoverImg());
ProductTypeDto productTypeDto = productDto.getProductTypeDto();
if (productTypeDto != null) {
bookServeDTO.setFromType(productTypeDto.getTypeCode());
bookServeDTO.setFromTypeName(productTypeDto.getTypeName());
}
}
}
if (!MapUtils.isEmpty(appDtoMap) && AppAndProductTypeEnum.APP.value.equals(bookServeDTO.getServeType())) {
AppDto appDto = appDtoMap.get(bookServeDTO.getServeId());
if (appDto != null) {
bookServeDTO.setServeName(appDto.getTitle());
bookServeDTO.setCoverImg(appDto.getSquareImg());
bookServeDTO.setFromType(appDto.getTypeCode());
bookServeDTO.setFromTypeName(appDto.getTypeName());
}
}
}
}
}
package com.pcloud.book.group.dto;
import com.pcloud.common.dto.BaseDto;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description
* @Author zhuyajie
* @Date 2020/4/14 17:05
**/
@Data
public class BookServeDTO extends BaseDto {
private static final long serialVersionUID = 7725930392678110441L;
@ApiModelProperty("作品或应用id")
private Long serveId;
@ApiModelProperty("类型;APP应用,PRODUCT作品")
private String serveType;
@ApiModelProperty("应用或作品名称")
private String serveName;
@ApiModelProperty("类型")
private String fromType;
@ApiModelProperty("类型名称")
private String fromTypeName;
@ApiModelProperty("图片地址")
private String coverImg;
@ApiModelProperty("链接")
private String url;
@ApiModelProperty("类型;APP应用,PRODUCT作品")
private String typeCode;
}
......@@ -704,4 +704,10 @@ public interface BookGroupFacade {
@ApiOperation("根据小程序id获取信息")
@GetMapping("getByAppletScene")
ResponseDto<?> getByAppletScene(@CookieValue("userInfo") String userInfo,@RequestParam("scene") String scene);
@ApiOperation("获取小睿社群书和现代纸书所配资源")
@GetMapping("getBookAndBookGroupServeList")
ResponseDto<?> getBookAndBookGroupServeList(
@RequestParam("adviserId") Long adviserId, @RequestParam("bookId")Long bookId, @RequestParam("channelId")Long channelId);
}
......@@ -1134,4 +1134,14 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
return new ResponseDto<>();
}
@Override
@GetMapping("getBookAndBookGroupServeList")
public ResponseDto<?> getBookAndBookGroupServeList(
@RequestParam("adviserId") Long adviserId, @RequestParam("bookId")Long bookId, @RequestParam("channelId")Long channelId){
if (null==adviserId||null==bookId||null==channelId){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(bookGroupBiz.getBookAndBookGroupServeList(adviserId,bookId,channelId));
}
}
......@@ -82,6 +82,13 @@
AND from_type = #{fromType}
</select>
<delete id="deleteByBookIdUserId" parameterType="com.pcloud.book.applet.entity.AppletUserBookcase">
DELETE FROM applet_user_bookcase
WHERE wechat_user_id=#{wechatUserId}
AND book_id=#{bookId}
AND channel_id=#{channelId}
AND adviser_id=#{adviserId}
</delete>
</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