Commit f11adc48 by 桂前礼

feat: [1003400、1003401] 资讯及网课可展示的数量、点击按钮查看更多

parent ba02a19b
......@@ -99,7 +99,7 @@ public interface RightsSettingBiz {
* @Param [rightsSettingId, wechatUserId, type]
* @return com.pcloud.book.rightsSetting.entity.RightsSetting
**/
RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId, Long bookId, Long channelId, Integer readType);
RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId, Long bookId, Long channelId, Integer readType, Integer currentPage, Integer numPerPage);
RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId, Integer readType);
......
package com.pcloud.book.rightsSetting.biz.impl;
import cn.hutool.core.collection.CollUtil;
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.AppletGroupSearchRecordBiz;
......@@ -94,13 +94,11 @@ 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;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -121,9 +119,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
......@@ -1040,13 +1035,23 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* @Param [rightsSetting, wechatUserId]
**/
@ParamLog(value = "填充线上专课", isAfterReturn = false)
private RightsSetting setOnlineExclCourse(RightsSetting rightsSetting, Long wechatUserId, Integer readType, Long bookId) {
private RightsSetting setOnlineExclCourse(RightsSetting rightsSetting, Long wechatUserId, Integer readType, Long bookId, Integer currentPage, Integer numPerPage) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemTypeNew.ONLINE_EXCL_COURSE, readType);
boolean hasPage = Objects.nonNull(currentPage) && Objects.nonNull(numPerPage);
if (null != rightsSettingTitle){
List<RightsNowItem> nowItems = rightsNowItemDao
.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value));
List<RightsNowItem> nowItems = null;
if(hasPage){
Map<String, Object> map = CollUtil.newHashMap(2);
map.put("rightsSettingTitleId",rightsSettingTitle.getId());
map.put("types",Collections.singletonList(RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value));
PageBeanNew<RightsNowItem> pageBeanNew = rightsNowItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getListByRightsSettingTitleId");
nowItems = pageBeanNew.getRecordList();
rightsSettingTitle.setRightsSettingItemList4Page(pageBeanNew);
}else {
nowItems = rightsNowItemDao.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value));
}
processNowItems(rightsSettingTitle, nowItems, RightsNowItemTypeNew.ONLINE_EXCL_COURSE, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value), BookConstant.MAX_NEWS_COUNT, bookId);
Long.valueOf(RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value), BookConstant.MAX_NEWS_COUNT, bookId, currentPage, numPerPage);
rightsSetting.setOnlineRightsSettingTitle(rightsSettingTitle);
}
return rightsSetting;
......@@ -1060,13 +1065,23 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* @Param [rightsSetting, wechatUserId]
**/
@ParamLog(value = "填充线上网课", isAfterReturn = false)
private RightsSetting setOnlineCourse(RightsSetting rightsSetting, Long wechatUserId, Integer readType, Long bookId) {
private RightsSetting setOnlineCourse(RightsSetting rightsSetting, Long wechatUserId, Integer readType, Long bookId, Integer currentPage, Integer numPerPage) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemTypeNew.ONLINE_COURSE, readType);
boolean hasPage = Objects.nonNull(currentPage) && Objects.nonNull(numPerPage);
if (null != rightsSettingTitle){
List<RightsNowItem> nowItems = rightsNowItemDao
.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.ONLINE_COURSE.value));
List<RightsNowItem> nowItems = null;
if (hasPage){
Map<String, Object> map = CollUtil.newHashMap(2);
map.put("rightsSettingTitleId",rightsSettingTitle.getId());
map.put("types",Collections.singletonList(RightsNowItemTypeNew.ONLINE_COURSE.value));
PageBeanNew<RightsNowItem> pageBeanNew = rightsNowItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getListByRightsSettingTitleId");
nowItems = pageBeanNew.getRecordList();
rightsSettingTitle.setRightsSettingItemList4Page(pageBeanNew);
}else {
nowItems = rightsNowItemDao.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.ONLINE_COURSE.value));
}
processNowItems(rightsSettingTitle, nowItems, RightsNowItemTypeNew.ONLINE_COURSE, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.ONLINE_COURSE.value), BookConstant.MAX_NEWS_COUNT_GROUP, bookId);
Long.valueOf(RightsNowItemTypeNew.ONLINE_COURSE.value), BookConstant.MAX_NEWS_COUNT, bookId, currentPage, numPerPage);
rightsSetting.setOnlineRightsSettingTitle(rightsSettingTitle);
}
return rightsSetting;
......@@ -1087,7 +1102,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<RightsNowItem> nowItems = rightsNowItemDao
.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.COACH.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemTypeNew.COACH, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.COACH.value), BookConstant.MAX_NEWS_COUNT, bookId);
Long.valueOf(RightsNowItemTypeNew.COACH.value), BookConstant.MAX_NEWS_COUNT, bookId, null, null);
rightsSetting.setLearningToolTitle(rightsSettingTitle);
}
return rightsSetting;
......@@ -1109,7 +1124,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<RightsNowItem> nowItems = rightsNowItemDao
.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.LEARNING_TOOL.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemTypeNew.LEARNING_TOOL, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.LEARNING_TOOL.value), BookConstant.MAX_NEWS_COUNT, bookId);
Long.valueOf(RightsNowItemTypeNew.LEARNING_TOOL.value), BookConstant.MAX_NEWS_COUNT, bookId, null, null);
rightsSetting.setLearningToolTitle(rightsSettingTitle);
}
return rightsSetting;
......@@ -1129,7 +1144,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<RightsNowItem> nowItems = rightsNowItemDao
.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.DRAW.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemTypeNew.DRAW, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.DRAW.value), BookConstant.MAX_NEWS_COUNT, bookId);
Long.valueOf(RightsNowItemTypeNew.DRAW.value), BookConstant.MAX_NEWS_COUNT, bookId, null, null);
rightsSetting.setDrawSettingTitle(rightsSettingTitle);
}
return rightsSetting;
......@@ -1172,7 +1187,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
**/
private void processNowItems(RightsSettingTitle rightsSettingTitle, List<RightsNowItem> nowItems, RightsNowItemTypeNew itemType,
Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
Integer top, Long bookId) {
Integer top, Long bookId, Integer currentPage, Integer numPerPage) {
if (null == rightsSettingTitle || null == rightsSettingTitle.getRightsSettingId()) {
return;
}
......@@ -1195,9 +1210,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
items.add(nowItem);
}
}
// 此处只有资讯才会补充资讯
if (RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingTitle.getServeType())){
if (items.size() < top && rightsSettingTitle.getCollageState()!= null && rightsSettingTitle.getCollageState().intValue() == collage.intValue()){
// 首页才会拼 此处只有资讯才会补充资讯
boolean hasPage = Objects.isNull(currentPage) || (Objects.equals(currentPage, 0) && Objects.equals(numPerPage, 3));
if (hasPage && RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingTitle.getServeType())) {
if (items.size() < top && rightsSettingTitle.getCollageState() != null && rightsSettingTitle.getCollageState().intValue() == collage.intValue()) {
// 填充咨询
supplementNews(rightsSettingId, wechatUserId, rightsClassifyId, top - items.size(), items, bookId, itemType.value);
}
......@@ -1927,7 +1943,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("根据权益id和类型获取即享权益项")
@Override
public RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId,
Long bookId, Long channelId, Integer readType) {
Long bookId, Long channelId, Integer readType, Integer currentPage, Integer numPerPage) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting == null) {
throw new BookBizException(BookBizException.ERROR, "未找到权益!");
......@@ -1946,7 +1962,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
// 获取线上网课权益
if (RightsNowItemTypeNew.ONLINE_COURSE.value.equals(type)) {
return setOnlineCourse(rightsSetting, wechatUserId, readType, bookId);
return setOnlineCourse(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage);
}
// 获取专享礼券包权益
if (RightsNowItemTypeNew.GIFT_COUPON_PACKAGE.value.equals(type)) {
......@@ -1954,7 +1970,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
// 获取专享社群
if (RightsNowItemTypeNew.GROUP_SERVICE.value.equals(type)) {
return setGroupService(rightsSetting, wechatUserId, readType, bookId);
return setGroupService(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage);
}
// 老师1V1
if (RightsNowItemTypeNew.COACH.value.equals(type)) {
......@@ -1962,24 +1978,36 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
// 获取线上专课
if (RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value.equals(type)) {
return setOnlineExclCourse(rightsSetting, wechatUserId, readType, bookId);
return setOnlineExclCourse(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage);
}
return rightsSetting;
}
@ParamLog(value = "填充专享社群", isAfterReturn = false)
private RightsSetting setGroupService(RightsSetting rightsSetting, Long wechatUserId, Integer readType, Long bookId) {
private RightsSetting setGroupService(RightsSetting rightsSetting, Long wechatUserId, Integer readType, Long bookId, Integer currentPage, Integer numPerPage) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemTypeNew.GROUP_SERVICE, readType);
boolean hasPage = Objects.nonNull(currentPage) && Objects.nonNull(numPerPage);
if (null != rightsSettingTitle) {
List<RightsNowItem> nowItems = rightsNowItemDao
.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.GROUP_SERVICE.value));
List<RightsNowItem> nowItems = null;
if(hasPage){
Map<String, Object> map = CollUtil.newHashMap(2);
map.put("rightsSettingTitleId",rightsSettingTitle.getId());
map.put("types",Collections.singletonList(RightsNowItemTypeNew.GROUP_SERVICE.value));
PageBeanNew<RightsNowItem> pageBeanNew = rightsNowItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getListByRightsSettingTitleId");
nowItems = pageBeanNew.getRecordList();
rightsSettingTitle.setRightsSettingItemList4Page(pageBeanNew);
}else {
nowItems = rightsNowItemDao.getListByRightsSettingTitleId(rightsSettingTitle.getId(), Collections.singletonList(RightsNowItemTypeNew.GROUP_SERVICE.value));
}
if (RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingTitle.getServeType())){
processNowItems(rightsSettingTitle, nowItems, RightsNowItemTypeNew.GROUP_SERVICE, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.GROUP_SERVICE.value), BookConstant.MAX_NEWS_COUNT_GROUP, bookId);
Long.valueOf(RightsNowItemTypeNew.GROUP_SERVICE.value), BookConstant.MAX_NEWS_COUNT, bookId, null, null);
rightsSetting.setGroupServiceTitle(rightsSettingTitle);
} else {
processNowItems4Group(rightsSettingTitle, nowItems, RightsNowItemTypeNew.GROUP_SERVICE, rightsSetting.getId(), wechatUserId,
Long.valueOf(RightsNowItemTypeNew.GROUP_SERVICE.value), BookConstant.MAX_NEWS_COUNT_GROUP, bookId,readType);
Long.valueOf(RightsNowItemTypeNew.GROUP_SERVICE.value), BookConstant.MAX_NEWS_COUNT, bookId,readType);
rightsSetting.setGroupServiceTitle(rightsSettingTitle);
}
......
package com.pcloud.book.rightsSetting.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.page.PageBeanNew;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
@Data
public class RightsSettingTitle implements Serializable {
......@@ -36,6 +37,11 @@ public class RightsSettingTitle implements Serializable {
private String serveType;
/**
* 分页
*/
private PageBeanNew<RightsNowItem> rightsSettingItemList4Page;
/**
* 列表
*/
private List<RightsNowItem> rightsSettingItemList;
......
package com.pcloud.book.rightsSetting.facade;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
......@@ -16,8 +15,9 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil;
import org.slf4j.Logger;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CookieValue;
......@@ -29,13 +29,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import javax.validation.constraints.Min;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.SneakyThrows;
import java.util.List;
@RequestMapping("rightsSetting")
@RestController("rightsSettingFacede")
......@@ -167,17 +162,20 @@ public class RightsSettingFacede {
@SneakyThrows
@ApiOperation("根据权益id和类型获取即享权益项")
@GetMapping("getRightsSettingRightsNowItemsByType")
public ResponseDto<RightsSetting> getRightsSettingRightsNowItemsByType( @CookieValue("userInfo") String userInfo,
public ResponseDto<RightsSetting> getRightsSettingRightsNowItemsByType(@CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") @Min(value = 1,
message = "权益id不能小于1") Long rightsSettingId,
@RequestParam("rightsSettingType") @Min(value = 1,
message = "权益类型不能小于1") Integer rightsSettingType ,
@RequestParam(value = "adviserId",required = false) Long adviserId,
@RequestParam(value = "bookId", required = false)Long bookId,
@RequestParam(value = "channelId", required = false)Long channelId,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType) {
message = "权益类型不能小于1") Integer rightsSettingType,
@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "readType", required = false) @ApiParam("阅读方式1轻松2高效3深度") Integer readType,
@RequestParam(value = "numPerPage", required = false) Integer numPerPage,
@RequestParam(value = "currentPage", required = false) Integer currentPage
) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItemsByType(rightsSettingId, wechatUserId, rightsSettingType,adviserId,bookId,channelId,readType));
return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItemsByType(rightsSettingId, wechatUserId, rightsSettingType, adviserId, bookId, channelId, readType, currentPage, numPerPage));
}
@ApiOperation("根据权益id获取即享权益项专享礼包")
......
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