Commit 2daed7f2 by 田超

Merge branch 'master' of ssh://begitlab.chubanyun.me:12122/rays/pcloud-book into feature/110

parents 7249061b a58ba714
...@@ -474,4 +474,16 @@ public class BookConstant { ...@@ -474,4 +474,16 @@ public class BookConstant {
* 手机号授权 * 手机号授权
*/ */
public static final String BOOK_PHONE_AUTH_CACHE_KEY = CacheConstant.BOOK + "getBookPhoneAuth:"; public static final String BOOK_PHONE_AUTH_CACHE_KEY = CacheConstant.BOOK + "getBookPhoneAuth:";
/**
* 编辑默认渠道缓存
*/
public static final String ADVISER_DEFAULT_CHANNEL_ID_CACHE = CacheConstant.BOOK + "adviserDefaultChannelIdCache";
/**
* 关注公众号临时二维码
*/
public static final String PAGE_ID_TEMP_CODE_CACHE = CacheConstant.BOOK + "TEMPCODE";
public static final String PAGE_ID_CODE_CACHE = CacheConstant.BOOK + "PAGECODE";
public static final String PAGE_ID_LOGOURL_CACHE = CacheConstant.BOOK + "LOGOURL";
} }
...@@ -317,4 +317,9 @@ public interface BookService { ...@@ -317,4 +317,9 @@ public interface BookService {
@ApiOperation("更新昨日修改过的书刊的标签") @ApiOperation("更新昨日修改过的书刊的标签")
@GetMapping("updateYesterdayBookNewLabel") @GetMapping("updateYesterdayBookNewLabel")
void updateYesterdayBookNewLabel(); void updateYesterdayBookNewLabel();
@GetMapping("getBookFromRedis")
ResponseEntity<ResponseDto<BookDto>> getBookFromRedis(@RequestParam(value = "bookId") Long bookId);
} }
...@@ -77,7 +77,7 @@ public interface AppletRecordBiz { ...@@ -77,7 +77,7 @@ public interface AppletRecordBiz {
*/ */
Map<Long, AppletAppOrProductDTO> getAppOrProductBrowseCount(Integer recordType, List<Long> serveIds); Map<Long, AppletAppOrProductDTO> getAppOrProductBrowseCount(Integer recordType, List<Long> serveIds);
void fillAppletRecord(List<AppletRecordDTO> recordList, Integer bookType); void fillAppletRecord(List<AppletRecordDTO> recordList, Integer bookType, Long wechatUserId);
Object handleAppletRecordTypeCode(Long lastAppletRecordId); Object handleAppletRecordTypeCode(Long lastAppletRecordId);
......
...@@ -148,7 +148,7 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz ...@@ -148,7 +148,7 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz
aggrStatis = appletRecordCHMapper.getAggrStatis(paramMap); aggrStatis = appletRecordCHMapper.getAggrStatis(paramMap);
} }
// 加载其它数据 // 加载其它数据
appletRecordBiz.fillAppletRecord(aggrStatis, YesOrNoNumEnum.NO.getValue()); appletRecordBiz.fillAppletRecord(aggrStatis, YesOrNoNumEnum.NO.getValue(), null);
// 删除部分不存在的数据 // 删除部分不存在的数据
aggrStatis = aggrStatis.stream().filter(x->x.getSourceDelete() == 0).collect(Collectors.toList()); aggrStatis = aggrStatis.stream().filter(x->x.getSourceDelete() == 0).collect(Collectors.toList());
// 设置缓存 // 设置缓存
...@@ -354,7 +354,7 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz ...@@ -354,7 +354,7 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz
//7天内扫码量高的资源的总扫码量 //7天内扫码量高的资源的总扫码量
List<AppletRecordDTO> sourceAggrStatis = appletRecordCHMapper.getAggrStatis4H5(map); List<AppletRecordDTO> sourceAggrStatis = appletRecordCHMapper.getAggrStatis4H5(map);
appletRecordBiz.fillAppletRecord(sourceAggrStatis, YesOrNoNumEnum.NO.getValue()); appletRecordBiz.fillAppletRecord(sourceAggrStatis, YesOrNoNumEnum.NO.getValue(), null);
sourceAggrStatis = sourceAggrStatis.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList()); sourceAggrStatis = sourceAggrStatis.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList());
if (ListUtils.isEmpty(sourceAggrStatis)) { if (ListUtils.isEmpty(sourceAggrStatis)) {
continue; continue;
...@@ -423,7 +423,7 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz ...@@ -423,7 +423,7 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz
if (ListUtils.isEmpty(countList)) { if (ListUtils.isEmpty(countList)) {
return new PageBeanNew(currentPage, numPerPage, 0, Lists.newArrayList()); return new PageBeanNew(currentPage, numPerPage, 0, Lists.newArrayList());
} }
appletRecordBiz.fillAppletRecord(countList, YesOrNoNumEnum.NO.getValue()); appletRecordBiz.fillAppletRecord(countList, YesOrNoNumEnum.NO.getValue(), wechatUserId);
countList = countList.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList()); countList = countList.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList());
dealServeNamePic(countList, isDefaultList, sourceFrom); dealServeNamePic(countList, isDefaultList, sourceFrom);
if (ListUtils.isEmpty(countList)) { if (ListUtils.isEmpty(countList)) {
......
...@@ -50,11 +50,12 @@ import com.pcloud.book.group.tools.SendWeixinRequestTools; ...@@ -50,11 +50,12 @@ 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.skill.biz.PcloudGroupActivityBiz; import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.applet.dto.GroupActivity4AppletDTO; import com.pcloud.book.applet.dto.GroupActivity4AppletDTO;
import com.pcloud.book.skill.remind.RedisTool; import com.pcloud.book.util.common.CommonUtils;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.properties.BookProps;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.mybatis.cache.redis.RedisCache; import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
...@@ -62,7 +63,6 @@ import com.pcloud.common.utils.BeanUtils; ...@@ -62,7 +63,6 @@ import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil; import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.cache.redis.RedisSessionUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum; import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.resourcecenter.product.dto.ProductDto; import com.pcloud.resourcecenter.product.dto.ProductDto;
...@@ -73,8 +73,8 @@ import org.slf4j.Logger; ...@@ -73,8 +73,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
...@@ -137,6 +137,8 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -137,6 +137,8 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
private AppletTrackMapper appletTrackMapper; private AppletTrackMapper appletTrackMapper;
@Autowired @Autowired
private ReaderConsr readerConsr; private ReaderConsr readerConsr;
@Autowired
private BookProps bookProps;
@Override @Override
@ParamLog("通过ID查询单条数据") @ParamLog("通过ID查询单条数据")
...@@ -267,7 +269,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -267,7 +269,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
} }
recordList = listAppletRecord.getRecordList(); recordList = listAppletRecord.getRecordList();
fillAppletRecord(recordList, bookType); fillAppletRecord(recordList, bookType, wechatUserId);
return listAppletRecord; return listAppletRecord;
} }
...@@ -440,7 +442,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -440,7 +442,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
} }
private void fillTypeCode(List<AppletRecordDTO> recordList) { private void fillTypeCode(List<AppletRecordDTO> recordList) {
fillAppletRecord(recordList, YesOrNoNumEnum.YES.getValue()); fillAppletRecord(recordList, YesOrNoNumEnum.YES.getValue(), null);
recordList.stream().forEach(appletRecordDTO -> { recordList.stream().forEach(appletRecordDTO -> {
if (Objects.equals(AppletRecordTypeEnum.NEWS.value, appletRecordDTO.getRecordType()) && null != appletRecordDTO.getAppletNewsDTO()) { if (Objects.equals(AppletRecordTypeEnum.NEWS.value, appletRecordDTO.getRecordType()) && null != appletRecordDTO.getAppletNewsDTO()) {
//填充资讯信息 //填充资讯信息
...@@ -458,7 +460,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -458,7 +460,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
} }
@Override @Override
public void fillAppletRecord(List<AppletRecordDTO> recordList, Integer bookType) { public void fillAppletRecord(List<AppletRecordDTO> recordList, Integer bookType, Long wechatUserId) {
if (ListUtils.isEmpty(recordList)) { if (ListUtils.isEmpty(recordList)) {
return; return;
} }
...@@ -587,7 +589,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -587,7 +589,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
appletRecordDTO.setCoverImg(Optional.ofNullable(bookDtoMap.get(appletRecordDTO.getBookId())).map(BookDto::getCoverImg).orElse("")); appletRecordDTO.setCoverImg(Optional.ofNullable(bookDtoMap.get(appletRecordDTO.getBookId())).map(BookDto::getCoverImg).orElse(""));
} }
//填充应用信息 //填充应用信息
fillApp4Record(appDtoMap, appDtoMappFuture, appletRecordDTO); fillApp4Record(appDtoMap, appDtoMappFuture, appletRecordDTO, wechatUserId);
} else if (Objects.equals(AppletRecordTypeEnum.BOOK.value, appletRecordDTO.getRecordType())) { } else if (Objects.equals(AppletRecordTypeEnum.BOOK.value, appletRecordDTO.getRecordType())) {
//填充书籍信息 //填充书籍信息
fillBook4Record(appletUserBookcaseDTOMap, appletUserBookcaseDTOMapFuture, appletRecordDTO); fillBook4Record(appletUserBookcaseDTOMap, appletUserBookcaseDTOMapFuture, appletRecordDTO);
...@@ -722,7 +724,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -722,7 +724,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
appletRecordDTO.setIsDelete(appletNewsDTO.getIsDelete()); appletRecordDTO.setIsDelete(appletNewsDTO.getIsDelete());
} }
private void fillApp4Record(Map<Long, AppDto> appDtoMap, Future<Map<Long, AppDto>> appDtoMappFuture, AppletRecordDTO appletRecordDTO) { private void fillApp4Record(Map<Long, AppDto> appDtoMap, Future<Map<Long, AppDto>> appDtoMappFuture, AppletRecordDTO appletRecordDTO, Long wechatUserId) {
try { try {
appDtoMap = appDtoMappFuture.get(); appDtoMap = appDtoMappFuture.get();
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
...@@ -764,6 +766,25 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -764,6 +766,25 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
} }
appletAppOrProductDTO.setServeType(AppAndProductTypeEnum.APP.value); appletAppOrProductDTO.setServeType(AppAndProductTypeEnum.APP.value);
appletAppOrProductDTO.setServeId(appletRecordDTO.getFromId()); appletAppOrProductDTO.setServeId(appletRecordDTO.getFromId());
//优化跳转
if (AppTypeEnum.ARTICLE.value.equals(appletAppOrProductDTO.getServeTypeCode())) {
if (appDto != null && !StringUtil.isEmpty(appDto.getTurnUrl())) {
if (appDto.getTurnUrl().contains("5rs.me/") || appDto.getTurnUrl().contains("raysgo.com/") || appDto.getTurnUrl().contains("raysyun.com/")
|| null == wechatUserId) {
appletAppOrProductDTO.setResultUrl(appDto.getTurnUrl());
} else {
Long sceneId = CommonUtils.getSceneId(appletAppOrProductDTO.getResultUrl());
if (null != sceneId) {
//外链跳转到指定中间页
String jumpUrl = BookProps.getProductDomain() + "transfer?offId" + accountSettingDto.getAccountSettingId() + "&appId=" + appDto.getAppId() + "&url=" +
URLEncoder.encode(appDto.getTurnUrl()) + "&sceneId=" + sceneId + "&wechatUserId=" + wechatUserId;
appletAppOrProductDTO.setResultUrl(jumpUrl);
}
}
}
}
appletRecordDTO.setAppletAppOrProductDTO(appletAppOrProductDTO); appletRecordDTO.setAppletAppOrProductDTO(appletAppOrProductDTO);
} }
...@@ -880,7 +901,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -880,7 +901,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
} }
private void fillTypeCode4List(List<AppletRecordDTO> recordList) { private void fillTypeCode4List(List<AppletRecordDTO> recordList) {
fillAppletRecord(recordList, YesOrNoNumEnum.YES.getValue()); fillAppletRecord(recordList, YesOrNoNumEnum.YES.getValue(), null);
recordList.stream().forEach(appletRecordDTO -> { recordList.stream().forEach(appletRecordDTO -> {
if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value, appletRecordDTO.getRecordType()) && null != appletRecordDTO.getAppletAppOrProductDTO()) { if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value, appletRecordDTO.getRecordType()) && null != appletRecordDTO.getAppletAppOrProductDTO()) {
// 填充作品信息 // 填充作品信息
...@@ -909,7 +930,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz { ...@@ -909,7 +930,7 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
if (ListUtils.isEmpty(recordList)) { if (ListUtils.isEmpty(recordList)) {
return new AppletRecordDTO(); return new AppletRecordDTO();
} }
fillAppletRecord(recordList, YesOrNoNumEnum.NO.getValue()); fillAppletRecord(recordList, YesOrNoNumEnum.NO.getValue(), wechatUserId);
recordList = recordList.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList()); recordList = recordList.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList());
if (ListUtils.isEmpty(recordList)) { if (ListUtils.isEmpty(recordList)) {
return new AppletRecordDTO(); return new AppletRecordDTO();
......
...@@ -503,4 +503,6 @@ public interface BookAdviserBiz { ...@@ -503,4 +503,6 @@ public interface BookAdviserBiz {
* 获取编辑的立项书数量和非立项书数量 * 获取编辑的立项书数量和非立项书数量
*/ */
Map<Long, AdviserBookStatisDto> getAdviserBookStatis(AdviserBookStatisRequestDto requestDto); Map<Long, AdviserBookStatisDto> getAdviserBookStatis(AdviserBookStatisRequestDto requestDto);
Integer getBookIsOpenCatalog(Long bookId, Long channelId, Long adviserId);
} }
...@@ -826,4 +826,11 @@ public interface BookBiz { ...@@ -826,4 +826,11 @@ public interface BookBiz {
* 通过isbn,书名等信息去es库里面匹配图书封面 * 通过isbn,书名等信息去es库里面匹配图书封面
*/ */
List<String> listBookCover(String isbn, String bookName, String author, String publish); List<String> listBookCover(String isbn, String bookName, String author, String publish);
/**
* 从缓存中获取基本信息
* @param bookId
* @return
*/
BookDto getBookFromRedis(Long bookId);
} }
...@@ -3544,4 +3544,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -3544,4 +3544,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
} }
return adviserBookStatisList.stream().collect(Collectors.toMap(x->x.getAdviserId(), Function.identity(), (v1, v2)->v1)); return adviserBookStatisList.stream().collect(Collectors.toMap(x->x.getAdviserId(), Function.identity(), (v1, v2)->v1));
} }
@Override
public Integer getBookIsOpenCatalog(Long bookId, Long channelId, Long adviserId) {
Integer isOpenCatalog = bookAdviserDao.getBookIsOpenCatalog(bookId,channelId,adviserId);
return null == isOpenCatalog?0:isOpenCatalog;
}
} }
...@@ -2613,11 +2613,6 @@ public class BookBizImpl implements BookBiz { ...@@ -2613,11 +2613,6 @@ public class BookBizImpl implements BookBiz {
if (bookDto == null) { if (bookDto == null) {
return new BookDto(); return new BookDto();
} }
Integer joinGroupType = bookGroupDao.getJoinGroupType(paramMap);
if (JoinGroupTypeEnum.XIAORUI.getCode().equals(joinGroupType)) {
Long classifyId = bookRaysClassifyDao.getClassifyIdByBookTemplateId(bookDto.getTempletId());
bookDto.setClassifyId(null != classifyId ? classifyId.intValue() : null);
}
// 填充分类 // 填充分类
CompletableFuture<Void> fillClassifyFuture = CompletableFuture.runAsync(() -> { CompletableFuture<Void> fillClassifyFuture = CompletableFuture.runAsync(() -> {
...@@ -4668,4 +4663,16 @@ public class BookBizImpl implements BookBiz { ...@@ -4668,4 +4663,16 @@ public class BookBizImpl implements BookBiz {
dto.setPublish(publish); dto.setPublish(publish);
return bookElasticSearchConsr.searchBookExtendImg(dto); return bookElasticSearchConsr.searchBookExtendImg(dto);
} }
@Override
public BookDto getBookFromRedis(Long bookId) {
BookDto bookDto = bookCache.getBookFromRedis(bookId);
if (null == bookDto) {
bookDto = bookDao.getBaseById(bookId);
if (null != bookDto) {
bookCache.setBookInfoToRedis(bookDto);
}
}
return bookDto;
}
} }
...@@ -17,6 +17,8 @@ import java.util.Objects; ...@@ -17,6 +17,8 @@ import java.util.Objects;
@Component("bookCache") @Component("bookCache")
public class BookCache { public class BookCache {
private static String BOOK_BASE_INFO_CACHE = "book:baseinfo:cache";
public void clearCache4BookBaseInfo(Long bookId){ public void clearCache4BookBaseInfo(Long bookId){
if (Objects.nonNull(bookId)){ if (Objects.nonNull(bookId)){
StringBuffer key = new StringBuffer(BookConstant.BOOK_CACHE); StringBuffer key = new StringBuffer(BookConstant.BOOK_CACHE);
...@@ -92,6 +94,7 @@ public class BookCache { ...@@ -92,6 +94,7 @@ public class BookCache {
} }
JedisClusterUtils.del(key.toString()); JedisClusterUtils.del(key.toString());
JedisClusterUtils.del(isbnKey.toString()); JedisClusterUtils.del(isbnKey.toString());
JedisClusterUtils.hdel(BOOK_BASE_INFO_CACHE, bookId.toString());
} }
/** /**
...@@ -144,5 +147,20 @@ public class BookCache { ...@@ -144,5 +147,20 @@ public class BookCache {
return JedisClusterUtils.decr(key); return JedisClusterUtils.decr(key);
} }
public BookDto getBookFromRedis(Long bookId) {
if (null == bookId) {
return null;
}
BookDto bookDto = JedisClusterUtils.hgetJson2Class(BOOK_BASE_INFO_CACHE, bookId.toString(), BookDto.class);
return bookDto;
}
public void setBookInfoToRedis(BookDto bookDto) {
if (null == bookDto || null == bookDto.getBookId()) {
return;
}
JedisClusterUtils.hset2Json(BOOK_BASE_INFO_CACHE, bookDto.getBookId().toString(), bookDto);
}
} }
...@@ -357,4 +357,6 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> { ...@@ -357,4 +357,6 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> {
void batchUpdateIsPrint(List<BookRequestVO> bookRequestVOS); void batchUpdateIsPrint(List<BookRequestVO> bookRequestVOS);
List<AdviserBookStatisDto> getAdviserBookStatis(AdviserBookStatisRequestDto requestDto); List<AdviserBookStatisDto> getAdviserBookStatis(AdviserBookStatisRequestDto requestDto);
Integer getBookIsOpenCatalog(Long bookId, Long channelId, Long adviserId);
} }
...@@ -547,4 +547,13 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book ...@@ -547,4 +547,13 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book
public List<AdviserBookStatisDto> getAdviserBookStatis(AdviserBookStatisRequestDto requestDto) { public List<AdviserBookStatisDto> getAdviserBookStatis(AdviserBookStatisRequestDto requestDto) {
return getSessionTemplate().selectList(getStatement("getAdviserBookStatis"), requestDto); return getSessionTemplate().selectList(getStatement("getAdviserBookStatis"), requestDto);
} }
@Override
public Integer getBookIsOpenCatalog(Long bookId, Long channelId, Long adviserId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookIsOpenCatalog"), paramMap);
}
} }
...@@ -230,11 +230,7 @@ public class BookAdviserServiceImpl implements BookAdviserService { ...@@ -230,11 +230,7 @@ public class BookAdviserServiceImpl implements BookAdviserService {
public ResponseEntity<ResponseDto<Integer>> getBookIsOpenCatalog(@RequestParam("bookId") Long bookId, public ResponseEntity<ResponseDto<Integer>> getBookIsOpenCatalog(@RequestParam("bookId") Long bookId,
@RequestParam("channelId") Long channelId, @RequestParam("channelId") Long channelId,
@RequestParam("adviserId") Long adviserId) throws BizException { @RequestParam("adviserId") Long adviserId) throws BizException {
Integer isOpenCatalog = 0; Integer isOpenCatalog = bookAdviserBiz.getBookIsOpenCatalog(bookId, channelId, adviserId);
BookAdviserDto base = bookAdviserBiz.getBase(bookId, channelId, adviserId);
if (null != base) {
isOpenCatalog = base.getIsOpenCatalog();
}
return ResponseHandleUtil.toResponse(isOpenCatalog); return ResponseHandleUtil.toResponse(isOpenCatalog);
} }
......
...@@ -297,4 +297,12 @@ public class BookServiceImpl implements BookService { ...@@ -297,4 +297,12 @@ public class BookServiceImpl implements BookService {
public void updateYesterdayBookNewLabel() { public void updateYesterdayBookNewLabel() {
ThreadPoolUtils.OTHER_THREAD_POOL.execute(()->bookLabelBiz.updateYesterdayBookNewLabel()); ThreadPoolUtils.OTHER_THREAD_POOL.execute(()->bookLabelBiz.updateYesterdayBookNewLabel());
} }
@Override
@GetMapping("getBookFromRedis")
public ResponseEntity<ResponseDto<BookDto>> getBookFromRedis(@RequestParam("bookId") Long bookId) {
return ResponseHandleUtil.toResponse(bookBiz.getBookFromRedis(bookId));
}
} }
...@@ -306,4 +306,16 @@ public class AppConsr { ...@@ -306,4 +306,16 @@ public class AppConsr {
} }
return null; return null;
} }
@ParamLog(description = "获取应用基本信息与价格", isAfterReturn = false)
public Map<Long, AppDto> mapBaseWithPriceByIds(List<Long> appIds){
if(ListUtils.isEmpty(appIds)) return null;
try{
Map<Long, AppDto> appBaseStatus = ResponseHandleUtil.parseMap(appService.mapBaseWithPriceByIds(appIds), Long.class, AppDto.class);
return appBaseStatus;
}catch (Exception e){
LOGGER.error("获取应用基本信息与价格失败"+ e.getMessage(), e);
}
return null;
}
} }
...@@ -186,6 +186,52 @@ public class ProductConsr { ...@@ -186,6 +186,52 @@ public class ProductConsr {
} }
/**
* 资源中心拉取商品最基本信息
*/
public Map<Long, ProductDto> getProductBasesByIds4Book(List<Long> productIds) throws BizException {
LOGGER.info("【资源中心(消)】获取商品最最基本信息4Book,<START>.[productIds]=" + productIds + "]");
if (productIds == null || productIds.isEmpty()) {
return null;
}
Map<Long, ProductDto> productDtoMap = new HashMap<>();
productIds = productIds.stream().distinct().collect(Collectors.toList());
Integer size = productIds.size();
if (productIds.size() > 1000) {
Integer[] queryCountArray = {0, 1, 2, 3};
Integer queryCount = 4;
//并发查询
List<Long> finalProductIds = productIds;
Map<Long, ProductDto> finalProductDtoMap = productDtoMap;
CompletableFuture[] completableFutures = Arrays.stream(queryCountArray).
map(x -> CompletableFuture.supplyAsync(() -> {
Integer startIndex = size / queryCount * x;
Integer endIndex = size / queryCount * (x + 1);
List<Long> queryList = finalProductIds.subList(startIndex, endIndex);
Map<Long, ProductDto> productMap = ResponseHandleUtil.parseMapResponse(productService.getProductBasesByIds4Book(queryList), Long.class,
ProductDto.class);
return productMap;
}, ThreadPoolUtils.EXPORT_THREAD_POOL).whenComplete(((productMap, throwable) -> {
finalProductDtoMap.putAll(productMap);
}))).toArray(CompletableFuture[]::new);
try {
CompletableFuture.allOf(completableFutures).get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.warn("[getProductBasesByIds4Book] 填充信息失败,err:{}", e.getMessage(), e);
}
return finalProductDtoMap;
} else {
try {
productDtoMap = ResponseHandleUtil.parseMapResponse(productService.getProductBasesByIds4Book(productIds), Long.class, ProductDto.class);
} catch (BizException e) {
LOGGER.warn("调用:productService.getProductBasesByIds4Book报错", e.getMessage(), e);
}
return productDtoMap;
}
}
/** /**
* 资源中心拉取商品基本信息 * 资源中心拉取商品基本信息
*/ */
......
...@@ -371,4 +371,40 @@ public class TradeConsr { ...@@ -371,4 +371,40 @@ public class TradeConsr {
} }
return null; return null;
} }
/**
* 应用作品购买状态
*/
public Map<String, Boolean> mapAppProductBuyStateOpt(Long wechatUserId, List<Long> appIds, List<Long> productIds) {
if (null == wechatUserId || (ListUtils.isEmpty(appIds) && ListUtils.isEmpty(productIds))) {
return new HashMap<>();
}
OrderSearchDto orderSearchDto = new OrderSearchDto();
orderSearchDto.setAppIds(appIds);
orderSearchDto.setProductIds(productIds);
orderSearchDto.setWechatUserId(wechatUserId);
try {
return ResponseHandleUtil.parseMap(orderFormService.mapAppProductBuyStateOpt(orderSearchDto),String.class,Boolean.class);
} catch (Exception e) {
LOGGER.error("调用orderFormService.mapAppProductBuyStateOpt失败"+e.getMessage(), e);
}
return null;
}
/**
* 课程单节课购买状态
*/
public Map<Long, Boolean> mapCourseProductBuyStateOpt(Long wechatUserId, List<Long> productIds) {
if (null == wechatUserId || ListUtils.isEmpty(productIds)) {
return new HashMap<>();
}
OrderSearchDto orderSearchDto = new OrderSearchDto();
orderSearchDto.setProductIds(productIds);
orderSearchDto.setWechatUserId(wechatUserId);
try {
return ResponseHandleUtil.parseMap(orderFormService.mapCourseProductBuyStateOpt(orderSearchDto),Long.class,Boolean.class);
} catch (Exception e) {
LOGGER.error("调用orderFormService.mapCourseProductBuyStateOpt失败"+e.getMessage(), e);
}
return null;
}
} }
...@@ -2,7 +2,6 @@ package com.pcloud.book.copyright.biz.impl; ...@@ -2,7 +2,6 @@ package com.pcloud.book.copyright.biz.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr; import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.live.LiveCons; import com.pcloud.book.consumer.live.LiveCons;
...@@ -32,10 +31,8 @@ import com.pcloud.common.utils.DateUtils; ...@@ -32,10 +31,8 @@ import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils; 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.cookie.Cookie; import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.readercenter.wechat.entity.WechatUser; import com.pcloud.readercenter.wechat.entity.WechatUser;
import com.pcloud.resourcecenter.base.constants.ResourceRedisCons; import com.pcloud.resourcecenter.base.constants.ResourceRedisCons;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -191,41 +188,24 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz { ...@@ -191,41 +188,24 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
@Override @Override
public Boolean checkIsHaveAuthWithServer(String userInfo, Long serverId, String serverType) { public Boolean checkIsHaveAuthWithServer(String userInfo, Long serverId, String serverType) {
// 如果包含超级作者资源, 则直接返回 // 如果包含超级作者资源, 则直接返回
long t1 = System.currentTimeMillis(); if (checkIsSuperProduct(serverId)) {
if(checkIsSuperProduct(serverId)){
long t2 = System.currentTimeMillis();
System.out.println("第0阶段耗时=" + (t2 - t1));
return false; return false;
} }
long t2 = System.currentTimeMillis();
System.out.println("第1阶段耗时=" + (t2 - t1));
// 否则查询授权关系 // 否则查询授权关系
Long bookId = qrcodeSceneConsr.getBookId4SceneId(Cookie.getId(userInfo,Cookie._SCENE_ID)); Long bookId = qrcodeSceneConsr.getBookId4SceneId(Cookie.getId(userInfo, Cookie._SCENE_ID));
long t3 = System.currentTimeMillis();
System.out.println("第2阶段耗时=" + (t3 - t2));
Long channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID); Long channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID);
Long adviserId = Cookie.getId(userInfo,Cookie._ADVISER_ID); Long adviserId = Cookie.getId(userInfo, Cookie._ADVISER_ID);
Long wecharUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wecharUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if("live".equalsIgnoreCase(serverType)){ if ("live".equalsIgnoreCase(serverType)) {
List<Long> id = new ArrayList<>(1); List<Long> id = new ArrayList<>(1);
id.add(serverId); id.add(serverId);
Map<Long, Boolean> map = liveCons.checkIsSuperMerchant(id); Map<Long, Boolean> map = liveCons.checkIsSuperMerchant(id);
if(map != null && Boolean.TRUE.equals(map.get(serverId))){ if (map != null && Boolean.TRUE.equals(map.get(serverId))) {
return false; return false;
} }
else{
return checkIsHaveAuthWithServer(bookId,channelId,adviserId,wecharUserId,serverId);
}
}
else{
Boolean aBoolean = checkIsHaveAuthWithServer(bookId, channelId, adviserId, wecharUserId, serverId);
long t4 = System.currentTimeMillis();
System.out.println("第3阶段耗时=" + (t4 - t3));
return aBoolean;
} }
return checkIsHaveAuthWithServer(bookId, channelId, adviserId, wecharUserId, serverId);
} }
private Boolean checkIsHaveAuthWithServer(Long bookId, Long channelId, Long adviserId, Long wecharUserId, Long serverId) { private Boolean checkIsHaveAuthWithServer(Long bookId, Long channelId, Long adviserId, Long wecharUserId, Long serverId) {
......
...@@ -531,9 +531,16 @@ public interface ResourcePageBiz { ...@@ -531,9 +531,16 @@ public interface ResourcePageBiz {
* @param channelId * @param channelId
* @param enableAdverting * @param enableAdverting
* @param navigationId * @param navigationId
* @param officialAccountsId
* @return * @return
*/ */
List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId); List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId, Long officialAccountsId);
List<Integer> getColumnTypeByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId);
//优化 此处把模块分开调接口 columnType
List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4WechatV2(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId,
Integer enableAdverting, Long navigationId,Integer columnType, Long officialAccountsId);
/** /**
* 保存分享配置 * 保存分享配置
......
...@@ -8,7 +8,6 @@ import com.pcloud.advertising.advertising.dto.AdvertisingSpaceDTO; ...@@ -8,7 +8,6 @@ import com.pcloud.advertising.advertising.dto.AdvertisingSpaceDTO;
import com.pcloud.advertising.advertising.dto.AdvertisingSpaceItemDTO; import com.pcloud.advertising.advertising.dto.AdvertisingSpaceItemDTO;
import com.pcloud.analysisengine.browse.dto.BrowseRecordStatisticDTO; import com.pcloud.analysisengine.browse.dto.BrowseRecordStatisticDTO;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.app.MapBaseStatusDTO;
import com.pcloud.book.applet.biz.AppletBooklistBiz; import com.pcloud.book.applet.biz.AppletBooklistBiz;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz; import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.applet.biz.AppletRecordAggrStatisBiz; import com.pcloud.book.applet.biz.AppletRecordAggrStatisBiz;
...@@ -129,6 +128,7 @@ import com.pcloud.common.core.constant.AdviserTaskConstants; ...@@ -129,6 +128,7 @@ import com.pcloud.common.core.constant.AdviserTaskConstants;
import com.pcloud.common.core.constant.MQTopicProducer; import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.core.constant.ProductTypeConstant; import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.core.constant.SystemCode; import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
...@@ -163,6 +163,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -163,6 +163,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
...@@ -174,13 +175,13 @@ import java.util.List; ...@@ -174,13 +175,13 @@ 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.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
...@@ -1026,10 +1027,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1026,10 +1027,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePageId = pageId; resourcePageId = pageId;
navigationId = naviId; navigationId = naviId;
}*/ }*/
long t1 = System.currentTimeMillis(); List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId,null);
List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId);
long t2 = System.currentTimeMillis();
System.out.println("第一步耗时="+(t2 - t1));
if (CollUtil.isNotEmpty(serveVOS)) { if (CollUtil.isNotEmpty(serveVOS)) {
List<ResourcePageItemVO> itemVOList; List<ResourcePageItemVO> itemVOList;
if (null != wechatUserId) { if (null != wechatUserId) {
...@@ -1037,13 +1035,9 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1037,13 +1035,9 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} else { } else {
itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, null); itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, null);
} }
long t3 = System.currentTimeMillis();
System.out.println("第二步耗时="+(t3 - t2));
if (CollUtil.isNotEmpty(itemVOList)) { if (CollUtil.isNotEmpty(itemVOList)) {
//二维码类型 //二维码类型
fillQrcodeType(resourcePageId, itemVOList); fillQrcodeType(resourcePageId, itemVOList);
long t4 = System.currentTimeMillis();
System.out.println("第三步耗时="+(t4 - t3));
Map<String, List<ResourcePageItemVO>> listMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getServeType)); Map<String, List<ResourcePageItemVO>> listMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getServeType));
itemVOList = new ArrayList<>(); itemVOList = new ArrayList<>();
//应用和作品提出来一起查 //应用和作品提出来一起查
...@@ -1057,14 +1051,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1057,14 +1051,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
this.fillResourceByType(entry.getValue(), wechatUserId, entry.getKey()); this.fillResourceByType(entry.getValue(), wechatUserId, entry.getKey());
itemVOList.addAll(entry.getValue()); itemVOList.addAll(entry.getValue());
} }
long t6 = System.currentTimeMillis();
System.out.println("第四步-1耗时="+(t6 - t4));
if(CollUtil.isNotEmpty(itemAppAndProductVOList)){ if(CollUtil.isNotEmpty(itemAppAndProductVOList)){
fillAppProductServe(itemAppAndProductVOList, wechatUserId); fillAppProductServe(itemAppAndProductVOList, wechatUserId);
itemVOList.addAll(itemAppAndProductVOList); itemVOList.addAll(itemAppAndProductVOList);
} }
long t5 = System.currentTimeMillis();
System.out.println("第四步-2耗时="+(t5 - t6));
itemVOList.sort(Comparator.comparing(ResourcePageItemVO::getId)); itemVOList.sort(Comparator.comparing(ResourcePageItemVO::getId));
Map<Long, List<ResourcePageItemVO>> columnMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getResourcePageColumnId)); Map<Long, List<ResourcePageItemVO>> columnMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getResourcePageColumnId));
List<ResourceColumnAndServeVO> removeColumns = new ArrayList<>(); List<ResourceColumnAndServeVO> removeColumns = new ArrayList<>();
...@@ -1086,8 +1076,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1086,8 +1076,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
columnAndServeVO.setLogoUrl(itemVOS.get(0).getLogoUrl()); columnAndServeVO.setLogoUrl(itemVOS.get(0).getLogoUrl());
} }
} }
long t7 = System.currentTimeMillis();
System.out.println("第五步耗时="+(t7 - t5));
if (!ListUtils.isEmpty(removeColumns)) { if (!ListUtils.isEmpty(removeColumns)) {
serveVOS.removeAll(removeColumns); serveVOS.removeAll(removeColumns);
} }
...@@ -1097,10 +1085,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1097,10 +1085,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
serveVOS = CollUtil.toList(); serveVOS = CollUtil.toList();
} }
// 填充广告 // 填充广告
long t8 = System.currentTimeMillis();
this.fillAdvertising(serveVOS, bookId, adviserId, channelId, enableAdverting); this.fillAdvertising(serveVOS, bookId, adviserId, channelId, enableAdverting);
long t9 = System.currentTimeMillis();
System.out.println("第六步耗时="+(t9 - t8));
return serveVOS; return serveVOS;
} }
...@@ -1393,22 +1378,22 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1393,22 +1378,22 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
Map<Long, AppDto> appDtoMap= new HashMap<>(); Map<Long, AppDto> appDtoMap= new HashMap<>();
Map<Long, ProductDto> productDtoMap = new HashMap<>(); Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, MapBaseStatusDTO> appPriceMap = new HashMap<>(); // Map<Long, MapBaseStatusDTO> appPriceMap = new HashMap<>();
Future<Map<Long, AppDto>>appMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{ Future<Map<Long, AppDto>>appMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return appConsr.mapBaseByIds(appIds); return appConsr.mapBaseWithPriceByIds(appIds);
}); });
Future<Map<Long, ProductDto>>productMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{ Future<Map<Long, ProductDto>>productMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return productConsr.getProductBasesByIds(productIds); return productConsr.getProductBasesByIds4Book(productIds);
}); });
Future<Map<Long, MapBaseStatusDTO>> appPriceMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{ /* Future<Map<Long, MapBaseStatusDTO>> appPriceMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return appConsr.mapBaseStatusById(appIds); return appConsr.mapBaseStatusById(appIds);
}); });*/
Map<Long, AccountSettingDto> channelAccountSettingDtoMap = new HashMap<>(); Map<Long, AccountSettingDto> channelAccountSettingDtoMap = new HashMap<>();
Map<Long, AccountSetting> accountSettingMap = new HashMap<>(); Map<Long, AccountSetting> accountSettingMap = new HashMap<>();
//应用配置公众号工具 //应用配置公众号工具
Map<Long, Long> appOfficialAccountToolMap = new HashMap<>(); Map<Long, Long> appOfficialAccountToolMap = new HashMap<>();
//是否购买 //是否购买
Map<Long, Boolean> buyStateMap = new HashMap<>(); Map<String, Boolean> buyStateMap = new HashMap<>();
//课程是否购买(单节/整套) //课程是否购买(单节/整套)
Map<Long, Boolean> courseBuyStateMap = new HashMap<>(); Map<Long, Boolean> courseBuyStateMap = new HashMap<>();
if (null != wechatUserId) { if (null != wechatUserId) {
...@@ -1419,11 +1404,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1419,11 +1404,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
Future<Map<Long, AccountSettingDto>> channelAccountSettingDtoSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{ Future<Map<Long, AccountSettingDto>> channelAccountSettingDtoSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return channelConsr.listWechatAccountInfo(channelIds); return channelConsr.listWechatAccountInfo(channelIds);
}); });
Future<Map<Long, Boolean>> buyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{ Future<Map<String, Boolean>> buyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return tradeConsr.mapAppProductBuyState(wechatUserId, appIds, nonCourseProductIds); return tradeConsr.mapAppProductBuyStateOpt(wechatUserId, appIds, nonCourseProductIds);
}); });
Future<Map<Long, Boolean>> courseBuyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{ Future<Map<Long, Boolean>> courseBuyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return tradeConsr.mapCourseProductBuyState(wechatUserId, courseProductIds); return tradeConsr.mapCourseProductBuyStateOpt(wechatUserId, courseProductIds);
}); });
try { try {
appOfficialAccountToolMap = appOfficialAccountToolSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS); appOfficialAccountToolMap = appOfficialAccountToolSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
...@@ -1456,13 +1441,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1456,13 +1441,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} catch (InterruptedException | ExecutionException | TimeoutException e) { } catch (InterruptedException | ExecutionException | TimeoutException e) {
log.warn("调用资源中心获取商品信息错误:"+e.getMessage(), e); log.warn("调用资源中心获取商品信息错误:"+e.getMessage(), e);
} }
try { /* try {
appPriceMap = appPriceMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS); appPriceMap = appPriceMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) { } catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用应用中心获取应用价格信息错误:"+e.getMessage(), e); log.error("调用应用中心获取应用价格信息错误:"+e.getMessage(), e);
} }*/
long t2 = System.currentTimeMillis(); Map<Long,Long> defaultChannelIdMap=new HashMap<>();
System.out.println("第四-2-1步耗时="+(t2 - t1));
for (ResourcePageItemVO itemVO : itemVOS) { for (ResourcePageItemVO itemVO : itemVOS) {
Long serveId = itemVO.getServeId(); Long serveId = itemVO.getServeId();
String serveType = itemVO.getServeType(); String serveType = itemVO.getServeType();
...@@ -1474,12 +1458,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1474,12 +1458,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
itemVO.setTypeCode(appDto.getTypeCode()); itemVO.setTypeCode(appDto.getTypeCode());
itemVO.setTypeName(appDto.getTypeName()); itemVO.setTypeName(appDto.getTypeName());
itemVO.setTransverseImg(appDto.getTransverseImg()); itemVO.setTransverseImg(appDto.getTransverseImg());
itemVO.setPrice(appDto.getPrice()); itemVO.setPrice(null ==appDto.getRetailPrice() ? Double.valueOf(0d) : appDto.getRetailPrice().doubleValue());
itemVO.setHasThirdLink(!StringUtil.isEmpty(appDto.getTurnUrl())?true:false); itemVO.setHasThirdLink(!StringUtil.isEmpty(appDto.getTurnUrl())?true:false);
if (!MapUtils.isEmpty(appPriceMap) && appPriceMap.containsKey(serveId)) { /* if (!MapUtils.isEmpty(appPriceMap) && appPriceMap.containsKey(serveId)) {
BigDecimal price = appPriceMap.get(serveId).getRetailPrice(); BigDecimal price = appPriceMap.get(serveId).getRetailPrice();
itemVO.setPrice(null == price?Double.valueOf(0d):price.doubleValue()); itemVO.setPrice(null == price?Double.valueOf(0d):price.doubleValue());
} }*/
//标记应用共享状态 //标记应用共享状态
itemVO.setAppCreateUser(appDto.getCreatedUser()); itemVO.setAppCreateUser(appDto.getCreatedUser());
itemVO.setShareState(appDto.getShareState()); itemVO.setShareState(appDto.getShareState());
...@@ -1507,14 +1491,34 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1507,14 +1491,34 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
Long channelId = getChannelIdFromUrl(itemVO.getLinkUrl()); Long channelId = getChannelIdFromUrl(itemVO.getLinkUrl());
if (null == channelId) { if (null == channelId) {
log.info(itemVO.getServeName() + "无运营平台, serveId=" + itemVO.getServeId()); log.info(itemVO.getServeName() + "无运营平台, serveId=" + itemVO.getServeId());
channelId = adviserConsr.getDefaultChannel(adviserId); if(defaultChannelIdMap.containsKey(adviserId)){
channelId = defaultChannelIdMap.get(adviserId);
if(null!=channelId){
channelId = adviserConsr.getDefaultChannel(adviserId);
}
}else {
channelId = adviserConsr.getDefaultChannel(adviserId);
if (null != channelId) {
defaultChannelIdMap.put(adviserId, channelId);
}
}
} }
itemVO.setChannelId(channelId); itemVO.setChannelId(channelId);
if (null != wechatUserId) { if (null != wechatUserId) {
setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap); setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap);
itemVO.setBuyState(false); itemVO.setBuyState(false);
if (!MapUtils.isEmpty(buyStateMap) && buyStateMap.containsKey(serveId)) { if (!MapUtils.isEmpty(buyStateMap)) {
itemVO.setBuyState(buyStateMap.get(serveId)); if(ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)){
String key="PRODUCT"+serveId;
if(buyStateMap.containsKey(key)){
itemVO.setBuyState(buyStateMap.get(key));
}
}else if(ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(serveType)){
String key="APP"+serveId;
if(buyStateMap.containsKey(key)){
itemVO.setBuyState(buyStateMap.get(key));
}
}
} }
if (!MapUtils.isEmpty(courseBuyStateMap) && courseBuyStateMap.containsKey(serveId) if (!MapUtils.isEmpty(courseBuyStateMap) && courseBuyStateMap.containsKey(serveId)
&& ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(itemVO.getServeType())) { && ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(itemVO.getServeType())) {
...@@ -1522,8 +1526,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1522,8 +1526,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
} }
} }
long t3 = System.currentTimeMillis();
System.out.println("第四-2-2步耗时="+(t3 - t2));
} }
/** /**
...@@ -1944,45 +1946,67 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1944,45 +1946,67 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
if (null == bookGroupId && null == sceneId) { if (null == bookGroupId && null == sceneId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数缺失"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数缺失");
} }
ResourcePage bySceneId = null; Long bookId = null;
if (null != bookGroupId) { if (null != bookGroupId) {
bySceneId = resourcePageDao.getByBookGroupId(bookGroupId); bookId = resourcePageDao.getBookIdByBookGroupId(bookGroupId);
} else if (null != sceneId) { } else if (null != sceneId) {
bySceneId = resourcePageDao.getBySceneId(sceneId); bookId = resourcePageDao.getBookIdBySceneId(sceneId);
} }
//上邮临时处理方案 //上邮临时处理方案
if (null != bySceneId && null != bySceneId.getBookId() && null != JedisClusterUtils.hget(nftReleaseLockKey, bySceneId.getBookId().toString())) { if (null != bookId && null != JedisClusterUtils.hget(nftReleaseLockKey, bookId.toString())) {
if (null != bookGroupId) { if (null != bookGroupId) {
bookGroupId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bySceneId.getBookId().toString(), NftBookState.class).getNftBookGroupId(); bookGroupId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bookId.toString(), NftBookState.class).getNftBookGroupId();
} else if (null != sceneId) { } else if (null != sceneId) {
sceneId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bySceneId.getBookId().toString(), NftBookState.class).getNftSceneId();; sceneId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bookId.toString(), NftBookState.class).getNftSceneId();;
} }
} }
ResourcePageVO resourcePageVO = new ResourcePageVO(); ResourcePageVO pageVO = new ResourcePageVO();
if (null != bookGroupId) { if (null != bookGroupId) {
resourcePageVO = getResourcePageByBookGroupId4Wechat(bookGroupId, wechatUserId); pageVO = getResourcePageByBookGroupId4Wechat(bookGroupId, wechatUserId);
} else if (null != sceneId) { } else if (null != sceneId) {
resourcePageVO = getResourcePageBySceneId4Wechat(sceneId); pageVO = getResourcePageBySceneId4Wechat(sceneId);
} }
ResourcePageVO resourcePageVO = pageVO;
if (null != resourcePageVO.getId()) { if (null != resourcePageVO.getId()) {
//查收藏状态 //查收藏状态
ResourcePageCollect collect = resourcePageCollectDao.getCollectRecordByUser(wechatUserId, resourcePageVO.getId()); Integer collectState = resourcePageCollectDao.getCollectStateByUser(wechatUserId, resourcePageVO.getId());
resourcePageVO.setCollectState(null == collect ? 0 : 1); resourcePageVO.setCollectState(null == collectState ? 0 : 1);
// 实体店铺
resourcePageVO.setResourcePageBookstoreList(resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.BOOKSTORE));
// 优惠券
resourcePageVO.setResourcePageCouponList(resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.COUPONS));
} else {
resourcePageVO.setResourcePageBookstoreList(CollUtil.toList());
resourcePageVO.setResourcePageCouponList(CollUtil.toList());
}
if (null != resourcePageVO.getAdviserId()) {
resourcePageVO.setPushTextOpenStatus(qrcodeSceneConsr.getPushTextOpenStatus(resourcePageVO.getAdviserId()));
} }
// 实体店铺
CompletableFuture<List<ResourcePageBookstoreVO>> storeFuture = CompletableFuture.supplyAsync(() -> {
return resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.BOOKSTORE);
});
// 优惠券
CompletableFuture<List<ResourcePageBookstoreVO>> couponFuture = CompletableFuture.supplyAsync(() -> {
return resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.COUPONS);
});
//加载导航 //加载导航
this.fillNavigation(resourcePageVO, wechatUserId); CompletableFuture<Void> navigationFuture = CompletableFuture.runAsync(() -> {
this.fillNavigation(resourcePageVO, wechatUserId);
});
//加载企业微信落地页信息 //加载企业微信落地页信息
this.fillWxworkPage(resourcePageVO); CompletableFuture<Void> wxworkPageFuture = CompletableFuture.runAsync(() -> {
this.fillWxworkPage(resourcePageVO);
});
//扫码推送二维码名称权限状态
CompletableFuture<Integer> pushTextFuture = CompletableFuture.supplyAsync(() -> {
return qrcodeSceneConsr.getPushTextOpenStatus(resourcePageVO.getAdviserId());
});
CompletableFuture.allOf(storeFuture, couponFuture, navigationFuture, wxworkPageFuture, pushTextFuture).join();
List<ResourcePageBookstoreVO> bookstoreVOS = new ArrayList<>();
List<ResourcePageBookstoreVO> couponVOS = new ArrayList<>();
Integer pushTextPermission = 0;
try {
bookstoreVOS = storeFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
couponVOS = couponFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
pushTextPermission = pushTextFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("查询实体店铺/优惠券失败"+e.getMessage(),e);
}
resourcePageVO.setResourcePageBookstoreList(bookstoreVOS);
resourcePageVO.setResourcePageCouponList(couponVOS);
resourcePageVO.setPushTextOpenStatus(pushTextPermission);
return resourcePageVO; return resourcePageVO;
} }
...@@ -2016,8 +2040,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -2016,8 +2040,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
resourcePageVO.setLastReadTime(DateUtils.formatDate(new Date())); resourcePageVO.setLastReadTime(DateUtils.formatDate(new Date()));
//小程序 //小程序
BookAppletScene bookAppletScene = bookAppletSceneDao.getByBookGroupId(bookGroupId); String appletId = bookAppletSceneDao.getAppletIdByBookGroupId(bookGroupId);
resourcePageVO.setAppletId(null == bookAppletScene ? null : bookAppletScene.getAppletId()); resourcePageVO.setAppletId(appletId);
ResourcePage resourcePage = resourcePageDao.getByBookGroupId(bookGroupId); ResourcePage resourcePage = resourcePageDao.getByBookGroupId(bookGroupId);
if (null != resourcePage) { if (null != resourcePage) {
resourcePageVO.setShowBook(resourcePage.getShowBook()); resourcePageVO.setShowBook(resourcePage.getShowBook());
...@@ -2043,35 +2067,9 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -2043,35 +2067,9 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
private ResourcePageVO getResourcePageBySceneId4Wechat(Long sceneId) { private ResourcePageVO getResourcePageBySceneId4Wechat(Long sceneId) {
ResourcePageVO resourcePageVO = new ResourcePageVO(); ResourcePageVO resourcePageVO = new ResourcePageVO();
resourcePageVO.setSceneId(sceneId); resourcePageVO.setSceneId(sceneId);
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = qrcodeSceneConsr.listBaseInfoByIds(Arrays.asList(sceneId)); Future<Map<Long, QrcodeSceneDto>> qrcodeFuture = ThreadPoolUtils.RESOURCE_POOL.submit(()->{
if (!MapUtils.isEmpty(qrcodeSceneDtoMap) && qrcodeSceneDtoMap.containsKey(sceneId)) { return qrcodeSceneConsr.listBaseInfoByIds(Arrays.asList(sceneId));
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(sceneId); });
Long bookId = qrcodeSceneDto.getAdviserBookId();
Long adviserId = qrcodeSceneDto.getCreatedByUserLogin();
Long channelId = qrcodeSceneDto.getChannelPartyId();
resourcePageVO.setBookId(bookId);
resourcePageVO.setAdviserId(adviserId);
resourcePageVO.setChannelId(channelId);
resourcePageVO.setQrcodeName(qrcodeSceneDto.getSceneName());
if (null != bookId) {
BookDto bookDto = bookBiz.getBaseById(bookId);
if (null != bookDto) {
resourcePageVO.setBookImg(bookDto.getCoverImg());
resourcePageVO.setBookName(bookDto.getBookName());
}
}
Map<Long, AdviserBaseInfoDto> agentMap = adviserConsr.getAdviserId2AdviserInfoDtoMap(Arrays.asList(adviserId));
if (!MapUtils.isEmpty(agentMap)) {
resourcePageVO.setAgentName(Optional.ofNullable(agentMap.get(adviserId)).orElseGet(AdviserBaseInfoDto::new).getAgentName());
}
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
if(accountSettingDto != null){
resourcePageVO.setAccountSettingId(accountSettingDto.getAccountSettingId());
}
}
//小程序
BookAppletScene bookAppletScene = bookAppletSceneDao.getBySceneId(sceneId);
resourcePageVO.setAppletId(null == bookAppletScene?null:bookAppletScene.getAppletId());
ResourcePage resourcePage = resourcePageDao.getBySceneId(sceneId); ResourcePage resourcePage = resourcePageDao.getBySceneId(sceneId);
if (null != resourcePage) { if (null != resourcePage) {
resourcePageVO.setShowBook(resourcePage.getShowBook()); resourcePageVO.setShowBook(resourcePage.getShowBook());
...@@ -2092,6 +2090,54 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -2092,6 +2090,54 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePageVO.setNavigationJumpType(resourcePage.getNavigationJumpType()); resourcePageVO.setNavigationJumpType(resourcePage.getNavigationJumpType());
resourcePageVO.setIsShowPrice(resourcePage.getIsShowPrice()); resourcePageVO.setIsShowPrice(resourcePage.getIsShowPrice());
} }
//小程序
resourcePageVO.setAppletId(bookAppletSceneDao.getAppletIdBySceneId(sceneId));
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = new HashMap<>();
try {
qrcodeSceneDtoMap = qrcodeFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT,TimeUnit.SECONDS);
}catch (Exception e) {
log.error("查二维码失败"+e.getMessage(),e);
}
if (!MapUtils.isEmpty(qrcodeSceneDtoMap) && qrcodeSceneDtoMap.containsKey(sceneId)) {
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(sceneId);
Long bookId = qrcodeSceneDto.getAdviserBookId();
resourcePageVO.setBookId(bookId);
resourcePageVO.setAdviserId(qrcodeSceneDto.getCreatedByUserLogin());
resourcePageVO.setChannelId(qrcodeSceneDto.getChannelPartyId());
resourcePageVO.setQrcodeName(qrcodeSceneDto.getSceneName());
if (null != bookId) {
BookDto bookDto = bookBiz.getBaseById(bookId);
if (null != bookDto) {
resourcePageVO.setBookImg(bookDto.getCoverImg());
resourcePageVO.setBookName(bookDto.getBookName());
}
}
}
Long adviserId = resourcePageVO.getAdviserId();
CompletableFuture<Map<Long, AdviserBaseInfoDto>> agentFuture = CompletableFuture.supplyAsync(() -> {
return adviserConsr.getAdviserId2AdviserInfoDtoMap(null == adviserId?new ArrayList<>():Arrays.asList(adviserId));
});
CompletableFuture<AccountSettingDto> accountSettingFuture = CompletableFuture.supplyAsync(() -> {
return qrcodeSceneConsr.getWechatInfo(resourcePageVO.getChannelId());
});
CompletableFuture.allOf(agentFuture, accountSettingFuture).join();
Map<Long, AdviserBaseInfoDto> agentMap = new HashMap<>();
AccountSettingDto accountSettingDto = new AccountSettingDto();
try {
agentMap = agentFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT,TimeUnit.SECONDS);
accountSettingDto = accountSettingFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT,TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("查询出版社/公众号失败"+e.getMessage(),e);
}
if (!MapUtils.isEmpty(agentMap)) {
resourcePageVO.setAgentName(Optional.ofNullable(agentMap.get(adviserId)).orElseGet(AdviserBaseInfoDto::new).getAgentName());
}
if(accountSettingDto != null){
resourcePageVO.setAccountSettingId(accountSettingDto.getAccountSettingId());
}
return resourcePageVO; return resourcePageVO;
} }
...@@ -2102,7 +2148,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -2102,7 +2148,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
* * @param null * * @param null
*/ */
private void updateSeq4Batch(Long resourcePageId, Long navigationId) { private void updateSeq4Batch(Long resourcePageId, Long navigationId) {
List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId); List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId,null);
if (ListUtils.isEmpty(serveVOS)) { if (ListUtils.isEmpty(serveVOS)) {
return; return;
} }
...@@ -3167,22 +3213,54 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -3167,22 +3213,54 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
qrcodeTemp.setAccountSettingId(accountSettingId); qrcodeTemp.setAccountSettingId(accountSettingId);
qrcodeTemp.setCreatedUser(wechatUserId); qrcodeTemp.setCreatedUser(wechatUserId);
qrcodeTemp.setPageId(resourcePageId); qrcodeTemp.setPageId(resourcePageId);
String qrcodeUrl = qrcodeSceneConsr.createTempQrcode4H5(qrcodeTemp); String qrcodeUrl = null;
try {
qrcodeUrl = qrcodeSceneConsr.createTempQrcode4H5(qrcodeTemp);
} catch (Exception e) {
log.warn("H5生成临时二维码失败"+e.getMessage());
pageItemVO = new ResourcePageItemVO();
pageItemVO.setPopupState(popupState);
return pageItemVO;
}
//todo 每个人生成的码都缓存下来。如果公众号id。或者logoUrl变了。要删缓存。临时二维码有效期30天
String tempKey=BookConstant.PAGE_ID_TEMP_CODE_CACHE+resourcePageId+"-"+accountSettingId+"-"+wechatUserId;
String logoUrlKey=BookConstant.PAGE_ID_LOGOURL_CACHE+resourcePageId+"-"+accountSettingId+"-"+wechatUserId;
String pageKey=BookConstant.PAGE_ID_CODE_CACHE+resourcePageId+"-"+accountSettingId+"-"+wechatUserId;
if (!StringUtil.isEmpty(qrcodeUrl) && !StringUtil.isEmpty(logoUrl)) { if (!StringUtil.isEmpty(qrcodeUrl) && !StringUtil.isEmpty(logoUrl)) {
//添加Logo String cacheQrcodeUrl = JedisClusterUtils.get(tempKey);
String url = ""; String cacheLogoUrl = JedisClusterUtils.get(logoUrlKey);
String tmpDirPath = FileUtil.getTmpDirPath(); //qrcodeUrl 变了要重新生成
if (!tmpDirPath.endsWith(File.separator)) { if(StrUtil.isBlank(cacheQrcodeUrl)){
tmpDirPath = tmpDirPath + File.separator; JedisClusterUtils.set(tempKey,qrcodeUrl,60*60*24*30);
}else{
//如果缓存里面有值。然后就从缓存里面拿的和新拿到的qrcodeUrl比较。如果不同。说明原来的临时二维码到期了。重新生成了。那么都要重新生成一次
if(!cacheQrcodeUrl.equalsIgnoreCase(qrcodeUrl)){
//重新生成
JedisClusterUtils.set(tempKey,qrcodeUrl,60*60*24*30);
qrcodeUrl = getQrcodeUrl(logoUrl, qrcodeUrl);
JedisClusterUtils.set(pageKey,qrcodeUrl,60*60*24*30);
}
} }
File file = FileUtil.touch(tmpDirPath + UUIDUitl.generateShort() + ".png"); //logoUrl 变了也要重新生成
HttpUtil.downloadFile(qrcodeUrl, file); if(StrUtil.isBlank(cacheLogoUrl)){
try { JedisClusterUtils.set(logoUrlKey,qrcodeUrl,60*60*24*30);
url = QrCodeUtil.decode(file); }else{
} catch (QrCodeException e){ //如果缓存里面有值。然后就从缓存里面拿的和新拿到的logoUrl比较。如果不同。说明变了logoUrl了。那么都要重新生成一次
log.info("解析二维码图片失败,qrcodeUrl:{}", qrcodeUrl); if(!cacheLogoUrl.equalsIgnoreCase(logoUrl)){
//重新生成
JedisClusterUtils.set(logoUrlKey,logoUrl,60*60*24*30);
qrcodeUrl = getQrcodeUrl(logoUrl, qrcodeUrl);
JedisClusterUtils.set(pageKey,qrcodeUrl,60*60*24*30);
}
}
String cachePageUrl = JedisClusterUtils.get(pageKey);
if(StrUtil.isNotBlank(cachePageUrl)){
qrcodeUrl= cachePageUrl;
}else {
//添加Logo
qrcodeUrl = getQrcodeUrl(logoUrl, qrcodeUrl);
JedisClusterUtils.set(pageKey,qrcodeUrl,60*60*24*30);
} }
qrcodeUrl = this.getLogoQrcode(url, logoUrl, qrcodeUrl);
} }
pageItemVO.setResultUrl(qrcodeUrl); pageItemVO.setResultUrl(qrcodeUrl);
if (!StringUtil.isEmpty(qrcodeUrl)) { if (!StringUtil.isEmpty(qrcodeUrl)) {
...@@ -3193,6 +3271,23 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -3193,6 +3271,23 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return pageItemVO; return pageItemVO;
} }
private String getQrcodeUrl(String logoUrl, String qrcodeUrl) {
String url = "";
String tmpDirPath = FileUtil.getTmpDirPath();
if (!tmpDirPath.endsWith(File.separator)) {
tmpDirPath = tmpDirPath + File.separator;
}
File file = FileUtil.touch(tmpDirPath + UUIDUitl.generateShort() + ".png");
HttpUtil.downloadFile(qrcodeUrl, file);
try {
url = QrCodeUtil.decode(file);
} catch (QrCodeException e){
log.info("解析二维码图片失败,qrcodeUrl:{}", qrcodeUrl);
}
qrcodeUrl = this.getLogoQrcode(url, logoUrl, qrcodeUrl);
return qrcodeUrl;
}
@Override @Override
public ResourcePageDTO getResourcePageById(Long resourcePageId) { public ResourcePageDTO getResourcePageById(Long resourcePageId) {
ResourcePageDTO resourcePageDTO = new ResourcePageDTO(); ResourcePageDTO resourcePageDTO = new ResourcePageDTO();
...@@ -3577,8 +3672,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -3577,8 +3672,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@Override @Override
public List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId) { public List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId,
List<ResourceColumnAndServeVO> resourceColumnAndServeVOS = this.getColumnAndServeListByPageId(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId); Long adviserId, Long channelId, Integer enableAdverting,
Long navigationId, Long officialAccountsId) {
List<ResourceColumnAndServeVO> resourceColumnAndServeVOS = this.getColumnAndServeListByPageId(resourcePageId, wechatUserId, bookId,
adviserId, channelId, enableAdverting, navigationId);
//填充自定义图片 //填充自定义图片
if (ListUtils.isEmpty(resourceColumnAndServeVOS)) { if (ListUtils.isEmpty(resourceColumnAndServeVOS)) {
return new ArrayList<>(); return new ArrayList<>();
...@@ -3593,9 +3691,143 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -3593,9 +3691,143 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return new ArrayList<>(); return new ArrayList<>();
} }
fillSelfPic(resourcePageItemVOList); fillSelfPic(resourcePageItemVOList);
//填充跳转地址
try {
fillJumpUrl(resourcePageItemVOList, wechatUserId, resourcePageId, officialAccountsId);
} catch (Exception e) {
log.error("book.fillJumpUrl失败");
}
return resourceColumnAndServeVOS; return resourceColumnAndServeVOS;
} }
private void fillJumpUrl(List<ResourcePageItemVO> resourcePageItemVOList, Long wechatUserId, Long resourcePageId, Long officialAccountsId) {
if (CollUtil.isEmpty(resourcePageItemVOList)) {
return;
}
List<ResourcePageItemVO> resourcePageItemVOS = resourcePageItemVOList.stream().filter(e -> AppTypeEnum.ARTICLE.value.equals(e.getTypeCode())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(resourcePageItemVOS)) {
ResourcePage byId = resourcePageDao.getById(resourcePageId);
if (null == byId || null == byId.getSceneId()) {
return;
}
List<Long> appIds = resourcePageItemVOS.stream().map(e -> e.getServeId()).collect(Collectors.toList());
Map<Long, AppDto> appDtoMap = appConsr.mapByIds(appIds);
resourcePageItemVOS.stream().forEach(e -> {
if (AppTypeEnum.ARTICLE.value.equals(e.getTypeCode()) && CollUtil.isNotEmpty(appDtoMap) && null != appDtoMap.get(e.getServeId())) {
AppDto appDto = appDtoMap.get(e.getServeId());
if (appDto != null && !StringUtil.isEmpty(appDto.getTurnUrl())) {
if (appDto.getTurnUrl().contains("5rs.me/") || appDto.getTurnUrl().contains("raysgo.com/") || appDto.getTurnUrl().contains("raysyun.com/")
|| null == wechatUserId) {
e.setResultUrl(appDto.getTurnUrl());
} else {
//外链跳转到指定中间页
String jumpUrl = BookProps.getProductDomain() + "transfer?offId" + officialAccountsId + "&appId=" + appDto.getAppId() + "&url=" +
URLEncoder.encode(appDto.getTurnUrl()) + "&sceneId=" + byId.getSceneId() + "&wechatUserId=" + wechatUserId;
e.setResultUrl(jumpUrl);
}
}
}
});
}
}
@Override
public List<Integer> getColumnTypeByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId) {
List<Integer> columnIdList = resourcePageColumnDao.getColumnIdListByPageId(resourcePageId, navigationId);
if(CollUtil.isEmpty(columnIdList)){
columnIdList=new ArrayList<>();
}
columnIdList.add(0);
return columnIdList;
}
//优化 此处把模块分开调接口 通过columnType
@Override
public List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4WechatV2(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId,
Long channelId, Integer enableAdverting, Long navigationId, Integer columnType, Long officialAccountsId) {
List<ResourceColumnAndServeVO> serveVOS=new ArrayList<>();
if(null!= columnType && columnType!=0) {
serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId, columnType);
if (CollUtil.isNotEmpty(serveVOS)) {
List<ResourcePageItemVO> itemVOList;
if (null != wechatUserId) {
itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, true);
} else {
itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, null);
}
if (CollUtil.isNotEmpty(itemVOList)) {
//二维码类型
fillQrcodeType(resourcePageId, itemVOList);
Map<String, List<ResourcePageItemVO>> listMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getServeType));
itemVOList = new ArrayList<>();
//应用和作品提出来一起查
List<ResourcePageItemVO> itemAppAndProductVOList = new ArrayList<>();
//过滤一些资源,重新排序
for (Map.Entry<String, List<ResourcePageItemVO>> entry : listMap.entrySet()) {
if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(entry.getKey()) || ServeTypeEnum.PRODUCT.getValue().equals(entry.getKey())) {
itemAppAndProductVOList.addAll(entry.getValue());
continue;
}
this.fillResourceByType(entry.getValue(), wechatUserId, entry.getKey());
itemVOList.addAll(entry.getValue());
}
if (CollUtil.isNotEmpty(itemAppAndProductVOList)) {
fillAppProductServe(itemAppAndProductVOList, wechatUserId);
itemVOList.addAll(itemAppAndProductVOList);
}
itemVOList.sort(Comparator.comparing(ResourcePageItemVO::getId));
Map<Long, List<ResourcePageItemVO>> columnMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getResourcePageColumnId));
List<ResourceColumnAndServeVO> removeColumns = new ArrayList<>();
for (ResourceColumnAndServeVO columnAndServeVO : serveVOS) {
List<ResourcePageItemVO> itemVOS = columnMap.get(columnAndServeVO.getResourcePageColumnId());
if (ListUtils.isEmpty(itemVOS)) {
removeColumns.add(columnAndServeVO);
continue;
}
columnAndServeVO.setItemVOList(itemVOS);
String serveType = itemVOS.get(0).getServeType();
if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(serveType) ||
(ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType))) {
serveType = "APP/PRODUCT";
}
columnAndServeVO.setServeType(serveType);
//图片位
if (ResourcePageConstants.ColumnTypeEnum.PICTURE.getCode().equals(columnAndServeVO.getColumnType())) {
columnAndServeVO.setLogoUrl(itemVOS.get(0).getLogoUrl());
}
}
if (!ListUtils.isEmpty(removeColumns)) {
serveVOS.removeAll(removeColumns);
}
}
}
if (CollUtil.isEmpty(serveVOS)) {
serveVOS = CollUtil.toList();
}
}else {
this.fillAdvertising(serveVOS, bookId, adviserId, channelId, enableAdverting);
}
//填充自定义图片
if (ListUtils.isEmpty(serveVOS)) {
return new ArrayList<>();
}
List<ResourcePageItemVO> resourcePageItemVOList = new ArrayList<>();
serveVOS.stream().forEach(e -> {
if (!ListUtils.isEmpty(e.getItemVOList())) {
resourcePageItemVOList.addAll(e.getItemVOList());
}
});
if (ListUtils.isEmpty(resourcePageItemVOList)) {
return new ArrayList<>();
}
fillSelfPic(resourcePageItemVOList);
//填充跳转地址
fillJumpUrl(resourcePageItemVOList, wechatUserId, resourcePageId, officialAccountsId);
return serveVOS;
}
@Override @Override
public Integer saveShareConfig(ResourcePageShareParam param) { public Integer saveShareConfig(ResourcePageShareParam param) {
checkShareParam(param); checkShareParam(param);
......
...@@ -99,6 +99,9 @@ public class ResourcePageBookstoreBizImpl implements ResourcePageBookstoreBiz { ...@@ -99,6 +99,9 @@ public class ResourcePageBookstoreBizImpl implements ResourcePageBookstoreBiz {
@Override @Override
public List<ResourcePageBookstoreVO> getByResourcePageId(Long resourcePageId, Long channelId, Long wechatUserId, ResourcePageFixtureTypeEnum fixtureTypeEnum) { public List<ResourcePageBookstoreVO> getByResourcePageId(Long resourcePageId, Long channelId, Long wechatUserId, ResourcePageFixtureTypeEnum fixtureTypeEnum) {
if (null == resourcePageId) {
return CollUtil.toList();
}
List<ResourcePageBookstoreVO> list = resourcePageBookstoreDao.getByResourcePageId(resourcePageId, fixtureTypeEnum.fixtureType); List<ResourcePageBookstoreVO> list = resourcePageBookstoreDao.getByResourcePageId(resourcePageId, fixtureTypeEnum.fixtureType);
if(CollUtil.isEmpty(list)){ if(CollUtil.isEmpty(list)){
return CollUtil.toList(); return CollUtil.toList();
......
...@@ -55,4 +55,8 @@ public interface BookAppletSceneDao extends BaseDao<BookAppletScene> { ...@@ -55,4 +55,8 @@ public interface BookAppletSceneDao extends BaseDao<BookAppletScene> {
* @return * @return
*/ */
BookAppletSceneDTO getBookAppletByBookId(Long bookId, Long channelId, Long adviserId); BookAppletSceneDTO getBookAppletByBookId(Long bookId, Long channelId, Long adviserId);
String getAppletIdByBookGroupId(Long bookGroupId);
String getAppletIdBySceneId(Long sceneId);
} }
...@@ -27,4 +27,6 @@ public interface ResourcePageCollectDao extends BaseDao<ResourcePageCollect>{ ...@@ -27,4 +27,6 @@ public interface ResourcePageCollectDao extends BaseDao<ResourcePageCollect>{
* * @param null * * @param null
*/ */
Integer getUserIsNotNew(Long wechatUserId); Integer getUserIsNotNew(Long wechatUserId);
Integer getCollectStateByUser(Long wechatUserId, Long resourcePageId);
} }
\ No newline at end of file
...@@ -29,7 +29,9 @@ public interface ResourcePageColumnDao extends BaseDao<ResourcePageColumn> { ...@@ -29,7 +29,9 @@ public interface ResourcePageColumnDao extends BaseDao<ResourcePageColumn> {
* @date:2021/3/29 13:45 * @date:2021/3/29 13:45
* * @param null * * @param null
*/ */
List<ResourceColumnAndServeVO> getColumnListByPageId(Long resourcePageId, Long navigationId); List<ResourceColumnAndServeVO> getColumnListByPageId(Long resourcePageId, Long navigationId,Integer columnType);
List<Integer> getColumnIdListByPageId(Long resourcePageId, Long navigationId);
/** /**
* 根据类型查询 * 根据类型查询
......
...@@ -125,4 +125,8 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{ ...@@ -125,4 +125,8 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
* * @param null * * @param null
*/ */
void updateNavigationFormat(Long resourcePageId, Integer navigationColor, Integer navigationFormat, Integer navigationJumpType); void updateNavigationFormat(Long resourcePageId, Integer navigationColor, Integer navigationFormat, Integer navigationJumpType);
Long getBookIdByBookGroupId(Long bookGroupId);
Long getBookIdBySceneId(Long sceneId);
} }
...@@ -56,4 +56,14 @@ public class BookAppletSceneDaoImpl extends BaseDaoImpl<BookAppletScene> impleme ...@@ -56,4 +56,14 @@ public class BookAppletSceneDaoImpl extends BaseDaoImpl<BookAppletScene> impleme
map.put("adviserId", adviserId); map.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookAppletByBookId"), map); return getSessionTemplate().selectOne(getStatement("getBookAppletByBookId"), map);
} }
@Override
public String getAppletIdByBookGroupId(Long bookGroupId) {
return getSessionTemplate().selectOne(getStatement("getAppletIdByBookGroupId"), bookGroupId);
}
@Override
public String getAppletIdBySceneId(Long sceneId) {
return getSessionTemplate().selectOne(getStatement("getAppletIdBySceneId"), sceneId);
}
} }
...@@ -31,4 +31,12 @@ public class ResourcePageCollectDaoImpl extends BaseDaoImpl<ResourcePageCollect> ...@@ -31,4 +31,12 @@ public class ResourcePageCollectDaoImpl extends BaseDaoImpl<ResourcePageCollect>
public Integer getUserIsNotNew(Long wechatUserId) { public Integer getUserIsNotNew(Long wechatUserId) {
return getSessionTemplate().selectOne(getStatement("getUserIsNotNew"), wechatUserId); return getSessionTemplate().selectOne(getStatement("getUserIsNotNew"), wechatUserId);
} }
@Override
public Integer getCollectStateByUser(Long wechatUserId, Long resourcePageId) {
Map<String, Object> map = new HashMap<>();
map.put("wechatUserId", wechatUserId);
map.put("resourcePageId", resourcePageId);
return getSessionTemplate().selectOne(getStatement("getCollectStateByUser"), map);
}
} }
...@@ -30,14 +30,23 @@ public class ResourcePageColumnDaoImpl extends BaseDaoImpl<ResourcePageColumn> i ...@@ -30,14 +30,23 @@ public class ResourcePageColumnDaoImpl extends BaseDaoImpl<ResourcePageColumn> i
} }
@Override @Override
public List<ResourceColumnAndServeVO> getColumnListByPageId(Long resourcePageId, Long navigationId) { public List<ResourceColumnAndServeVO> getColumnListByPageId(Long resourcePageId, Long navigationId,Integer columnType) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("navigationId", navigationId); map.put("navigationId", navigationId);
map.put("resourcePageId", resourcePageId); map.put("resourcePageId", resourcePageId);
map.put("columnType", columnType);
return getSessionTemplate().selectList(getStatement("getColumnListByPageId"), map); return getSessionTemplate().selectList(getStatement("getColumnListByPageId"), map);
} }
@Override @Override
public List<Integer> getColumnIdListByPageId(Long resourcePageId, Long navigationId) {
Map<String, Object> map = new HashMap<>();
map.put("navigationId", navigationId);
map.put("resourcePageId", resourcePageId);
return getSessionTemplate().selectList(getStatement("getColumnIdListByPageId"), map);
}
@Override
public List<ResourcePageColumn> getByColumnTypeAndPage(Long resourcePageId, Integer columnType) { public List<ResourcePageColumn> getByColumnTypeAndPage(Long resourcePageId, Integer columnType) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("resourcePageId", resourcePageId); map.put("resourcePageId", resourcePageId);
......
...@@ -166,4 +166,14 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re ...@@ -166,4 +166,14 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
map.put("navigationJumpType", navigationJumpType); map.put("navigationJumpType", navigationJumpType);
getSessionTemplate().update(getStatement("updateNavigationFormat"), map); getSessionTemplate().update(getStatement("updateNavigationFormat"), map);
} }
@Override
public Long getBookIdByBookGroupId(Long bookGroupId) {
return getSessionTemplate().selectOne(getStatement("getBookIdByBookGroupId"), bookGroupId);
}
@Override
public Long getBookIdBySceneId(Long sceneId) {
return getSessionTemplate().selectOne(getStatement("getBookIdBySceneId"), sceneId);
}
} }
...@@ -108,7 +108,40 @@ public class ResourcePageFacade { ...@@ -108,7 +108,40 @@ public class ResourcePageFacade {
@RequestParam(value = "enableAdverting", required = false) Integer enableAdverting, @RequestParam(value = "enableAdverting", required = false) Integer enableAdverting,
@RequestParam(value = "navigationId", required = false) Long navigationId){ @RequestParam(value = "navigationId", required = false) Long navigationId){
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId4Wechat(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId)); Long officialAccountsId = Cookie.getId(userInfo, Cookie._OFFICIAL_ACCOUNTS_ID);
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId4Wechat(resourcePageId, wechatUserId, bookId, adviserId,
channelId, enableAdverting, navigationId, officialAccountsId));
}
//优化 此处把模块分开调接口
@ApiOperation("客户端-根据页面id查资源页栏目分类")
@GetMapping("getColumnTypeByPageId4Wechat")
public ResponseDto<?> getColumnTypeByPageId4Wechat(@CookieValue("userInfo") String userInfo,
@RequestParam("resourcePageId") Long resourcePageId,
@RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "enableAdverting", required = false) Integer enableAdverting,
@RequestParam(value = "navigationId", required = false) Long navigationId){
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(resourcePageBiz.getColumnTypeByPageId4Wechat(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId));
}
//优化 此处把模块分开调接口 columnType
@ApiOperation("客户端-根据页面id查资源页栏目及资源")
@GetMapping("getColumnAndServeListByPageId4WechatV2")
public ResponseDto<?> getColumnAndServeListByPageId4WechatV2(@CookieValue("userInfo") String userInfo,
@RequestParam("resourcePageId") Long resourcePageId,
@RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "enableAdverting", required = false) Integer enableAdverting,
@RequestParam(value = "navigationId", required = false) Long navigationId,
@RequestParam(value = "columnType", required = false) Integer columnType){
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
Long officialAccountsId = Cookie.getId(userInfo, Cookie._OFFICIAL_ACCOUNTS_ID);
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId4WechatV2(resourcePageId, wechatUserId, bookId, adviserId,
channelId, enableAdverting, navigationId,columnType, officialAccountsId));
} }
@ApiOperation("客户端分页查栏目资源") @ApiOperation("客户端分页查栏目资源")
......
...@@ -2,6 +2,7 @@ package com.pcloud.book.util.common; ...@@ -2,6 +2,7 @@ package com.pcloud.book.util.common;
import java.util.*; import java.util.*;
import cn.hutool.core.util.StrUtil;
import com.pcloud.common.utils.DateNewUtils; import com.pcloud.common.utils.DateNewUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
...@@ -166,4 +167,22 @@ public class CommonUtils { ...@@ -166,4 +167,22 @@ public class CommonUtils {
calendar.set(14, 0); calendar.set(14, 0);
return calendar.getTime(); return calendar.getTime();
} }
public static Long getSceneId(String url) {
if (StrUtil.isEmpty(url) || !url.contains("sceneId")) {
return null;
}
String sceneIdStr = null;
Long sceneId = null;
try {
sceneIdStr = url.substring( url.indexOf("sceneId") + 8 , url.indexOf("&", url.indexOf("sceneId")));
} catch (Exception e) {
e.printStackTrace();
}
if (StrUtil.isNotEmpty(sceneIdStr)) {
sceneId = Long.valueOf(sceneIdStr);
}
return sceneId;
}
} }
...@@ -106,8 +106,9 @@ public class ThreadPoolUtils { ...@@ -106,8 +106,9 @@ public class ThreadPoolUtils {
/** /**
* 远程调用线程池 * 远程调用线程池
* maximumPoolSize设置大一些,避免阻塞
*/ */
public static final ThreadPoolExecutor REMOTE_CALL_POOL = new ThreadPoolExecutor(8, 8, 0, TimeUnit.SECONDS, public static final ThreadPoolExecutor REMOTE_CALL_POOL = new ThreadPoolExecutor(8, 128, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("remote-call-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("remote-call-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
/** /**
* 书刊记录埋点线程池 * 书刊记录埋点线程池
......
...@@ -161,4 +161,16 @@ public class BookProps { ...@@ -161,4 +161,16 @@ public class BookProps {
public void setMiniOfficialAccountsId(Long miniOfficialAccountsId) { public void setMiniOfficialAccountsId(Long miniOfficialAccountsId) {
BookProps.miniOfficialAccountsId = miniOfficialAccountsId; BookProps.miniOfficialAccountsId = miniOfficialAccountsId;
} }
private static String productDomain;
public static String getProductDomain() {
return productDomain;
}
@Value("${PRODUCT_DOMAIN}")
public void setProductDomain(String productDomain) {
BookProps.productDomain = productDomain;
}
} }
...@@ -1406,4 +1406,18 @@ ...@@ -1406,4 +1406,18 @@
HAVING bookCount >= #{bookCount} HAVING bookCount >= #{bookCount}
</if> </if>
</select> </select>
<select id="getBookIsOpenCatalog" resultType="integer" parameterType="map">
SELECT
IFNULL(is_open_catalog,0)
FROM
BOOK_ADVISER
WHERE
BOOK_ID = #{bookId}
AND
CHANNEL_ID = #{channelId}
AND
ADVISER_ID = #{adviserId}
</select>
</mapper> </mapper>
...@@ -141,4 +141,22 @@ ...@@ -141,4 +141,22 @@
limit 1 limit 1
</select> </select>
<select id="getAppletIdByBookGroupId" parameterType="long" resultType="string">
SELECT
applet_id
FROM book_applet_scene
WHERE book_group_id=#{bookGroupId}
AND is_delete = 0
limit 1
</select>
<select id="getAppletIdBySceneId" parameterType="long" resultType="string">
SELECT
applet_id
FROM book_applet_scene
WHERE scene_id=#{sceneId}
AND is_delete = 0
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -71,4 +71,14 @@ ...@@ -71,4 +71,14 @@
and is_new = 0 and is_new = 0
</select> </select>
<select id="getCollectStateByUser" parameterType="map" resultType="integer">
select
collect_state
from resource_page_collect
where resource_page_id = #{resourcePageId}
and wechat_user_id = #{wechatUserId}
and collect_state = 1
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -125,11 +125,26 @@ ...@@ -125,11 +125,26 @@
<if test="navigationId != null"> <if test="navigationId != null">
and navigation_id = #{navigationId} and navigation_id = #{navigationId}
</if> </if>
<if test="columnType!=null">
and column_type = #{columnType}
</if>
ORDER BY ORDER BY
column_seq ASC, column_seq ASC,
id ASC id ASC
</select> </select>
<select id="getColumnIdListByPageId" resultType="Integer" parameterType="map">
SELECT
DISTINCT column_type
FROM
resource_page_column
WHERE
resource_page_id = #{resourcePageId}
<if test="navigationId != null">
and navigation_id = #{navigationId}
</if>
</select>
<select id="getByColumnTypeAndPage" parameterType="map" resultMap="ResourcePageColumnMap"> <select id="getByColumnTypeAndPage" parameterType="map" resultMap="ResourcePageColumnMap">
select select
id, resource_page_id, column_type, column_name, column_format, column_seq, show_more, show_count, create_time, navigation_id, background_type, background_url id, resource_page_id, column_type, column_name, column_format, column_seq, show_more, show_count, create_time, navigation_id, background_type, background_url
......
...@@ -355,4 +355,20 @@ ...@@ -355,4 +355,20 @@
where id = #{id} where id = #{id}
</select> </select>
<select id="getBookIdByBookGroupId" parameterType="long" resultType="long" >
select
book_id
from resource_page
where book_group_id = #{bookGroupId}
limit 1
</select>
<select id="getBookIdBySceneId" parameterType="long" resultType="long">
select
book_id
from resource_page
where scene_id = #{sceneId}
limit 1
</select>
</mapper> </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