Commit b31f40df by 裴大威

Merge branch '1002786-merge' into 'master'

1002786

See merge request rays/pcloud-book!654
parents 62152721 7a000318
......@@ -24,6 +24,7 @@ import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -178,32 +179,32 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@ParamLog("获取用户最后一次点击的书(有社群书的取最后一次社群书,没有的取现代纸书)")
@Override
public UserLastBookReDTO getUserLastBookRe(Long wechatUserId) {
if (wechatUserId==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
if (wechatUserId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
//查询最后一本社群书
UserLastBookReDTO lastBookRe = appletUserBookcaseDao.getUserLastGroupBookRe(wechatUserId);
if (lastBookRe!=null){
if (lastBookRe != null) {
lastBookRe.setHasBook(true);
lastBookRe.setBookGroup(true);
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(lastBookRe.getBookId(), lastBookRe.getAdviserId(), lastBookRe.getChannelId());
if (rightsSettingDto!=null){
if (rightsSettingDto != null) {
lastBookRe.setRightSettingId(rightsSettingDto.getId());
}
return lastBookRe;
}else {
} else {
//查询最后一本书
UserLastBookReDTO userLastRe = appletUserBookcaseDao.getUserLastRe(wechatUserId);
if (userLastRe!=null){
if (userLastRe != null) {
userLastRe.setBookGroup(false);
userLastRe.setHasBook(true);
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(userLastRe.getBookId(), userLastRe.getAdviserId(), userLastRe.getChannelId());
if (rightsSettingDto!=null){
if (rightsSettingDto != null) {
userLastRe.setRightSettingId(rightsSettingDto.getId());
}
return userLastRe;
}else {
lastBookRe=new UserLastBookReDTO();
} else {
lastBookRe = new UserLastBookReDTO();
lastBookRe.setHasBook(false);
return lastBookRe;
}
......
......@@ -36,5 +36,5 @@ public interface AppletNewsDao extends BaseDao<AppletNews> {
*/
List<AppletNewsDTO> getByNewsByTempletLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, String rightsType);
List<AppletNews> getByTempletAndClassify(Long firstClassify, Long secondClassify, Long rightsClassifyId, Integer top);
List<AppletNews> getByTempletAndClassify(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long rightsClassifyId, Integer top);
}
......@@ -39,10 +39,12 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
}
@Override
public List<AppletNews> getByTempletAndClassify(Long firstClassify, Long secondClassify, Long rightsClassifyId, Integer top) {
public List<AppletNews> getByTempletAndClassify(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long rightsClassifyId, Integer top) {
Map<String,Object> map = new HashMap<>();
map.put("firstClassify", firstClassify);
map.put("secondClassify", secondClassify);
map.put("gradeLabelId",gradeLabelId);
map.put("subjectLabelId", subjectLabelId);
map.put("rightsClassifyId",rightsClassifyId);
map.put("top", top);
return getSessionTemplate().selectList(getStatement("getByTempletAndClassify"),map);
......
......@@ -34,4 +34,14 @@ public class HotBook extends BaseEntity {
@ApiModelProperty("书封面")
private String coverImg;
@ApiModelProperty("运营id")
private Long channelId;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("出版社")
private String publish;
}
......@@ -4621,7 +4621,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
if (null==bookAppletScene){
return;
}
BookGroupDTO bookGroupDTO = bookGroupDao. getBookBaseInfoById(bookAppletScene.getBookGroupId());
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookAppletScene.getBookGroupId());
if (null==bookGroupDTO){
return;
}
......@@ -4747,6 +4747,17 @@ public class BookGroupBizImpl implements BookGroupBiz {
@Override
public Map<String, Object> getBookBaseInfo4Applet(Long adviserId, Long channelId, Long bookId) {
Map<String,Object> map = new HashMap<>();
//是否小睿,小睿权益id
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId,channelId,adviserId);
Boolean isXIAORUI=false;
if (null!=bookGroupDTO && JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupDTO.getJoinGroupType())){
isXIAORUI=true;
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(bookId,channelId,adviserId);
if (null!=rightsSettingDto){
map.put("rightsSettingId", rightsSettingDto.getId());
}
}
//书刊分类对应的小睿分类
BookAdviserDto adviserDto = bookAdviserDao.getBase(bookId,channelId,adviserId);
if (null!=adviserDto){
Long raysClassifyId = bookRaysClassifyDao.getClassifyIdByBookTemplateId(adviserDto.getTempletId());
......@@ -4754,10 +4765,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
map.put("raysClassifyId",raysClassifyId);
}
}
//获取书名
BookDto bookDto = bookBiz.getBaseById(bookId);
if (null != bookDto) {
map.put("bookName", bookDto.getBookName());
}
map.put("isXIAORUI",isXIAORUI);
return map;
}
......
......@@ -18,7 +18,6 @@ import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.giftcoupon.dao.GiftCouponPackageDao;
import com.pcloud.book.giftcoupon.dao.GiftReceiveDao;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
......@@ -28,7 +27,6 @@ import com.pcloud.book.rightsSetting.dao.RightsNowItemDao;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao;
import com.pcloud.book.rightsSetting.dao.check.RightsSettingCheck;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletItemDTO;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
......@@ -38,6 +36,7 @@ import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.util.common.CommonUtils;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
......@@ -525,7 +524,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
String key= "BOOK:RIGHTS_SETTING:USER_RIGHTS_ITEM"+wechatUserId+"-"+rightsSettingId+"-"+item.getRightsClassifyId();
//权益分类下资讯
List<AppletNewsDTO> newsDTOS=JedisClusterUtils.getJsonList(key,AppletNewsDTO.class);
if (ListUtils.isEmpty(newsDTOS)) {//数据库取
if (ListUtils.isEmpty(newsDTOS)||newsDTOS.size()<3) {//数据库取
if (!MapUtils.isEmpty(map) && map.containsKey(item.getRightsClassifyId())) {
newsDTOS=map.get(item.getRightsClassifyId());
if (newsDTOS.size()>3){//随机取三条
......@@ -538,7 +537,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
newsDTOS = dtos;
}
JedisClusterUtils.setJsonList(key,newsDTOS,24*3600);
JedisClusterUtils.setJsonList(key,newsDTOS, CommonUtils.todayRemainingSeconds());
}
}
item.setAppletNewsDTOS(newsDTOS);
......@@ -554,8 +553,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("根据权益id获取即享权益项")
@Override
public RightsSetting getRightsSettingRightsNowItems(Long rightsSettingId, Long wechatUserId) {
RightsSetting rightsSetting=new RightsSetting();
rightsSetting.setId(rightsSettingId);
RightsSetting rightsSetting=rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting==null){
throw new BookBizException(BookBizException.ERROR,"未找到权益!");
}
fillRightsNowItems(rightsSetting);
return rightsSetting;
}
......@@ -581,29 +582,42 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (rightsSetting==null){
return fill;
}
fill.setFillServes(getChangedAppletItems(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),1L,4));
fill.setFillOnlineCourses(getChangedAppletItems(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),2L,2));
fill.setFillLearningTools(getChangedAppletItems(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),3L,1));
fill.setFillDraws(getChangedAppletItems(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),4L,1));
fill.setFillGiftCouponPackages(getChangedAppletItems(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),5L,4));
fill.setFillGroups(getChangedAppletItems(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),6L,1));
Long firstClassify=rightsSetting.getFirstClassify();
Long secondClassify = rightsSetting.getSecondClassify();
Long gradeLabelId=null;
Long subjectLabelId=null;
if (rightsSetting.getRightsSettingType()==2){//书刊权益,分类标签从编辑书刊取
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId());
firstClassify=adviserDto.getTempletId();
secondClassify=adviserDto.getSecondTempletId();
gradeLabelId=adviserDto.getGraLabelId();
subjectLabelId=adviserDto.getSubLabelId();
}
BaseTempletClassify classify = new BaseTempletClassify();
classify.setFirstClassify(firstClassify);
classify.setSecondClassify(secondClassify);
classify.setGradeLabelId(gradeLabelId);
classify.setSubjectLabelId(subjectLabelId);
setClassifyAndLabel(classify);
firstClassify=classify.getFirstClassify();
secondClassify=classify.getSecondClassify();
gradeLabelId=classify.getGradeLabelId();
subjectLabelId=classify.getSubjectLabelId();
fill.setFillServes(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,1L,4));
fill.setFillOnlineCourses(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,2L,2));
fill.setFillLearningTools(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,3L,1));
fill.setFillDraws(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,4L,1));
fill.setFillGiftCouponPackages(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,5L,4));
fill.setFillGroups(getAppletItems(firstClassify,secondClassify,gradeLabelId,subjectLabelId,6L,1));
return fill;
}
private List<FillRightsSettingAppletItemDTO> getChangedAppletItems(Long firstClassify, Long secondClassify, Long rightsClassifyId, Integer top){
List<AppletNews> appletNews=appletNewsDao.getByTempletAndClassify(firstClassify,secondClassify,rightsClassifyId,top);
List<FillRightsSettingAppletItemDTO> fills=new ArrayList<>();
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 fills;
}
for (AppletNews news:appletNews){
FillRightsSettingAppletItemDTO fill=new FillRightsSettingAppletItemDTO();
fill.setAppletNewsId(news.getId());
fill.setNewsName(news.getNewsName());
fill.setPicUrl(news.getPic1());
fills.add(fill);
return new ArrayList<>();
}
return fills;
return appletNews;
}
@ParamLog("用户是否领取专享礼包券")
......
package com.pcloud.book.rightsSetting.dto;
import com.pcloud.book.applet.entity.AppletNews;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -14,21 +15,21 @@ import java.util.List;
public class FillRightsSettingAppletsDTO {
@ApiModelProperty("补充配置资源")
private List<FillRightsSettingAppletItemDTO> fillServes;
private List<AppletNews> fillServes;
@ApiModelProperty("补充配置资源")
private List<FillRightsSettingAppletItemDTO> fillOnlineCourses;
private List<AppletNews> fillOnlineCourses;
@ApiModelProperty("补充学习工具")
private List<FillRightsSettingAppletItemDTO> fillLearningTools;
private List<AppletNews> fillLearningTools;
@ApiModelProperty("补充抽奖")
private List<FillRightsSettingAppletItemDTO> fillDraws;
private List<AppletNews> fillDraws;
@ApiModelProperty("补充专享礼包券")
private List<FillRightsSettingAppletItemDTO> fillGiftCouponPackages;
private List<AppletNews> fillGiftCouponPackages;
@ApiModelProperty("补充社群共读")
private List<FillRightsSettingAppletItemDTO> fillGroups;
private List<AppletNews> fillGroups;
}
......@@ -17,7 +17,7 @@ public enum RightsTypeEnum {
*/
LONG_TERM("LONG_TERM");
public String value;
public final String value;
RightsTypeEnum(String value) {
this.value = value;
......
......@@ -212,6 +212,12 @@
<if test="secondClassify!=null">
AND t.second_classify =#{secondClassify}
</if>
<if test="gradeLabelId != null">
AND t.grade_label_id = #{gradeLabelId}
</if>
<if test="subjectLabelId != null">
AND t.subject_label_id = #{subjectLabelId}
</if>
<if test="rightsClassifyId!=null">
AND t.rights_classify_id =#{rightsClassifyId}
</if>
......
......@@ -40,7 +40,7 @@
LEFT JOIN BOOK_ADVISER a ON c.book_id=a.BOOK_ID AND c.adviser_id=a.ADVISER_ID
AND c.channel_id=a.CHANNEL_ID AND a.IS_DELETE = 0
INNER JOIN BOOK b ON c.BOOK_ID = b.BOOK_ID AND b.IS_DELETE = 0
INNER JOIN book_group d ON d.BOOK_ID = a.BOOK_ID and d.create_user=c.adviser_id and d.channel_id=c.channel_id AND d.IS_DELETE = 0
LEFT JOIN book_group d ON d.BOOK_ID = a.BOOK_ID and d.create_user=c.adviser_id and d.channel_id=c.channel_id AND d.IS_DELETE = 0
WHERE c.wechat_user_id=#{wechatUserId}
GROUP BY c.book_id,c.adviser_id,c.channel_id
ORDER BY c.create_time DESC
......
......@@ -45,7 +45,10 @@
h.create_time createTime,
b.BOOK_NAME bookName,
b.COVER_IMG coverImg,
b.author,
b.publish,
a.ADVISER_ID adviserId,
a.channel_id channelId,
count(r.id) searchCount
from hot_book h
LEFT JOIN search_record r
......
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