Commit 6ea7ac98 by 郑勇

feat: [1006602] 扫码接口优化

parent 70d20230
......@@ -461,4 +461,13 @@ public class BookConstant {
public static final String SUPER_MERCHANT_LIST = CacheConstant.BOOK + "superMerchantList";
/**
* 资源配置sceneId查询
*/
public static final String RESOURCE_PAGE_BY_SCENE_ID = CacheConstant.BOOK + "resourcePageBySceneId";
/**
* 资源配置bookGroupId查询
*/
public static final String RESOURCE_PAGE_BY_BOOK_GROUP_ID = CacheConstant.BOOK + "resourcePageByBookGroupId";
}
......@@ -713,4 +713,25 @@ public class QrcodeSceneConsr {
LOGGER.error("调用qrcodeSceneService.updateLandingPageType失败"+e.getMessage(),e);
}
}
@ParamLog("删除二维码解析地址")
public void deleteParseRedis(Long sceneId, Long bookGroupId) {
try {
qrcodeSceneService.deleteParseRedis(null,sceneId, bookGroupId);
}catch (Exception e) {
LOGGER.error("调用qrcodeSceneService.updateLandingPageType失败"+e.getMessage(),e);
}
}
@ParamLog(description = "获取二维码基本信息")
public QrcodeSceneDto getOnlySceneInfoById(Long sceneId) throws BizException {
if(sceneId == null) return null;
try {
return ResponseHandleUtil.parseResponse(qrcodeSceneService.getOnlySceneInfoById(sceneId), QrcodeSceneDto.class);
} catch (BizException e) {
LOGGER.error("【二维码-渠道(消)】 获取二维码最最基本信息失败,<ERROR>.[getById]:" + e.getMessage(),
e);
}
return null;
}
}
......@@ -240,7 +240,7 @@ public class ReaderConsr {
public Map<Long, AgentCity> getAgentPositionByAdviserIds(List<Long> advisers) {
LOGGER.info("根据advisers查询出版社地理位置:{}", advisers);
Map<Long, AgentCity> map = CollUtil.newHashMap(0);
Map<Long, AgentCity> map = new HashMap<>();
try {
map = ResponseHandleUtil.parseMap(agentService.getAgentPositionByAdviserIds(advisers), Long.class, AgentCity.class);
} catch (Exception e) {
......
......@@ -138,6 +138,51 @@ public class ProductConsr {
}
}
/**
* 资源中心拉取商品最最基本信息
*/
public Map<Long, ProductDto> getProductBasesByIds(List<Long> productIds) throws BizException {
LOGGER.info("【资源中心(消)】获取商品最最基本信息,<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.getProductBasesByIds(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("[getProBasesByIds] 填充信息失败,err:{}", e.getMessage(), e);
}
return finalProductDtoMap;
} else {
try {
productDtoMap = ResponseHandleUtil.parseMapResponse(productService.getProductBasesByIds(productIds), Long.class, ProductDto.class);
} catch (BizException e) {
LOGGER.warn("调用:productService.getProductBasesByIds报错", e.getMessage(), e);
}
return productDtoMap;
}
}
/**
* 资源中心拉取商品基本信息
......
......@@ -254,7 +254,7 @@ public class TradeConsr {
*/
public Map<Long, OrderGroupFormDto> getOrderGroupForm4ES(List<Long> qrcodeIds) {
LOGGER.error("根据群ID去交易中心查询群内订单统计信息.[getOrderGroupForm4ES] qrcodeIds:{}", qrcodeIds);
Map<Long, OrderGroupFormDto> map = CollUtil.newHashMap(0);
Map<Long, OrderGroupFormDto> map = new HashMap<>();
if (CollUtil.isEmpty(qrcodeIds)) {
return map;
}
......
......@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -38,7 +39,7 @@ public class WechatConsr {
public Map<String, ESGroupBookQrcodeDTO> aggGroupMemberUser(List<String> wxGroupIds) {
log.info("WechatConsr.aggGroupMemberUser 获取群成员城市及性别信息 wxGroupIds:{}", wxGroupIds);
Map<String, ESGroupBookQrcodeDTO> map = CollUtil.newHashMap(0);
Map<String, ESGroupBookQrcodeDTO> map = new HashMap<>();
try {
map = ResponseHandleUtil.parseMap(groupMemberService.aggGroupMemberUser(wxGroupIds), String.class, ESGroupBookQrcodeDTO.class);
} catch (Exception e) {
......
......@@ -676,6 +676,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
if (JoinGroupTypeEnum.XIAORUI.getCode().equals(joinGroupType)) {
this.createBookGroupAppletUrl(bookGroup.getId(), bookId, channelId, adviserId);
}
//删除二维码解析缓存
qrcodeSceneConsr.deleteParseRedis(null,bookGroup.getId());
return bookGroup;
}
......@@ -1114,6 +1116,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
bookGroupDao.update(bookGroup);
//更新至超级搜索
searchProducer.update(bookGroup.getId());
//删除二维码跳转解析
qrcodeSceneConsr.deleteParseRedis(null,bookGroup.getId());
}
/**
......@@ -1202,7 +1206,14 @@ public class BookGroupBizImpl implements BookGroupBiz {
@ParamLog(value = "根据书刊ID删除", isAfterReturn = false)
@Transactional(rollbackFor = Exception.class)
public void deleteByBookId( Long bookId, Long channelId, Long adviserId ) throws BizException {
List<BookGroupDTO> bookGroupDTOList = bookGroupDao.listBookGroup(bookId, channelId, adviserId);
bookGroupDao.deleteByBookId(bookId, channelId, adviserId);
if(CollUtil.isNotEmpty(bookGroupDTOList)){
//删除二维码解析缓存
for (BookGroupDTO bookGroupDTO : bookGroupDTOList) {
qrcodeSceneConsr.deleteParseRedis(null,bookGroupDTO.getId());
}
}
}
/**
......@@ -1212,7 +1223,14 @@ public class BookGroupBizImpl implements BookGroupBiz {
@ParamLog(value = "根据书刊ID恢复", isAfterReturn = false)
@Transactional(rollbackFor = Exception.class)
public void recoverByBookId( Long bookId, Long channelId, Long adviserId ) throws BizException {
List<BookGroupDTO> bookGroupDTOList = bookGroupDao.listBookGroup(bookId, channelId, adviserId);
bookGroupDao.recoverByBookId(bookId, channelId, adviserId);
if(CollUtil.isNotEmpty(bookGroupDTOList)){
//删除二维码解析缓存
for (BookGroupDTO bookGroupDTO : bookGroupDTOList) {
qrcodeSceneConsr.deleteParseRedis(null,bookGroupDTO.getId());
}
}
}
/**
......@@ -1237,6 +1255,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
bookGroup.setBookId(bookId);
bookGroup.setId(bookGroupId);
long result = bookGroupDao.linkBookGroup(bookGroup);
//删除二维码解析缓存
qrcodeSceneConsr.deleteParseRedis(null,bookGroupId);
if (result <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "关联社群书失败!");
}
......@@ -1982,6 +2002,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "该社群码下已有分类!");
}
bookGroupDao.deleteByBookGroupId(bookGroupId);
//删除二维码解析缓存
qrcodeSceneConsr.deleteParseRedis(null,bookGroupId);
}
@Override
......@@ -1994,6 +2016,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
throw new BookBizException(BookBizException.ID_NOT_EXIST, "没有该数据!");
}
bookGroupDao.deleteByBookGroupId(bookGroupId);
//删除二维码解析缓存
qrcodeSceneConsr.deleteParseRedis(null,bookGroupId);
bookAppletSceneDao.deleteByBookGroupId(bookGroupId);
//更新至超级搜索中
searchProducer.delete(bookGroupId);
......@@ -4740,6 +4764,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
//删除旧数据
bookGroupDao.deleteByBookGroupId(oldBookGroupId);
//删除二维码解析缓存
qrcodeSceneConsr.deleteParseRedis(null,oldBookGroupId);
//插入转换记录表
QrChangeRecord qrChangeRecord = QrChangeRecord.builder().oldBookGroupId(oldBookGroupId).newBookGroupId(newBookGroupId).build();
bookGroupDao.insertQrChangeRecord(qrChangeRecord);
......@@ -5689,6 +5715,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
this.createBookGroupAppletUrl(bookGroupId,bookGroupDTO.getBookId(),bookGroupDTO.getChannelId(),bookGroupDTO.getCreateUser());
//修改joinGroupType
bookGroupDao.updateJoinGroupType(bookGroupId,JoinGroupTypeEnum.XIAORUI.getCode());
qrcodeSceneConsr.deleteParseRedis(null,bookGroupId);
}
bookGroupDao.updateBookGroupOpenWeapp(bookGroupId, openWeapp);
}
......
package com.pcloud.book.group.biz.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
......@@ -50,6 +51,7 @@ import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.book.group.biz.ResourcePageBookstoreBiz;
import com.pcloud.book.group.constant.ResourcePageConstants;
import com.pcloud.book.group.constant.ResourcePageConstants.ServeTypeEnum;
import com.pcloud.book.group.dao.BookAppletSceneDao;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.ResourcePageCollectDao;
......@@ -366,6 +368,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
//校验能否开启小睿
this.checkOpenRays(resourcePage.getBookId(), updateResourcePageVO.getOpenRays());
resourcePageDao.insert(resourcePage);
//加到缓存中
addResourcePageToRedis(resourcePage);
} else {
resourcePage.setStyle(updateResourcePageVO.getStyle());
resourcePage.setOpenRays(updateResourcePageVO.getOpenRays());
......@@ -387,6 +391,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePage.setTransparency(updateResourcePageVO.getTransparency());
resourcePage.setIsShowPrice(updateResourcePageVO.getIsShowPrice());
resourcePageDao.update(resourcePage);
//删除缓存中
delResourcePageToRedis(resourcePage);
}
if (updateResourcePageVO.getOpenRays() == 1) {
//小程序码
......@@ -400,6 +406,14 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
//同一本书其他码下关闭小睿流程
resourcePageDao.setOtherPageRaysClose(resourcePage.getBookId(), resourcePage.getChannelId(), resourcePage.getCreateUser(), sceneId, null);
//为了维护缓存。要先查出来其他码。然后更新
List<ResourcePage> otherPageRaysClose = resourcePageDao.getOtherPageRaysClose(resourcePage.getBookId(), resourcePage.getChannelId(), resourcePage.getCreateUser(), sceneId, null);
if(CollUtil.isNotEmpty(otherPageRaysClose)){
otherPageRaysClose.forEach(e->{
addResourcePageToRedis(e);
});
}
//添加小程序默认导航 之前关闭才添加
if (!YesOrNoNumEnum.YES.getValue().equals(openRays)) {
this.addDefaultAppletNavigation(resourcePage.getId());
......@@ -414,6 +428,30 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return resourcePage.getId();
}
private void addResourcePageToRedis(ResourcePage resourcePage) {
ResourcePageDTO resourcePageDTO=new ResourcePageDTO();
BeanUtil.copyProperties(resourcePage,resourcePageDTO);
if(null!=resourcePage.getSceneId()) {
JedisClusterUtils.hset2Json(BookConstant.RESOURCE_PAGE_BY_SCENE_ID,resourcePage.getSceneId().toString(),resourcePageDTO);
JedisClusterUtils.expire(BookConstant.RESOURCE_PAGE_BY_SCENE_ID, 3600 * 24);
}
if(null!=resourcePage.getBookGroupId()) {
JedisClusterUtils.hset2Json(BookConstant.RESOURCE_PAGE_BY_BOOK_GROUP_ID,resourcePage.getBookGroupId().toString(),resourcePageDTO);
JedisClusterUtils.expire(BookConstant.RESOURCE_PAGE_BY_BOOK_GROUP_ID, 3600 * 24);
}
}
private void delResourcePageToRedis(ResourcePage resourcePage) {
if(null!=resourcePage.getSceneId()) {
JedisClusterUtils.hdel(BookConstant.RESOURCE_PAGE_BY_SCENE_ID,resourcePage.getSceneId().toString());
qrcodeSceneConsr.deleteParseRedis(resourcePage.getSceneId(),null);
}
if(null!=resourcePage.getBookGroupId()) {
JedisClusterUtils.hdel(BookConstant.RESOURCE_PAGE_BY_BOOK_GROUP_ID,resourcePage.getBookGroupId().toString());
qrcodeSceneConsr.deleteParseRedis(null,resourcePage.getBookGroupId());
}
}
private Long getBookGroupIdBySceneId(QrcodeSceneDto qrcodeSceneDto) {
if (null == qrcodeSceneDto || StringUtil.isEmpty(qrcodeSceneDto.getQrcodeType())
|| StringUtil.isEmpty(qrcodeSceneDto.getSceneCode())) {
......@@ -443,6 +481,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
//校验能否开启小睿
this.checkOpenRays(resourcePage.getBookId(), updateResourcePageVO.getOpenRays());
resourcePageDao.insert(resourcePage);
//加到缓存中
addResourcePageToRedis(resourcePage);
} else {
resourcePage.setStyle(updateResourcePageVO.getStyle());
resourcePage.setOpenRays(updateResourcePageVO.getOpenRays());
......@@ -459,6 +499,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePage.setTransparency(updateResourcePageVO.getTransparency());
resourcePage.setIsShowPrice(updateResourcePageVO.getIsShowPrice());
resourcePageDao.update(resourcePage);
//删除缓存中
delResourcePageToRedis(resourcePage);
}
if (updateResourcePageVO.getOpenRays() == 1) {
//小程序码
......@@ -472,6 +514,14 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
//同一本书其他码下关闭小睿流程
resourcePageDao.setOtherPageRaysClose(resourcePage.getBookId(), resourcePage.getChannelId(), resourcePage.getCreateUser(), null, bookGroupId);
//为了维护缓存。要先查出来其他码。然后更新
List<ResourcePage> otherPageRaysClose = resourcePageDao.getOtherPageRaysClose(resourcePage.getBookId(), resourcePage.getChannelId(), resourcePage.getCreateUser(), null, bookGroupId);
if(CollUtil.isNotEmpty(otherPageRaysClose)){
otherPageRaysClose.forEach(e->{
addResourcePageToRedis(e);
});
}
//添加小程序默认导航 之前关闭才添加
if (!YesOrNoNumEnum.YES.getValue().equals(openRays)) {
this.addDefaultAppletNavigation(resourcePage.getId());
......@@ -514,6 +564,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePage.setChannelId(null == qrcodeSceneDto?null:qrcodeSceneDto.getChannelPartyId());
}
resourcePageDao.insert(resourcePage);
//加入缓存
addResourcePageToRedis(resourcePage);
if (PageLandingPageTypeEnum.RESOURCE.getCode().equals(landingPageType)) {
//本书服务页添加默认导航
this.addDefaultBookServeNavigation(resourcePage.getId());
......@@ -696,6 +748,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
resourcePage.setOfficialSceneId(officialSceneId);
resourcePageDao.update(resourcePage);
//删除缓存
delResourcePageToRedis(resourcePage);
}
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getById(officialSceneId);
qrcodeUrl = qrcodeSceneDto.getQrcodeUrl();
......@@ -972,7 +1026,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePageId = pageId;
navigationId = naviId;
}*/
long t1 = System.currentTimeMillis();
List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId);
long t2 = System.currentTimeMillis();
System.out.println("第一步耗时="+(t2 - t1));
if (CollUtil.isNotEmpty(serveVOS)) {
List<ResourcePageItemVO> itemVOList;
if (null != wechatUserId) {
......@@ -980,16 +1037,34 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} else {
itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, null);
}
long t3 = System.currentTimeMillis();
System.out.println("第二步耗时="+(t3 - t2));
if (CollUtil.isNotEmpty(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));
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());
}
long t6 = System.currentTimeMillis();
System.out.println("第四步-1耗时="+(t6 - t4));
if(CollUtil.isNotEmpty(itemAppAndProductVOList)){
fillAppProductServe(itemAppAndProductVOList, wechatUserId);
itemVOList.addAll(itemAppAndProductVOList);
}
long t5 = System.currentTimeMillis();
System.out.println("第四步-2耗时="+(t5 - t6));
itemVOList.sort(Comparator.comparing(ResourcePageItemVO::getId));
Map<Long, List<ResourcePageItemVO>> columnMap = itemVOList.stream().collect(Collectors.groupingBy(ResourcePageItemVO::getResourcePageColumnId));
List<ResourceColumnAndServeVO> removeColumns = new ArrayList<>();
......@@ -1011,6 +1086,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
columnAndServeVO.setLogoUrl(itemVOS.get(0).getLogoUrl());
}
}
long t7 = System.currentTimeMillis();
System.out.println("第五步耗时="+(t7 - t5));
if (!ListUtils.isEmpty(removeColumns)) {
serveVOS.removeAll(removeColumns);
}
......@@ -1020,7 +1097,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
serveVOS = CollUtil.toList();
}
// 填充广告
long t8 = System.currentTimeMillis();
this.fillAdvertising(serveVOS, bookId, adviserId, channelId, enableAdverting);
long t9 = System.currentTimeMillis();
System.out.println("第六步耗时="+(t9 - t8));
return serveVOS;
}
......@@ -1288,8 +1368,13 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
List<Long> courseProductIds = new ArrayList<>();
List<Long> nonCourseProductIds = new ArrayList<>();
List<String> courseProductTypeCodes = Arrays.asList("VIDEO_SCHEDULE", "VIDEO_COURSE", "AUDIO_COURSE", "AUDIO_SCHEDULE", "LIVE");
List<Long> channelIds=new ArrayList<>();
for (ResourcePageItemVO vo : itemVOS) {
Long serveId = vo.getServeId();
Long channelId = getChannelIdFromUrl(vo.getLinkUrl());
if(null!=channelId && !channelIds.contains(channelId)){
channelIds.add(channelId);
}
if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(vo.getServeType()) && !appIds.contains(serveId)) {
appIds.add(serveId);
continue;
......@@ -1305,6 +1390,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
}
}
long t1 = System.currentTimeMillis();
Map<Long, AppDto> appDtoMap= new HashMap<>();
Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, MapBaseStatusDTO> appPriceMap = new HashMap<>();
......@@ -1312,26 +1398,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return appConsr.mapBaseByIds(appIds);
});
Future<Map<Long, ProductDto>>productMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return productConsr.getProBasesByIds(productIds);
return productConsr.getProductBasesByIds(productIds);
});
Future<Map<Long, MapBaseStatusDTO>> appPriceMapSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return appConsr.mapBaseStatusById(appIds);
});
try {
appDtoMap = appMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用应用中心获取应用信息错误:"+e.getMessage(), e);
}
try {
productDtoMap = productMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.warn("调用资源中心获取商品信息错误:"+e.getMessage(), e);
}
try {
appPriceMap = appPriceMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用应用中心获取应用价格信息错误:"+e.getMessage(), e);
}
Map<Long, AccountSettingDto> channelAccountSettingDtoMap = new HashMap<>();
Map<Long, AccountSetting> accountSettingMap = new HashMap<>();
//应用配置公众号工具
......@@ -1341,7 +1412,13 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
//课程是否购买(单节/整套)
Map<Long, Boolean> courseBuyStateMap = new HashMap<>();
if (null != wechatUserId) {
appOfficialAccountToolMap = appConsr.getPayOfficialAccountsToolByAppIds(appIds);
// appOfficialAccountToolMap = appConsr.getPayOfficialAccountsToolByAppIds(appIds);
Future<Map<Long, Long>> appOfficialAccountToolSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return appConsr.getPayOfficialAccountsToolByAppIds(appIds);
});
Future<Map<Long, AccountSettingDto>> channelAccountSettingDtoSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return channelConsr.listWechatAccountInfo(channelIds);
});
Future<Map<Long, Boolean>> buyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return tradeConsr.mapAppProductBuyState(wechatUserId, appIds, nonCourseProductIds);
});
......@@ -1349,6 +1426,16 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return tradeConsr.mapCourseProductBuyState(wechatUserId, courseProductIds);
});
try {
appOfficialAccountToolMap = appOfficialAccountToolSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用查应用关联的公众号工具的付费公众号失败:"+e.getMessage(), e);
}
try {
channelAccountSettingDtoMap = channelAccountSettingDtoSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用批量获取公众号信息失败:"+e.getMessage(), e);
}
try {
buyStateMap = buyStateSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用交易中心查询是否购买失败:"+e.getMessage(), e);
......@@ -1359,6 +1446,23 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
log.error("调用交易中心查询课程是否购买错误失败:"+e.getMessage(), e);
}
}
try {
appDtoMap = appMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用应用中心获取应用信息错误:"+e.getMessage(), e);
}
try {
productDtoMap = productMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.warn("调用资源中心获取商品信息错误:"+e.getMessage(), e);
}
try {
appPriceMap = appPriceMapSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用应用中心获取应用价格信息错误:"+e.getMessage(), e);
}
long t2 = System.currentTimeMillis();
System.out.println("第四-2-1步耗时="+(t2 - t1));
for (ResourcePageItemVO itemVO : itemVOS) {
Long serveId = itemVO.getServeId();
String serveType = itemVO.getServeType();
......@@ -1418,6 +1522,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
}
}
long t3 = System.currentTimeMillis();
System.out.println("第四-2-2步耗时="+(t3 - t2));
}
/**
......@@ -2119,7 +2225,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
pageOneServe.setQrcodeType("own");
} else if (null != sceneId) {
resourcePage = resourcePageDao.getBySceneId(sceneId);
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getById(sceneId);
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getOnlySceneInfoById(sceneId);
pageOneServe.setQrcodeType(null == qrcodeSceneDto?"ali":qrcodeSceneDto.getQrcodeType());
}
if (null != resourcePage) {
......@@ -2377,6 +2483,13 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
List<Long> sceneIds = dto.getSceneIds();
if (!ListUtils.isEmpty(sceneIds)) {
resourcePageDao.updateBookBySceneIds(sceneIds, dto.getBookId(), dto.getChannelId());
//删除缓存
List<ResourcePage> list = resourcePageDao.getBySceneIds(sceneIds);
if(CollUtil.isNotEmpty(list)){
list.forEach(e->{
delResourcePageToRedis(e);
});
}
}
}
}
......@@ -2640,6 +2753,13 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
ResourcePage resourcePage = resourcePageDao.getBySceneId(sceneId);
if (null != resourcePage) {
resourcePageDao.updateBookIdBySceneId(bookId, sceneId);
//删除缓存
List<ResourcePage> list = resourcePageDao.getBySceneIds(CollUtil.newArrayList(sceneId));
if(CollUtil.isNotEmpty(list)){
list.forEach(e->{
delResourcePageToRedis(e);
});
}
}
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getById(sceneId);
Long bookGroupId = this.getBookGroupIdBySceneId(qrcodeSceneDto);
......@@ -3315,6 +3435,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePage.setOpenRays(0);
resourcePage.setOpenFood(0);
resourcePageDao.update(resourcePage);
//删除缓存
delResourcePageToRedis(resourcePage);
ThreadPoolUtils.RESOURCE_POOL.execute(()->{
//同步到chanelcenter
qrcodeSceneConsr.updateLandingPageType(sceneId, landingPageType);
......
......@@ -391,6 +391,8 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
List<BookGroupDTO> getDTOByBookIdList(Long bookId, Long channelId, Long adviserId);
List<BookGroupDTO> listBookGroup(Long bookId, Long channelId, Long adviserId);
List<BookQrcodeVO> listBookQrcodes(Long bookId, Long channelId, Long adviserId, String sceneName, List<Long> locationIds);
List<BookQrcodeVO> listBookQrcodeVOByIds(List<Long> bookGroupIds);
......
......@@ -92,6 +92,8 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
* * @param null
*/
void updateBookBySceneIds(List<Long> sceneIds, Long bookId, Long channelId);
List<ResourcePage> getBySceneIds(List<Long> sceneIds);
/**
*同一本书其他码下关闭小睿流程
* @author:zhuyajie
......@@ -100,6 +102,8 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
*/
void setOtherPageRaysClose(Long bookId, Long channelId, Long createUser, Long sceneId, Long bookGroupId);
List<ResourcePage> getOtherPageRaysClose(Long bookId, Long channelId, Long createUser, Long sceneId, Long bookGroupId);
/**
* 书刊是否开启小睿
* @author:zhuyajie
......
......@@ -320,7 +320,7 @@ public class BookGroupClassifyDaoImpl extends BaseDaoImpl<BookGroupClassify> imp
@Override
public List<BookAdviserInfo> getBookAndAdviserByClassifyIds(Set<Long> classifyIds) {
HashMap<String, Object> map = CollUtil.newHashMap(1);
HashMap<String, Object> map = new HashMap<>();
map.put("classifyIds",classifyIds);
return getSqlSession().selectList("getBookAndAdviserByClassifyIds",map);
}
......
......@@ -528,6 +528,15 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
}
@Override
public List<BookGroupDTO> listBookGroup(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 super.getSqlSession().selectList(getStatement("listBookGroup"), paramMap);
}
@Override
public List<BookQrcodeVO> listBookQrcodes(Long bookId, Long channelId, Long adviserId, String sceneName, List<Long> locationIds) {
Map<String, Object> paramMap = MapUtil.of("bookId", bookId);
paramMap.put("channelId", channelId);
......
......@@ -334,7 +334,7 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
@Override
public List<ESBookGroupQrcode> selectPage(long start, long offset) {
HashMap<String, Object> map = CollUtil.newHashMap(2);
HashMap<String, Object> map = new HashMap<>();
map.put("start",start);
map.put("offset",offset);
return getSessionTemplate().selectList("selectPage",map);
......@@ -342,14 +342,14 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
@Override
public String getMediaId(Long id) {
HashMap<String, Object> map = CollUtil.newHashMap(2);
HashMap<String, Object> map = new HashMap<>();
map.put("id",id);
return getSessionTemplate().selectOne(getStatement("getMediaId"),map);
}
@Override
public void updateMediaId(Long id, String mediaId, Date date) {
HashMap<String, Object> map = CollUtil.newHashMap(2);
HashMap<String, Object> map = new HashMap<>();
map.put("id",id);
map.put("mediaId",mediaId);
map.put("date",date);
......@@ -358,7 +358,7 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
@Override
public List<GroupQrcodeDTO> getMigrateGroup(List<String> groups) {
HashMap<String, Object> map = CollUtil.newHashMap(1);
HashMap<String, Object> map = new HashMap<>();
map.put("list",groups);
return getSessionTemplate().selectList(getStatement("getMigrateGroup"),map);
}
......@@ -370,7 +370,7 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
@Override
public void removeMediaIdByIds(List<Long> ids) {
HashMap<String, Object> map = CollUtil.newHashMap(1);
HashMap<String, Object> map = new HashMap<>();
map.put("list",ids);
getSessionTemplate().delete(getStatement("removeMediaIdByIds"),map);
}
......
......@@ -82,6 +82,13 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
}
@Override
public List<ResourcePage> getBySceneIds(List<Long> sceneIds) {
Map<String, Object> map = new HashMap<>();
map.put("sceneIds", sceneIds);
return getSessionTemplate().selectList(getStatement("getBySceneIds"), map);
}
@Override
public void setOtherPageRaysClose(Long bookId, Long channelId, Long createUser, Long sceneId, Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookId", bookId);
......@@ -93,6 +100,17 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
}
@Override
public List<ResourcePage> getOtherPageRaysClose(Long bookId, Long channelId, Long createUser, Long sceneId, Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookId", bookId);
map.put("channelId", channelId);
map.put("createUser", createUser);
map.put("bookGroupId", bookGroupId);
map.put("sceneId", sceneId);
return getSessionTemplate().selectList(getStatement("getOtherPageRaysClose"), map);
}
@Override
public Boolean isOpenRaysBook(Long bookId, Long channelId, Long adviserId) {
Map<String, Object> map = new HashMap<>();
map.put("bookId", bookId);
......
......@@ -361,7 +361,7 @@ public class BookBrowseRecordBizImpl implements BookBrowseRecordBiz {
@Override
public Map<String, String> getCitiesByIp(List<String> ips) {
Map<String, String> map = CollUtil.newHashMap();
Map<String, String> map = new HashMap<>();
List<IpData> ipData = ipDataMapper.listCityByIp(ips);
if (!CollUtil.isEmpty(ipData)) {
map = ipData.stream().collect(Collectors.toMap(IpData::getIp, IpData::getCity));
......
......@@ -1678,7 +1678,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null != rightsSettingTitle){
List<RightsNowItem> nowItems = null;
if(hasPage){
Map<String, Object> map = CollUtil.newHashMap(2);
Map<String, Object> map = new HashMap<>();
map.put("rightsSettingTitleId",rightsSettingTitle.getId());
map.put("types",Collections.singletonList(RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value));
PageBeanNew<RightsNowItem> pageBeanNew = rightsNowItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getListByRightsSettingTitleId");
......@@ -1708,7 +1708,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null != rightsSettingTitle){
List<RightsNowItem> nowItems = null;
if (hasPage){
Map<String, Object> map = CollUtil.newHashMap(2);
Map<String, Object> map = new HashMap<>();
map.put("rightsSettingTitleId",rightsSettingTitle.getId());
map.put("types",Collections.singletonList(RightsNowItemTypeNew.ONLINE_COURSE.value));
PageBeanNew<RightsNowItem> pageBeanNew = rightsNowItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getListByRightsSettingTitleId");
......@@ -3420,7 +3420,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<RightsNowItem> nowItems = null;
if(hasPage){
Map<String, Object> map = CollUtil.newHashMap(2);
Map<String, Object> map = new HashMap<>();
map.put("rightsSettingTitleId",rightsSettingTitle.getId());
map.put("types",Collections.singletonList(RightsNowItemTypeNew.GROUP_SERVICE.value));
PageBeanNew<RightsNowItem> pageBeanNew = rightsNowItemDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getListByRightsSettingTitleId");
......@@ -4033,7 +4033,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
// 查询书刊权益ID列表
List<Long> rightsSettingIds = rightsSettingDtos.stream().map(RightsSettingDto::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(rightsSettingIds)) {
Map<String, Object> map = CollUtil.newHashMap(4);
Map<String, Object> map = new HashMap<>();
map.put("list", rightsSettingIds);
map.put("deepRead", deepRead);
map.put("easyRead", easyRead);
......
......@@ -156,6 +156,16 @@
and join_group_type != 4
</select>
<select id="listBookGroup" resultMap="BookGroupDTO" parameterType="map">
select
<include refid="Base_Column_List"/>
from book_group
where is_delete = 0
and book_id = #{bookId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and create_user = #{adviserId,jdbcType=BIGINT}
</select>
<select id="getDTOByBookIdsAnsAdviserIds" resultMap="BookGroupDTO" parameterType="map">
select
<include refid="Base_Column_List"/>
......
......@@ -244,6 +244,17 @@
</foreach>
</update>
<select id="getBySceneIds" parameterType="map" resultMap="ResourcePageMap">
select
<include refid="Base_Column_List"/>
from resource_page
WHERE
scene_id IN
<foreach collection="sceneIds" close=")" open="(" separator="," index="index" item="item">
#{item}
</foreach>
</select>
<update id="setOtherPageRaysClose" parameterType="map">
UPDATE resource_page
SET open_rays = 0
......@@ -259,6 +270,22 @@
</if>
</update>
<select id="getOtherPageRaysClose" parameterType="map" resultMap="ResourcePageMap">
select
<include refid="Base_Column_List"/>
from resource_page
WHERE
book_id = #{bookId}
AND channel_id = #{channelId}
AND create_user = #{createUser}
<if test="sceneId != null">
AND scene_id != #{sceneId}
</if>
<if test="bookGroupId != null">
AND book_group_id != #{bookGroupId}
</if>
</select>
<select id="isOpenRaysBook" resultType="boolean" parameterType="map">
SELECT
COUNT(1)
......
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