Commit 20dbb89e by 桂前礼

feat: [1003651] 强化banner的转化和灵活配置能力

parent 636613d8
......@@ -49,5 +49,7 @@ public interface AppletBannerBiz {
* @date:2020/7/17 16:03
* * @param null
*/
PageBeanNew<AppletBannerDTO> listBanner4Wechat(Integer currentPage, Integer numPerPage, Boolean showState, Long officialAccountsId);
PageBeanNew<AppletBannerDTO> listBanner4Wechat(Integer currentPage, Integer numPerPage, Boolean showState, Long officialAccountsId, Long wechatUserId);
void bannerClickRecord(Long wechatUserId, Long bannerId);
}
package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.applet.biz.AppletBannerBiz;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.dao.AppletBannerDao;
import com.pcloud.book.applet.dao.AppletUserBookcaseDao;
import com.pcloud.book.applet.dto.AppletBannerDTO;
import com.pcloud.book.applet.dto.AppletBannerStats;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.ServeItemInfoDTO;
import com.pcloud.book.applet.entity.AppletBanner;
import com.pcloud.book.applet.entity.AppletBannerRecord;
import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.applet.mapper.AppletBannerRecordMapper;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.user.ChannelConsr;
import com.pcloud.book.util.properties.BookProps;
import com.pcloud.channelcenter.wechat.entity.AccountSetting;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ParamChecker;
import com.pcloud.common.utils.ServeLinkUtils;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
/**
* 小程序banner
*/
@Component
@Slf4j
public class AppletBannerBizImpl implements AppletBannerBiz {
@Autowired
private AppletBannerDao appletBannerDao;
@Autowired
private AppletNewsBiz appletNewsBiz;
@Autowired
private AppletBannerRecordMapper appletBannerRecordMapper;
@Autowired
private ProductConsr productConsr;
@Autowired
private AppConsr appConsr;
@Autowired
private AppletUserBookcaseDao appletUserBookcaseDao;
@Autowired
private RightsSettingBiz rightsSettingBiz;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Override
public Long addBanner(AppletBanner appletBanner) {
if (!ListUtil.toList(3,4).contains(appletBanner.getJumpType())) {
ParamChecker.checkStringIsEmpty(appletBanner.getBannerPic(), "Banner图缺失!");
}
if (null == appletBanner.getAgentId()){
appletBanner.setAgentId(0L);
}
......@@ -48,6 +89,9 @@ public class AppletBannerBizImpl implements AppletBannerBiz {
if (null==appletBanner.getId()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少id");
}
if (Objects.nonNull(appletBanner.getJumpType()) && !ListUtil.toList(3, 4).contains(appletBanner.getJumpType())) {
ParamChecker.checkStringIsEmpty(appletBanner.getBannerPic(), "Banner图缺失!");
}
appletBannerDao.update(appletBanner);
}
......@@ -62,23 +106,191 @@ public class AppletBannerBizImpl implements AppletBannerBiz {
AppletBannerDTO appletBannerDTO = new AppletBannerDTO();
if (null != appletBanner){
BeanUtils.copyProperties(appletBanner,appletBannerDTO);
fillServeInfo(ListUtil.toList(appletBannerDTO));
List<AppletBannerStats> bannerPVUV = appletBannerRecordMapper.getBannerPVUV(ListUtil.toList(appletBanner.getId()));
if (CollUtil.isNotEmpty(bannerPVUV) && Objects.nonNull(bannerPVUV.get(0))){
AppletBannerStats appletBannerStats = bannerPVUV.get(0);
String pv = Objects.nonNull(appletBannerStats.getPv()) ? String.valueOf(appletBannerStats.getPv()) : "0";
String uv = Objects.nonNull(appletBannerStats.getUv()) ? String.valueOf(appletBannerStats.getUv()) : "0";
appletBannerDTO.setClickPVUV(pv + "/" + uv);
}
}
return appletBannerDTO;
}
@Override
public PageBeanNew<AppletBannerDTO> listBanner(Integer currentPage, Integer numPerPage, Boolean showState, Long agentId) {
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
map.put("showState", showState);
map.put("agentId", agentId);
PageBeanNew<AppletBannerDTO> pageBeanNew = appletBannerDao.listPageNew(
new PageParam(currentPage,numPerPage), map, "listBanner");
return pageBeanNew;
PageBeanNew<AppletBannerDTO> banner = appletBannerDao.listPageNew(new PageParam(currentPage, numPerPage), map, "listBanner");
if (Objects.isNull(banner) || CollUtil.isEmpty(banner.getRecordList())) {
return banner;
}
// 填充 资讯 | 作品 | 应用 信息
fillServeInfo(banner.getRecordList());
List<Long> bannerIds = banner.getRecordList().stream().filter(Objects::nonNull).map(AppletBannerDTO::getId).collect(Collectors.toList());
if (CollUtil.isEmpty(bannerIds)) {
return banner;
}
// 根据 bannerId 统计 PV/UV
List<AppletBannerStats> bannerPVUV = appletBannerRecordMapper.getBannerPVUV(bannerIds);
if (CollUtil.isEmpty(bannerPVUV)) {
return banner;
}
Map<Long, AppletBannerStats> bannerStatsMap = bannerPVUV.stream()
.collect(Collectors.toMap(AppletBannerStats::getBannerId, AppletBannerStats -> AppletBannerStats));
banner.getRecordList().forEach(item -> {
if (Objects.nonNull(item) && Objects.nonNull(item.getId()) && CollUtil.isNotEmpty(bannerStatsMap) && Objects.nonNull(bannerStatsMap.get(item.getId()))) {
AppletBannerStats bannerStats = bannerStatsMap.get(item.getId());
String pv = Objects.nonNull(bannerStats.getPv()) ? String.valueOf(bannerStats.getPv()) : "0";
String uv = Objects.nonNull(bannerStats.getUv()) ? String.valueOf(bannerStats.getUv()) : "0";
item.setClickPVUV(pv + "/" + uv);
}
});
return banner;
}
private void fillServeInfo(List<AppletBannerDTO> recordList) {
// 获取资讯信息
Map<Long, AppletNewsDTO> newsDTOMap = new HashMap<>();
CompletableFuture<List<Long>> newsBannerFuture = CompletableFuture.supplyAsync(() -> recordList.stream()
.filter(x -> Objects.nonNull(x) && Objects.equals(x.getJumpType(), 3))
.map(AppletBannerDTO::getServeId).filter(Objects::nonNull).distinct()
.collect(Collectors.toList())).whenComplete((list, throwable) -> {
if (Objects.nonNull(throwable)) {
log.error("[fillServeInfo] banner 图填充资讯信息失败,err:{}", throwable.getMessage(), throwable);
} else {
if (CollUtil.isEmpty(list)){
return;
}
Map<Long, AppletNewsDTO> dtoMap = appletNewsBiz.getByIds(list);
newsDTOMap.putAll(Objects.nonNull(dtoMap) ? dtoMap : new HashMap<>());
}
});
// 获取应用信息
Map<Long, AppDto> appDtoMap = new HashMap<>();
CompletableFuture<List<Long>> appBannerFuture = CompletableFuture.supplyAsync(() -> recordList.stream()
.filter(x -> Objects.nonNull(x) && Objects.equals(x.getServeType(), AppletRecordTypeEnum.APP.value))
.map(AppletBannerDTO::getServeId).collect(Collectors.toList())).whenComplete((list, throwable) -> {
if (Objects.nonNull(throwable)) {
log.error("[fillServeInfo] banner 图填充应用信息失败,err:{}", throwable.getMessage(), throwable);
} else {
Map<Long, AppDto> dtoMap = !ListUtils.isEmpty(list) ? appConsr.mapByIds4AuditPass(list) : new HashMap<>();
appDtoMap.putAll(dtoMap);
}
});
// 获取作品信息
Map<Long, ProductDto> productDtoMap = new HashMap<>();
CompletableFuture<List<Long>> productBannerFuture = CompletableFuture.supplyAsync(() -> recordList.stream()
.filter(x -> Objects.nonNull(x) && Objects.equals(x.getServeType(), AppletRecordTypeEnum.PRODUCT.value))
.map(AppletBannerDTO::getServeId).collect(Collectors.toList())).whenComplete((list, throwable) -> {
if (Objects.nonNull(throwable)) {
log.error("[fillServeInfo] banner 图填充作品信息失败,err:{}", throwable.getMessage(), throwable);
} else {
Map<Long, ProductDto> dtoMap = !ListUtils.isEmpty(list) ? productConsr.getProBasesByIds(list) : new HashMap<>();
productDtoMap.putAll(dtoMap);
}
});
try {
CompletableFuture.allOf(newsBannerFuture, appBannerFuture, productBannerFuture).get();
} catch (InterruptedException | ExecutionException e) {
log.error("[fillServeInfo] banner 填充信息失败,err:{}", e.getMessage(), e);
}
// 填充信息
for (AppletBannerDTO banner : recordList) {
if (Objects.nonNull(banner) && Objects.nonNull(banner.getServeId()) && Objects.nonNull(banner.getServeType())) {
Integer serveType = banner.getServeType();
if (Objects.equals(banner.getJumpType(), 3) && Objects.nonNull(newsDTOMap.get(banner.getServeId()))) {
banner.setNewsItem(newsDTOMap.get(banner.getServeId()));
} else if (Objects.equals(serveType, AppletRecordTypeEnum.APP.value) && Objects.nonNull(appDtoMap.get(banner.getServeId()))) {
AppDto appDto = appDtoMap.get(banner.getServeId());
String resultLinkUrl = null;
if (Objects.nonNull(appDto.getChannelId())) {
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
// 根据 APP 拼接 linkUrl
String linkUrl = ServeLinkUtils.getServeLink("APP", appDto.getTypeCode(), appDto.getAppId().toString(),
appDto.getSceneCode(), appDto.getChannelId().toString(), appDto.getCreatedUser().toString(), null);
if (Objects.nonNull(accountSettingDto)) {
resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, linkUrl);
}
}
ServeItemInfoDTO build = ServeItemInfoDTO.builder().serveId(appDto.getAppId()).serveType(serveType)
.serveName(appDto.getTitle()).servePic(appDto.getSquareImg()).transverseImg(appDto.getTransverseImg())
.resultUrl(resultLinkUrl).hasThirdLink(StrUtil.isNotBlank(appDto.getTurnUrl()))
.serveTypeName(appDto.getTypeName()).build();
banner.setAppItem(build);
} else if (Objects.equals(serveType, AppletRecordTypeEnum.PRODUCT.value) && Objects.nonNull(productDtoMap.get(banner.getServeId()))) {
ProductDto productDto = productDtoMap.get(banner.getServeId());
String resultLinkUrl = null;
if (Objects.nonNull(productDto.getChannelId())) {
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(productDto.getChannelId());
if (null != accountSettingDto) {
resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, productDto.getTurnUrl());
}
}
ServeItemInfoDTO build = ServeItemInfoDTO.builder().serveId(productDto.getProductId()).serveType(serveType)
.serveName(productDto.getProductName()).servePic(productDto.getCoverImg()).transverseImg(productDto.getPicture1())
.resultUrl(resultLinkUrl).hasThirdLink(StrUtil.isNotBlank(productDto.getSkipUrl()))
.serveTypeName(productDto.getProductTypeName()).build();
banner.setAppItem(build);
}
}
}
}
@Override
public PageBeanNew<AppletBannerDTO> listBanner4Wechat(Integer currentPage, Integer numPerPage, Boolean showState, Long officialAccountsId) {
public PageBeanNew<AppletBannerDTO> listBanner4Wechat(Integer currentPage, Integer numPerPage, Boolean showState, Long officialAccountsId, Long wechatUserId) {
Long agentId = appletNewsBiz.getAgentIdByAccountId(officialAccountsId);
return listBanner(currentPage, numPerPage, showState, agentId);
PageBeanNew<AppletBannerDTO> pageBeanNew = listBanner(currentPage, numPerPage, showState, agentId);
// 依据当前用户正在读的书,所属分类获取最新上架的资讯
processFillType(pageBeanNew.getRecordList(), wechatUserId);
return pageBeanNew;
}
private void processFillType(List<AppletBannerDTO> recordList, Long wechatUserId) {
if (CollUtil.isEmpty(recordList)) {
return;
}
List<AppletBannerDTO> fillBanner = recordList.stream().filter(x -> Objects.nonNull(x) && Objects.equals(x.getJumpType(), 3)
&& Objects.equals(x.getFillType(), 2)).collect(Collectors.toList());
if (CollUtil.isEmpty(fillBanner)) {
return;
}
AppletUserBookcase userReadBook = appletUserBookcaseDao.getUserReadBook(wechatUserId);
if (Objects.isNull(userReadBook)) {
recordList.removeAll(fillBanner);
return;
}
AppletNewsDTO newsDTO = rightsSettingBiz.getAppletNewsDTO4UserReadBook(userReadBook);
if (Objects.isNull(newsDTO) || Objects.isNull(newsDTO.getId())) {
recordList.removeAll(fillBanner);
return;
}
recordList.stream().filter(x -> Objects.nonNull(x) && Objects.equals(x.getJumpType(), 3)
&& Objects.equals(x.getFillType(), 2)).forEach(item -> item.setNewsItem(newsDTO));
}
@Override
public void bannerClickRecord(Long wechatUserId, Long bannerId) {
AppletBanner banner = appletBannerDao.getById(bannerId);
if (Objects.isNull(banner)) {
appletBannerRecordMapper.insert(AppletBannerRecord.builder()
.bannerId(bannerId).createTime(new Date()).wechatUserId(wechatUserId).build());
} else {
AppletBannerRecord record = AppletBannerRecord.builder()
.createTime(new Date()).wechatUserId(wechatUserId)
.bannerId(bannerId).jumpType(banner.getJumpType())
.serveId(banner.getServeId()).serveType(banner.getServeType()).build();
appletBannerRecordMapper.insert(record);
}
}
}
......@@ -4,7 +4,9 @@ import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("小程序banner")
public class AppletBannerDTO extends BaseDto {
......@@ -15,7 +17,7 @@ public class AppletBannerDTO extends BaseDto {
@ApiModelProperty("banner图")
private String bannerPic;
@ApiModelProperty("跳转类型(1指定页面2web页面)")
@ApiModelProperty("跳转类型 1指定页面, 2web页面, 3资讯, 4应用作品")
private Integer jumpType;
@ApiModelProperty("跳转地址")
......@@ -26,4 +28,22 @@ public class AppletBannerDTO extends BaseDto {
@ApiModelProperty("是否展示")
private Boolean showState;
@ApiModelProperty("点击量PV/UV")
private String clickPVUV;
@ApiModelProperty("咨询的选择方式 1自定义, 2自动获取")
private Integer fillType;
@ApiModelProperty("作品/应用/咨询的ID")
private Long serveId;
@ApiModelProperty("作品/应用/咨询的类型")
private Integer serveType;
@ApiModelProperty("咨询具体信息")
private AppletNewsDTO newsItem;
@ApiModelProperty("咨询具体信息")
private ServeItemInfoDTO appItem;
}
package com.pcloud.book.applet.dto;
import lombok.Data;
@Data
public class AppletBannerStats {
private Long bannerId;
private Long pv;
private Long uv;
}
package com.pcloud.book.applet.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("作品 应用信息封装")
public class ServeItemInfoDTO implements Serializable {
private static final long serialVersionUID = 127018233194941988L;
@ApiModelProperty("ID")
private Long serveId;
@ApiModelProperty("类型")
private Integer serveType;
@ApiModelProperty("名称")
private String serveName;
@ApiModelProperty("类型名称")
private String serveTypeName;
@ApiModelProperty("图片")
private String servePic;
@ApiModelProperty("宽图")
private String transverseImg;
@ApiModelProperty("跳转链接")
private String resultUrl;
@ApiModelProperty("是否包含第三方链接")
private Boolean hasThirdLink;
}
......@@ -4,7 +4,9 @@ import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("小程序banner")
public class AppletBanner extends BaseEntity {
......@@ -12,7 +14,7 @@ public class AppletBanner extends BaseEntity {
@ApiModelProperty("banner图")
private String bannerPic;
@ApiModelProperty("跳转类型(1指定页面2web页面)")
@ApiModelProperty("跳转类型 1指定页面, 2web页面, 3资讯, 4应用|作品")
private Integer jumpType;
@ApiModelProperty("跳转地址")
......@@ -26,4 +28,17 @@ public class AppletBanner extends BaseEntity {
@ApiModelProperty("出版社id")
private Long agentId;
/**
* 选择自动获取,将依据当前用户正在读的书,所属分类获取最新上架的资讯,
* 同时,如果不传banner将会自动获取咨询对应的大图
*/
@ApiModelProperty("咨询的选择方式 1自定义, 2自动获取")
private Integer fillType;
@ApiModelProperty("作品/应用/咨询的ID")
private Long serveId;
@ApiModelProperty("作品/应用/咨询的类型")
private Integer serveType;
}
package com.pcloud.book.applet.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* applet_banner_record
* @author guiq
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppletBannerRecord implements Serializable {
/**
* 编号
*/
private Long id;
/**
* banner图
*/
private Long bannerId;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 用户id
*/
private Long wechatUserId;
/**
* ID
*/
private Long serveId;
/**
* 资讯1 | 作品6 | 应用5
*/
private Integer serveType;
/**
* 跳转类型
*/
private Integer jumpType;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -39,10 +39,13 @@ import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.ParamChecker;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
......@@ -55,15 +58,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.util.List;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@Api(description = "小睿小程序首页")
@RestController("appletHomeFacade")
@RequestMapping("appletHome")
......@@ -343,10 +342,12 @@ public class AppletHomeFacade {
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage) {
Long officialAccountsId = Cookie.getId(userInfo,Cookie._OFFICIAL_ACCOUNTS_ID);
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletBannerBiz.listBanner4Wechat(currentPage, numPerPage, true, officialAccountsId));
return new ResponseDto<>(appletBannerBiz.listBanner4Wechat(currentPage, numPerPage, true, officialAccountsId, wechatUserId));
}
@ApiOperation("获取书单下书籍列表")
......@@ -1174,6 +1175,15 @@ public class AppletHomeFacade {
answerSubscribeDTO.setWechatUserId(wechatUserId);
return new ResponseDto<>(answerSubscribeBiz.getSubscribeState(answerSubscribeDTO));
}
@ApiOperation("小程序首页banner点击埋点")
@RequestMapping(value = "/bannerClickRecord", method = RequestMethod.GET)
public ResponseDto<Void> bannerClickRecord(@CookieValue("userInfo") String userInfo, @RequestParam("bannerId") Long bannerId) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
ParamChecker.checkNumberIsNull(bannerId, "参数缺失!");
appletBannerBiz.bannerClickRecord(wechatUserId, bannerId);
return new ResponseDto<>();
}
}
......
package com.pcloud.book.applet.mapper;
import com.pcloud.book.applet.dto.AppletBannerStats;
import com.pcloud.book.applet.entity.AppletBannerRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component
public interface AppletBannerRecordMapper {
int deleteByPrimaryKey(Long id);
int insert(AppletBannerRecord record);
int insertSelective(AppletBannerRecord record);
AppletBannerRecord selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AppletBannerRecord record);
int updateByPrimaryKey(AppletBannerRecord record);
List<AppletBannerStats> getBannerPVUV(@Param("bannerIds") List<Long> bannerIds);
}
\ No newline at end of file
......@@ -195,4 +195,6 @@ public interface RightsSettingBiz {
* @param nowItems
*/
void fillProductAndApp(List<RightsNowItem> nowItems);
AppletNewsDTO getAppletNewsDTO4UserReadBook(AppletUserBookcase userReadBook);
}
package com.pcloud.book.rightsSetting.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletBooklistBiz;
......@@ -111,9 +113,8 @@ import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -137,11 +138,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
......@@ -1585,6 +1581,48 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
nowItems.removeAll(list_remove);
}
@Override
public AppletNewsDTO getAppletNewsDTO4UserReadBook(AppletUserBookcase userReadBook) {
AppletNewsDTO appletNewsDTO = new AppletNewsDTO();
BaseTempletClassify baseTempletClassify = appletUserBookcaseDao.getBookClassifyInfo(userReadBook.getBookId(), userReadBook.getChannelId(), userReadBook.getAdviserId());
if (Objects.nonNull(baseTempletClassify) && Objects.nonNull(baseTempletClassify.getFirstClassify())) {
rightsSettingBiz.setClassifyAndLabel(baseTempletClassify);
Integer deepRead = null;
Integer easyRead = null;
Integer efficientRead = null;
if (ReadTypeEnum.QS_READ.value.equals(userReadBook.getReadType())) {
easyRead = 1;
} else if (ReadTypeEnum.GX_READ.value.equals(userReadBook.getReadType())) {
efficientRead = 1;
} else if (ReadTypeEnum.SD_READ.value.equals(userReadBook.getReadType())) {
deepRead = 1;
}
Map<String, Object> map = new HashMap<>();
map.put("firstClassify", baseTempletClassify.getFirstClassify());
map.put("secondClassify", baseTempletClassify.getSecondClassify());
map.put("gradeLabelId", baseTempletClassify.getGradeLabelId());
map.put("subjectLabelId", baseTempletClassify.getSubjectLabelId());
map.put("deepRead", deepRead);
map.put("easyRead", easyRead);
map.put("efficientRead", efficientRead);
PageBeanNew<AppletNewsDTO> page = appletNewsDao.listPageNew(new PageParam(0, 1), map, "getClassifyNewsByTempletLabel");
if (Objects.nonNull(page) && CollUtil.isNotEmpty(page.getRecordList())) {
appletNewsDTO = page.getRecordList().get(0);
} else {
map.put("firstClassify", baseTempletClassify.getFirstClassify());
map.put("secondClassify", baseTempletClassify.getSecondClassify());
map.put("gradeLabelId", baseTempletClassify.getGradeLabelId());
map.put("subjectLabelId", baseTempletClassify.getSubjectLabelId());
map.put("rightsType", null);
page = appletNewsDao.listPageNew(new PageParam(0, 1), map, "getPageByNewsByTempletLabel");
if (Objects.nonNull(page) && CollUtil.isNotEmpty(page.getRecordList())) {
appletNewsDTO = page.getRecordList().get(0);
}
}
}
return appletNewsDTO;
}
private void fillGiftCouponPack(RightsSetting rightsSetting, Integer readType) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemTypeNew.GIFT_COUPON_PACKAGE, readType);
if (null != rightsSettingTitle){
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.applet.dao.impl.AppletBannerDaoImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletBanner" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="banner_pic" property="bannerPic" jdbcType="VARCHAR" />
<result column="jump_type" property="jumpType" jdbcType="INTEGER" />
<result column="jump_url" property="jumpUrl" jdbcType="VARCHAR" />
<result column="seq" property="seq" jdbcType="INTEGER" />
<result column="show_state" property="showState" jdbcType="BOOLEAN" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="agent_id" property="agentId" jdbcType="BIGINT" />
<mapper namespace="com.pcloud.book.applet.dao.impl.AppletBannerDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletBanner">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="banner_pic" jdbcType="VARCHAR" property="bannerPic"/>
<result column="jump_type" jdbcType="INTEGER" property="jumpType"/>
<result column="jump_url" jdbcType="VARCHAR" property="jumpUrl"/>
<result column="seq" jdbcType="INTEGER" property="seq"/>
<result column="show_state" jdbcType="BOOLEAN" property="showState"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="agent_id" jdbcType="BIGINT" property="agentId"/>
<result column="serve_id" jdbcType="BIGINT" property="serveId"/>
<result column="serve_type" jdbcType="TINYINT" property="serveType"/>
<result column="fill_type" jdbcType="TINYINT" property="fillType"/>
</resultMap>
<sql id="Base_Column_List" >
id, banner_pic, jump_type, jump_url, seq, show_state, create_time, update_time, agent_id
<sql id="Base_Column_List">
id, banner_pic, jump_type, jump_url, seq, show_state, create_time, update_time, agent_id,
serve_id, serve_type, fill_type
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletBanner" useGeneratedKeys="true" keyProperty="id">
insert into applet_banner(
banner_pic, jump_type, jump_url, seq, show_state, create_time, update_time, agent_id
)
values (
#{bannerPic}, #{jumpType}, #{jumpUrl}, #{seq}, #{showState}, NOW(), NOW(), #{agentId}
)
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletBanner"
useGeneratedKeys="true">
insert into applet_banner
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bannerPic != null">
banner_pic,
</if>
<if test="jumpType != null">
jump_type,
</if>
<if test="jumpUrl != null">
jump_url,
</if>
<if test="seq != null">
seq,
</if>
<if test="showState != null">
show_state,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="agentId != null">
agent_id,
</if>
<if test="serveId != null">
serve_id,
</if>
<if test="serveType != null">
serve_type,
</if>
<if test="fillType != null">
fill_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bannerPic != null">
#{bannerPic,jdbcType=VARCHAR},
</if>
<if test="jumpType != null">
#{jumpType,jdbcType=INTEGER},
</if>
<if test="jumpUrl != null">
#{jumpUrl,jdbcType=VARCHAR},
</if>
<if test="seq != null">
#{seq,jdbcType=INTEGER},
</if>
<if test="showState != null">
#{showState,jdbcType=BOOLEAN},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="agentId != null">
#{agentId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
#{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
#{serveType,jdbcType=TINYINT},
</if>
<if test="fillType != null">
#{fillType,jdbcType=BOOLEAN},
</if>
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.applet.entity.AppletBanner">
update applet_banner
<set>
<if test="bannerPic != null">
banner_pic = #{bannerPic},
banner_pic = #{bannerPic,jdbcType=VARCHAR},
</if>
<if test="jumpType != null">
jump_type = #{jumpType,jdbcType=INTEGER},
</if>
<if test="jumpUrl != null">
jump_url = #{jumpUrl},
jump_url = #{jumpUrl,jdbcType=VARCHAR},
</if>
<if test="seq != null">
seq = #{seq,jdbcType=INTEGER},
......@@ -44,13 +114,29 @@
<if test="showState != null">
show_state = #{showState,jdbcType=BOOLEAN},
</if>
update_time=NOW()
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
update_time = NOW(),
<if test="agentId != null">
agent_id = #{agentId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
serve_id = #{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
serve_type = #{serveType,jdbcType=TINYINT},
</if>
<if test="fillType != null">
fill_type = #{fillType,jdbcType=BOOLEAN},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getById" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
select
<include refid="Base_Column_List"/>
from applet_banner
where id=#{id}
</select>
......@@ -67,7 +153,10 @@
seq seq,
show_state showState,
jump_type jumpType,
jump_url jumpUrl
jump_url jumpUrl,
fill_type fillType,
serve_id serveId,
serve_type serveType
FROM applet_banner
where 1=1
<if test="showState != null">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.applet.mapper.AppletBannerRecordMapper">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletBannerRecord">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="banner_id" jdbcType="BIGINT" property="bannerId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="wechat_user_id" jdbcType="BIGINT" property="wechatUserId"/>
<result column="serve_id" jdbcType="BIGINT" property="serveId"/>
<result column="serve_type" jdbcType="TINYINT" property="serveType"/>
<result column="jump_type" jdbcType="BOOLEAN" property="jumpType"/>
</resultMap>
<sql id="Base_Column_List">
id, banner_id, create_time, update_time, wechat_user_id, serve_id, serve_type, jump_type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from applet_banner_record
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from applet_banner_record
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletBannerRecord"
useGeneratedKeys="true">
insert into applet_banner_record (banner_id, create_time, update_time,
wechat_user_id, serve_id, serve_type,
jump_type)
values (#{bannerId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{wechatUserId,jdbcType=BIGINT}, #{serveId,jdbcType=BIGINT}, #{serveType,jdbcType=TINYINT},
#{jumpType,jdbcType=BOOLEAN})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="com.pcloud.book.applet.entity.AppletBannerRecord" useGeneratedKeys="true">
insert into applet_banner_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bannerId != null">
banner_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="wechatUserId != null">
wechat_user_id,
</if>
<if test="serveId != null">
serve_id,
</if>
<if test="serveType != null">
serve_type,
</if>
<if test="jumpType != null">
jump_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bannerId != null">
#{bannerId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="wechatUserId != null">
#{wechatUserId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
#{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
#{serveType,jdbcType=TINYINT},
</if>
<if test="jumpType != null">
#{jumpType,jdbcType=BOOLEAN},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.applet.entity.AppletBannerRecord">
update applet_banner_record
<set>
<if test="bannerId != null">
banner_id = #{bannerId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="wechatUserId != null">
wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
serve_id = #{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
serve_type = #{serveType,jdbcType=TINYINT},
</if>
<if test="jumpType != null">
jump_type = #{jumpType,jdbcType=BOOLEAN},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.applet.entity.AppletBannerRecord">
update applet_banner_record
set banner_id = #{bannerId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
serve_id = #{serveId,jdbcType=BIGINT},
serve_type = #{serveType,jdbcType=TINYINT},
jump_type = #{jumpType,jdbcType=BOOLEAN}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getBannerPVUV" resultType="com.pcloud.book.applet.dto.AppletBannerStats">
SELECT
t.banner_id bannerId,
count( 0 ) uv,
SUM( t.p ) pv
FROM
( SELECT banner_id, count( 0 ) p FROM applet_banner_record WHERE
banner_id IN
<foreach collection="bannerIds" close=")" item="item" open="(" separator=",">
${item}
</foreach>
GROUP BY banner_id, wechat_user_id ) t
GROUP BY
t.banner_id
</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