Commit fe4477da by 朱亚洁

feat:[1004091]本书服务改版

parent 6a433de3
......@@ -1034,4 +1034,6 @@ public interface BookGroupBiz {
List<String> getWxUserInAgents(List<Long> agentIds);
List<Long> getBookGroupIdInAgents(List<Long> agentIds);
void fillBookServe4RightsSetting(List<BookServeDTO> bookServeVOS);
}
......@@ -292,6 +292,7 @@ import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
......@@ -300,6 +301,10 @@ import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
......@@ -6321,4 +6326,141 @@ public class BookGroupBizImpl implements BookGroupBiz {
List<Long> list= bookGroupDao.getBookGroupIdInAgents(agentIds);
return list;
}
@Override
public void fillBookServe4RightsSetting(List<BookServeDTO> serveDTOList) {
if (ListUtils.isEmpty(serveDTOList)) {
return;
}
List<Long> appIds = new ArrayList<>();
List<Long> productIds = new ArrayList<>();
for (BookServeDTO bookServeDTO : serveDTOList){
if (bookServeDTO.getServeType().equals(AppAndProductTypeEnum.APP.value) && !appIds.contains(bookServeDTO.getServeId())){
appIds.add(bookServeDTO.getServeId());
} else if (bookServeDTO.getServeType().equals(AppAndProductTypeEnum.PRODUCT.value) && !productIds.contains(bookServeDTO.getServeId())){
productIds.add(bookServeDTO.getServeId());
}
}
Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, AppDto> appDtoMap = new HashMap<>();
List<BookServeDTO> removeList = new ArrayList<>(); //存储已经删除群的群分类; 精选文章类型并且跳转链接包含qrcode.5rs.me
FutureTask<Map<Long, ProductDto>> task = null;
FutureTask<Map<Long, AppDto>> task2 = null;
if (!ListUtils.isEmpty(productIds)) {
Callable<Map<Long, ProductDto>> callable = () -> productConsr.getProBasesByIds(productIds);
task = new FutureTask<>(callable);
new Thread(task).start();
}
if (!ListUtils.isEmpty(appIds)) {
Callable<Map<Long, AppDto>> callable = () -> appConsr.mapByIds4AuditPass(appIds);
task2 = new FutureTask<>(callable);
new Thread(task2).start();
}
if (task!=null) {
try {
productDtoMap = task.get();
} catch (InterruptedException e) {
LOGGER.error("获取商品失败fillProductAndApp");
} catch (ExecutionException e) {
LOGGER.error("获取商品失败fillProductAndApp");
}
}
if (task2!=null) {
try {
appDtoMap = task2.get();
} catch (InterruptedException e) {
LOGGER.error("获取应用失败fillProductAndApp");
} catch (ExecutionException e) {
LOGGER.error("获取应用失败fillProductAndApp");
}
}
Map<Long,AccountSettingDto>offMap = new HashMap<>();
for (BookServeDTO bookServeDTO : serveDTOList) {
AccountSettingDto accountSettingDto;
if (AppAndProductTypeEnum.PRODUCT.value.equals(bookServeDTO.getServeType())) {
if (!MapUtils.isEmpty(productDtoMap) && null != productDtoMap.get(bookServeDTO.getServeId())) {
ProductDto productDto = productDtoMap.get(bookServeDTO.getServeId());
if (checkRayUrl(productDto.getSkipUrl()) && ProductTypeConstant.ARTICLE.equals(bookServeDTO.getFromType())) {
removeList.add(bookServeDTO);
continue;
}
bookServeDTO.setServeName(productDto.getProductName());
bookServeDTO.setCoverImg(productDto.getCoverImg());
bookServeDTO.setTransverseImg(productDto.getPicture1());
if (productDto.getProductTypeDto() != null) {
bookServeDTO.setFromType(productDto.getProductTypeDto().getTypeCode());
bookServeDTO.setFromTypeName(productDto.getProductTypeDto().getTypeName());
}
//获取channelId,/C1404/product/display/10234028?adviserId=1001587&proType=MEMBER&source_type=QRCODE
Long channelId = null;
String url = bookServeDTO.getUrl();
if (url.contains("/C") && !url.startsWith("https")) {
url = url.substring(url.indexOf("/C") + 2);
url = url.substring(0, url.indexOf("/"));
if (!StringUtil.isEmpty(url)) {
channelId = Long.valueOf(url);
}
}
if (null != channelId) {
accountSettingDto = offMap.get(channelId);
if (accountSettingDto == null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
offMap.put(channelId, accountSettingDto);
}
if (null == accountSettingDto) {
LOGGER.info("运营平台未配置公众号channelId"+channelId);
removeList.add(bookServeDTO);
}
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, url);
bookServeDTO.setResultUrl(resultLinkUrl);
} else {
bookServeDTO.setResultUrl(url);
}
if (!StringUtil.isEmpty(productDto.getSkipUrl())) {
bookServeDTO.setHasThirdLink(true);
} else {
bookServeDTO.setHasThirdLink(false);
}
} else {
removeList.add(bookServeDTO);
}
continue;
}
if (AppAndProductTypeEnum.APP.value.equals(bookServeDTO.getServeType())) {
if (!MapUtils.isEmpty(appDtoMap) && null != appDtoMap.get(bookServeDTO.getServeId())) {
AppDto appDto = appDtoMap.get(bookServeDTO.getServeId());
if (checkRayUrl(appDto.getTurnUrl()) && AppTypeEnum.ARTICLE.value.equals(appDto.getTypeCode())){
removeList.add(bookServeDTO);
continue;
}
bookServeDTO.setServeName(appDto.getTitle());
bookServeDTO.setCoverImg(appDto.getSquareImg());
bookServeDTO.setFromType(appDto.getTypeCode());
bookServeDTO.setFromTypeName(appDto.getTypeName());
bookServeDTO.setTransverseImg(appDto.getTransverseImg());
accountSettingDto = offMap.get(appDto.getChannelId());
if(accountSettingDto==null){
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
offMap.put(appDto.getChannelId(),accountSettingDto);
}
if (null == accountSettingDto){
LOGGER.info("运营平台未配置公众号channelId"+appDto.getChannelId());
removeList.add(bookServeDTO);
}
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, bookServeDTO.getUrl());
bookServeDTO.setResultUrl(resultLinkUrl);
if (!StringUtil.isEmpty(appDto.getTurnUrl())){
bookServeDTO.setHasThirdLink(true);
} else {
bookServeDTO.setHasThirdLink(false);
}
} else {
removeList.add(bookServeDTO); //把要移除的统一放在一个集合
}
continue;
}
}
serveDTOList.removeAll(removeList);
}
}
......@@ -45,4 +45,10 @@ public class BookServeDTO extends BaseDto {
@ApiModelProperty("是否有第三方链接")
private Boolean hasThirdLink;
@ApiModelProperty("应用/资讯/作品图片-大图")
private String transverseImg;
@ApiModelProperty("跳转结果链接")
private String resultUrl;
}
......@@ -6,6 +6,7 @@ import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.PopupResourceInfoDTO;
import com.pcloud.book.rightsSetting.dto.ResourceList4Answer;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingQueryDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
......@@ -208,4 +209,43 @@ public interface RightsSettingBiz {
* * @param null
*/
Integer getPopupCount(Long wechatUserId, Long bookId, Integer popupType);
/**
* 更新权益配置
* @author:zhuyajie
* @date:2020/12/24 15:54
* * @param null
*/
void updateRightsSettingNew(RightsSetting rightsSetting);
/**
* 权益查询
* @author:zhuyajie
* @date:2020/12/24 16:49
* * @param null
*/
RightsSetting getRightsSettingNew(Long id);
/**
* 小程序查资源服务
* @author:zhuyajie
* @date:2020/12/24 17:43
* * @param null
*/
RightsSetting getRightsSettingItemsByTypeListNew(RightsSettingQueryDTO rightsSettingQueryDTO);
/**
* 所有权益分类-新版
* @author:zhuyajie
* @date:2020/12/25 14:15
* * @param null
*/
List<RightsSettingClassify> getAllRightsClassifyNew();
/**
* 处理权益旧数据
* @author:zhuyajie
* @date:2020/12/29 9:56
* * @param null
*/
void handleRightsSettingOld(List<Long> rightsSettingIdList);
}
......@@ -6,6 +6,7 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
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;
......@@ -75,6 +76,7 @@ import com.pcloud.book.rightsSetting.dto.PopupResourceInfoDTO;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.dto.ResourceList4Answer;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingQueryDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsCustomRelation;
......@@ -124,7 +126,7 @@ import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.labelcenter.label.service.LabelService;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -134,6 +136,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
......@@ -150,6 +153,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
......@@ -1595,6 +1600,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<Long> appIds = new ArrayList<>();
List<Long> groupIds = new ArrayList<>();
List<Long> appletNewsId = new ArrayList<>();
List<Long> booklistIds = new ArrayList<>();
for (RightsNowItem item : nowItems) {
if (item.getServeId() != null && AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
......@@ -1612,11 +1618,16 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
&& !appletNewsId.contains(item.getServeId())) {
appletNewsId.add(item.getServeId());
}
if (item.getServeId() != null && RightsServeTypeEnum.BOOKLIST.name().equals(item.getServeType()) && !booklistIds
.contains(item.getServeId())){
booklistIds.add(item.getServeId());
}
}
Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, AppDto> appDtoMap = new HashMap<>();
Map<Long, GroupActivity4AppletDTO> groupDtoMap = new HashMap<>();
Map<Long, AppletNewsDTO> newsDtoMap = new HashMap<>();
Map<Long, AppletOuterBooklistDTO> outerBooklistDTOMap = new HashMap<>();
List<RightsNowItem> list_remove = new ArrayList<>(); //存储已经删除群的群分类; 精选文章类型并且跳转链接包含qrcode.5rs.me
FutureTask<Map<Long, ProductDto>> task = null;
FutureTask<Map<Long, AppDto>> task2 = null;
......@@ -1654,16 +1665,17 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (!ListUtils.isEmpty(appletNewsId)) {
newsDtoMap = appletNewsBiz.getByIds(appletNewsId);
}
if (!ListUtils.isEmpty(booklistIds)){
outerBooklistDTOMap = appletBooklistBiz.getByIds(booklistIds);
}
Map<Long,AccountSettingDto>offMap = new HashMap<>();
for (RightsNowItem item : nowItems) {
Integer type = item.getType();
if (RightsNowItemTypeNew.ONLINE_COURSE.value.equals(type)
|| RightsNowItemTypeNew.LEARNING_TOOL.value.equals(type)
|| RightsNowItemTypeNew.DRAW.value.equals(type)
|| RightsNowItemTypeNew.SERVES.value.equals(type)
|| RightsNowItemTypeNew.GROUP_SERVICE.value.equals(type)
|| RightsNowItemTypeNew.COACH.value.equals(type)
|| RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value.equals(type)) {
//默认设置
item.setOuterBooklistDTOS(Lists.newArrayList());
//排序值,答案听力优先
item.setRank(nowItems.indexOf(item)+10);
if (null != type) {
AccountSettingDto accountSettingDto;
if (AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())) {
ProductDto productDto = productDtoMap.get(item.getServeId());
......@@ -1709,6 +1721,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
list_remove.add(item);
}
}
this.setRank(item);
continue;
}
if (AppAndProductTypeEnum.APP.value.equals(item.getServeType())) {
AppDto appDto = appDtoMap.get(item.getServeId());
......@@ -1739,6 +1753,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} else {
list_remove.add(item); //把要移除的统一放在一个集合
}
this.setRank(item);
continue;
}
if (RightsServeTypeEnum.GROUP.name().equals(item.getServeType())) {
GroupActivity4AppletDTO groupActivity4AppletDTO = groupDtoMap.get(item.getServeId());
......@@ -1757,6 +1773,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}else{
list_remove.add(item); //把要移除的统一放在一个集合
}
continue;
}
if (RightsServeTypeEnum.NEWS.name().equals(item.getServeType())) {
AppletNewsDTO appletNewsDTO = newsDtoMap.get(item.getServeId());
......@@ -1785,6 +1802,18 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
item.setAppraisalImg(appletNewsDTO.getAppraisalImg());
item.setBrowseCount(appletNewsDTO.getBrowseCount());
}
continue;
}
if (RightsServeTypeEnum.BOOKLIST.name().equals(item.getServeType())) {
AppletOuterBooklistDTO outerBooklistDTO = outerBooklistDTOMap.get(item.getServeId());
if (null != outerBooklistDTO){
item.getOuterBooklistDTOS().add(outerBooklistDTO);
item.setBooklistName(outerBooklistDTO.getBooklistName());
item.setUserName(outerBooklistDTO.getUserName());
item.setPublish(outerBooklistDTO.getPublish());
item.setDisplayPic(outerBooklistDTO.getDisplayPic());
}
continue;
}
}
}
......@@ -2450,7 +2479,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
// 处理馆配图书
processLibraryBook(bookId, adviserId, rightsSettingDto);
//填充收藏
fillCollect(wechatUserId, rightsSettingDto, RightsNowItemTypeNew.ONLINE_REMIND.value);
fillCollect(wechatUserId, rightsSettingDto, RightsWeekTypeEnum.ONLINE_REMIND.key);
return rightsSettingDto;
}
......@@ -2463,20 +2492,22 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<RightsSettingItem> rightsSettingLongTermItems = rightsSettingDto.getRightsSettingLongTermItems();
if (CollUtil.isNotEmpty(rightsSettingLongTermItems)) {
for (RightsSettingItem rightsSettingLongTermItem : rightsSettingLongTermItems) {
if (Objects.nonNull(rightsSettingLongTermItem))
if (Objects.nonNull(rightsSettingLongTermItem)) {
rightsSettingLongTermItem.setOuterBooklistDTOS(new ArrayList<>());
}
}
}
List<RightsSettingItem> rightsSettingWeekItems = rightsSettingDto.getRightsSettingWeekItems();
if (CollUtil.isNotEmpty(rightsSettingWeekItems)) {
for (RightsSettingItem rightsSettingWeekItem : rightsSettingWeekItems) {
if (Objects.nonNull(rightsSettingWeekItem))
if (Objects.nonNull(rightsSettingWeekItem)) {
rightsSettingWeekItem.setOuterBooklistDTOS(new ArrayList<>());
}
}
}
}
}
@Override
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId,
......@@ -2844,7 +2875,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
List<RightsNowItem> rightsNowItemList = new ArrayList<>();
if (RightsNowItemTypeNew.SERVES.value.equals(type)) {
if (fillCollect4Serve(wechatUserId, rightsSetting4Serves)) return;
if (fillCollect4Serve(wechatUserId, rightsSetting4Serves)) {return;}
} else if (RightsNowItemTypeNew.ONLINE_COURSE.value.equals(type)) {
if (null != rightsSetting4Serves.getOnlineRightsSettingTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getOnlineRightsSettingTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getOnlineRightsSettingTitle().getRightsSettingItemList();
......@@ -2865,7 +2896,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null != rightsSetting4Serves.getLearningToolTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getLearningToolTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getLearningToolTitle().getRightsSettingItemList();
}
} else if (RightsNowItemTypeNew.ONLINE_REMIND.value.equals(type)) {
} else if (RightsWeekTypeEnum.ONLINE_REMIND.key.equals(type)) {
if (!ListUtils.isEmpty(rightsSetting4Serves.getRightsSettingWeekItems())){
for (RightsSettingItem rightsSettingItem : rightsSetting4Serves.getRightsSettingWeekItems()) {
if (!ListUtils.isEmpty(rightsSettingItem.getRightsSettingItemList4Serve())) {
......@@ -2946,15 +2977,18 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private void fillCollect4RightsNowItem(Long wechatUserId, List<RightsNowItem> rightsNowItems) {
log.info("为应用或作品填充是否收藏");
List<ServeCollect> serveCollects = new ArrayList<>();
rightsNowItems.forEach(e -> {
ServeCollect serveCollect = new ServeCollect();
serveCollect.setWechatUserId(wechatUserId);
serveCollect.setServeId(e.getServeId());
serveCollect.setServeType(Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ? AppletRecordTypeEnum.PRODUCT.value : AppletRecordTypeEnum.APP.value);
serveCollects.add(serveCollect);
});
// List<ServeCollect> serveCollects = new ArrayList<>();
// rightsNowItems.forEach(e -> {
// ServeCollect serveCollect = new ServeCollect();
// serveCollect.setWechatUserId(wechatUserId);
// serveCollect.setServeId(e.getServeId());
// serveCollect.setServeType(Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ? AppletRecordTypeEnum.PRODUCT.value : AppletRecordTypeEnum.APP.value);
// serveCollects.add(serveCollect);
// });
// List<ServeCollect> serveCollectList = serveCollectBiz.getList4RightsSetting(serveCollects);
if (ListUtils.isEmpty(rightsNowItems)) {
return;
}
List<ServeCollect> serveCollectList = serveCollectBiz.getList4RightsSettingByWechatUserId(wechatUserId);
if (ListUtils.isEmpty(serveCollectList)) {
return;
......@@ -3911,4 +3945,444 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
return itemList;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateRightsSettingNew(RightsSetting rightsSetting) {
if (rightsSetting == null) {
return;
}
//处理前端传过来的数据
handleRightsSetting4Sort(rightsSetting);
rightsSettingCheck.rightsSettingCheck(rightsSetting);
if (null == rightsSetting.getId()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少id!");
}
Long rightsSettingId = rightsSetting.getId();
if (Objects.equals(RightsTypeEnum.BASE.code, rightsSetting.getStepType())) {
//更新基本信息
updateRightsSettingBase(rightsSetting, rightsSettingId);
} else if (Objects.equals(RightsTypeEnum.NOW.code, rightsSetting.getStepType())) {
//更新即享权益
updateRightNowItemByRightIdNew(rightsSetting);
rightsSettingDAO.updateUser(rightsSetting);
}else if (Objects.equals(RightsTypeEnum.UP_NUMBER.code, rightsSetting.getStepType())) {
updateNumber(rightsSetting);
rightsSettingDAO.updateUser(rightsSetting);
}
}
private void updateRightNowItemByRightIdNew(RightsSetting rightsSetting) {
Long rightsSettingId = rightsSetting.getId();
List<RightsNowItem> items = new ArrayList<>();
RightsSettingNow rightsSettingNow = rightsSetting.getRightsSettingNow();
//根据权益id删除原来的
rightsSettingTitleMapper.deleteByRightSettingId(rightsSettingId);
rightsNowItemDao.deleteByRightsSettingId(rightsSettingId);
List<RightsSettingTitle> rightsSettingTitleList = rightsSettingNow.getNewRightsSettingTitles();
if (ListUtils.isEmpty(rightsSettingTitleList)) {
return;
}
//给每个权益设置id
rightsSettingTitleList.forEach(e -> {
e.setRightsSettingId(rightsSettingId);
e.setDisplayType(e.getDisplayType()==null?0:e.getDisplayType());
});
rightsSettingTitleMapper.batchInsert(rightsSettingTitleList);
//设置每个权益详情
setNowItems(rightsSettingTitleList, rightsSettingId, items);
//校验itme参数
rightsSettingCheck.checkRightNowItems(items);
if (!ListUtils.isEmpty(items)) {
rightsNowItemDao.batchInsert(items);
}
}
@Override
@ParamLog("获取权益设置")
public RightsSetting getRightsSettingNew(Long id) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(id);
if (null == rightsSetting) {
return new RightsSetting();
}
//书刊分类关联书刊
fillBookName(id, rightsSetting);
//立享权益
List<Integer> types = new ArrayList<>();
types.addAll(Arrays.asList(RightsSettingConstant.RIGHTSSETTING_TYPES_NEW));
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingIdAndTypes(rightsSetting.getId(), types);
if (!ListUtils.isEmpty(rightsSettingTitles)) {
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), types);
if (!ListUtils.isEmpty(nowItems)) {
rightsSettingTitles = fillRightsNowItems4RightsSettingNew(rightsSettingTitles, nowItems);
}
}
RightsSettingNow rightsSettingNow = new RightsSettingNow();
rightsSettingNow.setRightsSettingTitles(rightsSettingTitles);
rightsSetting.setRightsSettingNow(rightsSettingNow);
//设置阅读指引
fillReadGuide(rightsSetting);
//填充分类及标签
fillLabelNames(Lists.newArrayList(rightsSetting));
return rightsSetting;
}
private List<RightsSettingTitle> fillRightsNowItems4RightsSettingNew(List<RightsSettingTitle> rightsSettingTitles, List<RightsNowItem> nowItems) {
log.info("即享权益内容填充");
if (ListUtils.isEmpty(rightsSettingTitles) || ListUtils.isEmpty(nowItems)) {
return rightsSettingTitles;
}
fillProductAndApp(nowItems);
Map<Long, List<RightsNowItem>> nowItemMap = nowItems.stream().filter(e -> null != e.getRightsSettingTitleId())
.collect(Collectors.groupingBy(x -> x.getRightsSettingTitleId()));
List<RightsSettingTitle> removeList = new ArrayList<>();
for (RightsSettingTitle rightsSettingTitle : rightsSettingTitles) {
// 填充应用、作品、社群、资讯
if (!MapUtils.isEmpty(nowItemMap) && !ListUtils.isEmpty(nowItemMap.get(rightsSettingTitle.getId()))) {
rightsSettingTitle.setRightsSettingItemList(nowItemMap.get(rightsSettingTitle.getId()));
}
//填充礼券包
if (RightsNowItemTypeNew.GIFT_COUPON_PACKAGE.value.equals(rightsSettingTitle.getRightsSettingNowType())) {
List<RightsNowItem> giftCouponPackItems = rightsNowItemDao.getGiftCouponListByRightsSettingTitleId(rightsSettingTitle.getId());
if (!ListUtils.isEmpty(giftCouponPackItems)) {
rightsSettingTitle.setRightsSettingItemList(giftCouponPackItems);
} else {
removeList.add(rightsSettingTitle);
}
}
}
rightsSettingTitles.removeAll(removeList);
if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitles = rightsSettingTitles.stream().
sorted(Comparator.comparing(item -> item.getSeqNum(), Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
}
return rightsSettingTitles;
}
@ParamLog("根据权益id和类型获取即享权益项")
@Override
public RightsSetting getRightsSettingItemsByTypeListNew(RightsSettingQueryDTO rightsSettingQueryDTO) {
Long rightsSettingId = rightsSettingQueryDTO.getRightsSettingId();
Long wechatUserId = rightsSettingQueryDTO.getWechatUserId();
List<Integer> types = rightsSettingQueryDTO.getRightsSettingTypes();
Long adviserId = rightsSettingQueryDTO.getAdviserId();
Long bookId = rightsSettingQueryDTO.getBookId();
Long channelId = rightsSettingQueryDTO.getChannelId();
if (ListUtils.isEmpty(types)) {
throw new BookBizException(BookBizException.ERROR, "权益类型为空!");
}
RightsSetting rightsSetting = null;
if (null != rightsSettingId) {
rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
}
List<RightsSettingTitle> rightsSettingTitles = new ArrayList<>();
//权益配置的模块
if (null != rightsSetting) {
rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingIdAndTypes(rightsSetting.getId(), types);
if (!ListUtils.isEmpty(rightsSettingTitles)) {
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), types);
if (!ListUtils.isEmpty(nowItems)) {
rightsSettingTitles = fillRightsNowItems4RightsSettingNew(rightsSettingTitles, nowItems);
//设置收藏状态
this.fillCollect4RightsNowItem(wechatUserId, nowItems);
}
}
}
//本书配套资源
Map<Integer, List<RightsNowItem>> integerListMap = new HashMap<>();
if (types.contains(RightsNowItemTypeNew.FIXED_FIRST.value) && types.contains(RightsNowItemTypeNew.FIXED_SECOND.value)
&& types.contains(RightsNowItemTypeNew.FIXED_THIRD.value)) {
List<RightsNowItem> servesNowItems = getServeRightsSetting4New(adviserId, bookId, channelId);
//设置收藏状态
this.fillCollect4RightsNowItem(wechatUserId, servesNowItems);
integerListMap = servesNowItems.stream().collect(Collectors.groupingBy(RightsNowItem::getType));
}
if (!MapUtils.isEmpty(integerListMap)) {
//本书配套资源添加到各个模块
if (!ListUtils.isEmpty(rightsSettingTitles)) {
for (RightsSettingTitle rightsSettingTitle : rightsSettingTitles) {
if (null != integerListMap.get(rightsSettingTitle.getRightsSettingNowType())) {
List<RightsNowItem> newItemList = new ArrayList<>();
newItemList.addAll(integerListMap.get(rightsSettingTitle.getRightsSettingNowType()));
if (!ListUtils.isEmpty(rightsSettingTitle.getRightsSettingItemList())) {
newItemList.addAll(rightsSettingTitle.getRightsSettingItemList());
}
if (!ListUtils.isEmpty(newItemList)) {
//根据自定义排序
newItemList = newItemList.stream().sorted(Comparator.comparing(item -> item.getRank(), Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
}
rightsSettingTitle.setRightsSettingItemList(newItemList);
}
}
} else {
for (Map.Entry<Integer, List<RightsNowItem>> entry : integerListMap.entrySet()) {
RightsSettingTitle rightsSettingTitle = new RightsSettingTitle();
List<RightsNowItem> newItemList = entry.getValue();
if (!ListUtils.isEmpty(newItemList)) {
//根据自定义排序
newItemList = newItemList.stream().sorted(Comparator.comparing(item -> item.getRank(), Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
}
rightsSettingTitle.setRightsSettingNowType(entry.getKey());
rightsSettingTitle.setRightsSettingItemList(newItemList);
rightsSettingTitles.add(rightsSettingTitle);
}
}
}
RightsSettingNow rightsSettingNow = new RightsSettingNow();
rightsSettingNow.setRightsSettingTitles(rightsSettingTitles);
rightsSetting = rightsSetting==null?new RightsSetting():rightsSetting;
rightsSetting.setRightsSettingNow(rightsSettingNow);
return rightsSetting;
}
/**
* 本书配套服务按固定模块区分
* @author:zhuyajie
* @date:2020/12/25 9:17
* * @param null
*/
private List<RightsNowItem> getServeRightsSetting4New(Long adviserId, Long bookId, Long channelId){
List<RightsNowItem> servesNowItems = new ArrayList<>();
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(adviserId, bookId, channelId);
bookGroupBiz.removeCanNotBuy(bookServeVOS);
bookGroupBiz.fillBookServe4RightsSetting(bookServeVOS);
if (ListUtils.isEmpty(bookServeVOS)) {
return servesNowItems;
}
for (BookServeDTO vo : bookServeVOS) {
String typeCode = vo.getFromType();
String serveName = vo.getServeName();
RightsNowItem rightsNowItem = null;
//根据名称归类,排序在前面
if (serveName.contains("答案") || AppTypeEnum.ANSWER.value.equals(typeCode)) {
rightsNowItem = bookServeToRightsSettingItem(vo, RightsNowItemTypeNew.FIXED_FIRST.value, 1);
} else if (serveName.contains("听力") || AppTypeEnum.MATCH_LISTEN.value.equals(typeCode)) {
rightsNowItem = bookServeToRightsSettingItem(vo, RightsNowItemTypeNew.FIXED_FIRST.value, 2);
} else if (serveName.contains("视频") || serveName.contains("名师") || serveName.contains("微课")) {
rightsNowItem = bookServeToRightsSettingItem(vo, RightsNowItemTypeNew.FIXED_SECOND.value, 1);
}
//资料包、课件、试卷、图文、知识点汇总、测试卷、拓展资料、素材包、自测卷
else if (serveName.contains("资料包") ||serveName.contains("课件") || serveName.contains("试卷") || serveName.contains("图文")
|| serveName.contains("知识点汇总") || serveName.contains("测试卷") || serveName.contains("拓展资料")
|| serveName.contains("素材包") || serveName.contains("自测卷")){
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_THIRD.value, 1);
} else {
//根据类型归类
if (AppAndProductTypeEnum.APP.value.equals(vo.getServeType())) {
if (RightsSettingConstant.FIXED_SECOND_APPLET_APP_LIST.contains(typeCode)) {
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_SECOND.value,
RightsSettingConstant.FIXED_SECOND_APPLET_APP_LIST.indexOf(typeCode));
} else if (RightsSettingConstant.FIXED_THIRD_APPLET_APP_LIST.contains(typeCode)) {
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_THIRD.value,
RightsSettingConstant.FIXED_THIRD_APPLET_APP_LIST.indexOf(typeCode));
} else {
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_FIRST.value,10);
}
} else if (AppAndProductTypeEnum.PRODUCT.value.equals(vo.getServeType())){
if (RightsSettingConstant.FIXED_SECOND_APPLET_PRODUCT_LIST.contains(typeCode)) {
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_SECOND.value,
RightsSettingConstant.FIXED_SECOND_APPLET_PRODUCT_LIST.indexOf(typeCode));
} else if (RightsSettingConstant.FIXED_THIRD_APPLET_PRODUCT_LIST.contains(typeCode)) {
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_THIRD.value,
RightsSettingConstant.FIXED_THIRD_APPLET_PRODUCT_LIST.indexOf(typeCode));
} else {
rightsNowItem = bookServeToRightsSettingItem(vo,RightsNowItemTypeNew.FIXED_FIRST.value, 10);
}
}
}
if (null != rightsNowItem) {
servesNowItems.add(rightsNowItem);
}
}
return servesNowItems;
}
private RightsNowItem bookServeToRightsSettingItem(BookServeDTO bookServeDTO, Integer type, Integer rank) {
RightsNowItem item = new RightsNowItem();
item.setType(type);
item.setServeId(bookServeDTO.getServeId());
item.setServeType(bookServeDTO.getTypeCode());
item.setLinkUrl(bookServeDTO.getUrl());
item.setServeTypeCode(bookServeDTO.getFromType());
item.setServeTypeName(bookServeDTO.getFromTypeName());
item.setServeName(bookServeDTO.getServeName());
item.setResultUrl(bookServeDTO.getResultUrl());
item.setServePic(bookServeDTO.getCoverImg());
item.setTransverseImg(bookServeDTO.getTransverseImg());
item.setHasThirdLink(bookServeDTO.getHasThirdLink());
item.setRank(rank);
return item;
}
private RightsNowItem setRank(RightsNowItem item) {
if (null == item || StringUtil.isEmpty(item.getServeName())) {
return item;
}
String serveName = item.getServeName();
String serveTypeCode = item.getServeTypeCode();
if (serveName.contains("答案") || AppTypeEnum.ANSWER.value.equals(serveTypeCode)) {
item.setRank(1);
} else if (serveName.contains("听力") || AppTypeEnum.MATCH_LISTEN.value.equals(serveTypeCode)) {
item.setRank(2);
}
return item;
}
@Override
public List<RightsSettingClassify> getAllRightsClassifyNew() {
List<Integer> types = Arrays.asList(RightsSettingConstant.RIGHTSSETTING_TYPES_NEW);
return rightsSettingItemDao.getRightsClassifyByIds(types);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void handleRightsSettingOld(List<Long> rightsSettingIdList){
if (ListUtils.isEmpty(rightsSettingIdList)) {
return;
}
//处理立享权益配套资源包
this.handleNowRightsSettingOld(rightsSettingIdList);
//将每周、长期权益旧数据添加至立享权益
this.handleWeekRightsSettingOld(rightsSettingIdList);
}
@ParamLog("处理立享权益旧数据")
private void handleNowRightsSettingOld(List<Long> rightsSettingIdList) {
if (ListUtils.isEmpty(rightsSettingIdList)) {
return;
}
List<Integer> types = Arrays.asList(RightsNowItemTypeNew.FIXED_FIRST.value,
RightsNowItemTypeNew.FIXED_SECOND.value, RightsNowItemTypeNew.FIXED_THIRD.value);
for (Long rightsSettingId:rightsSettingIdList) {
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingIdAndTypes(rightsSettingId, types);
if (!ListUtils.isEmpty(rightsSettingTitles)) {
continue;
}
List<RightsSettingTitle> titles = new ArrayList<>();
for (Integer type:types){
RightsSettingTitle title = new RightsSettingTitle();
title.setRightsSettingId(rightsSettingId);
if (type.equals(RightsNowItemTypeNew.FIXED_FIRST.value)) {
title.setRightsSettingTitle("必备!第一手");
} else if (type.equals(RightsNowItemTypeNew.FIXED_SECOND.value)) {
title.setRightsSettingTitle("晋级!课程提升");
} else if (type.equals(RightsNowItemTypeNew.FIXED_THIRD.value)) {
title.setRightsSettingTitle("拓展!资料延伸");
}
title.setRightsSettingNowType(type);
title.setEasyRead(true);
title.setSeqNum(1);
title.setOpenState(true);
titles.add(title);
}
rightsSettingTitleMapper.batchInsert(titles);
Long fixedFirstTitleId = titles.get(0).getId();
Long fixedSecondTitleId = titles.get(1).getId();
Long fixedThirdTitleId = titles.get(2).getId();
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSettingId, Arrays.asList(RightsNowItemTypeNew.SERVES.value));
if (!ListUtils.isEmpty(nowItems)) {
fillProductAndApp(nowItems);
for (RightsNowItem rightsNowItem : nowItems){
String typeCode = rightsNowItem.getServeTypeCode();
if (AppAndProductTypeEnum.APP.value.equals(rightsNowItem.getServeType())) {
if (RightsSettingConstant.FIXED_SECOND_APPLET_APP_LIST.contains(typeCode)) {
rightsNowItem.setType(RightsNowItemTypeNew.FIXED_SECOND.value);
rightsNowItem.setRightsSettingTitleId(fixedSecondTitleId);
} else if (RightsSettingConstant.FIXED_THIRD_APPLET_APP_LIST.contains(typeCode)) {
rightsNowItem.setType(RightsNowItemTypeNew.FIXED_THIRD.value);
rightsNowItem.setRightsSettingTitleId(fixedThirdTitleId);
} else {
rightsNowItem.setType(RightsNowItemTypeNew.FIXED_FIRST.value);
rightsNowItem.setRightsSettingTitleId(fixedFirstTitleId);
}
} else if (AppAndProductTypeEnum.PRODUCT.value.equals(rightsNowItem.getServeType())){
if (RightsSettingConstant.FIXED_SECOND_APPLET_PRODUCT_LIST.contains(typeCode)) {
rightsNowItem.setType(RightsNowItemTypeNew.FIXED_SECOND.value);
rightsNowItem.setRightsSettingTitleId(fixedSecondTitleId);
} else if (RightsSettingConstant.FIXED_THIRD_APPLET_PRODUCT_LIST.contains(typeCode)) {
rightsNowItem.setType(RightsNowItemTypeNew.FIXED_THIRD.value);
rightsNowItem.setRightsSettingTitleId(fixedThirdTitleId);
} else {
rightsNowItem.setType(RightsNowItemTypeNew.FIXED_FIRST.value);
rightsNowItem.setRightsSettingTitleId(fixedFirstTitleId);
}
}
rightsNowItem.setRightsItemGroupId(null);
}
rightsNowItemDao.batchInsert(nowItems);
}
}
}
@ParamLog("处理每周、长期权益旧数据")
private void handleWeekRightsSettingOld(List<Long> rightsSettingIdList) {
if (ListUtils.isEmpty(rightsSettingIdList)) {
return;
}
List<RightsSettingItemDetail> itemDetailList = rightsSettingItemDetailDao.getByRightsSettingIdList(rightsSettingIdList);
if (!ListUtils.isEmpty(itemDetailList)) {
Map<Long,List<RightsSettingItemDetail>> listMap = itemDetailList.stream().collect(Collectors.groupingBy(RightsSettingItemDetail::getRightsSettingItemId));
List<Long> itemIds = itemDetailList.stream().map(RightsSettingItemDetail::getRightsSettingItemId).distinct().collect(Collectors.toList());
List<RightsSettingItem> itemList = rightsSettingItemDao.getRightSettingItemByIds(itemIds);
//添加到立享权益
List<RightsSettingTitle> titles = new ArrayList<>();
List<Integer> types = Arrays.asList(RightsWeekTypeEnum.ONLINE_REMIND.key, RightsWeekTypeEnum.ONLINE_READING_ACTIVITY.key,
RightsWeekTypeEnum.BOOK_RECOMMEND.key, RightsWeekTypeEnum.NEWS_PUSH.key,
RightsWeekTypeEnum.FAMILY_ACTIVITY.key, RightsWeekTypeEnum.OFFLINE_READING_ACTIVITY.key,
RightsWeekTypeEnum.COURSE_OR_GIFT.key);
for (RightsSettingItem item:itemList){
//是否已处理
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingIdAndTypes(item.getRightsSettingId(), types);
if (!ListUtils.isEmpty(rightsSettingTitles)) {
continue;
}
RightsSettingTitle title = new RightsSettingTitle();
title.setRightsSettingId(item.getRightsSettingId());
title.setRightsSettingTitle(item.getTitle());
title.setRightsSettingDesc(item.getDescription());
title.setRightsSettingNowType(Integer.valueOf(item.getRightsClassifyId().toString()));
title.setEasyRead(item.getEasyRead());
title.setDeepRead(item.getDeepRead());
title.setEfficientRead(item.getEfficientRead());
title.setSeqNum(21+itemList.indexOf(item));
title.setServeType(item.getServeType());
title.setCollageState(item.getCollageState());
title.setDisplayType(item.getDisplayType());
if (null != item.getOpenState() && 1==item.getOpenState()){
title.setOpenState(true);
}else {
title.setOpenState(false);
}
//模块资源
List<RightsNowItem> rightsNowItemList = new ArrayList<>();
List<RightsSettingItemDetail> itemDetails = listMap.get(item.getId());
if (!ListUtils.isEmpty(itemDetails)){
for (RightsSettingItemDetail itemDetail:itemDetails) {
RightsNowItem rightsNowItem = new RightsNowItem();
rightsNowItem.setServeId(itemDetail.getServeId());
rightsNowItem.setServeType(itemDetail.getServeType());
rightsNowItem.setLinkUrl(itemDetail.getLinkUrl());
if (null != itemDetail.getGroupType()) {
rightsNowItem.setGroupType(itemDetail.getGroupType().toString());
}
rightsNowItem.setType(title.getRightsSettingNowType());
rightsNowItem.setRightsSettingId(title.getRightsSettingId());
rightsNowItemList.add(rightsNowItem);
}
}
title.setRightsSettingItemList(rightsNowItemList);
titles.add(title);
}
rightsSettingTitleMapper.batchInsert(titles);
List<RightsNowItem> nowItemList = new ArrayList<>();
for (RightsSettingTitle title:titles){
List<RightsNowItem> rightsNowItemList = title.getRightsSettingItemList();
if (!ListUtils.isEmpty(rightsNowItemList)) {
rightsNowItemList.forEach(s-> s.setRightsSettingTitleId(title.getId()));
nowItemList.addAll(rightsNowItemList);
}
}
rightsNowItemDao.batchInsert(nowItemList);
}
}
}
package com.pcloud.book.rightsSetting.constants;
import com.pcloud.book.rightsSetting.enums.RightsNowItemTypeNew;
import com.pcloud.book.rightsSetting.enums.RightsWeekTypeEnum;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.enums.AppTypeEnum;
import java.util.Arrays;
import java.util.List;
public class RightsSettingConstant {
/**
......@@ -77,4 +82,46 @@ public class RightsSettingConstant {
* 教辅一级分类
*/
public static final Long[] K12_TEMPLET_ID_NEW = {534L};
/**
* 权益页改版
* 17固定模块一,18固定模块二,19固定模块三
* 3学习工具,4抽奖,5专享礼包券,6社群服务,15老师1V1,16线上专享课
* 7线上学习/阅读提醒,8线上读书活动,9书单推荐,10资讯推送
* 11亲子活动设计,13线下读书活动推荐,14抢兑课程/实物礼品
*/
public static final Integer[] RIGHTSSETTING_TYPES_NEW ={
RightsNowItemTypeNew.FIXED_FIRST.value, RightsNowItemTypeNew.FIXED_SECOND.value, RightsNowItemTypeNew.FIXED_THIRD.value,
RightsNowItemTypeNew.LEARNING_TOOL.value, RightsNowItemTypeNew.DRAW.value,
RightsNowItemTypeNew.GIFT_COUPON_PACKAGE.value, RightsNowItemTypeNew.GROUP_SERVICE.value,
RightsNowItemTypeNew.COACH.value, RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value,
RightsWeekTypeEnum.ONLINE_REMIND.key, RightsWeekTypeEnum.ONLINE_READING_ACTIVITY.key,
RightsWeekTypeEnum.BOOK_RECOMMEND.key, RightsWeekTypeEnum.NEWS_PUSH.key,
RightsWeekTypeEnum.FAMILY_ACTIVITY.key, RightsWeekTypeEnum.OFFLINE_READING_ACTIVITY.key,
RightsWeekTypeEnum.COURSE_OR_GIFT.key};
/**
*固定模块2展示的应用作品类型
* 直播课,视频,视频课,专家咨询,名师辅导
*/
public static final List<String> FIXED_SECOND_APPLET_APP_LIST = Arrays.asList(
AppTypeEnum.LIVE_TIMETABLE.value, AppTypeEnum.VIDEO.value, AppTypeEnum.QA.value, AppTypeEnum.TUTOR.value
);
public static final List<String> FIXED_SECOND_APPLET_PRODUCT_LIST = Arrays.asList(
ProductTypeConstant.SCHEDULE, ProductTypeConstant.VIDEO, ProductTypeConstant.VIDEO_SCHEDULE
);
/**
*固定模块3展示的应用作品类型
* 图文、课件、试卷、教辅资料包、素材包、作品集、高清大图,笔顺动图,热门电子书,在线题库
*/
public static final List<String> FIXED_THIRD_APPLET_APP_LIST = Arrays.asList(
AppTypeEnum.PDF.value, AppTypeEnum.COURSE_WARE.value, AppTypeEnum.TEST_PAPER.value,
AppTypeEnum.TEACH_RESOURCE.value, AppTypeEnum.IMAGE.value, AppTypeEnum.STROKE_ORDER.value,
AppTypeEnum.EBOOK.value, AppTypeEnum.ITEM_BANK.value, AppTypeEnum.BOOK.value
);
public static final List<String> FIXED_THIRD_APPLET_PRODUCT_LIST = Arrays.asList(
ProductTypeConstant.PDF,ProductTypeConstant.FORMAT, ProductTypeConstant.EBOOK,
ProductTypeConstant.ALBUM, ProductTypeConstant.PRETEST
);
}
......@@ -41,7 +41,6 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{
*/
List<RightsSettingClassify>getAllRightsClassify(String rightsType);
List<RightsSettingItem> getItemByRightsIdAndType(Long rightsSettingId, String rightsType);
List<RightsSettingItem> getItemsByRightsSettingId4Read(Long rightsSettingId, String rightsType);
......@@ -52,4 +51,20 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{
List<RightsSettingItem> getItemsByClassify(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId, String rightsType, Integer readType, Long rightsClassifyId, Long thirdClassify);
List<RightsSettingItem> getRightSettingInfo(String serveType, String rightsType, Long rightsSettingId);
/**
* 根据id查询权益模块列表
* @author:zhuyajie
* @date:2020/12/25 14:30
* * @param null
*/
List<RightsSettingClassify> getRightsClassifyByIds(List<Integer> ids);
/**
* 查配置的权益模块
* @author:zhuyajie
* @date:2020/12/29 11:26
* * @param null
*/
List<RightsSettingItem> getRightSettingItemByIds(List<Long> itemIds);
}
\ No newline at end of file
......@@ -48,4 +48,12 @@ public interface RightsSettingItemDetailDao extends BaseDao<RightsSettingItemDet
* @param activityIds
*/
void deleteInvalidActivityGroups(List<Long> activityIds);
/**
* 查权益配置的资源
* @author:zhuyajie
* @date:2020/12/29 11:09
* * @param null
*/
List<RightsSettingItemDetail> getByRightsSettingIdList(List<Long> rightsSettingIdList);
}
\ No newline at end of file
......@@ -42,14 +42,6 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp
}
@Override
public List<RightsSettingItem> getItemByRightsIdAndType(Long rightsSettingId, String rightsType) {
Map<String,Object> map = new HashMap<>();
map.put("rightsSettingId",rightsSettingId);
map.put("rightsType",rightsType);
return getSessionTemplate().selectList(getStatement("getItemByRightsIdAndType"), map);
}
@Override
public List<RightsSettingItem> getItemsByRightsSettingId4Read(Long rightsSettingId, String rightsType) {
Map<String,Object> map = new HashMap<>();
map.put("rightsSettingId",rightsSettingId);
......@@ -94,4 +86,18 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp
return getSessionTemplate().selectList(getStatement("getRightSettingInfo"), map);
}
@Override
public List<RightsSettingClassify> getRightsClassifyByIds(List<Integer> ids){
Map<String,Object> map = new HashMap<>();
map.put("list",ids);
return getSessionTemplate().selectList(getStatement("getRightsClassifyByIds"), map);
}
@Override
public List<RightsSettingItem> getRightSettingItemByIds(List<Long> itemIds) {
Map<String,Object> map = new HashMap<>();
map.put("list",itemIds);
return getSessionTemplate().selectList(getStatement("getRightSettingItemByIds"), map);
}
}
......@@ -55,4 +55,9 @@ public class RightsSettingItemDetailDaoImpl extends BaseDaoImpl<RightsSettingIte
public void deleteInvalidActivityGroups(List<Long> activityIds) {
getSessionTemplate().delete(getStatement("deleteInvalidActivityGroups"), activityIds);
}
@Override
public List<RightsSettingItemDetail> getByRightsSettingIdList(List<Long> rightsSettingIdList) {
return getSessionTemplate().selectList(getStatement("getByRightsSettingIdList"), rightsSettingIdList);
}
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.dto;
import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName com.pcloud.book.rightsSetting.dto.RightsSettingQueryDTO
* @Author zhuyajie
* @Description 小程序权益查询
* @Date 2020/12/25 9:29
* @Version 1.0
**/
@Data
public class RightsSettingQueryDTO {
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("权益类型列表")
private List<Integer> rightsSettingTypes;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("书刊id")
private Long bookId;
@ApiModelProperty("运营id")
private Long channelId;
@ApiModelProperty("用户id")
private Long wechatUserId;
}
package com.pcloud.book.rightsSetting.entity;
import com.pcloud.book.applet.dto.AppletOuterBooklistDTO;
import com.pcloud.book.applet.dto.GroupActivity4AppletDTO;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
......@@ -10,6 +11,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* @Description
......@@ -135,4 +137,26 @@ public class RightsNowItem extends BaseEntity {
@ApiModelProperty("评估价图片")
private String appraisalImg;
@ApiModelProperty("自定义排序")
private Integer rank;
@ApiModelProperty("外部书单列表")
private List<AppletOuterBooklistDTO> outerBooklistDTOS;
/**
* 书单主题名称
*/
private String booklistName;
/**
* 创建者名称
*/
private String userName;
/**
* 展示图
*/
private String displayPic;
/**
* 出版社
*/
private String publish;
}
package com.pcloud.book.rightsSetting.enums;
public enum RightsNowItemType {
/**
* 1线上网课
*/
ONLINE_COURSE(1),
/**
* 2学习工具
*/
LEARNING_TOOL(2),
/**
* 3抽奖
*/
DRAW(3),
/**
* 4专享礼包券
*/
GIFT_COUPON_PACKAGE(4),
/**
* 5社群服务
*/
GROUP_SERVICE(5),
/**
* 6 配套资料
*/
SERVES(6),
/**
* 7线上学习/阅读提醒
*/
ONLINE_REMIND(7),
/**
* 线上读书活动
*/
ONLINE_READING_ACTIVITY(8);
public final Integer value;
RightsNowItemType(Integer value) {
this.value = value;
}
}
......@@ -29,28 +29,29 @@ public enum RightsNowItemTypeNew {
* 6社群服务
*/
GROUP_SERVICE(6),
/*
*
* 7线上学习/阅读提醒
*/
ONLINE_REMIND(7),
/**
* 线上读书活动
*/
ONLINE_READING_ACTIVITY(8),
/**
* 老师1V1
*/
COACH(15),
/**
* 线上专享课
*/
ONLINE_EXCL_COURSE(16);
ONLINE_EXCL_COURSE(16),
/**
* 固定模块一/必备!第一手
*/
FIXED_FIRST(17),
/**
* 固定模块二/晋级!课程提升
*/
FIXED_SECOND(18),
/**
* 固定模块三/拓展!资料延伸
*/
FIXED_THIRD(19);
public final Integer value;
......
......@@ -7,6 +7,7 @@ package com.pcloud.book.rightsSetting.enums;
* @版本:1.0
*/
public enum RightsWeekTypeEnum {
//每周、长期权益添加到立享权益中
/**
* 7线上学习/阅读提醒
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.facade;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingQueryDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO;
import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsNowPopup;
......@@ -386,4 +387,47 @@ public class RightsSettingFacede {
}
return new ResponseDto<>(rightsSettingBiz.getRightsItemGroupsByBookGroup(bookGroupId, wechatUserId));
}
@ApiOperation("平台端更新权益设置-新版")
@PostMapping("updateRightsSettingNew")
public ResponseDto<?> updateRightsSettingNew( @RequestHeader("token") String token,
@RequestBody @Validated RightsSetting rightsSetting ) throws PermissionException {
Map<String,Object> map = SessionUtil.getToken4Redis(token);
Long userId = (Long) map.get(SessionUtil.USER_ID);
rightsSetting.setUpdateUserId(userId);
rightsSettingBiz.updateRightsSettingNew(rightsSetting);
return new ResponseDto<>();
}
@ApiOperation("平台端根据id查权益-新版")
@GetMapping("getRightsSettingNew")
public ResponseDto<RightsSetting> getRightsSettingNew(
@RequestHeader("token") String token,
@RequestParam("id") Long id ) throws PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(rightsSettingBiz.getRightsSettingNew(id));
}
@SneakyThrows
@ApiOperation("获取即享权益项-新版")
@PostMapping("getRightsSettingItemsByTypeListNew")
public ResponseDto<RightsSetting> getRightsSettingItemsByTypeListNew(
@CookieValue("userInfo") String userInfo, @RequestBody RightsSettingQueryDTO rightsSettingQueryDTO) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
rightsSettingQueryDTO.setWechatUserId(wechatUserId);
return new ResponseDto<>(rightsSettingBiz.getRightsSettingItemsByTypeListNew(rightsSettingQueryDTO));
}
@ApiOperation("所有权益分类-新版")
@GetMapping("getAllRightsClassifyNew")
public ResponseDto<List<RightsSettingClassify>> getAllRightsClassifyNew() {
return new ResponseDto<>(rightsSettingBiz.getAllRightsClassifyNew());
}
@ApiOperation("处理权益模块旧数据")
@PostMapping("handleRightsSettingOld")
public ResponseDto<?> handleRightsSettingOld(@RequestBody List<Long> rightsSettingIdList){
rightsSettingBiz.handleRightsSettingOld(rightsSettingIdList);
return new ResponseDto<>();
}
}
\ No newline at end of file
......@@ -26,4 +26,6 @@ public interface RightsSettingTitleMapper {
RightsSettingTitle getByRightSettingIdAndType(@Param("rightsSettingId") Long rightsSettingId, @Param("type") Integer type, @Param("readType")Integer readType);
ReadTypeCountDTO getCount4Title(Long rightsSettingId);
List<RightsSettingTitle> getByRightSettingIdAndTypes(@Param("rightsSettingId")Long rightsSettingId, @Param("types") List<Integer> types);
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsSettingItemDetail;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsNowItemTypeNew;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
......@@ -497,7 +497,7 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
return new GroupActivity4AppletDTO();
}
// 是否开启社群服务开关
RightsSettingTitle right = rightsSettingTitleMapper.getByRightSettingIdAndType(rightSettingId, RightsNowItemType.GROUP_SERVICE.value,readType);
RightsSettingTitle right = rightsSettingTitleMapper.getByRightSettingIdAndType(rightSettingId, RightsNowItemTypeNew.GROUP_SERVICE.value,readType);
if (null == right){
return new GroupActivity4AppletDTO();
}
......
......@@ -1206,7 +1206,7 @@
SELECT
DISTINCT t.book_group_id
FROM
book_group_cipher_user t t left JOIN book_group bg on t.book_group_id=t.id
book_group_cipher_user t left JOIN book_group bg on t.book_group_id=t.id
where bg.agent_id in
<foreach collection="agentIds" open="(" close=")" item="item" separator=",">
#{item}
......
......@@ -206,4 +206,21 @@
</foreach>
</delete>
<select id="getByRightsSettingIdList" parameterType="list" resultMap="BaseResultMap">
SELECT
d.rights_setting_item_id,
d.serve_id,
d.serve_type,
d.group_type,
d.link_url
FROM
rights_setting_item_detail d
LEFT JOIN rights_setting_item i ON i.id = d.rights_setting_item_id
WHERE
i.rights_setting_id in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -21,6 +21,11 @@
<result property="displayType" column="display_type" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id, rights_setting_id, rights_type, rights_classify_id, description, create_time, title, open_state, service_desc,
serve_type, collage_state, display_type
</sql>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultType="com.pcloud.book.rightsSetting.entity.RightsSettingItem" >
select
......@@ -282,4 +287,23 @@
order by c.create_time
</select>
<select id="getRightsClassifyByIds" parameterType="map" resultType="com.pcloud.book.rightsSetting.entity.RightsSettingClassify">
SELECT id, classify, rights_type rightsType,pic_url picUrl
FROM rights_setting_classify
WHERE
id in
<foreach collection="list" open="(" close=")" separator="," index="index" item="item">
#{item}
</foreach>
</select>
<select id="getRightSettingItemByIds" resultMap="RightsSettingItemMap" parameterType="map">
SELECT <include refid="Base_Column_List"/>
FROM rights_setting_item
WHERE id in
<foreach collection="list" open="(" close=")" separator="," index="index" item="item">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -212,4 +212,19 @@
rights_setting_id = #{rightsSettingId};
</select>
<select id="getByRightSettingIdAndTypes" resultMap="BaseResultMap" parameterType="map">
select
<include refid="baseSql"/>
from
rights_setting_title
where
rights_setting_id = #{rightsSettingId}
and
rights_setting_now_type in
<foreach collection="types" item="item" index="index" separator="," close=")" open="(">
#{item}
</foreach>
order by seq_num asc, id asc
</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