Commit 804ab042 by 田超

Merge branch 'feature/1003668' into 'master'

feat: [1003668] 中教图馆配书线上读书服务小睿流程修改

See merge request rays/pcloud-book!1011
parents 277f0df7 d044a42f
......@@ -720,6 +720,8 @@ public class BookDto extends BaseDto {
*/
private String volLabelName;
private Integer isLibraryBook;
@ApiModelProperty("是否出版融合")
private Integer isFuse;
@ApiModelProperty("负责人")
......@@ -819,6 +821,14 @@ public class BookDto extends BaseDto {
this.desc = desc;
}
public Integer getIsLibraryBook() {
return isLibraryBook;
}
public void setIsLibraryBook(Integer isLibraryBook) {
this.isLibraryBook = isLibraryBook;
}
public String getGraLabelName() {
return graLabelName;
}
......@@ -2183,11 +2193,12 @@ public class BookDto extends BaseDto {
", adviserAccount='" + adviserAccount + '\'' +
", adviserPwd='" + adviserPwd + '\'' +
", openWeapp=" + openWeapp +
", graLabelName=" + graLabelName +
", subLabelName=" + subLabelName +
", verLabelName=" + verLabelName +
", areaLabelName=" + areaLabelName +
", volLabelName=" + volLabelName +
", graLabelName='" + graLabelName + '\'' +
", subLabelName='" + subLabelName + '\'' +
", verLabelName='" + verLabelName + '\'' +
", areaLabelName='" + areaLabelName + '\'' +
", volLabelName='" + volLabelName + '\'' +
", isLibraryBook=" + isLibraryBook +
'}';
}
}
......@@ -269,4 +269,13 @@ public interface BookService {
ResponseEntity<ResponseDto<Map<Long, String>>> getLabelMapByIds(
@RequestBody List<Long> labelIds
) throws BizException;
@ApiOperation("判断是否馆配图书 生产环境传入adviserId 测试UAT传入BookID")
@RequestMapping(value = "/checkIsLibraryBook", method = RequestMethod.GET)
ResponseEntity<ResponseDto<Boolean>> checkIsLibraryBook(@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "bookId", required = false) Long bookId);
@ApiOperation("慎点 清除书籍基本信息的Redis缓存 pwd: clearCache4BookBaseInfo")
@RequestMapping(value = "/clearCache4BookBaseInfo",method = RequestMethod.GET)
void clearCache4BookBaseInfo(@RequestParam("pwd") String pwd);
}
......@@ -17,6 +17,7 @@ import com.pcloud.book.applet.entity.AppletUserClickRecord;
import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookAdviserBiz;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookRaysClassifyDao;
import com.pcloud.book.book.entity.BookRaysClassify;
......@@ -107,6 +108,8 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@Autowired
private ExportConsr exportConsr;
@Autowired
private BookBiz bookBiz;
@Autowired
private AdviserConsr adviserConsr;
@Override
......@@ -288,8 +291,9 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
if (wechatUserId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
UserLastBookReDTO lastBookRe;
//查询最后一本社群书
UserLastBookReDTO lastBookRe = appletUserBookcaseDao.getUserLastGroupBookRe(wechatUserId);
lastBookRe = appletUserBookcaseDao.getUserLastGroupBookRe(wechatUserId);
if (lastBookRe != null) {
lastBookRe.setHasBook(true);
lastBookRe.setBookGroup(true);
......@@ -297,24 +301,28 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
if (rightsSettingDto != null) {
lastBookRe.setRightSettingId(rightsSettingDto.getId());
}
return lastBookRe;
} else {
//查询最后一本书
UserLastBookReDTO userLastRe = appletUserBookcaseDao.getUserLastRe(wechatUserId);
if (userLastRe != null) {
userLastRe.setBookGroup(false);
userLastRe.setHasBook(true);
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(userLastRe.getBookId(), userLastRe.getAdviserId(), userLastRe.getChannelId());
lastBookRe = appletUserBookcaseDao.getUserLastRe(wechatUserId);
if (lastBookRe != null) {
lastBookRe.setBookGroup(false);
lastBookRe.setHasBook(true);
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(lastBookRe.getBookId(), lastBookRe.getAdviserId(), lastBookRe.getChannelId());
if (rightsSettingDto != null) {
userLastRe.setRightSettingId(rightsSettingDto.getId());
lastBookRe.setRightSettingId(rightsSettingDto.getId());
}
return userLastRe;
} else {
lastBookRe = new UserLastBookReDTO();
lastBookRe.setHasBook(false);
return lastBookRe;
}
}
if (lastBookRe.getHasBook()) {
lastBookRe.setIsLibraryBook(bookBiz.checkIsLibraryBook(lastBookRe.getAdviserId(), lastBookRe.getBookId()) ? 1 : 0);
}
if (Objects.isNull(lastBookRe.getRightSettingId())) {
lastBookRe.setRightSettingId(bookBiz.getDefaultRightsSettingId());
}
return lastBookRe;
}
@Override
......
......@@ -32,4 +32,7 @@ public class UserLastBookReDTO {
@ApiModelProperty("阅读方式")
private Integer readType;
@ApiModelProperty("是否馆配图书")
private Integer isLibraryBook;
}
......@@ -11,6 +11,7 @@ import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.dto.BookInfo4AnlysicsDTO;
import com.pcloud.book.book.dto.BookInfoAnalysicsDTO;
import com.pcloud.book.book.dto.BookInfoAndAuthStatusDTO;
import com.pcloud.book.book.dto.BookUniqueNumberDTO;
import com.pcloud.book.book.dto.CreateBookResultVO;
import com.pcloud.book.book.dto.CreateBookVO;
import com.pcloud.book.book.dto.QrcodeServeDto;
......@@ -24,7 +25,6 @@ import com.pcloud.book.book.vo.ListNoAuthGroupBookParam;
import com.pcloud.book.book.vo.SearchBookVO;
import com.pcloud.book.book.vo.request.BookQualifyInfoVO;
import com.pcloud.book.book.vo.request.BookSearchParamVO;
import com.pcloud.book.book.dto.BookUniqueNumberDTO;
import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.common.exceptions.BizException;
......@@ -690,4 +690,13 @@ public interface BookBiz {
PageBeanNew<QrcodeServeDto> getQrcodeDetail4Erp(Long sceneId, Long bookGroupId, Long channelId, Integer currentPage, Integer numPerPage);
BookGroupDTO checkQrcodeDetail4Erp(String url);
Boolean checkIsLibraryBook(Long adviserId, Long bookId);
/**
* 获取默认的权益ID
*/
Long getDefaultRightsSettingId();
void clearCache4BookBaseInfo(String pwd);
}
......@@ -3,10 +3,11 @@
*/
package com.pcloud.book.book.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.alibaba.fastjson.JSONObject;
import com.pcloud.analysisengine.qrcode.dto.BookTimeSourceDto;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
......@@ -49,6 +50,7 @@ import com.pcloud.book.book.dto.BookInfo4AnlysicsDTO;
import com.pcloud.book.book.dto.BookInfoAnalysicsDTO;
import com.pcloud.book.book.dto.BookInfoAndAuthStatusDTO;
import com.pcloud.book.book.dto.BookNameUpdateDTO;
import com.pcloud.book.book.dto.BookUniqueNumberDTO;
import com.pcloud.book.book.dto.CreateBookResultVO;
import com.pcloud.book.book.dto.CreateBookVO;
import com.pcloud.book.book.dto.CreateQrcodeVO;
......@@ -69,7 +71,6 @@ import com.pcloud.book.book.vo.ListNoAuthGroupBookParam;
import com.pcloud.book.book.vo.SearchBookVO;
import com.pcloud.book.book.vo.request.BookQualifyInfoVO;
import com.pcloud.book.book.vo.request.BookSearchParamVO;
import com.pcloud.book.book.dto.BookUniqueNumberDTO;
import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto;
import com.pcloud.book.consumer.analysisengine.SceneRecordConsr;
import com.pcloud.book.consumer.app.AppConsr;
......@@ -100,9 +101,7 @@ import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.entity.BookAppletScene;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.mq.producer.BookMQProducer;
import com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper;
import com.pcloud.book.util.common.ThreadPoolUtils;
......@@ -112,7 +111,6 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.qrcode.entity.QrcodeLabel;
import com.pcloud.channelcenter.qrcode.entity.QrcodeScene;
import com.pcloud.channelcenter.qrcode.entity.QrcodeStyle;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.dto.MessageDto;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
......@@ -136,8 +134,6 @@ import com.pcloud.labelcenter.label.service.LabelService;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.SpecificationDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.pcloud.usercenter.party.agent.dto.SaleAgentDTO;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -145,6 +141,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
......@@ -164,7 +161,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -282,7 +278,8 @@ public class BookBizImpl implements BookBiz {
private BookBiz bookBiz;
@Autowired
private LabelConsr labelConsr;
@Value("${system.env}")
private String envStr;
/**
* 创建书籍,同时建立与编辑的推广关系
......@@ -553,14 +550,19 @@ public class BookBizImpl implements BookBiz {
if (bookId == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "请选择书刊");
}
Long adviserId = null;
// 从redis获取书籍信息
BookDto bookDto = bookCache.getBookToRedis(bookId);
if (null == bookDto) {
bookDto = bookDao.getBaseById(bookId);
BookAdviserDto bookAdviserDto = bookAdviserBiz.getOneMainBook(bookId);
if (null != bookDto && null != bookAdviserDto){
if (null != bookDto && null != bookAdviserDto) {
bookDto.setTempletId(bookAdviserDto.getTempletId());
bookSet.setFirstTemplateName(bookDto);
adviserId = bookAdviserDto.getAdviserId();
}
if (Objects.nonNull(bookDto)){
bookDto.setIsLibraryBook(checkIsLibraryBook(adviserId, bookId) ? 1 : 0);
}
// 将数据存入redis
bookCache.setBookToRedis(bookDto);
......@@ -3228,6 +3230,51 @@ public class BookBizImpl implements BookBiz {
return bookGroupInfo;
}
@Override
public Boolean checkIsLibraryBook(Long adviserId, Long bookId) {
if ("pro".equals(envStr) && Objects.equals(adviserId, 1000019217L)) {
return Boolean.TRUE;
} else if ("uat".equalsIgnoreCase(envStr) && Objects.equals(bookId, 1398300L)) {
return Boolean.TRUE;
} else if ("test".equalsIgnoreCase(envStr) && Objects.equals(bookId, 5210593L)) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@Override
public Long getDefaultRightsSettingId() {
if ("pro".equals(envStr)) {
return 2267L;
} else if ("uat".equalsIgnoreCase(envStr)) {
return 119L;
} else if ("test".equalsIgnoreCase(envStr)) {
return 818L;
}
return 0L;
}
@Override
public void clearCache4BookBaseInfo(String pwd) {
if (StringUtil.isBlank(pwd) || !"clearCache4BookBaseInfo".equals(pwd)) {
return;
}
if (JedisClusterUtils.setnx(BookConstant.BOOK_CACHE + "CLEAR_CACHE", DateUtil.now())) {
JedisClusterUtils.expire(BookConstant.BOOK_CACHE + "CLEAR_CACHE", 60 * 60 * 3);
int currentPage = 0;
PageBeanNew<Long> pageBeanNew = bookDao.listPageNew(new PageParam(currentPage, 1000), null, "listBookId");
while (CollUtil.isNotEmpty(pageBeanNew.getRecordList()) && pageBeanNew.getPageCount() > currentPage++) {
for (Long aLong : pageBeanNew.getRecordList()) {
bookCache.clearCache4BookBaseInfo(aLong);
}
pageBeanNew = bookDao.listPageNew(new PageParam(currentPage, 1000), null, "listBookId");
}
JedisClusterUtils.del(BookConstant.BOOK_CACHE + "CLEAR_CACHE");
}
}
/**
* 查询社群书二维码信息
*/
......
package com.pcloud.book.book.cache;
import org.springframework.stereotype.Component;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.stereotype.Component;
import java.util.Objects;
/**
* 描述 :图书缓存数据
......@@ -16,6 +17,14 @@ import com.pcloud.common.utils.string.StringUtil;
@Component("bookCache")
public class BookCache {
public void clearCache4BookBaseInfo(Long bookId){
if (Objects.nonNull(bookId)){
StringBuffer key = new StringBuffer(BookConstant.BOOK_CACHE);
key.append(bookId);
JedisClusterUtils.del(key.toString());
}
}
/**
* 图书基本信息
* @param BookDto
......
......@@ -227,4 +227,19 @@ public class BookServiceImpl implements BookService {
public ResponseEntity<ResponseDto<Map<Long, String>>> getLabelMapByIds(@RequestBody List<Long> labelIds) throws BizException {
return ResponseHandleUtil.toResponse(bookLabelBiz.getLabelMapByIds(labelIds));
}
@Override
@RequestMapping(value = "/checkIsLibraryBook", method = RequestMethod.GET)
public ResponseEntity<ResponseDto<Boolean>> checkIsLibraryBook(@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "bookId", required = false) Long bookId) {
return ResponseHandleUtil.toResponse(bookBiz.checkIsLibraryBook(adviserId,bookId));
}
@Override
@RequestMapping(value = "/clearCache4BookBaseInfo",method = RequestMethod.GET)
public void clearCache4BookBaseInfo(@RequestParam("pwd") String pwd) {
bookBiz.clearCache4BookBaseInfo(pwd);
}
}
......@@ -5261,6 +5261,10 @@ public class BookGroupBizImpl implements BookGroupBiz {
map.put("coverImg", bookDto.getCoverImg());
}
map.put("isXIAORUI", isXIAORUI);
map.put("isLibraryBook", bookBiz.checkIsLibraryBook(adviserId, bookId) ? 1 : 0);
if (Objects.isNull(map.get("rightsSettingId"))) {
map.put("rightsSettingId", bookBiz.getDefaultRightsSettingId());
}
//资源数量
/* List<BookServeDTO> serveDTOList = this.getBookAndBookGroupServeIds(adviserId, bookId, channelId);
this.removeCanNotBuy(serveDTOList);
......
......@@ -1851,9 +1851,34 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
String cityCode = readerConsr.getCityCodeByWechatUserId(wechatUserId);
rightsSettingDto.setRightsSettingLongTermItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId, readType, bookId, adviserId, channelId, cityCode, currentPage, numPerPage,agentId));
}
// 处理馆配图书
processLibraryBook(bookId, adviserId, rightsSettingDto);
return rightsSettingDto;
}
/**
* 馆配图书 不展示书单
*
*/
private void processLibraryBook(Long bookId, Long adviserId, RightsSettingDto rightsSettingDto) {
if (bookBiz.checkIsLibraryBook(adviserId, bookId)) {
List<RightsSettingItem> rightsSettingLongTermItems = rightsSettingDto.getRightsSettingLongTermItems();
if (CollUtil.isNotEmpty(rightsSettingLongTermItems)) {
for (RightsSettingItem rightsSettingLongTermItem : rightsSettingLongTermItems) {
if (Objects.nonNull(rightsSettingLongTermItem))
rightsSettingLongTermItem.setOuterBooklistDTOS(new ArrayList<>());
}
}
List<RightsSettingItem> rightsSettingWeekItems = rightsSettingDto.getRightsSettingWeekItems();
if (CollUtil.isNotEmpty(rightsSettingWeekItems)) {
for (RightsSettingItem rightsSettingWeekItem : rightsSettingWeekItems) {
if (Objects.nonNull(rightsSettingWeekItem))
rightsSettingWeekItem.setOuterBooklistDTOS(new ArrayList<>());
}
}
}
}
@Override
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId,
......
......@@ -2534,4 +2534,8 @@
</set>
where book_id = #{bookId}
</update>
<select id="listBookId" resultType="long">
select BOOK_ID from book
</select>
</mapper>
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