Commit 5fb355ac by 郑勇

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

parent 3e9dfec3
...@@ -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";
} }
...@@ -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;
}
} }
...@@ -187,6 +187,52 @@ public class ProductConsr { ...@@ -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 { public Map<Long, Product4BookDTO> getProBasesWithSceneByIds(List<Long> productIds) throws BizException {
......
...@@ -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;
}
} }
...@@ -535,6 +535,11 @@ public interface ResourcePageBiz { ...@@ -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<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 * @param param
......
...@@ -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);
/** /**
* 根据类型查询 * 根据类型查询
......
...@@ -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);
......
...@@ -111,6 +111,35 @@ public class ResourcePageFacade { ...@@ -111,6 +111,35 @@ public class ResourcePageFacade {
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId4Wechat(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId)); 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("客户端分页查栏目资源") @ApiOperation("客户端分页查栏目资源")
@GetMapping("listPageResourcePageItem") @GetMapping("listPageResourcePageItem")
public ResponseDto<?> listPageResourcePageItem(@CookieValue("userInfo") String userInfo, public ResponseDto<?> listPageResourcePageItem(@CookieValue("userInfo") String userInfo,
......
...@@ -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
......
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