Commit 8e45e3a6 by 裴大威

Merge branch 'feat-1002817' into 'master'

1002817本书配套资料包内资源分类,支持配置分类资源录入

See merge request rays/pcloud-book!680
parents bc129ede 30cc5e69
...@@ -596,16 +596,16 @@ public class AppletHomeFacade { ...@@ -596,16 +596,16 @@ public class AppletHomeFacade {
@GetMapping("getGroupActivity4Applet") @GetMapping("getGroupActivity4Applet")
public ResponseDto<?> getGroupActivity4Applet( public ResponseDto<?> getGroupActivity4Applet(
@CookieValue("userInfo") String userInfo, @CookieValue("userInfo") String userInfo,
@RequestParam(value = "firstClassify", required = true) Long firstClassify, @RequestParam(value = "adviserId") Long adviserId,
@RequestParam(value = "secondClassify", required = false) Long secondClassify, @RequestParam(value = "bookId") Long bookId,
@RequestParam(value = "gradeLabelId", required = false) Long gradeLabelId, @RequestParam(value = "rightsSettingId") Long rightsSettingId,
@RequestParam(value = "subjectLabelId", required = false) Long subjectLabelId @RequestParam(value = "channelId") Long channelId
) throws PermissionException { ) {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null == wechatUserId){ if (null == wechatUserId){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
} }
return new ResponseDto<>(pcloudGroupActivityBiz.getGroupActivity4Applet(firstClassify, secondClassify, gradeLabelId, subjectLabelId)); return new ResponseDto<>(pcloudGroupActivityBiz.getGroupActivity4Applet(rightsSettingId, adviserId ,bookId, channelId));
} }
} }
......
...@@ -752,7 +752,7 @@ public class WechatGroupConsr { ...@@ -752,7 +752,7 @@ public class WechatGroupConsr {
} }
} }
public void sendMessageToMiniUser(SendMessageDTO sendMessageDTO) { public void sendMessageToMiniUser( SendMessageDTO sendMessageDTO) {
try { try {
selfRobotService.sendMessageToMiniUser(sendMessageDTO); selfRobotService.sendMessageToMiniUser(sendMessageDTO);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.biz; ...@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.biz;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO; import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto; import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify; import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem; import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
...@@ -77,9 +78,29 @@ public interface RightsSettingBiz { ...@@ -77,9 +78,29 @@ public interface RightsSettingBiz {
*/ */
List<RightsSettingClassify>getAllRightsClassify(String rightsType); List<RightsSettingClassify>getAllRightsClassify(String rightsType);
/**
* @Author David
* @Description 该方法没有补充咨询且会查询所有类型的即可权益,不利于扩展,请使用新方法getRightsSettingRightsNowItemsByType
* @Date 2020/4/25 11:44
* @Param [rightsSettingId, wechatUserId]
* @return com.pcloud.book.rightsSetting.entity.RightsSetting
**/
@Deprecated
RightsSetting getRightsSettingRightsNowItems(Long rightsSettingId, Long wechatUserId); RightsSetting getRightsSettingRightsNowItems(Long rightsSettingId, Long wechatUserId);
/**
* @Author David
* @Description 根据权益id和类型获取权益内容
* @Date 2020/4/25 11:44
* @Param [rightsSettingId, wechatUserId, type]
* @return com.pcloud.book.rightsSetting.entity.RightsSetting
**/
RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type);
RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId); RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId);
FillRightsSettingAppletsDTO getFillRightsSettingApplets(Long rightsSettingId, Long wechatUserId); FillRightsSettingAppletsDTO getFillRightsSettingApplets(Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
Integer top);
List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy);
} }
package com.pcloud.book.rightsSetting.biz.impl; package com.pcloud.book.rightsSetting.biz.impl;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO; import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletNewsBiz; import com.pcloud.book.applet.biz.AppletNewsBiz;
...@@ -19,28 +21,34 @@ import com.pcloud.book.consumer.app.AssistTempletConsr; ...@@ -19,28 +21,34 @@ import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr; import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr; import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.giftcoupon.dao.GiftReceiveDao; import com.pcloud.book.giftcoupon.dao.GiftReceiveDao;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.enums.AppAndProductTypeEnum; import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools; import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.check.RightsSettingCheck;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant; import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.dao.RightsItemGroupDao;
import com.pcloud.book.rightsSetting.dao.RightsNowItemDao; import com.pcloud.book.rightsSetting.dao.RightsNowItemDao;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO; import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao; import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao;
import com.pcloud.book.rightsSetting.dao.check.RightsSettingCheck;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO; import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto; import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsNowItem; import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify; import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem; import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle; import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.rightsSetting.enums.RightsItemGroupType;
import com.pcloud.book.rightsSetting.enums.RightsNowItemType; import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum; import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper; import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.util.common.CommonUtils; import com.pcloud.book.util.common.CommonUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
...@@ -48,10 +56,8 @@ import com.pcloud.common.utils.ListUtils; ...@@ -48,10 +56,8 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.resourcecenter.product.dto.ProductDto; import com.pcloud.resourcecenter.product.dto.ProductDto;
import io.swagger.annotations.ApiModelProperty;
import java.util.function.Function; import org.apache.commons.collections.CollectionUtils;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -59,13 +65,18 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -59,13 +65,18 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Random; import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
@Service @Service
@Slf4j @Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz { public class RightsSettingBizImpl implements RightsSettingBiz {
...@@ -102,14 +113,18 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -102,14 +113,18 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private BookBiz bookBiz; private BookBiz bookBiz;
@Autowired @Autowired
private RightsSettingTitleMapper rightsSettingTitleMapper; private RightsSettingTitleMapper rightsSettingTitleMapper;
@Autowired
private RightsItemGroupDao rightsItemGroupDao;
@Autowired
private BookGroupBiz bookGroupBiz;
@Override @Override
@ParamLog("新增权益设置") @ParamLog("新增权益设置")
public Long addRightsSetting(RightsSetting rightsSetting) { public Long addRightsSetting(RightsSetting rightsSetting) {
rightsSettingCheck.rightsSettingCheck(rightsSetting); rightsSettingCheck.rightsSettingCheck(rightsSetting);
setClassifyAndLabel(rightsSetting); setClassifyAndLabel(rightsSetting);
if (existCheck(rightsSetting)>0){ if (existCheck(rightsSetting) > 0) {
throw new BookBizException(BookBizException.ERROR,"已存在相同的权益设置"); throw new BookBizException(BookBizException.ERROR, "已存在相同的权益设置");
} }
rightsSettingDAO.insert(rightsSetting); rightsSettingDAO.insert(rightsSetting);
return rightsSetting.getId(); return rightsSetting.getId();
...@@ -118,16 +133,16 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -118,16 +133,16 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override @Override
public void setClassifyAndLabel(BaseTempletClassify baseTempletClassify) { public void setClassifyAndLabel(BaseTempletClassify baseTempletClassify) {
log.info("对于某些特殊分类做处理"); log.info("对于某些特殊分类做处理");
Boolean contain4K12 = false; Boolean contain4K12 = false;
if ("test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID_TEST,baseTempletClassify.getFirstClassify())){ if ("test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID_TEST, baseTempletClassify.getFirstClassify())) {
contain4K12 = true; contain4K12 = true;
}else if (!"test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID,baseTempletClassify.getFirstClassify())){ } else if (!"test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID, baseTempletClassify.getFirstClassify())) {
contain4K12 = true; contain4K12 = true;
} }
if (!ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID,baseTempletClassify.getFirstClassify())){ if (!ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID, baseTempletClassify.getFirstClassify())) {
baseTempletClassify.setSecondClassify(null); baseTempletClassify.setSecondClassify(null);
} }
if (!contain4K12){ if (!contain4K12) {
baseTempletClassify.setGradeLabelId(null); baseTempletClassify.setGradeLabelId(null);
baseTempletClassify.setSubjectLabelId(null); baseTempletClassify.setSubjectLabelId(null);
} }
...@@ -135,21 +150,22 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -135,21 +150,22 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
/** /**
* 校验权益是否存在 * 校验权益是否存在
*
* @param rightsSetting * @param rightsSetting
*/ */
public Integer existCheck(RightsSetting rightsSetting){ public Integer existCheck(RightsSetting rightsSetting) {
Integer count =0; Integer count = 0;
Map<String,Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("rightsSettingType", rightsSetting.getRightsSettingType()); paramMap.put("rightsSettingType", rightsSetting.getRightsSettingType());
paramMap.put("exceptId", rightsSetting.getId()); paramMap.put("exceptId", rightsSetting.getId());
if (rightsSetting.getRightsSettingType()==2){ if (rightsSetting.getRightsSettingType() == 2) {
paramMap.put("bookId", rightsSetting.getBookId()); paramMap.put("bookId", rightsSetting.getBookId());
}else if (rightsSetting.getRightsSettingType()==1){ } else if (rightsSetting.getRightsSettingType() == 1) {
setClassifyAndLabel(rightsSetting); setClassifyAndLabel(rightsSetting);
paramMap.put("firstClassify",rightsSetting.getFirstClassify()); paramMap.put("firstClassify", rightsSetting.getFirstClassify());
paramMap.put("secondClassify",rightsSetting.getSecondClassify()); paramMap.put("secondClassify", rightsSetting.getSecondClassify());
paramMap.put("gradeLabelId",rightsSetting.getGradeLabelId()); paramMap.put("gradeLabelId", rightsSetting.getGradeLabelId());
paramMap.put("subjectLabelId",rightsSetting.getSubjectLabelId()); paramMap.put("subjectLabelId", rightsSetting.getSubjectLabelId());
} }
List<RightsSettingDto> list = rightsSettingDAO.listRightsSettingPage(paramMap); List<RightsSettingDto> list = rightsSettingDAO.listRightsSettingPage(paramMap);
count = list.size(); count = list.size();
...@@ -162,18 +178,19 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -162,18 +178,19 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSettingDAO.deleteByPrimaryKey(id); rightsSettingDAO.deleteByPrimaryKey(id);
//删除即享权益项 //删除即享权益项
rightsNowItemDao.deleteByRightsSettingId(id); rightsNowItemDao.deleteByRightsSettingId(id);
rightsSettingItemDao.deleteByRightsSettingId(id,null); rightsSettingItemDao.deleteByRightsSettingId(id, null);
rightsItemGroupDao.deleteByRightsSettingId(id);
} }
@Override @Override
@ParamLog("更新权益设置") @ParamLog("更新权益设置")
public void updateRightsSetting(RightsSetting rightsSetting) { public void updateRightsSetting(RightsSetting rightsSetting) {
rightsSettingCheck.rightsSettingCheck(rightsSetting); rightsSettingCheck.rightsSettingCheck(rightsSetting);
if (null==rightsSetting.getId()){ if (null == rightsSetting.getId()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少id!"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少id!");
} }
if (existCheck(rightsSetting)>0){ if (existCheck(rightsSetting) > 0) {
throw new BookBizException(BookBizException.ERROR,"已存在相同的权益设置"); throw new BookBizException(BookBizException.ERROR, "已存在相同的权益设置");
} }
setClassifyAndLabel(rightsSetting); setClassifyAndLabel(rightsSetting);
rightsSetting.setUpdateTime(new Date()); rightsSetting.setUpdateTime(new Date());
...@@ -181,8 +198,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -181,8 +198,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
//更新即享权益 //更新即享权益
updateRightNowItemByRightId(rightsSetting); updateRightNowItemByRightId(rightsSetting);
//新增/修改每周或长期权益 //新增/修改每周或长期权益
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingWeekItems(),rightsSetting.getId(),RightsTypeEnum.WEEK.value); this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingWeekItems(), rightsSetting.getId(), RightsTypeEnum.WEEK.value);
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingLongTermItems(),rightsSetting.getId(),RightsTypeEnum.LONG_TERM.value); this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingLongTermItems(), rightsSetting.getId(), RightsTypeEnum.LONG_TERM.value);
} }
@ParamLog("更新权益的即享权益项集合") @ParamLog("更新权益的即享权益项集合")
...@@ -197,14 +214,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -197,14 +214,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
setRightsSettingId(rightsSetting, rightsSettingId, rightsSettingTitles); setRightsSettingId(rightsSetting, rightsSettingId, rightsSettingTitles);
//设置每个权益详情 //设置每个权益详情
setNowItems(rightsSetting, rightsSettingId, items); setNowItems(rightsSetting, rightsSettingId, items);
//处理权益配套资料分组
dealItemGroups(rightsSetting,rightsSettingId,items);
//根据权益id删除原来的 //根据权益id删除原来的
rightsNowItemDao.deleteByRightsSettingId(rightsSettingId); rightsNowItemDao.deleteByRightsSettingId(rightsSettingId);
if (!ListUtils.isEmpty(items)) { if (!ListUtils.isEmpty(items)) {
rightsNowItemDao.batchInsert(items); rightsNowItemDao.batchInsert(items);
} }
if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitles.stream().forEach(e -> e.setRightsSettingId(rightsSettingId));
}
if (null != rightsSetting.getOnlineRightsSettingTitle() && null == rightsSetting.getOnlineRightsSettingTitle().getId()) { if (null != rightsSetting.getOnlineRightsSettingTitle() && null == rightsSetting.getOnlineRightsSettingTitle().getId()) {
rightsSettingTitleMapper.deleteByRightSettingId(rightsSettingId); rightsSettingTitleMapper.deleteByRightSettingId(rightsSettingId);
if (!ListUtils.isEmpty(rightsSettingTitles)) { if (!ListUtils.isEmpty(rightsSettingTitles)) {
...@@ -216,6 +232,43 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -216,6 +232,43 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
@ParamLog("增加和删除分组")
private void dealItemGroups(RightsSetting rightsSetting, Long rightsSettingId, List<RightsNowItem> items) {
if (rightsSetting==null||ListUtils.isEmpty(rightsSetting.getRightsItemGroups())){
return;
}
for (RightsItemGroup group:rightsSetting.getRightsItemGroups()){
//集合转化为三个描述
if (!ListUtils.isEmpty(group.getDescList())){
if (group.getDescList().size()>0){
group.setDesc1(group.getDescList().get(0));
}
if (group.getDescList().size()>1){
group.setDesc2(group.getDescList().get(1));
}
if (group.getDescList().size()>2){
group.setDesc3(group.getDescList().get(2));
}
}
group.setRightsSettingId(rightsSettingId);
}
//删除之前的
rightsItemGroupDao.deleteByRightsSettingId(rightsSettingId);
//新增新的
rightsItemGroupDao.batchInsert(rightsSetting.getRightsItemGroups());
for (RightsItemGroup group:rightsSetting.getRightsItemGroups()){
if (ListUtils.isEmpty(group.getRightsNowItems())){
continue;
}
for (RightsNowItem item:group.getRightsNowItems()){
item.setType(RightsNowItemType.SERVES.value);
item.setRightsItemGroupId(group.getId());
item.setRightsSettingId(rightsSettingId);
items.add(item);
}
}
}
private void setNowItems(RightsSetting rightsSetting, Long rightsSettingId, List<RightsNowItem> items) { private void setNowItems(RightsSetting rightsSetting, Long rightsSettingId, List<RightsNowItem> items) {
log.info("填充即享权益具体项目的的基本参数"); log.info("填充即享权益具体项目的的基本参数");
if (null != rightsSetting.getOnlineRightsSettingTitle() && !ListUtils if (null != rightsSetting.getOnlineRightsSettingTitle() && !ListUtils
...@@ -305,13 +358,138 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -305,13 +358,138 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSetting.setBookName(bookDto == null ? "" : bookDto.getBookName()); rightsSetting.setBookName(bookDto == null ? "" : bookDto.getBookName());
} }
fillRightsNowItems(rightsSetting); fillRightsNowItems(rightsSetting);
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false));
fillGiftCouponPack(rightsSetting); fillGiftCouponPack(rightsSetting);
rightsSetting.setRightsSettingWeekItems(getItemsByRightsSettingId(id, RightsTypeEnum.WEEK.value)); rightsSetting.setRightsSettingWeekItems(getItemsByRightsSettingId(id, RightsTypeEnum.WEEK.value));
rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value)); rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value));
return rightsSetting; return rightsSetting;
} }
/**
* @return void
* @Author David
* @Description 设置线上网课
* @Date 2020/4/24 16:59
* @Param [rightsSetting, wechatUserId]
**/
@ParamLog(value = "填充线上网课", isAfterReturn = false)
private RightsSetting setOnlineCourse(RightsSetting rightsSetting, Long wechatUserId) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.ONLINE_COURSE);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), Collections.singletonList(RightsNowItemType.ONLINE_COURSE.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemType.ONLINE_COURSE, rightsSetting.getId(), wechatUserId, 2L, 3);
rightsSetting.setOnlineRightsSettingTitle(rightsSettingTitle);
return rightsSetting;
}
/**
* @Author David
* @Description 填充学习工具
* @Date 2020/4/24 20:10
* @Param [rightsSetting, wechatUserId]
* @return void
**/
@ParamLog(value = "填充学习工具", isAfterReturn = false)
private RightsSetting setLearningTool(RightsSetting rightsSetting, Long wechatUserId) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.LEARNING_TOOL);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), Collections.singletonList(RightsNowItemType.LEARNING_TOOL.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemType.LEARNING_TOOL, rightsSetting.getId(), wechatUserId, 3L, 1);
rightsSetting.setLearningToolTitle(rightsSettingTitle);
return rightsSetting;
}
/**
* @Author David
* @Description 填充抽奖
* @Date 2020/4/24 20:10
* @Param [rightsSetting, wechatUserId]
* @return void
**/
@ParamLog(value = "填充抽奖", isAfterReturn = false)
private RightsSetting setDraw(RightsSetting rightsSetting, Long wechatUserId) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.DRAW);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), Collections.singletonList(RightsNowItemType.DRAW.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemType.DRAW, rightsSetting.getId(), wechatUserId, 4L, 1);
rightsSetting.setDrawSettingTitle(rightsSettingTitle);
return rightsSetting;
}
@ParamLog(value = "填充礼券包", isAfterReturn = false)
private RightsSetting setGiftCouponPackage(RightsSetting rightsSetting, Long wechatUserId) {
fillGiftCouponPack(rightsSetting);
fillUserGiftReceiveStatus(rightsSetting,wechatUserId);
return rightsSetting;
}
/**
* @Author David
* @Description 获取权益标题
* @Date 2020/4/24 20:07
* @Param [rightsSetting, learningTool]
* @return com.pcloud.book.rightsSetting.entity.RightsSettingTitle
**/
private RightsSettingTitle getRightsSettingTitle(RightsSetting rightsSetting, RightsNowItemType learningTool) {
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSetting.getId());
Map<Integer, RightsSettingTitle> rightsSettingTitleMap = new HashMap<>();
if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitleMap = rightsSettingTitles.stream().collect(Collectors.toMap(RightsSettingTitle::getRightsSettingNowType, Function.identity()));
}
RightsSettingTitle rightsSettingTitle = new RightsSettingTitle();
if (null != rightsSettingTitleMap.get(learningTool.value)) {
rightsSettingTitle = rightsSettingTitleMap.get(learningTool.value);
}
return rightsSettingTitle;
}
/**
* @return void
* @Author David
* @Description 处理即刻资源
* @Date 2020/4/24 17:45
* @Param [nowItems]
**/
private void processNowItems(RightsSettingTitle rightsSettingTitle, List<RightsNowItem> nowItems, RightsNowItemType itemType,
Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
Integer top) {
List<RightsNowItem> items = Lists.newArrayList();
if (CollectionUtils.isEmpty(nowItems)) {
// 填充咨询
supplementNews(rightsSettingId, wechatUserId, rightsClassifyId, top, items);
rightsSettingTitle.setRightsSettingItemList(items);
return;
}
// 处理权益中的应用/作品
fillProductAndApp(nowItems);
//移除不能购买的应用或作品
removeCanNotBuy(nowItems);
for (RightsNowItem nowItem : nowItems) {
if (itemType.value.equals(nowItem.getType())) {
items.add(nowItem);
}
}
if (items.size() < top) {
// 填充咨询
supplementNews(rightsSettingId, wechatUserId, rightsClassifyId, top, items);
}
rightsSettingTitle.setRightsSettingItemList(items);
}
/**
* @Author David
* @Description 补充咨询
* @Date 2020/4/25 12:20
* @Param [rightsSettingId, wechatUserId, rightsClassifyId, top, items]
* @return void
**/
private void supplementNews( Long rightsSettingId, Long wechatUserId, Long rightsClassifyId, Integer top, List<RightsNowItem> items) {
FillRightsSettingAppletsDTO applets = getFillRightsSettingApplets(rightsSettingId, wechatUserId, rightsClassifyId, top);
List<AppletNews> news = applets.getDesignatedNews();
for (AppletNews appletNews : news) {
items.add(RightsNowItem.builder().serveId(appletNews.getId()).serveName(appletNews.getNewsName()).serveTypeName("资讯").servePic(appletNews.getPic1()).type(0).build());
}
}
@Deprecated
@ParamLog("填充资源") @ParamLog("填充资源")
private void fillRightsNowItems(RightsSetting rightsSetting) { private void fillRightsNowItems(RightsSetting rightsSetting) {
List<Integer> types = new ArrayList<>(); List<Integer> types = new ArrayList<>();
...@@ -342,19 +520,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -342,19 +520,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), types); List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), types);
if (!ListUtils.isEmpty(nowItems)) { if (!ListUtils.isEmpty(nowItems)) {
List<Long> productIds = new ArrayList<>(); fillProductAndApp(nowItems);
List<Long> appIds = new ArrayList<>();
for (RightsNowItem item : nowItems) {
if (item.getServeId() != null && AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
productIds.add(item.getServeId());
}
if (item.getServeId() != null && AppAndProductTypeEnum.APP.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
appIds.add(item.getServeId());
}
}
fillProductAndApp(nowItems, productIds, appIds);
rightsSettingTitler4Online.setRightsSettingItemList( rightsSettingTitler4Online.setRightsSettingItemList(
nowItems.stream().filter(s -> RightsNowItemType.ONLINE_COURSE.value.equals(s.getType())).collect(Collectors.toList())); nowItems.stream().filter(s -> RightsNowItemType.ONLINE_COURSE.value.equals(s.getType())).collect(Collectors.toList()));
rightsSettingTitler4Learningtool.setRightsSettingItemList( rightsSettingTitler4Learningtool.setRightsSettingItemList(
...@@ -370,12 +536,27 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -370,12 +536,27 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSetting.setGiftCouponPackageTitle(null == rightsSettingTitleMap.get(RightsNowItemType.GIFT_COUPON_PACKAGE.value) ? rightsSetting.setGiftCouponPackageTitle(null == rightsSettingTitleMap.get(RightsNowItemType.GIFT_COUPON_PACKAGE.value) ?
new RightsSettingTitle() : rightsSettingTitleMap.get(RightsNowItemType.GIFT_COUPON_PACKAGE.value)); new RightsSettingTitle() : rightsSettingTitleMap.get(RightsNowItemType.GIFT_COUPON_PACKAGE.value));
rightsSetting.setServesTitle(null == rightsSettingTitleMap.get(RightsNowItemType.SERVES.value) ? rightsSetting.setServesTitle(null == rightsSettingTitleMap.get(RightsNowItemType.SERVES.value) ?
rightsSettingTitler4Serves: rightsSettingTitleMap.get(RightsNowItemType.SERVES.value)); rightsSettingTitler4Serves : rightsSettingTitleMap.get(RightsNowItemType.SERVES.value));
} }
private void fillProductAndApp(List<RightsNowItem> nowItems, List<Long> productIds, List<Long> appIds) { private void fillProductAndApp(List<RightsNowItem> nowItems) {
log.info("即享权益填充产品和app内容"); log.info("即享权益填充产品和app内容");
if (ListUtils.isEmpty(nowItems)){
return;
}
List<Long> productIds = new ArrayList<>();
List<Long> appIds = new ArrayList<>();
for (RightsNowItem item : nowItems) {
if (item.getServeId() != null && AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
productIds.add(item.getServeId());
}
if (item.getServeId() != null && AppAndProductTypeEnum.APP.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
appIds.add(item.getServeId());
}
}
Map<Long, ProductDto> productDtoMap = new HashMap<>(); Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, AppDto> appDtoMap = new HashMap<>(); Map<Long, AppDto> appDtoMap = new HashMap<>();
if (!ListUtils.isEmpty(productIds)) { if (!ListUtils.isEmpty(productIds)) {
...@@ -387,8 +568,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -387,8 +568,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
for (RightsNowItem item : nowItems) { for (RightsNowItem item : nowItems) {
Integer type = item.getType(); Integer type = item.getType();
if (RightsNowItemType.ONLINE_COURSE.value.equals(type) if (RightsNowItemType.ONLINE_COURSE.value.equals(type)
|| RightsNowItemType.LEARNING_TOOL.value.equals(type) || RightsNowItemType.LEARNING_TOOL.value.equals(type)
|| RightsNowItemType.DRAW.value.equals(type)) { || RightsNowItemType.DRAW.value.equals(type)
|| RightsNowItemType.SERVES.value.equals(type)) {
AccountSettingDto accountSettingDto; AccountSettingDto accountSettingDto;
if (AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())) { if (AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())) {
ProductDto productDto = productDtoMap.get(item.getServeId()); ProductDto productDto = productDtoMap.get(item.getServeId());
...@@ -434,37 +616,42 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -434,37 +616,42 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
} }
private void fillGiftCouponPack(RightsSetting rightsSetting){ private void fillGiftCouponPack(RightsSetting rightsSetting) {
List<RightsNowItem> giftCouponPackItems = rightsNowItemDao.getGiftCouponListByRightsSettingId(rightsSetting.getId()); List<RightsNowItem> giftCouponPackItems = rightsNowItemDao.getGiftCouponListByRightsSettingId(rightsSetting.getId());
RightsSettingTitle rightsSettingTitler4Gift = new RightsSettingTitle(); RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.GIFT_COUPON_PACKAGE);
if (null != rightsSetting.getGiftCouponPackageTitle()){ if (null != rightsSetting.getGiftCouponPackageTitle()) {
rightsSettingTitler4Gift = rightsSetting.getGiftCouponPackageTitle(); // 礼券包默认开启
} rightsSettingTitle.setOpenState(true);
rightsSettingTitler4Gift.setRightsSettingItemList(giftCouponPackItems); rightsSetting.setGiftCouponPackageTitle(rightsSettingTitle);
rightsSetting.setGiftCouponPackageTitle(rightsSettingTitler4Gift); rightsSettingTitle = rightsSetting.getGiftCouponPackageTitle();
}
rightsSettingTitle.setRightsSettingItemList(giftCouponPackItems);
rightsSetting.setGiftCouponPackageTitle(rightsSettingTitle);
} }
@Override @Override
@ParamLog(value = "获取权益分类分页列表",isAfterReturn = false) @ParamLog(value = "获取权益分类分页列表", isAfterReturn = false)
public PageBeanNew<RightsSettingDto> listRightsSettingPage(Integer currentPage, Integer numPerPage, RightsSetting rightsSetting) { public PageBeanNew<RightsSettingDto> listRightsSettingPage(Integer currentPage, Integer numPerPage, RightsSetting rightsSetting) {
Map<String,Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
if (null != rightsSetting.getFirstClassify()){ if (null != rightsSetting.getFirstClassify()) {
setClassifyAndLabel(rightsSetting); setClassifyAndLabel(rightsSetting);
} }
paramMap.put("rightsSettingType", rightsSetting.getRightsSettingType()); paramMap.put("rightsSettingType", rightsSetting.getRightsSettingType());
PageBeanNew<RightsSettingDto> rightsSettingDtoPageBeanNew; PageBeanNew<RightsSettingDto> rightsSettingDtoPageBeanNew;
if (rightsSetting.getRightsSettingType()==2){//书刊权益 if (rightsSetting.getRightsSettingType() == 2) {//书刊权益
paramMap.put("bookQuery",rightsSetting.getBookQuery()); paramMap.put("bookQuery", rightsSetting.getBookQuery());
rightsSettingDtoPageBeanNew = rightsSettingDAO.listPageNew(new PageParam(currentPage,numPerPage),paramMap,"listBookRightsSettingPage"); rightsSettingDtoPageBeanNew = rightsSettingDAO.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listBookRightsSettingPage");
}else { } else {
paramMap.put("firstClassify",rightsSetting.getFirstClassify()); paramMap.put("firstClassify", rightsSetting.getFirstClassify());
paramMap.put("secondClassify",rightsSetting.getSecondClassify()); paramMap.put("secondClassify", rightsSetting.getSecondClassify());
paramMap.put("gradeLabelId",rightsSetting.getGradeLabelId()); paramMap.put("gradeLabelId", rightsSetting.getGradeLabelId());
paramMap.put("subjectLabelId",rightsSetting.getSubjectLabelId()); paramMap.put("subjectLabelId", rightsSetting.getSubjectLabelId());
rightsSettingDtoPageBeanNew = rightsSettingDAO.listPageNew(new PageParam(currentPage,numPerPage),paramMap,"listRightsSettingPage"); rightsSettingDtoPageBeanNew = rightsSettingDAO.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listRightsSettingPage");
} }
if (null != rightsSettingDtoPageBeanNew && !ListUtils.isEmpty(rightsSettingDtoPageBeanNew.getRecordList())){ if (null != rightsSettingDtoPageBeanNew && !ListUtils.isEmpty(rightsSettingDtoPageBeanNew.getRecordList())) {
List<RightsSettingDto> rightsSettingDtos = rightsSettingDtoPageBeanNew.getRecordList(); List<RightsSettingDto> rightsSettingDtos = rightsSettingDtoPageBeanNew.getRecordList();
setLabelContent(rightsSettingDtos); setLabelContent(rightsSettingDtos);
} }
return rightsSettingDtoPageBeanNew; return rightsSettingDtoPageBeanNew;
...@@ -473,85 +660,84 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -473,85 +660,84 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private void setLabelContent(List<RightsSettingDto> rightsSettingDtos) { private void setLabelContent(List<RightsSettingDto> rightsSettingDtos) {
log.info("权益设置标签具体内容"); log.info("权益设置标签具体内容");
if (ListUtils.isEmpty(rightsSettingDtos)){ if (ListUtils.isEmpty(rightsSettingDtos)) {
return; return;
} }
List<Long> firstClassifyIds = new ArrayList<>(); List<Long> firstClassifyIds;
List<Long> secondClassifyIds = new ArrayList<>(); List<Long> secondClassifyIds;
List<Long> classifyIds = new ArrayList<>(); List<Long> classifyIds = new ArrayList<>();
List<Long> gradeLabelIds = new ArrayList<>(); List<Long> gradeLabelIds;
List<Long> subjectLabelIds = new ArrayList<>(); List<Long> subjectLabelIds;
List<Long> labelIds = new ArrayList<>(); List<Long> labelIds = new ArrayList<>();
firstClassifyIds = rightsSettingDtos.stream().map(e -> e.getFirstClassify()).collect(Collectors.toList()); firstClassifyIds = rightsSettingDtos.stream().map(RightsSetting::getFirstClassify).collect(Collectors.toList());
secondClassifyIds = rightsSettingDtos.stream().map(e -> e.getSecondClassify()).collect(Collectors.toList()); secondClassifyIds = rightsSettingDtos.stream().map(RightsSetting::getSecondClassify).collect(Collectors.toList());
gradeLabelIds = rightsSettingDtos.stream().map(e -> e.getGradeLabelId()).collect(Collectors.toList()); gradeLabelIds = rightsSettingDtos.stream().map(RightsSetting::getGradeLabelId).collect(Collectors.toList());
subjectLabelIds = rightsSettingDtos.stream().map(e -> e.getSubjectLabelId()).collect(Collectors.toList()); subjectLabelIds = rightsSettingDtos.stream().map(RightsSetting::getSubjectLabelId).collect(Collectors.toList());
if (!ListUtils.isEmpty(firstClassifyIds)){ if (!ListUtils.isEmpty(firstClassifyIds)) {
classifyIds.addAll(firstClassifyIds); classifyIds.addAll(firstClassifyIds);
} }
if (!ListUtils.isEmpty(secondClassifyIds)){ if (!ListUtils.isEmpty(secondClassifyIds)) {
classifyIds.addAll(secondClassifyIds); classifyIds.addAll(secondClassifyIds);
} }
if (!ListUtils.isEmpty(gradeLabelIds)){ if (!ListUtils.isEmpty(gradeLabelIds)) {
labelIds.addAll(gradeLabelIds); labelIds.addAll(gradeLabelIds);
} }
if (!ListUtils.isEmpty(subjectLabelIds)){ if (!ListUtils.isEmpty(subjectLabelIds)) {
labelIds.addAll(subjectLabelIds); labelIds.addAll(subjectLabelIds);
} }
Map<Long, AssistTempletDTO> classifyMap = new HashMap<>(); Map<Long, AssistTempletDTO> classifyMap = new HashMap<>();
Map<Long, BookLabel> labelMap= new HashMap<>(); Map<Long, BookLabel> labelMap = new HashMap<>();
if (!ListUtils.isEmpty(classifyIds)){ if (!ListUtils.isEmpty(classifyIds)) {
classifyMap = assistTempletConsr.mapByIds4Classify(classifyIds); classifyMap = assistTempletConsr.mapByIds4Classify(classifyIds);
} }
if (!ListUtils.isEmpty(labelIds)){ if (!ListUtils.isEmpty(labelIds)) {
labelMap = bookLabelDao.getMapByIds(labelIds); labelMap = bookLabelDao.getMapByIds(labelIds);
} }
for (RightsSettingDto rightsSettingDto : rightsSettingDtos){ for (RightsSettingDto rightsSettingDto : rightsSettingDtos) {
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getFirstClassify())){ if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getFirstClassify())) {
rightsSettingDto.setFirstClassifyContent(classifyMap.get(rightsSettingDto.getFirstClassify()).getTempletName()); rightsSettingDto.setFirstClassifyContent(classifyMap.get(rightsSettingDto.getFirstClassify()).getTempletName());
} }
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getSecondClassify())){ if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getSecondClassify())) {
rightsSettingDto.setSecondClassifyContent(classifyMap.get(rightsSettingDto.getSecondClassify()).getTempletName()); rightsSettingDto.setSecondClassifyContent(classifyMap.get(rightsSettingDto.getSecondClassify()).getTempletName());
} }
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getGradeLabelId())){ if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getGradeLabelId())) {
rightsSettingDto.setGradeLabelIdContent(labelMap.get(rightsSettingDto.getGradeLabelId()).getName()); rightsSettingDto.setGradeLabelIdContent(labelMap.get(rightsSettingDto.getGradeLabelId()).getName());
} }
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getSubjectLabelId())){ if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getSubjectLabelId())) {
rightsSettingDto.setSubjectLabelIdContent(labelMap.get(rightsSettingDto.getSubjectLabelId()).getName()); rightsSettingDto.setSubjectLabelIdContent(labelMap.get(rightsSettingDto.getSubjectLabelId()).getName());
} }
} }
} }
@Override @Override
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId) { public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId) {
//医疗保健分类校验 //医疗保健分类校验
if (ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID,firstClassify)){ if (ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID, firstClassify)) {
subjectLabelId=null; subjectLabelId = null;
gradeLabelId=null; gradeLabelId = null;
} }
//k12教育分类校验 //k12教育分类校验
else if ("test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID_TEST,firstClassify)){ else if ("test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID_TEST, firstClassify)) {
secondClassify=null; secondClassify = null;
}else if (!"test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID,firstClassify)){ } else if (!"test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID, firstClassify)) {
secondClassify=null; secondClassify = null;
} } else {
else { secondClassify = null;
secondClassify=null; subjectLabelId = null;
subjectLabelId=null; gradeLabelId = null;
gradeLabelId=null; }
} RightsSettingDto dto = rightsSettingDAO.getByLabel(firstClassify, secondClassify, gradeLabelId, subjectLabelId);
RightsSettingDto dto = rightsSettingDAO.getByLabel(firstClassify,secondClassify,gradeLabelId,subjectLabelId);
return dto; return dto;
} }
@Override @Override
public Integer getUserCount() { public Integer getUserCount() {
Integer userCount = 102336; Integer userCount = 102336;
String key="BOOK:APPLET:RIGHTS_SETTING_USER_COUNT"; String key = "BOOK:APPLET:RIGHTS_SETTING_USER_COUNT";
String value = JedisClusterUtils.get(key); String value = JedisClusterUtils.get(key);
if (StringUtil.isEmpty(value)){ if (StringUtil.isEmpty(value)) {
JedisClusterUtils.set(key,userCount.toString(),24*3600); JedisClusterUtils.set(key, userCount.toString(), 24 * 3600);
}else { } else {
userCount = Integer.valueOf(value); userCount = Integer.valueOf(value);
} }
return userCount; return userCount;
...@@ -559,12 +745,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -559,12 +745,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override @Override
public void batchInsertRightsSettingItem(List<RightsSettingItem> rightsSettingItemList, Long rightsSettingId, String rightsType) { public void batchInsertRightsSettingItem(List<RightsSettingItem> rightsSettingItemList, Long rightsSettingId, String rightsType) {
if (null==rightsSettingId||StringUtil.isEmpty(rightsType)){ if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) {
return; return;
} }
rightsSettingItemDao.deleteByRightsSettingId(rightsSettingId,rightsType); rightsSettingItemDao.deleteByRightsSettingId(rightsSettingId, rightsType);
if (!ListUtils.isEmpty(rightsSettingItemList)){ if (!ListUtils.isEmpty(rightsSettingItemList)) {
for (RightsSettingItem rightsSettingItem:rightsSettingItemList){ for (RightsSettingItem rightsSettingItem : rightsSettingItemList) {
rightsSettingItem.setRightsSettingId(rightsSettingId); rightsSettingItem.setRightsSettingId(rightsSettingId);
rightsSettingItem.setRightsType(rightsType); rightsSettingItem.setRightsType(rightsType);
} }
...@@ -585,15 +771,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -585,15 +771,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
public RightsSettingDto getRightsSettingByBookId4AppletHome(Long bookId, Long adviserId, Long channelId) { public RightsSettingDto getRightsSettingByBookId4AppletHome(Long bookId, Long adviserId, Long channelId) {
//根据书获取权益 //根据书获取权益
RightsSettingDto rightsSettingDto = rightsSettingDAO.getByBookId(bookId); RightsSettingDto rightsSettingDto = rightsSettingDAO.getByBookId(bookId);
if (null==rightsSettingDto){ if (null == rightsSettingDto) {
//根据分类获取权益 //根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId,channelId,adviserId); BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
if (null!=adviserDto){ if (null != adviserDto) {
rightsSettingDto = getByLabel(adviserDto.getTempletId(),adviserDto.getSecondTempletId(),adviserDto.getGraLabelId(),adviserDto.getSubLabelId()); rightsSettingDto = getByLabel(adviserDto.getTempletId(), adviserDto.getSecondTempletId(), adviserDto.getGraLabelId(), adviserDto.getSubLabelId());
} }
} }
if (null==rightsSettingDto){ if (null == rightsSettingDto) {
log.error("该书没有匹配的分类权益,bookId="+bookId); log.error("该书没有匹配的分类权益,bookId=" + bookId);
return new RightsSettingDto(); return new RightsSettingDto();
} }
return rightsSettingDto; return rightsSettingDto;
...@@ -601,26 +787,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -601,26 +787,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override @Override
@ParamLog(value = "小程序首页本周/长期权益查询", isAfterReturn = false) @ParamLog(value = "小程序首页本周/长期权益查询", isAfterReturn = false)
public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType){ public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType) {
RightsSettingDto rightsSettingDto = new RightsSettingDto(); RightsSettingDto rightsSettingDto = new RightsSettingDto();
//每周/长期权益 //每周/长期权益
if (RightsTypeEnum.WEEK.value.equals(rightsType)){ if (RightsTypeEnum.WEEK.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingWeekItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId)); rightsSettingDto.setRightsSettingWeekItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId));
} else if (RightsTypeEnum.LONG_TERM.value.equals(rightsType)){ } else if (RightsTypeEnum.LONG_TERM.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingLongTermItems(getItemsByRightsSettingId4Applet(rightsSettingId,RightsTypeEnum.LONG_TERM.value, wechatUserId)); rightsSettingDto.setRightsSettingLongTermItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId));
} }
return rightsSettingDto; return rightsSettingDto;
} }
@Override @Override
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId){ public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId) {
List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId,rightsType); List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType);
if (ListUtils.isEmpty(list)){ if (ListUtils.isEmpty(list)) {
return new ArrayList<>(); return new ArrayList<>();
} }
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId); RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting.getRightsSettingType()==2){//书刊权益,分类标签从编辑书刊取 if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId()); BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId());
rightsSetting.setFirstClassify(adviserDto.getTempletId()); rightsSetting.setFirstClassify(adviserDto.getTempletId());
rightsSetting.setSecondClassify(adviserDto.getSecondTempletId()); rightsSetting.setSecondClassify(adviserDto.getSecondTempletId());
...@@ -628,37 +814,37 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -628,37 +814,37 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSetting.setSubjectLabelId(adviserDto.getSubLabelId()); rightsSetting.setSubjectLabelId(adviserDto.getSubLabelId());
} }
//匹配资讯 //匹配资讯
List<AppletNewsDTO> appletNewsDTOS = appletNewsBiz.getNewsByTempletLabel(rightsSetting.getFirstClassify(), rightsSetting.getSecondClassify(), rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId(),rightsType); List<AppletNewsDTO> appletNewsDTOS = appletNewsBiz.getNewsByTempletLabel(rightsSetting.getFirstClassify(), rightsSetting.getSecondClassify(), rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId(), rightsType);
if (ListUtils.isEmpty(appletNewsDTOS)){ if (ListUtils.isEmpty(appletNewsDTOS)) {
//没有则根据书刊分类和标签获取 //没有则根据书刊分类和标签获取
appletNewsDTOS = appletNewsBiz.getNewsByTempletLabel(rightsSetting.getFirstClassify(), rightsSetting.getSecondClassify(), rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId(),null); appletNewsDTOS = appletNewsBiz.getNewsByTempletLabel(rightsSetting.getFirstClassify(), rightsSetting.getSecondClassify(), rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId(), null);
if (ListUtils.isEmpty(appletNewsDTOS)){ if (ListUtils.isEmpty(appletNewsDTOS)) {
return list; return list;
} }
} }
Map<Long, List<AppletNewsDTO>> map = appletNewsDTOS.stream().collect(Collectors.groupingBy(AppletNewsDTO::getRightsClassifyId)); Map<Long, List<AppletNewsDTO>> map = appletNewsDTOS.stream().collect(Collectors.groupingBy(AppletNewsDTO::getRightsClassifyId));
for (RightsSettingItem item:list){ for (RightsSettingItem item : list) {
//用户-权益-权益分类 //用户-权益-权益分类
String key= "BOOK:RIGHTS_SETTING:USER_RIGHTS_ITEM"+wechatUserId+"-"+rightsSettingId+"-"+item.getRightsClassifyId(); String key = "BOOK:RIGHTS_SETTING:USER_RIGHTS_ITEM" + wechatUserId + "-" + rightsSettingId + "-" + item.getRightsClassifyId();
//权益分类下资讯 //权益分类下资讯
List<AppletNewsDTO> newsDTOS=JedisClusterUtils.getJsonList(key,AppletNewsDTO.class); List<AppletNewsDTO> newsDTOS = JedisClusterUtils.getJsonList(key, AppletNewsDTO.class);
if (ListUtils.isEmpty(newsDTOS)||newsDTOS.size()<3) {//数据库取 if (ListUtils.isEmpty(newsDTOS) || newsDTOS.size() < 3) {//数据库取
if (!MapUtils.isEmpty(map) && map.containsKey(item.getRightsClassifyId())) { if (!MapUtils.isEmpty(map) && map.containsKey(item.getRightsClassifyId())) {
newsDTOS=map.get(item.getRightsClassifyId()); newsDTOS = map.get(item.getRightsClassifyId());
if (newsDTOS.size()>3){//随机取三条 if (newsDTOS.size() > 3) {//随机取三条
List<AppletNewsDTO>dtos = new ArrayList<>(); List<AppletNewsDTO> dtos = new ArrayList<>();
while (dtos.size()<3){ while (dtos.size() < 3) {
AppletNewsDTO dto = newsDTOS.get(new Random().nextInt(newsDTOS.size())); AppletNewsDTO dto = newsDTOS.get(new Random().nextInt(newsDTOS.size()));
if (!dtos.contains(dto)){ if (!dtos.contains(dto)) {
dtos.add(dto); dtos.add(dto);
} }
} }
newsDTOS = dtos; newsDTOS = dtos;
} }
JedisClusterUtils.setJsonList(key,newsDTOS, CommonUtils.todayRemainingSeconds()); JedisClusterUtils.setJsonList(key, newsDTOS, CommonUtils.todayRemainingSeconds());
} }
} }
item.setAppletNewsDTOS(newsDTOS); item.setAppletNewsDTOS(newsDTOS);
} }
return list; return list;
} }
...@@ -671,49 +857,77 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -671,49 +857,77 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("根据权益id获取即享权益项") @ParamLog("根据权益id获取即享权益项")
@Override @Override
public RightsSetting getRightsSettingRightsNowItems(Long rightsSettingId, Long wechatUserId) { public RightsSetting getRightsSettingRightsNowItems(Long rightsSettingId, Long wechatUserId) {
RightsSetting rightsSetting=rightsSettingDAO.selectByPrimaryKey(rightsSettingId); RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting==null){ if (rightsSetting == null) {
throw new BookBizException(BookBizException.ERROR,"未找到权益!"); throw new BookBizException(BookBizException.ERROR, "未找到权益!");
} }
fillRightsNowItems(rightsSetting); fillRightsNowItems(rightsSetting);
return rightsSetting; return rightsSetting;
} }
@ParamLog("根据权益id和类型获取即享权益项")
@Override
public RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting == null) {
throw new BookBizException(BookBizException.ERROR, "未找到权益!");
}
// 获取抽奖权益
if (RightsNowItemType.DRAW.value.equals(type)) {
return setDraw(rightsSetting, wechatUserId);
}
// 获取学习工具权益
if (RightsNowItemType.LEARNING_TOOL.value.equals(type)) {
return setLearningTool(rightsSetting, wechatUserId);
}
// 获取线上网课权益
if (RightsNowItemType.ONLINE_COURSE.value.equals(type)) {
return setOnlineCourse(rightsSetting, wechatUserId);
}
// 获取专享礼券包权益
if (RightsNowItemType.GIFT_COUPON_PACKAGE.value.equals(type)) {
return setGiftCouponPackage(rightsSetting, wechatUserId);
}
return rightsSetting;
}
@ParamLog("根据权益id获取即享权益项专享礼包") @ParamLog("根据权益id获取即享权益项专享礼包")
@Override @Override
public RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId) { public RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId) {
RightsSetting rightsSetting=new RightsSetting(); RightsSetting rightsSetting = new RightsSetting();
rightsSetting.setId(rightsSettingId); rightsSetting.setId(rightsSettingId);
RightsSettingTitle rightsSettingTitle4Gift = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSettingId,RightsNowItemType.GIFT_COUPON_PACKAGE.value); RightsSettingTitle rightsSettingTitle4Gift = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSettingId, RightsNowItemType.GIFT_COUPON_PACKAGE.value);
if (null != rightsSettingTitle4Gift){ if (null != rightsSettingTitle4Gift) {
rightsSetting.setGiftCouponPackageTitle(rightsSettingTitle4Gift); rightsSetting.setGiftCouponPackageTitle(rightsSettingTitle4Gift);
} }
fillGiftCouponPack(rightsSetting); fillGiftCouponPack(rightsSetting);
fillUserGiftReceiveStatus(rightsSetting,wechatUserId); fillUserGiftReceiveStatus(rightsSetting, wechatUserId);
return rightsSetting; return rightsSetting;
} }
@ParamLog("根据权益id获取即享权益项补充咨询") @ParamLog("根据权益id获取即享权益项补充咨询")
@Override @Override
public FillRightsSettingAppletsDTO getFillRightsSettingApplets(Long rightsSettingId, Long wechatUserId) { public FillRightsSettingAppletsDTO getFillRightsSettingApplets(Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
if (rightsSettingId==null){ Integer top) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!"); if (rightsSettingId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
} }
FillRightsSettingAppletsDTO fill=new FillRightsSettingAppletsDTO(); FillRightsSettingAppletsDTO fill = new FillRightsSettingAppletsDTO();
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId); RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting==null){ if (rightsSetting == null) {
return fill; return fill;
} }
Long firstClassify=rightsSetting.getFirstClassify(); Long firstClassify = rightsSetting.getFirstClassify();
Long secondClassify = rightsSetting.getSecondClassify(); Long secondClassify = rightsSetting.getSecondClassify();
Long gradeLabelId=null; Long gradeLabelId = null;
Long subjectLabelId=null; Long subjectLabelId = null;
if (rightsSetting.getRightsSettingType()==2){//书刊权益,分类标签从编辑书刊取 if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId()); BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId());
firstClassify=adviserDto.getTempletId(); firstClassify = adviserDto.getTempletId();
secondClassify=adviserDto.getSecondTempletId(); secondClassify = adviserDto.getSecondTempletId();
gradeLabelId=adviserDto.getGraLabelId(); gradeLabelId = adviserDto.getGraLabelId();
subjectLabelId=adviserDto.getSubLabelId(); subjectLabelId = adviserDto.getSubLabelId();
} }
BaseTempletClassify classify = new BaseTempletClassify(); BaseTempletClassify classify = new BaseTempletClassify();
classify.setFirstClassify(firstClassify); classify.setFirstClassify(firstClassify);
...@@ -721,40 +935,142 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -721,40 +935,142 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
classify.setGradeLabelId(gradeLabelId); classify.setGradeLabelId(gradeLabelId);
classify.setSubjectLabelId(subjectLabelId); classify.setSubjectLabelId(subjectLabelId);
setClassifyAndLabel(classify); setClassifyAndLabel(classify);
firstClassify=classify.getFirstClassify(); firstClassify = classify.getFirstClassify();
secondClassify=classify.getSecondClassify(); secondClassify = classify.getSecondClassify();
gradeLabelId=classify.getGradeLabelId(); gradeLabelId = classify.getGradeLabelId();
subjectLabelId=classify.getSubjectLabelId(); subjectLabelId = classify.getSubjectLabelId();
fill.setFillServes(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,1L,4)); if (Objects.isNull(rightsClassifyId)) {
fill.setFillOnlineCourses(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,2L,3)); fill.setFillServes(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, 1L, 4));
fill.setFillLearningTools(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,3L,1)); fill.setFillOnlineCourses(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, 2L, 3));
fill.setFillDraws(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,4L,1)); fill.setFillLearningTools(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, 3L, 1));
fill.setFillGiftCouponPackages(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,5L,4)); fill.setFillDraws(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, 4L, 1));
fill.setFillGroups(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,6L,1)); fill.setFillGiftCouponPackages(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, 5L, 4));
fill.setFillGroups(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, 6L, 1));
} else {
fill.setDesignatedNews(getAppletItems(firstClassify, secondClassify, gradeLabelId, subjectLabelId, rightsClassifyId, top));
}
return fill; return fill;
} }
private List<AppletNews> getAppletItems(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long rightsClassifyId,Integer top){
List<AppletNews> appletNews=appletNewsDao.getByTempletAndClassify(firstClassify,secondClassify,gradeLabelId,subjectLabelId,rightsClassifyId,top);
if (ListUtils.isEmpty(appletNews)){ @ParamLog("根据权益id获取即享权益配套资料分组集合")
@Override
public List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy) {
if (rightsSettingId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
List<RightsItemGroup> groups = rightsItemGroupDao.getListByRightSettingId(rightsSettingId);
if (ListUtils.isEmpty(groups)) {
return groups;
}
List<Long> groupIds=new ArrayList<>();
List<RightsItemGroup> originals=new ArrayList<>();
List<RightsNowItem> nowItems=new ArrayList<>();
for (RightsItemGroup group:groups){
if (group.getShowState() == null || group.getShowState()){
groupIds.add(group.getId());
if (RightsItemGroupType.ORIGINAL.value.equals(group.getType())){
originals.add(group);
}
}
List<String> descList=new ArrayList<>();
if (!StringUtil.isEmpty(group.getDesc1())){
descList.add(group.getDesc1());
}
if (!StringUtil.isEmpty(group.getDesc2())){
descList.add(group.getDesc2());
}
if (!StringUtil.isEmpty(group.getDesc3())){
descList.add(group.getDesc3());
}
group.setDescList(descList);
}
if (!ListUtils.isEmpty(groupIds)){
nowItems = rightsNowItemDao.getListByGroupIds(groupIds);
if (nowItems == null) {
nowItems = new ArrayList<>();
}
}
if (!ListUtils.isEmpty(originals) && adviserId != null && bookId != null && channelId != null) {
//获取原有的资源
RightsItemGroup originalGroup = originals.get(0);
List<RightsNowItem> originalItems = getOriginalItems(originalGroup.getId(), adviserId, bookId, channelId, rightsSettingId);
nowItems.addAll(originalItems);
}
//填充应用和作品
fillProductAndApp(nowItems);
if (removeCanNotBuy != null && removeCanNotBuy) {
//移除不能购买的应用或作品
removeCanNotBuy(nowItems);
}
Map<Long, List<RightsNowItem>> itemMap = nowItems.stream().collect(Collectors.groupingBy(RightsNowItem::getRightsItemGroupId));
for (RightsItemGroup group : groups) {
group.setRightsNowItems(itemMap.get(group.getId()));
}
return groups;
}
@ParamLog("移除不能购买的应用或作品")
private void removeCanNotBuy(List<RightsNowItem> nowItems) {
if (ListUtils.isEmpty(nowItems)) {
return;
}
List<RightsNowItem> toRemoveList = new ArrayList<>();
for (RightsNowItem item : nowItems) {
if (AppAndProductTypeEnum.APP.value.equals(item.getServeType()) && ArrayUtils.contains(RightsSettingConstant.APPLET_APP_NOT_SUPPORT, item.getServeTypeCode())
|| AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType()) && ArrayUtils.contains(RightsSettingConstant.APPLET_PRODUCT_NOT_SUPPORT, item.getServeTypeCode())) {
toRemoveList.add(item);
}
}
if (!ListUtils.isEmpty(toRemoveList)) {
nowItems.removeAll(toRemoveList);
}
}
@ParamLog("获取原有配套资料")
private List<RightsNowItem> getOriginalItems(Long originalGroupId, Long adviserId, Long bookId, Long channelId,Long rightsSettingId) {
List<RightsNowItem> nowItems=new ArrayList<>();
if (originalGroupId==null||rightsSettingId==null){
return nowItems;
}
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(adviserId, bookId, channelId);
if (!ListUtils.isEmpty(bookServeVOS)) {
for (BookServeDTO vo : bookServeVOS) {
RightsNowItem item = new RightsNowItem();
item.setRightsSettingId(rightsSettingId);
item.setRightsItemGroupId(originalGroupId);
item.setType(RightsNowItemType.SERVES.value);
item.setServeId(vo.getServeId());
item.setServeType(vo.getTypeCode());
item.setLinkUrl(vo.getUrl());
nowItems.add(item);
}
}
return nowItems;
}
private List<AppletNews> getAppletItems(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long rightsClassifyId, Integer top) {
List<AppletNews> appletNews = appletNewsDao.getByTempletAndClassify(firstClassify, secondClassify, gradeLabelId, subjectLabelId, rightsClassifyId, top);
if (ListUtils.isEmpty(appletNews)) {
return new ArrayList<>(); return new ArrayList<>();
} }
return appletNews; return appletNews;
} }
@ParamLog("用户是否领取专享礼包券") @ParamLog("用户是否领取专享礼包券")
private void fillUserGiftReceiveStatus(RightsSetting rightsSetting,Long wechatUserId) { private void fillUserGiftReceiveStatus(RightsSetting rightsSetting, Long wechatUserId) {
if (rightsSetting==null||wechatUserId==null||ListUtils.isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())){ if (rightsSetting == null || wechatUserId == null || ListUtils.isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())) {
return; return;
} }
List<Long> list = giftReceiveDao.getUserReceiveGiftId(wechatUserId); List<Long> list = giftReceiveDao.getUserReceiveGiftId(wechatUserId);
if (ListUtils.isEmpty(list)){ if (ListUtils.isEmpty(list)) {
list=new ArrayList<>(); list = new ArrayList<>();
} }
for (RightsNowItem item:rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList()){ for (RightsNowItem item : rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList()) {
if (list.contains(item.getGiftCouponPackageId())){ if (list.contains(item.getGiftCouponPackageId())) {
item.setUserGiftReceive(true); item.setUserGiftReceive(true);
}else { } else {
item.setUserGiftReceive(false); item.setUserGiftReceive(false);
} }
} }
......
package com.pcloud.book.rightsSetting.dao.check; package com.pcloud.book.rightsSetting.check;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsNowItem; import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
...@@ -38,6 +39,27 @@ public class RightsSettingCheck { ...@@ -38,6 +39,27 @@ public class RightsSettingCheck {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!");
} }
checkRightNowItem(rightsSetting); checkRightNowItem(rightsSetting);
checkRightItemGroups(rightsSetting);
}
private void checkRightItemGroups(RightsSetting rightsSetting) {
if (rightsSetting==null||ListUtils.isEmpty(rightsSetting.getRightsItemGroups())){
return;
}
for (RightsItemGroup group: rightsSetting.getRightsItemGroups()){
if (group.getShowState()==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "分组是否显示为空!");
}
if (group.getType()==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "分组类型为空为空!");
}
if (StringUtil.isEmpty(group.getName())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "分组名称为空!");
}
if (!ListUtils.isEmpty(group.getRightsNowItems())){
checkRightNowItemApp(group.getRightsNowItems());
}
}
} }
private void checkRightNowItem(RightsSetting rightsSetting) { private void checkRightNowItem(RightsSetting rightsSetting) {
...@@ -62,11 +84,11 @@ public class RightsSettingCheck { ...@@ -62,11 +84,11 @@ public class RightsSettingCheck {
} }
} }
private void checkRightNowItemApp(List<RightsNowItem> onlineCourseNowItems) { private void checkRightNowItemApp(List<RightsNowItem> items) {
if (ListUtils.isEmpty(onlineCourseNowItems)){ if (ListUtils.isEmpty(items)){
return; return;
} }
for (RightsNowItem item : onlineCourseNowItems) { for (RightsNowItem item : items) {
if (item.getServeId() == null) { if (item.getServeId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "作品或应用id为空!"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "作品或应用id为空!");
} }
......
package com.pcloud.book.rightsSetting.constants; package com.pcloud.book.rightsSetting.constants;
import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.enums.AppTypeEnum;
public class RightsSettingConstant { public class RightsSettingConstant {
/** /**
...@@ -14,4 +17,16 @@ public class RightsSettingConstant { ...@@ -14,4 +17,16 @@ public class RightsSettingConstant {
* 医疗保健编辑书刊分类id * 医疗保健编辑书刊分类id
*/ */
public static final Long[] MEDICAL_INSURANCE_TEMPLET_ID = {63L}; public static final Long[] MEDICAL_INSURANCE_TEMPLET_ID = {63L};
/**
*小程序不支持展示的应用类型
*/
public static final String[] APPLET_APP_NOT_SUPPORT = {AppTypeEnum.WISH.value, AppTypeEnum.KK.value,
AppTypeEnum.INTERACT.value, AppTypeEnum.MEMBER.value, AppTypeEnum.ENROLL.value};
/**
*小程序不支持展示的商品类型
*/
public static final String[] APPLET_PRODUCT_NOT_SUPPORT = {ProductTypeConstant.QA,ProductTypeConstant.TOOL,
ProductTypeConstant.TUTORIAL,ProductTypeConstant.ATTENDANCE_TASK, ProductTypeConstant.MEMBER,
ProductTypeConstant.THIRDPARTY,ProductTypeConstant.LINK};
} }
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @ClassName com.pcloud.book.rightsSetting.dao.RightsItemGroupDao
* @Author ruansiyuan
* @Description 权益配套资料分组数据层
* @Date 2020/4/26 16:26
* @Version 1.0
**/
public interface RightsItemGroupDao extends BaseDao<RightsItemGroup> {
Integer batchInsert(List<RightsItemGroup> list);
void deleteByRightsSettingId(Long rightsSettingId);
List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId);
}
\ No newline at end of file
...@@ -19,4 +19,6 @@ public interface RightsNowItemDao extends BaseDao<RightsNowItem> { ...@@ -19,4 +19,6 @@ public interface RightsNowItemDao extends BaseDao<RightsNowItem> {
List<RightsNowItem> getListByRightsSettingId(Long rightsSettingId,List<Integer> types); List<RightsNowItem> getListByRightsSettingId(Long rightsSettingId,List<Integer> types);
List<RightsNowItem> getGiftCouponListByRightsSettingId(Long id); List<RightsNowItem> getGiftCouponListByRightsSettingId(Long id);
List<RightsNowItem> getListByGroupIds(List<Long> groupIds);
} }
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsItemGroupDao;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @ClassName com.pcloud.book.rightsSetting.dao.impl.RightsItemGroupDaoImpl
* @Author ruansiyuan
* @Description 权益配套资料分组数据实现层
* @Date 2020/4/26 16:27
* @Version 1.0
**/
@Component("rightsItemGroupDao")
public class RightsItemGroupDaoImpl extends BaseDaoImpl<RightsItemGroup> implements RightsItemGroupDao {
@Override
public Integer batchInsert(List<RightsItemGroup> list) {
return super.getSqlSession().insert(getStatement("batchInsert"),list);
}
@Override
public void deleteByRightsSettingId(Long rightsSettingId) {
super.getSqlSession().delete(getStatement("deleteByRightsSettingId"),rightsSettingId);
}
@Override
public List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId) {
return super.getSqlSession().selectList(getStatement("getListByRightSettingId"),rightsSettingId);
}
}
\ No newline at end of file
...@@ -40,4 +40,11 @@ public class RightsNowItemDaoImpl extends BaseDaoImpl<RightsNowItem> implements ...@@ -40,4 +40,11 @@ public class RightsNowItemDaoImpl extends BaseDaoImpl<RightsNowItem> implements
map.put("rightsSettingId",rightsSettingId); map.put("rightsSettingId",rightsSettingId);
return super.getSqlSession().selectList(getStatement("getGiftCouponListByRightsSettingId"),map); return super.getSqlSession().selectList(getStatement("getGiftCouponListByRightsSettingId"),map);
} }
@Override
public List<RightsNowItem> getListByGroupIds(List<Long> groupIds) {
Map<String,Object> map=new HashMap<>();
map.put("groupIds",groupIds);
return super.getSqlSession().selectList(getStatement("getListByGroupIds"),map);
}
} }
...@@ -32,4 +32,11 @@ public class FillRightsSettingAppletsDTO { ...@@ -32,4 +32,11 @@ public class FillRightsSettingAppletsDTO {
@ApiModelProperty("补充社群共读") @ApiModelProperty("补充社群共读")
private List<AppletNews> fillGroups; private List<AppletNews> fillGroups;
/**
* @Author David
* @Description 当不需要全部时只获取对应资讯
* @Date 2020/4/24 16:08
**/
private List<AppletNews> designatedNews;
} }
package com.pcloud.book.rightsSetting.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @ClassName com.pcloud.book.rightsSetting.entity.RightsItemGroup
* @Author ruansiyuan
* @Description 权益配套资料分组
* @Date 2020/4/26 16:22
* @Version 1.0
**/
@ApiModel("权益配套资料分组")
@Data
public class RightsItemGroup extends BaseEntity {
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("分组名称")
private String name;
@ApiModelProperty("是否展示")
private Boolean showState;
@ApiModelProperty("类型:1本书原版资料,2自定义")
private Integer type;
@ApiModelProperty("图片")
private String pic;
@ApiModelProperty("描述1")
private String desc1;
@ApiModelProperty("描述2")
private String desc2;
@ApiModelProperty("描述3")
private String desc3;
@ApiModelProperty("描述集合")
private List<String> descList;
@ApiModelProperty("应用或作品集合")
private List<RightsNowItem> rightsNowItems;
}
\ No newline at end of file
...@@ -2,35 +2,43 @@ package com.pcloud.book.rightsSetting.entity; ...@@ -2,35 +2,43 @@ package com.pcloud.book.rightsSetting.entity;
import com.pcloud.common.entity.BaseEntity; import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/** /**
* @Description * @Description
* @Author ruansiyuan * @Author ruansiyuan
* @Date 2020/4/19 17:41 * @Date 2020/4/19 17:41
**/ **/
@EqualsAndHashCode(callSuper = true)
@Data @Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RightsNowItem extends BaseEntity { public class RightsNowItem extends BaseEntity {
@ApiModelProperty("权益id") @ApiModelProperty("权益id")
private Long rightsSettingId; private Long rightsSettingId;
@ApiModelProperty("应用作品id") @ApiModelProperty("应用/资讯/作品id")
private Long serveId; private Long serveId;
@ApiModelProperty("应用作品类型") @ApiModelProperty("应用/资讯/作品类型")
private String serveType; private String serveType;
@ApiModelProperty("链接url") @ApiModelProperty("链接url")
private String linkUrl; private String linkUrl;
@ApiModelProperty("类型(1线上网课,2学习工具,3抽奖,4专享礼包券)") @ApiModelProperty("类型(0咨询,1线上网课,2学习工具,3抽奖,4专享礼包券,6配套资料)")
private Integer type; private Integer type;
@ApiModelProperty("专享礼包券id") @ApiModelProperty("专享礼包券id")
private Long giftCouponPackageId; private Long giftCouponPackageId;
@ApiModelProperty("应用作品图片") @ApiModelProperty("应用/资讯/作品图片")
private String servePic; private String servePic;
@ApiModelProperty("应用作品名称") @ApiModelProperty("应用/资讯/作品名称")
private String serveName; private String serveName;
@ApiModelProperty("应用作品类型名称") @ApiModelProperty("应用/资讯/作品类型名称")
private String serveTypeName; private String serveTypeName;
@ApiModelProperty("应用作品类型编码") @ApiModelProperty("应用/资讯/作品类型编码")
private String serveTypeCode; private String serveTypeCode;
@ApiModelProperty("结果链接") @ApiModelProperty("结果链接")
private String resultUrl; private String resultUrl;
...@@ -46,6 +54,16 @@ public class RightsNowItem extends BaseEntity { ...@@ -46,6 +54,16 @@ public class RightsNowItem extends BaseEntity {
private String giftCouponCoverPic; private String giftCouponCoverPic;
@ApiModelProperty("专享礼包券领取状态") @ApiModelProperty("专享礼包券领取状态")
private Boolean userGiftReceive; private Boolean userGiftReceive;
@ApiModelProperty("权益配套资料分组id")
private Long rightsItemGroupId;
@ApiModelProperty("券类型(2-书币券,1-课程券)")
private Integer couponType;
@ApiModelProperty("使用说明")
private String instructions;
@ApiModelProperty("课程券使用方式(1-链接兑取,2-复制码)")
private Integer useType;
@ApiModelProperty("兑换地址")
private String exchangeAddress;
} }
...@@ -86,6 +86,9 @@ public class RightsSetting extends BaseTempletClassify { ...@@ -86,6 +86,9 @@ public class RightsSetting extends BaseTempletClassify {
*/ */
private List<RightsSettingItem> rightsSettingLongTermItems; private List<RightsSettingItem> rightsSettingLongTermItems;
@ApiModelProperty("权益配套资料分组集合")
private List<RightsItemGroup> rightsItemGroups;
public RightsSetting() { public RightsSetting() {
} }
......
package com.pcloud.book.rightsSetting.enums;
public enum RightsItemGroupType {
/**
* 1本书原配套
*/
ORIGINAL(1),
/**
* 2自定义
*/
USER_DEFINED(2);
/**
* 值
*/
public final Integer value;
RightsItemGroupType(Integer value) {
this.value = value;
}
}
...@@ -20,11 +20,10 @@ public enum RightsNowItemType { ...@@ -20,11 +20,10 @@ public enum RightsNowItemType {
GIFT_COUPON_PACKAGE(4), GIFT_COUPON_PACKAGE(4),
/** /**
* 5专享礼包券 * 5社群服务
*/ */
GROUP_SERVICE(5), GROUP_SERVICE(5),
/** /**
* 6 配套资料 * 6 配套资料
*/ */
......
...@@ -13,7 +13,6 @@ import com.pcloud.common.utils.SessionUtil; ...@@ -13,7 +13,6 @@ import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie; import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -26,48 +25,53 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,48 +25,53 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import javax.validation.constraints.Min;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
@RequestMapping("rightsSetting") @RequestMapping("rightsSetting")
@RestController("rightsSettingFacede") @RestController("rightsSettingFacede")
public class RightsSettingFacede { public class RightsSettingFacede {
@Autowired @Autowired
private RightsSettingBiz rightsSettingBiz; private RightsSettingBiz rightsSettingBiz;
@PostMapping("addRightsSetting") @PostMapping("addRightsSetting")
public ResponseDto<Long> addRightsSetting(@RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting) throws PermissionException { public ResponseDto<Long> addRightsSetting( @RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting ) throws PermissionException {
SessionUtil.getToken4Redis(token); SessionUtil.getToken4Redis(token);
return new ResponseDto<Long>(rightsSettingBiz.addRightsSetting(rightsSetting)); return new ResponseDto<Long>(rightsSettingBiz.addRightsSetting(rightsSetting));
} }
@GetMapping("deleteRightsSetting") @GetMapping("deleteRightsSetting")
public ResponseDto<?> deleteRightsSetting(@RequestHeader("token") String token, @RequestParam("id") Long id) throws PermissionException { public ResponseDto<?> deleteRightsSetting( @RequestHeader("token") String token, @RequestParam("id") Long id ) throws PermissionException {
SessionUtil.getToken4Redis(token); SessionUtil.getToken4Redis(token);
rightsSettingBiz.deleteRightsSetting(id); rightsSettingBiz.deleteRightsSetting(id);
return new ResponseDto<>(); return new ResponseDto<>();
} }
@PostMapping("updateRightsSetting") @PostMapping("updateRightsSetting")
public ResponseDto<?> updateRightsSetting(@RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting) throws PermissionException { public ResponseDto<?> updateRightsSetting( @RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting ) throws PermissionException {
SessionUtil.getToken4Redis(token); SessionUtil.getToken4Redis(token);
rightsSettingBiz.updateRightsSetting(rightsSetting); rightsSettingBiz.updateRightsSetting(rightsSetting);
return new ResponseDto<>(); return new ResponseDto<>();
} }
@GetMapping("getRightsSetting") @GetMapping("getRightsSetting")
public ResponseDto<RightsSetting> getRightsSetting(@RequestHeader("token") String token, @RequestParam("id") Long id) throws PermissionException { public ResponseDto<RightsSetting> getRightsSetting( @RequestHeader("token") String token, @RequestParam("id") Long id ) throws PermissionException {
SessionUtil.getToken4Redis(token); SessionUtil.getToken4Redis(token);
return new ResponseDto<RightsSetting>(rightsSettingBiz.getRightsSetting(id)); return new ResponseDto<RightsSetting>(rightsSettingBiz.getRightsSetting(id));
} }
@GetMapping("listRightsSettingPage") @GetMapping("listRightsSettingPage")
public ResponseDto<PageBeanNew<RightsSettingDto>> listRightsSettingPage(@RequestHeader("token") String token, public ResponseDto<PageBeanNew<RightsSettingDto>> listRightsSettingPage( @RequestHeader("token") String token,
@RequestParam("currentPage") Integer currentPage, @RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage, @RequestParam("numPerPage") Integer numPerPage,
@RequestParam(value = "firstClassify", required = false) Long firstClassify, @RequestParam(value = "firstClassify", required = false) Long firstClassify,
@RequestParam(value = "secondClassify", required = false) Long secondClassify, @RequestParam(value = "secondClassify", required = false) Long secondClassify,
@RequestParam(value = "gradeLabelId", required = false) Long gradeLabelId, @RequestParam(value = "gradeLabelId", required = false) Long gradeLabelId,
@RequestParam(value = "subjectLabelId", required = false) Long subjectLabelId, @RequestParam(value = "rightsSettingType", required = false, defaultValue = "1") Integer rightsSettingType, @RequestParam(value = "subjectLabelId", required = false) Long subjectLabelId, @RequestParam(value = "rightsSettingType", required = false, defaultValue = "1") Integer rightsSettingType,
@RequestParam(value = "bookQuery", required = false) String bookQuery @RequestParam(value = "bookQuery", required = false) String bookQuery
) throws PermissionException { ) throws PermissionException {
SessionUtil.getToken4Redis(token); SessionUtil.getToken4Redis(token);
...@@ -83,25 +87,25 @@ public class RightsSettingFacede { ...@@ -83,25 +87,25 @@ public class RightsSettingFacede {
@ApiOperation("获取读者数量-每天自增") @ApiOperation("获取读者数量-每天自增")
@GetMapping("getUserCount") @GetMapping("getUserCount")
public ResponseDto<Integer> getUserCount(){ public ResponseDto<Integer> getUserCount() {
return new ResponseDto<>(rightsSettingBiz.getUserCount()); return new ResponseDto<>(rightsSettingBiz.getUserCount());
} }
@ApiOperation("新增每周/长期权益") @ApiOperation("新增每周/长期权益")
@PostMapping("addRightsSettingItem") @PostMapping("addRightsSettingItem")
public ResponseDto<?> addRightsSettingItem(@RequestBody List<RightsSettingItem> rightsSettingItems, public ResponseDto<?> addRightsSettingItem( @RequestBody List<RightsSettingItem> rightsSettingItems,
@RequestParam("rightsSettingId") Long rightsSettingId, @RequestParam("rightsType") String rightsType){ @RequestParam("rightsSettingId") Long rightsSettingId, @RequestParam("rightsType") String rightsType ) {
rightsSettingBiz.batchInsertRightsSettingItem(rightsSettingItems,rightsSettingId,rightsType); rightsSettingBiz.batchInsertRightsSettingItem(rightsSettingItems, rightsSettingId, rightsType);
return new ResponseDto<>(); return new ResponseDto<>();
} }
@ApiOperation("小程序首页权益基本信息查询") @ApiOperation("小程序首页权益基本信息查询")
@GetMapping("getRightsSettingByBookId4AppletHome") @GetMapping("getRightsSettingByBookId4AppletHome")
public ResponseDto<?> getRightsSettingByBookId4AppletHome( public ResponseDto<?> getRightsSettingByBookId4AppletHome(
@CookieValue("userInfo")String userInfo, @RequestParam("adviserId") Long adviserId, @CookieValue("userInfo") String userInfo, @RequestParam("adviserId") Long adviserId,
@RequestParam("bookId")Long bookId, @RequestParam("channelId")Long channelId){ @RequestParam("bookId") Long bookId, @RequestParam("channelId") Long channelId ) {
Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null==adviserId||null==bookId||null==channelId){ if (null == adviserId || null == bookId || null == channelId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
} }
return new ResponseDto<>(rightsSettingBiz.getRightsSettingByBookId4AppletHome(bookId, adviserId, channelId)); return new ResponseDto<>(rightsSettingBiz.getRightsSettingByBookId4AppletHome(bookId, adviserId, channelId));
...@@ -110,11 +114,11 @@ public class RightsSettingFacede { ...@@ -110,11 +114,11 @@ public class RightsSettingFacede {
@ApiOperation("小程序首页本周/长期权益查询") @ApiOperation("小程序首页本周/长期权益查询")
@GetMapping("getItemByRightsSettingId4AppletHome") @GetMapping("getItemByRightsSettingId4AppletHome")
public ResponseDto<?> getItemByRightsSettingId4AppletHome( public ResponseDto<?> getItemByRightsSettingId4AppletHome(
@CookieValue("userInfo")String userInfo, @CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId, @RequestParam("rightsSettingId") Long rightsSettingId,
@RequestParam(value = "rightsType",required = false) String rightsType){ @RequestParam(value = "rightsType", required = false) String rightsType ) {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null==rightsSettingId || StringUtil.isEmpty(rightsType)){ if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
} }
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType)); return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType));
...@@ -122,47 +126,75 @@ public class RightsSettingFacede { ...@@ -122,47 +126,75 @@ public class RightsSettingFacede {
@ApiOperation("所有权益分类") @ApiOperation("所有权益分类")
@GetMapping("getAllRightsClassify") @GetMapping("getAllRightsClassify")
public ResponseDto<List<RightsSettingClassify>>getAllRightsClassify( public ResponseDto<List<RightsSettingClassify>> getAllRightsClassify(
@RequestParam(value = "rightsType", required = false) String rightsType){ @RequestParam(value = "rightsType", required = false) String rightsType ) {
return new ResponseDto<>(rightsSettingBiz.getAllRightsClassify(rightsType)); return new ResponseDto<>(rightsSettingBiz.getAllRightsClassify(rightsType));
} }
@ApiOperation("根据权益id获取即享权益项") @ApiOperation("根据权益id获取即享权益项")
@GetMapping("getRightsSettingRightsNowItems") @GetMapping("getRightsSettingRightsNowItems")
public ResponseDto<RightsSetting> getRightsSettingRightsNowItems( public ResponseDto<RightsSetting> getRightsSettingRightsNowItems(
@CookieValue("userInfo")String userInfo, @CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId @RequestParam("rightsSettingId") Long rightsSettingId
) throws PermissionException { ) throws PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null==rightsSettingId){ if (null == rightsSettingId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
} }
return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItems(rightsSettingId,wechatUserId)); return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItems(rightsSettingId, wechatUserId));
}
@SneakyThrows
@ApiOperation("根据权益id和类型获取即享权益项")
@GetMapping("getRightsSettingRightsNowItemsByType")
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 ) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItemsByType(rightsSettingId, wechatUserId, rightsSettingType));
} }
@ApiOperation("根据权益id获取即享权益项专享礼包") @ApiOperation("根据权益id获取即享权益项专享礼包")
@GetMapping("getRightsSettingGiftCoupons") @GetMapping("getRightsSettingGiftCoupons")
public ResponseDto<RightsSetting> getRightsSettingGiftCoupons( public ResponseDto<RightsSetting> getRightsSettingGiftCoupons(
@CookieValue("userInfo")String userInfo, @CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId @RequestParam("rightsSettingId") Long rightsSettingId
) throws PermissionException { ) throws PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null==rightsSettingId){ if (null == rightsSettingId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
} }
return new ResponseDto<>(rightsSettingBiz.getRightsSettingGiftCoupons(rightsSettingId,wechatUserId)); return new ResponseDto<>(rightsSettingBiz.getRightsSettingGiftCoupons(rightsSettingId, wechatUserId));
} }
@ApiOperation("根据权益id获取即享权益项补充咨询") @ApiOperation("根据权益id获取即享权益项补充咨询")
@GetMapping("getFillRightsSettingApplets") @GetMapping("getFillRightsSettingApplets")
public ResponseDto<?> getFillRightsSettingApplets( public ResponseDto<?> getFillRightsSettingApplets(
@CookieValue("userInfo")String userInfo, @CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId @RequestParam("rightsSettingId") Long rightsSettingId
) throws PermissionException { ) throws PermissionException {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == rightsSettingId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getFillRightsSettingApplets(rightsSettingId, wechatUserId, null, null));
}
@ApiOperation("根据权益id获取即享权益配套资料分组集合")
@GetMapping("getRightsItemGroups")
public ResponseDto<?> getRightsItemGroups(
@CookieValue("userInfo")String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId,
@RequestParam("adviserId") Long adviserId,
@RequestParam("bookId")Long bookId,
@RequestParam("channelId")Long channelId
) throws PermissionException {
Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null==rightsSettingId){ if (null==rightsSettingId){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
} }
return new ResponseDto<>(rightsSettingBiz.getFillRightsSettingApplets(rightsSettingId,wechatUserId)); return new ResponseDto<>(rightsSettingBiz.getRightsItemGroups(rightsSettingId, adviserId, bookId, channelId, true));
} }
} }
\ No newline at end of file
...@@ -41,11 +41,7 @@ public interface PcloudGroupActivityBiz { ...@@ -41,11 +41,7 @@ public interface PcloudGroupActivityBiz {
/** /**
* 根据分类获取社群共读 * 根据分类获取社群共读
* @param firstClassify
* @param secondClassify
* @param gradeLabelId
* @param subjectLabelId
* @return * @return
*/ */
GroupActivity4AppletDTO getGroupActivity4Applet(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId); GroupActivity4AppletDTO getGroupActivity4Applet(Long rightSettingId, Long adviserId, Long bookId, Long channelId);
} }
...@@ -6,7 +6,9 @@ import com.google.common.collect.Maps; ...@@ -6,7 +6,9 @@ import com.google.common.collect.Maps;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO; import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dao.BookLabelDao; import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.entity.BookLabel; import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr; import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.label.LabelConsr; import com.pcloud.book.consumer.label.LabelConsr;
...@@ -18,6 +20,9 @@ import com.pcloud.book.reading.biz.ReadingActivityBiz; ...@@ -18,6 +20,9 @@ import com.pcloud.book.reading.biz.ReadingActivityBiz;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto; import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz; import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao; import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dao.PcloudSkillDao; import com.pcloud.book.skill.dao.PcloudSkillDao;
...@@ -46,6 +51,7 @@ import java.util.HashMap; ...@@ -46,6 +51,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
...@@ -83,6 +89,10 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz { ...@@ -83,6 +89,10 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
private BookLabelDao bookLabelDao; private BookLabelDao bookLabelDao;
@Autowired @Autowired
private AssistTempletConsr assistTempletConsr; private AssistTempletConsr assistTempletConsr;
@Autowired
private BookBiz bookBiz;
@Autowired
private RightsSettingTitleMapper rightsSettingTitleMapper;
@ParamLog("保存共读活动") @ParamLog("保存共读活动")
@Override @Override
...@@ -276,17 +286,31 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz { ...@@ -276,17 +286,31 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
} }
@Override @Override
public GroupActivity4AppletDTO getGroupActivity4Applet(Long firstClassify, Long secondClassify, public GroupActivity4AppletDTO getGroupActivity4Applet(Long rightSettingId, Long adviserId, Long bookId, Long channelId) {
Long gradeLabelId, Long subjectLabelId) { BookDto adviserBook = bookBiz.getAdviserBook(bookId, adviserId, channelId);
BookDto dto = Optional.ofNullable(adviserBook).orElseThrow(() -> new BookBizException(BookBizException.ID_NOT_EXIST, "未找到相关书刊"));
// 处理分类和标签
BaseTempletClassify baseTempletClassify = new BaseTempletClassify();
baseTempletClassify.setFirstClassify(dto.getTempletId());
baseTempletClassify.setSecondClassify(dto.getSecondTempletId());
baseTempletClassify.setGradeLabelId(dto.getGraLabelId());
baseTempletClassify.setSubjectLabelId(dto.getSubLabelId());
rightsSettingBiz.setClassifyAndLabel(baseTempletClassify);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("firstClassify", firstClassify); map.put("firstClassify", baseTempletClassify.getFirstClassify());
map.put("secondClassify", secondClassify); map.put("secondClassify", baseTempletClassify.getSecondClassify());
map.put("gradeLabelId", gradeLabelId); map.put("gradeLabelId", baseTempletClassify.getGradeLabelId());
map.put("subjectLabelId", subjectLabelId); map.put("subjectLabelId", baseTempletClassify.getSubjectLabelId());
GroupActivity4AppletDTO groupActivity4AppletDTO = pcloudGroupActivityDao.getGroupActivity4Applet(map); GroupActivity4AppletDTO groupActivity4AppletDTO = pcloudGroupActivityDao.getGroupActivity4Applet(map);
if(groupActivity4AppletDTO == null){ if(groupActivity4AppletDTO == null){
return new GroupActivity4AppletDTO(); return new GroupActivity4AppletDTO();
} }
// 是否开启社群服务开关
RightsSettingTitle right = rightsSettingTitleMapper.getByRightSettingIdAndType(rightSettingId, RightsNowItemType.GROUP_SERVICE.value);
groupActivity4AppletDTO.setOpenStatus(Objects.isNull(right) ? false : right.getOpenState());
groupActivity4AppletDTO.setRightsSettingTitle(right.getRightsSettingTitle());
groupActivity4AppletDTO.setRightsSettingDesc(right.getRightsSettingDesc());
String filterStr = StringUtilParent.replaceHtml(groupActivity4AppletDTO.getDesc()); String filterStr = StringUtilParent.replaceHtml(groupActivity4AppletDTO.getDesc());
String subStr = filterStr.length() > 60 ? filterStr.substring(0, 60) + "..." : filterStr; String subStr = filterStr.length() > 60 ? filterStr.substring(0, 60) + "..." : filterStr;
groupActivity4AppletDTO.setCutDesc(subStr); groupActivity4AppletDTO.setCutDesc(subStr);
......
...@@ -2,6 +2,7 @@ package com.pcloud.book.skill.dto; ...@@ -2,6 +2,7 @@ package com.pcloud.book.skill.dto;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -17,6 +18,8 @@ public class GroupActivity4AppletDTO implements Serializable { ...@@ -17,6 +18,8 @@ public class GroupActivity4AppletDTO implements Serializable {
private Long id; private Long id;
private Boolean openStatus;
@ApiModelProperty("共读活动id") @ApiModelProperty("共读活动id")
private Long groupActivityId; private Long groupActivityId;
...@@ -50,4 +53,10 @@ public class GroupActivity4AppletDTO implements Serializable { ...@@ -50,4 +53,10 @@ public class GroupActivity4AppletDTO implements Serializable {
@ApiModelProperty("头像列表") @ApiModelProperty("头像列表")
private List<String> headUrlList; private List<String> headUrlList;
@ApiModelProperty("权益标题")
private String rightsSettingTitle;
@ApiModelProperty("权益描述")
private String rightsSettingDesc;
} }
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.rightsSetting.dao.impl.RightsItemGroupDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsItemGroup">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="rightsSettingId" column="rights_setting_id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="showState" column="show_state" jdbcType="TINYINT"/>
<result property="type" column="type" jdbcType="TINYINT"/>
<result property="pic" column="pic" jdbcType="VARCHAR"/>
<result property="desc1" column="desc1" jdbcType="VARCHAR"/>
<result property="desc2" column="desc2" jdbcType="VARCHAR"/>
<result property="desc3" column="desc3" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from rights_item_group
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from rights_item_group
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsItemGroup" useGeneratedKeys="true" keyProperty="id">
insert into rights_item_group
<trim prefix="(" suffix=")" suffixOverrides=",">
rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{rightsSettingId,jdbcType=BIGINT},
#{name,jdbcType=VARCHAR},
#{showState,jdbcType=TINYINT},
#{type,jdbcType=TINYINT},
#{pic,jdbcType=VARCHAR},
#{desc1,jdbcType=VARCHAR},
#{desc2,jdbcType=VARCHAR},
#{desc3,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsItemGroup" useGeneratedKeys="true" keyProperty="id">
insert into rights_item_group (
rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.rightsSettingId,jdbcType=BIGINT},
#{item.name,jdbcType=VARCHAR},
#{item.showState,jdbcType=TINYINT},
#{item.type,jdbcType=TINYINT},
#{item.pic,jdbcType=VARCHAR},
#{item.desc1,jdbcType=VARCHAR},
#{item.desc2,jdbcType=VARCHAR},
#{item.desc3,jdbcType=VARCHAR},
NOW()
)
</foreach>
</insert>
<delete id="deleteByRightsSettingId" parameterType="long">
delete from rights_item_group
where rights_setting_id=#{rightsSettingId}
</delete>
<select id="getListByRightSettingId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from rights_item_group
where rights_setting_id=#{rightsSettingId}
</select>
</mapper>
\ No newline at end of file
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
<result property="type" column="type" jdbcType="BIGINT"/> <result property="type" column="type" jdbcType="BIGINT"/>
<result property="giftCouponPackageId" column="gift_coupon_package_id" jdbcType="BIGINT"/> <result property="giftCouponPackageId" column="gift_coupon_package_id" jdbcType="BIGINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="rightsItemGroupId" column="rights_item_group_id" jdbcType="BIGINT"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time id, rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time, rights_item_group_id
</sql> </sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long"> <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowItem" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowItem" useGeneratedKeys="true" keyProperty="id">
insert into rights_now_item insert into rights_now_item
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time, rights_item_group_id
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
#{rightsSettingId,jdbcType=BIGINT}, #{rightsSettingId,jdbcType=BIGINT},
...@@ -41,13 +42,14 @@ ...@@ -41,13 +42,14 @@
#{linkUrl,jdbcType=VARCHAR}, #{linkUrl,jdbcType=VARCHAR},
#{type,jdbcType=INTEGER}, #{type,jdbcType=INTEGER},
#{giftCouponPackageId,jdbcType=BIGINT}, #{giftCouponPackageId,jdbcType=BIGINT},
NOW() NOW(),
#{rightsItemGroupId,jdbcType=BIGINT}
</trim> </trim>
</insert> </insert>
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowItem" useGeneratedKeys="true" keyProperty="id"> <insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowItem" useGeneratedKeys="true" keyProperty="id">
insert into rights_now_item ( insert into rights_now_item (
rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time, rights_item_group_id
) values ) values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
( (
...@@ -57,7 +59,8 @@ ...@@ -57,7 +59,8 @@
#{item.linkUrl,jdbcType=VARCHAR}, #{item.linkUrl,jdbcType=VARCHAR},
#{item.type,jdbcType=INTEGER}, #{item.type,jdbcType=INTEGER},
#{item.giftCouponPackageId,jdbcType=BIGINT}, #{item.giftCouponPackageId,jdbcType=BIGINT},
NOW() NOW(),
#{item.rightsItemGroupId,jdbcType=BIGINT}
) )
</foreach> </foreach>
</insert> </insert>
...@@ -94,7 +97,11 @@ ...@@ -94,7 +97,11 @@
t1.cover_pic giftCouponCoverPic, t1.cover_pic giftCouponCoverPic,
t1.denomination giftCouponDenomination, t1.denomination giftCouponDenomination,
t1.valid_date_begin giftCouponValidDateBegin, t1.valid_date_begin giftCouponValidDateBegin,
t1.valid_date_end giftCouponValidDateEnd t1.valid_date_end giftCouponValidDateEnd,
t1.coupon_type couponType,
t1.instructions instructions,
t1.use_type useType,
t1.exchange_address exchangeAddress
FROM FROM
rights_now_item t rights_now_item t
INNER JOIN gift_coupon_package t1 ON t.gift_coupon_package_id = t1.id INNER JOIN gift_coupon_package t1 ON t.gift_coupon_package_id = t1.id
...@@ -104,4 +111,13 @@ ...@@ -104,4 +111,13 @@
and now() <![CDATA[ <= ]]> t1.valid_date_end and now() <![CDATA[ <= ]]> t1.valid_date_end
</select> </select>
<select id="getListByGroupIds" parameterType="map" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
from rights_now_item t
where rights_item_group_id in
<foreach collection="groupIds" item="item" open="(" separator="," close=")">
${item}
</foreach>
</select>
</mapper> </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