Commit 5fb355ac by 郑勇

feat: [1006670] 落地页3期接口优化

parent 3e9dfec3
......@@ -474,4 +474,16 @@ public class BookConstant {
* 手机号授权
*/
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";
}
......@@ -306,4 +306,16 @@ public class AppConsr {
}
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;
}
}
......@@ -187,6 +187,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;
}
}
/**
* 资源中心拉取商品基本信息
*/
public Map<Long, Product4BookDTO> getProBasesWithSceneByIds(List<Long> productIds) throws BizException {
......
......@@ -371,4 +371,40 @@ public class TradeConsr {
}
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;
}
}
......@@ -535,6 +535,11 @@ public interface ResourcePageBiz {
*/
List<ResourceColumnAndServeVO> getColumnAndServeListByPageId4Wechat(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId);
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);
/**
* 保存分享配置
* @param param
......
......@@ -181,6 +181,8 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.security.auth.callback.CallbackHandler;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
......@@ -1026,10 +1028,7 @@ 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));
List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId,null);
if (CollUtil.isNotEmpty(serveVOS)) {
List<ResourcePageItemVO> itemVOList;
if (null != wechatUserId) {
......@@ -1037,13 +1036,9 @@ 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<>();
//应用和作品提出来一起查
......@@ -1057,14 +1052,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
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<>();
......@@ -1086,8 +1077,6 @@ 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);
}
......@@ -1097,10 +1086,7 @@ 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;
}
......@@ -1393,22 +1379,22 @@ 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<>();
// Map<Long, MapBaseStatusDTO> appPriceMap = new HashMap<>();
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(() ->{
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);
});
});*/
Map<Long, AccountSettingDto> channelAccountSettingDtoMap = new HashMap<>();
Map<Long, AccountSetting> accountSettingMap = 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<>();
if (null != wechatUserId) {
......@@ -1419,11 +1405,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
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);
Future<Map<String, Boolean>> buyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return tradeConsr.mapAppProductBuyStateOpt(wechatUserId, appIds, nonCourseProductIds);
});
Future<Map<Long, Boolean>> courseBuyStateSubmit = ThreadPoolUtils.RESOURCE_POOL.submit(() ->{
return tradeConsr.mapCourseProductBuyState(wechatUserId, courseProductIds);
return tradeConsr.mapCourseProductBuyStateOpt(wechatUserId, courseProductIds);
});
try {
appOfficialAccountToolMap = appOfficialAccountToolSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
......@@ -1456,13 +1442,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.warn("调用资源中心获取商品信息错误:"+e.getMessage(), e);
}
try {
/* 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));
}*/
Map<Long,Long> defaultChannelIdMap=new HashMap<>();
for (ResourcePageItemVO itemVO : itemVOS) {
Long serveId = itemVO.getServeId();
String serveType = itemVO.getServeType();
......@@ -1474,12 +1459,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
itemVO.setTypeCode(appDto.getTypeCode());
itemVO.setTypeName(appDto.getTypeName());
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);
if (!MapUtils.isEmpty(appPriceMap) && appPriceMap.containsKey(serveId)) {
/* if (!MapUtils.isEmpty(appPriceMap) && appPriceMap.containsKey(serveId)) {
BigDecimal price = appPriceMap.get(serveId).getRetailPrice();
itemVO.setPrice(null == price?Double.valueOf(0d):price.doubleValue());
}
}*/
//标记应用共享状态
itemVO.setAppCreateUser(appDto.getCreatedUser());
itemVO.setShareState(appDto.getShareState());
......@@ -1507,14 +1492,34 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
Long channelId = getChannelIdFromUrl(itemVO.getLinkUrl());
if (null == channelId) {
log.info(itemVO.getServeName() + "无运营平台, serveId=" + itemVO.getServeId());
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);
if (null != wechatUserId) {
setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap);
itemVO.setBuyState(false);
if (!MapUtils.isEmpty(buyStateMap) && buyStateMap.containsKey(serveId)) {
itemVO.setBuyState(buyStateMap.get(serveId));
if (!MapUtils.isEmpty(buyStateMap)) {
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)
&& ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(itemVO.getServeType())) {
......@@ -1522,8 +1527,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
}
}
long t3 = System.currentTimeMillis();
System.out.println("第四-2-2步耗时="+(t3 - t2));
}
/**
......@@ -2102,7 +2105,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
* * @param null
*/
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)) {
return;
}
......@@ -3167,9 +3170,65 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
qrcodeTemp.setAccountSettingId(accountSettingId);
qrcodeTemp.setCreatedUser(wechatUserId);
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)) {
String cacheQrcodeUrl = JedisClusterUtils.get(tempKey);
String cacheLogoUrl = JedisClusterUtils.get(logoUrlKey);
//qrcodeUrl 变了要重新生成
if(StrUtil.isBlank(cacheQrcodeUrl)){
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);
}
}
//logoUrl 变了也要重新生成
if(StrUtil.isBlank(cacheLogoUrl)){
JedisClusterUtils.set(logoUrlKey,qrcodeUrl,60*60*24*30);
}else{
//如果缓存里面有值。然后就从缓存里面拿的和新拿到的logoUrl比较。如果不同。说明变了logoUrl了。那么都要重新生成一次
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= cacheQrcodeUrl;
}else {
//添加Logo
qrcodeUrl = getQrcodeUrl(logoUrl, qrcodeUrl);
JedisClusterUtils.set(pageKey,qrcodeUrl,60*60*24*30);
}
}
pageItemVO.setResultUrl(qrcodeUrl);
if (!StringUtil.isEmpty(qrcodeUrl)) {
popupState = true;
}
pageItemVO.setPopupState(popupState);
pageItemVO.setLinkUrl(null);
return pageItemVO;
}
private String getQrcodeUrl(String logoUrl, String qrcodeUrl) {
String url = "";
String tmpDirPath = FileUtil.getTmpDirPath();
if (!tmpDirPath.endsWith(File.separator)) {
......@@ -3183,14 +3242,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
log.info("解析二维码图片失败,qrcodeUrl:{}", qrcodeUrl);
}
qrcodeUrl = this.getLogoQrcode(url, logoUrl, qrcodeUrl);
}
pageItemVO.setResultUrl(qrcodeUrl);
if (!StringUtil.isEmpty(qrcodeUrl)) {
popupState = true;
}
pageItemVO.setPopupState(popupState);
pageItemVO.setLinkUrl(null);
return pageItemVO;
return qrcodeUrl;
}
@Override
......@@ -3597,6 +3649,98 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
@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) {
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);
return serveVOS;
}
@Override
public Integer saveShareConfig(ResourcePageShareParam param) {
checkShareParam(param);
shareMapper.save(buildNewShareConfig(param));
......
......@@ -29,7 +29,9 @@ public interface ResourcePageColumnDao extends BaseDao<ResourcePageColumn> {
* @date:2021/3/29 13:45
* * @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);
/**
* 根据类型查询
......
......@@ -30,14 +30,23 @@ public class ResourcePageColumnDaoImpl extends BaseDaoImpl<ResourcePageColumn> i
}
@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.put("navigationId", navigationId);
map.put("resourcePageId", resourcePageId);
map.put("columnType", columnType);
return getSessionTemplate().selectList(getStatement("getColumnListByPageId"), map);
}
@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) {
Map<String, Object> map = new HashMap<>();
map.put("resourcePageId", resourcePageId);
......
......@@ -111,6 +111,35 @@ public class ResourcePageFacade {
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId4Wechat(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId));
}
//优化 此处把模块分开调接口
@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);
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId4WechatV2(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId,columnType));
}
@ApiOperation("客户端分页查栏目资源")
@GetMapping("listPageResourcePageItem")
public ResponseDto<?> listPageResourcePageItem(@CookieValue("userInfo") String userInfo,
......
......@@ -125,11 +125,26 @@
<if test="navigationId != null">
and navigation_id = #{navigationId}
</if>
<if test="columnType!=null">
and column_type = #{columnType}
</if>
ORDER BY
column_seq ASC,
id ASC
</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, resource_page_id, column_type, column_name, column_format, column_seq, show_more, show_count, create_time, navigation_id, background_type, background_url
......
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