Commit efbf6613 by 田超

Merge branch 'fixbug/1004247' into 'master'

bug:[1004247] fixCollect

See merge request rays/pcloud-book!1183
parents 8016f8b9 3d396fbe
...@@ -2,6 +2,7 @@ package com.pcloud.book.applet.biz.impl; ...@@ -2,6 +2,7 @@ package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.AppTypeDto; import com.pcloud.appcenter.app.dto.AppTypeDto;
import com.pcloud.appcenter.app.entity.AppType; import com.pcloud.appcenter.app.entity.AppType;
...@@ -274,6 +275,9 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -274,6 +275,9 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
paramCheck(serveCollect); paramCheck(serveCollect);
fillParam(serveCollect); fillParam(serveCollect);
AppletTaskDTO appletTaskDTO = new AppletTaskDTO(); AppletTaskDTO appletTaskDTO = new AppletTaskDTO();
if (StringUtil.isEmpty(serveCollect.getServeTypeName())) {
fillTypeCodeAndTypeName(Lists.newArrayList(serveCollect));
}
serveCollectDao.insert(serveCollect); serveCollectDao.insert(serveCollect);
Integer taskCount = readerConsr.getTaskCount(serveCollect.getWechatUserId(), MoneyReceiveTypeEnum.COLLECTION.key); Integer taskCount = readerConsr.getTaskCount(serveCollect.getWechatUserId(), MoneyReceiveTypeEnum.COLLECTION.key);
Integer subtractTaskCount = RmallContants.COLLECTION_MONEY_TIMES - 1; Integer subtractTaskCount = RmallContants.COLLECTION_MONEY_TIMES - 1;
...@@ -504,17 +508,23 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -504,17 +508,23 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
} }
private void fillTypeCodeAndTypeName(List<ServeCollect> recordList){ private void fillTypeCodeAndTypeName(List<ServeCollect> recordList){
List<Long> newsIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.NEWS.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList());
List<Long> productsIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.PRODUCT.value.equals(serveCollect.getServeType())). List<Long> productsIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.PRODUCT.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList()); map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList());
List<Long> appIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.APP.value.equals(serveCollect.getServeType())). List<Long> appIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.APP.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList()); map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList());
Map<Long, AppletNewsDTO> newsDtoMap = new HashMap<>();
Future<Map<Long, AppletNewsDTO>> newsDtoMapFuture = null;
Map<Long,ProductDto> productDtoMap = new HashMap<>(); Map<Long,ProductDto> productDtoMap = new HashMap<>();
Future<Map<Long,ProductDto>> productDtoMapFuture = null; Future<Map<Long,ProductDto>> productDtoMapFuture = null;
Map<Long,AppDto> appDtoMap = new HashMap<>(); Map<Long,AppDto> appDtoMap = new HashMap<>();
Future<Map<Long,AppDto>> appDtoMapFuture = null; Future<Map<Long,AppDto>> appDtoMapFuture = null;
if (!ListUtils.isEmpty(newsIdList)) {
newsDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appletNewsBiz.getByIds4Record(newsIdList));
}
if (!CollUtil.isEmpty(productsIdList)){ if (!CollUtil.isEmpty(productsIdList)){
productDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> productConsr.getProBasesByIds(productsIdList)); productDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> productConsr.getProBasesByIds(productsIdList));
} }
...@@ -524,6 +534,9 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -524,6 +534,9 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
Iterator<ServeCollect> iterator = recordList.iterator(); Iterator<ServeCollect> iterator = recordList.iterator();
while(iterator.hasNext()){ while(iterator.hasNext()){
ServeCollect serveCollect = iterator.next(); ServeCollect serveCollect = iterator.next();
if (Objects.equals(AppletRecordTypeEnum.NEWS.value, serveCollect.getServeType()) && null != newsDtoMap) {
fillNewsTypeNameAndTypeCode(newsDtoMap, newsDtoMapFuture, serveCollect);
}
if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value,serveCollect.getServeType())){ if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value,serveCollect.getServeType())){
fillProTypeNameAndTypeCode(productDtoMap,productDtoMapFuture,serveCollect); fillProTypeNameAndTypeCode(productDtoMap,productDtoMapFuture,serveCollect);
} }
...@@ -556,6 +569,12 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -556,6 +569,12 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
} }
/**
* 填充App收藏的TypeName与TypeCode
* @param appDtoMap
* @param appDtoMapFuture
* @param serveCollect
*/
private void fillAppTypeNameAndTypeCode(Map<Long,AppDto> appDtoMap,Future<Map<Long,AppDto>> appDtoMapFuture,ServeCollect serveCollect){ private void fillAppTypeNameAndTypeCode(Map<Long,AppDto> appDtoMap,Future<Map<Long,AppDto>> appDtoMapFuture,ServeCollect serveCollect){
try { try {
appDtoMap = appDtoMapFuture.get(); appDtoMap = appDtoMapFuture.get();
...@@ -571,6 +590,25 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -571,6 +590,25 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
} }
} }
private void fillNewsTypeNameAndTypeCode ( Map<Long, AppletNewsDTO> newsDtoMap,Future<Map<Long, AppletNewsDTO>> newsDtoMapFuture,ServeCollect serveCollect){
try {
newsDtoMap = newsDtoMapFuture.get();
}catch (InterruptedException | ExecutionException e){
LOGGER.error("获取App详情错误:{}==",e);
}
if (CollUtil.isEmpty(newsDtoMap)){
return;
}
if (null != newsDtoMap.get(serveCollect.getServeId())){
if (serveCollect.getServeTypeCode() == null){
serveCollect.setServeTypeCode("NEWS");
}
if (null == serveCollect.getServeTypeName()){
serveCollect.setServeTypeName(newsDtoMap.get(serveCollect.getServeId()).getSource());
}
}
}
@Override @Override
public List<Long> getAllCollect(Long wechatUserId,String typeCode) { public List<Long> getAllCollect(Long wechatUserId,String typeCode) {
return serveCollectDao.getAllCollect(wechatUserId,typeCode); return serveCollectDao.getAllCollect(wechatUserId,typeCode);
......
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