Commit a5bc3788 by 田超

Merge branch 'feature/1005387' into 'master'

feat:[1005387]本书服务页优化

See merge request rays/pcloud-book!1409
parents debe368e 4cd4f800
...@@ -6,6 +6,7 @@ import com.pcloud.appcenter.app.dto.AppDto; ...@@ -6,6 +6,7 @@ import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.AppIdTypeDTO; import com.pcloud.appcenter.app.dto.AppIdTypeDTO;
import com.pcloud.appcenter.app.dto.AppRaysDTO; import com.pcloud.appcenter.app.dto.AppRaysDTO;
import com.pcloud.appcenter.app.dto.AppTypeDto; import com.pcloud.appcenter.app.dto.AppTypeDto;
import com.pcloud.appcenter.app.dto.app.MapBaseStatusDTO;
import com.pcloud.appcenter.app.service.AppService; import com.pcloud.appcenter.app.service.AppService;
import com.pcloud.appcenter.app.service.AppTypeService; import com.pcloud.appcenter.app.service.AppTypeService;
import com.pcloud.appcenter.base.dto.AppPriceCacheDTO; import com.pcloud.appcenter.base.dto.AppPriceCacheDTO;
...@@ -293,4 +294,16 @@ public class AppConsr { ...@@ -293,4 +294,16 @@ public class AppConsr {
} }
return new HashMap<>(); return new HashMap<>();
} }
@ParamLog(description = "获取应用状态与价格", isAfterReturn = false)
public Map<Long, MapBaseStatusDTO> mapBaseStatusById(List<Long> appIds){
if(ListUtils.isEmpty(appIds)) return null;
try{
Map<Long, MapBaseStatusDTO> appBaseStatus = ResponseHandleUtil.parseMap(appService.mapBaseStatusById(appIds), Long.class, MapBaseStatusDTO.class);
return appBaseStatus;
}catch (Exception e){
LOGGER.error("获取应用状态与价格失败"+ e.getMessage(), e);
}
return null;
}
} }
...@@ -329,4 +329,46 @@ public class TradeConsr { ...@@ -329,4 +329,46 @@ public class TradeConsr {
} }
return new HashMap<>(); return new HashMap<>();
} }
/**
* 应用作品购买状态
* @author:zhuyajie
* @date:2021/9/6 15:48
* * @param null
*/
public Map<Long, Boolean> mapAppProductBuyState(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.mapAppProductBuyState(orderSearchDto),Long.class,Boolean.class);
} catch (Exception e) {
LOGGER.error("调用orderFormService.mapAppProductBuyState失败"+e.getMessage(), e);
}
return null;
}
/**
* 课程单节课购买状态
* @author:zhuyajie
* @date:2021/9/7 12:37
* * @param null
*/
public Map<Long, Boolean> mapCourseProductBuyState(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.mapCourseProductBuyState(orderSearchDto),Long.class,Boolean.class);
} catch (Exception e) {
LOGGER.error("调用orderFormService.mapCourseProductBuyState失败"+e.getMessage(), e);
}
return null;
}
} }
...@@ -66,7 +66,7 @@ public interface ResourcePageBiz { ...@@ -66,7 +66,7 @@ public interface ResourcePageBiz {
* @date:2021/3/29 11:49 * @date:2021/3/29 11:49
* * @param null * * @param null
*/ */
List<ResourceColumnAndServeVO> getColumnAndServeListByPageId(Long resourcePageId, Boolean isWechat, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId); List<ResourceColumnAndServeVO> getColumnAndServeListByPageId(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId);
/** /**
* 根据书刊查资源页基本配置 * 根据书刊查资源页基本配置
* @author:zhuyajie * @author:zhuyajie
...@@ -81,7 +81,7 @@ public interface ResourcePageBiz { ...@@ -81,7 +81,7 @@ public interface ResourcePageBiz {
* @date:2021/3/31 19:06 * @date:2021/3/31 19:06
* * @param null * * @param null
*/ */
PageBeanNew<ResourcePageItemVO> listPageResourcePageItem(Integer currentPage, Integer numPerPage, Long resourcePageColumnId); PageBeanNew<ResourcePageItemVO> listPageResourcePageItem(Integer currentPage, Integer numPerPage, Long resourcePageColumnId, Long wechatUserId);
/** /**
* 根据社群码id查询 * 根据社群码id查询
...@@ -173,7 +173,7 @@ public interface ResourcePageBiz { ...@@ -173,7 +173,7 @@ public interface ResourcePageBiz {
* @date:2021/4/21 15:09 * @date:2021/4/21 15:09
* * @param null * * @param null
*/ */
ResourcePageOneServe hasOneResource(Long bookGroupId, Long sceneId); ResourcePageOneServe hasOneResource(Long bookGroupId, Long sceneId, Long wechatUserId);
/** /**
* 自有码配置的资源列表 * 自有码配置的资源列表
......
...@@ -11,6 +11,7 @@ import com.pcloud.advertising.advertising.dto.AdvertisingSpaceDTO; ...@@ -11,6 +11,7 @@ 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;
...@@ -34,6 +35,7 @@ import com.pcloud.book.consumer.channel.QrcodeSceneConsr; ...@@ -34,6 +35,7 @@ import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.raystask.AdviserTaskConsr; import com.pcloud.book.consumer.raystask.AdviserTaskConsr;
import com.pcloud.book.consumer.reader.ReaderConsr; import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr; import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.consumer.trade.TradeConsr;
import com.pcloud.book.consumer.user.AdviserConsr; import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.user.AgentConsr; import com.pcloud.book.consumer.user.AgentConsr;
import com.pcloud.book.consumer.user.ChannelConsr; import com.pcloud.book.consumer.user.ChannelConsr;
...@@ -84,7 +86,12 @@ import org.springframework.stereotype.Component; ...@@ -84,7 +86,12 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.File; import java.io.File;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -164,6 +171,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -164,6 +171,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
private ResourcePageNavigationDao resourcePageNavigationDao; private ResourcePageNavigationDao resourcePageNavigationDao;
@Autowired @Autowired
private ResourcePagePicDao resourcePagePicDao; private ResourcePagePicDao resourcePagePicDao;
@Autowired
private TradeConsr tradeConsr;
@Override @Override
public Long updateResourcePage(UpdateResourcePageVO updateResourcePageVO) { public Long updateResourcePage(UpdateResourcePageVO updateResourcePageVO) {
...@@ -679,11 +688,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -679,11 +688,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@Override @Override
public List<ResourceColumnAndServeVO> getColumnAndServeListByPageId(Long resourcePageId, Boolean isWechat, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId) { public List<ResourceColumnAndServeVO> getColumnAndServeListByPageId(Long resourcePageId, Long wechatUserId, Long bookId, Long adviserId, Long channelId, Integer enableAdverting, Long navigationId) {
List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId); List<ResourceColumnAndServeVO> serveVOS = resourcePageColumnDao.getColumnListByPageId(resourcePageId, navigationId);
if (CollUtil.isNotEmpty(serveVOS)) { if (CollUtil.isNotEmpty(serveVOS)) {
List<ResourcePageItemVO> itemVOList; List<ResourcePageItemVO> itemVOList;
if (isWechat) { if (null != wechatUserId) {
itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, true); itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, true);
} else { } else {
itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, null); itemVOList = resourcePageItemDao.getResourcePageItemByPageId(resourcePageId, null);
...@@ -695,7 +704,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -695,7 +704,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
itemVOList = new ArrayList<>(); itemVOList = new ArrayList<>();
//过滤一些资源,重新排序 //过滤一些资源,重新排序
for (Map.Entry<String, List<ResourcePageItemVO>> entry : listMap.entrySet()) { for (Map.Entry<String, List<ResourcePageItemVO>> entry : listMap.entrySet()) {
this.fillResourceByType(entry.getValue(), isWechat, entry.getKey()); this.fillResourceByType(entry.getValue(), wechatUserId, entry.getKey());
itemVOList.addAll(entry.getValue()); itemVOList.addAll(entry.getValue());
} }
itemVOList.sort(Comparator.comparing(ResourcePageItemVO::getId)); itemVOList.sort(Comparator.comparing(ResourcePageItemVO::getId));
...@@ -808,24 +817,24 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -808,24 +817,24 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("按类型填充资源") @ParamLog("按类型填充资源")
private void fillResourceByType(List<ResourcePageItemVO> itemVOS, Boolean isWechat, String serveType) { private void fillResourceByType(List<ResourcePageItemVO> itemVOS, Long wechatUserId, String serveType) {
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
} }
if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(serveType)) { if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(serveType)) {
fillAppProductServe(itemVOS, isWechat); fillAppProductServe(itemVOS, wechatUserId);
} else if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)) {
fillAppProductServe(itemVOS, isWechat); fillAppProductServe(itemVOS, wechatUserId);
} else if (ResourcePageConstants.ServeTypeEnum.OFFICIAL_ACCOUNT.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.OFFICIAL_ACCOUNT.getValue().equals(serveType)) {
fillOfficialAccount(itemVOS, isWechat); fillOfficialAccount(itemVOS, wechatUserId);
} else if (ResourcePageConstants.ServeTypeEnum.BOOKLIST.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.BOOKLIST.getValue().equals(serveType)) {
fillBooklistServe(itemVOS, isWechat); fillBooklistServe(itemVOS);
} else if (ResourcePageConstants.ServeTypeEnum.ADVISER_BOOK.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.ADVISER_BOOK.getValue().equals(serveType)) {
fillAdviserBook(itemVOS, isWechat); fillAdviserBook(itemVOS);
} else if (ResourcePageConstants.ServeTypeEnum.GROUP_ACTIVITY.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.GROUP_ACTIVITY.getValue().equals(serveType)) {
fillGroupServe(itemVOS, isWechat); fillGroupServe(itemVOS);
} else if (ResourcePageConstants.ServeTypeEnum.THIRD_RESOURCE.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.THIRD_RESOURCE.getValue().equals(serveType)) {
fillThirdResource(itemVOS, isWechat); fillThirdResource(itemVOS);
} else if (ResourcePageConstants.ServeTypeEnum.WXWORK_GROUP.getValue().equals(serveType)) { } else if (ResourcePageConstants.ServeTypeEnum.WXWORK_GROUP.getValue().equals(serveType)) {
fillWxworkGroup(itemVOS); fillWxworkGroup(itemVOS);
} }
...@@ -873,7 +882,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -873,7 +882,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("填充第三方资源") @ParamLog("填充第三方资源")
private void fillThirdResource(List<ResourcePageItemVO> itemVOS, Boolean isWechat) { private void fillThirdResource(List<ResourcePageItemVO> itemVOS) {
log.info("填充第三方资源"); log.info("填充第三方资源");
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
...@@ -893,7 +902,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -893,7 +902,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("填充编辑书刊链接") @ParamLog("填充编辑书刊链接")
private void fillAdviserBook(List<ResourcePageItemVO> itemVOS, Boolean isWechat) { private void fillAdviserBook(List<ResourcePageItemVO> itemVOS) {
log.info("填充编辑书刊链接"); log.info("填充编辑书刊链接");
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
...@@ -919,7 +928,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -919,7 +928,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("填充公众号二维码") @ParamLog("填充公众号二维码")
private void fillOfficialAccount(List<ResourcePageItemVO> itemVOS, Boolean isWechat) { private void fillOfficialAccount(List<ResourcePageItemVO> itemVOS, Long wechatUserId) {
log.info("填充公众号二维码"); log.info("填充公众号二维码");
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
...@@ -937,7 +946,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -937,7 +946,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
} else { } else {
//弹窗方式,在客户端栏目中不展示 //弹窗方式,在客户端栏目中不展示
if (isWechat) { if (null != wechatUserId) {
removeList.add(itemVO); removeList.add(itemVO);
continue; continue;
} }
...@@ -959,7 +968,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -959,7 +968,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("填充应用作品") @ParamLog("填充应用作品")
private void fillAppProductServe(List<ResourcePageItemVO> itemVOS, Boolean isWechat) { private void fillAppProductServe(List<ResourcePageItemVO> itemVOS, Long wechatUserId) {
log.info("填充应用作品"); log.info("填充应用作品");
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
...@@ -967,22 +976,79 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -967,22 +976,79 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
Long adviserId = itemVOS.get(0).getCreateUser(); Long adviserId = itemVOS.get(0).getCreateUser();
List<Long> appIds = new ArrayList<>(); List<Long> appIds = new ArrayList<>();
List<Long> productIds = new ArrayList<>(); List<Long> productIds = new ArrayList<>();
List<Long> courseProductIds = new ArrayList<>();
List<Long> nonCourseProductIds = new ArrayList<>();
List<String> courseProductTypeCodes = Arrays.asList("VIDEO_SCHEDULE", "VIDEO_COURSE", "AUDIO_COURSE", "AUDIO_SCHEDULE", "LIVE");
for (ResourcePageItemVO vo : itemVOS) { for (ResourcePageItemVO vo : itemVOS) {
Long serveId = vo.getServeId(); Long serveId = vo.getServeId();
if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(vo.getServeType()) && !appIds.contains(serveId)) { if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(vo.getServeType()) && !appIds.contains(serveId)) {
appIds.add(serveId); appIds.add(serveId);
} else if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(vo.getServeType()) && !productIds.contains(serveId)) { continue;
productIds.add(serveId); }
if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(vo.getServeType())) {
if (!productIds.contains(serveId)) {
productIds.add(serveId);
}
if (courseProductTypeCodes.contains(vo.getTypeCode())) {
courseProductIds.add(serveId);
} else {
nonCourseProductIds.add(serveId);
}
} }
} }
Map<Long, AppDto> appDtoMap = appConsr.mapBaseByIds(appIds); Map<Long, AppDto> appDtoMap= new HashMap<>();
Map<Long, ProductDto> productDtoMap = productConsr.getProBasesByIds(productIds); Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, MapBaseStatusDTO> appPriceMap = new HashMap<>();
Future<Map<Long, AppDto>>appMapSubmit = ThreadPoolUtils.OTHER_POOL.submit(() ->{
return appConsr.mapBaseByIds(appIds);
});
Future<Map<Long, ProductDto>>productMapSubmit = ThreadPoolUtils.OTHER_POOL.submit(() ->{
return productConsr.getProBasesByIds(productIds);
});
Future<Map<Long, MapBaseStatusDTO>> appPriceMapSubmit = ThreadPoolUtils.OTHER_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.error("调用资源中心获取商品信息错误:"+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, 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<>();
if (isWechat) { //是否购买
Map<Long, Boolean> buyStateMap = new HashMap<>();
//课程是否购买(单节/整套)
Map<Long, Boolean> courseBuyStateMap = new HashMap<>();
if (null != wechatUserId) {
appOfficialAccountToolMap = appConsr.getPayOfficialAccountsToolByAppIds(appIds); appOfficialAccountToolMap = appConsr.getPayOfficialAccountsToolByAppIds(appIds);
Future<Map<Long, Boolean>> buyStateSubmit = ThreadPoolUtils.OTHER_POOL.submit(() ->{
return tradeConsr.mapAppProductBuyState(wechatUserId, appIds, nonCourseProductIds);
});
Future<Map<Long, Boolean>> courseBuyStateSubmit = ThreadPoolUtils.OTHER_POOL.submit(() ->{
return tradeConsr.mapCourseProductBuyState(wechatUserId, courseProductIds);
});
try {
buyStateMap = buyStateSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用交易中心查询是否购买失败:"+e.getMessage(), e);
}
try {
courseBuyStateMap = courseBuyStateSubmit.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("调用交易中心查询课程是否购买错误失败:"+e.getMessage(), e);
}
} }
for (ResourcePageItemVO itemVO : itemVOS) { for (ResourcePageItemVO itemVO : itemVOS) {
Long serveId = itemVO.getServeId(); Long serveId = itemVO.getServeId();
...@@ -997,6 +1063,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -997,6 +1063,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
itemVO.setTransverseImg(appDto.getTransverseImg()); itemVO.setTransverseImg(appDto.getTransverseImg());
itemVO.setPrice(appDto.getPrice()); itemVO.setPrice(appDto.getPrice());
itemVO.setHasThirdLink(!StringUtil.isEmpty(appDto.getTurnUrl())?true:false); itemVO.setHasThirdLink(!StringUtil.isEmpty(appDto.getTurnUrl())?true:false);
if (!MapUtils.isEmpty(appPriceMap) && appPriceMap.containsKey(serveId)) {
BigDecimal price = appPriceMap.get(serveId).getRetailPrice();
itemVO.setPrice(null == price?Double.valueOf(0d):price.doubleValue());
}
} else if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType) } else if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)
&& !MapUtils.isEmpty(productDtoMap) && productDtoMap.containsKey(serveId)) { && !MapUtils.isEmpty(productDtoMap) && productDtoMap.containsKey(serveId)) {
ProductDto productDto = productDtoMap.get(itemVO.getServeId()); ProductDto productDto = productDtoMap.get(itemVO.getServeId());
...@@ -1015,14 +1085,25 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1015,14 +1085,25 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} else { } else {
continue; continue;
} }
if (null == itemVO.getPrice()) {
itemVO.setPrice(Double.valueOf(0d));
}
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); channelId = adviserConsr.getDefaultChannel(adviserId);
} }
itemVO.setChannelId(channelId); itemVO.setChannelId(channelId);
if (isWechat) { if (null != wechatUserId) {
setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap); setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap);
itemVO.setBuyState(false);
if (!MapUtils.isEmpty(buyStateMap) && buyStateMap.containsKey(serveId)) {
itemVO.setBuyState(buyStateMap.get(serveId));
}
if (!MapUtils.isEmpty(courseBuyStateMap) && courseBuyStateMap.containsKey(serveId)
&& ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(itemVO.getServeType())) {
itemVO.setBuyState(courseBuyStateMap.get(serveId));
}
} }
} }
} }
...@@ -1081,7 +1162,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1081,7 +1162,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("填充社群") @ParamLog("填充社群")
private void fillGroupServe(List<ResourcePageItemVO> itemVOS, Boolean isWechat) { private void fillGroupServe(List<ResourcePageItemVO> itemVOS) {
log.info("填充社群"); log.info("填充社群");
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
...@@ -1108,7 +1189,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1108,7 +1189,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@ParamLog("填充平台书单") @ParamLog("填充平台书单")
private void fillBooklistServe(List<ResourcePageItemVO> itemVOS, Boolean isWechat) { private void fillBooklistServe(List<ResourcePageItemVO> itemVOS) {
log.info("填充平台书单"); log.info("填充平台书单");
if (ListUtils.isEmpty(itemVOS)) { if (ListUtils.isEmpty(itemVOS)) {
return; return;
...@@ -1166,7 +1247,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1166,7 +1247,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
@Override @Override
public PageBeanNew<ResourcePageItemVO> listPageResourcePageItem(Integer currentPage, Integer numPerPage, Long resourcePageColumnId) { public PageBeanNew<ResourcePageItemVO> listPageResourcePageItem(Integer currentPage, Integer numPerPage, Long resourcePageColumnId,
Long wechatUserId) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("resourcePageColumnId", resourcePageColumnId); paramMap.put("resourcePageColumnId", resourcePageColumnId);
PageBeanNew<ResourcePageItemVO> pageBeanNew = resourcePageItemDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "getResourcePageItemByColumnId"); PageBeanNew<ResourcePageItemVO> pageBeanNew = resourcePageItemDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "getResourcePageItemByColumnId");
...@@ -1175,7 +1257,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1175,7 +1257,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
Map<String, List<ResourcePageItemVO>> listMap = pageBeanNew.getRecordList().stream().collect(Collectors.groupingBy(ResourcePageItemVO::getServeType)); Map<String, List<ResourcePageItemVO>> listMap = pageBeanNew.getRecordList().stream().collect(Collectors.groupingBy(ResourcePageItemVO::getServeType));
for (Map.Entry<String, List<ResourcePageItemVO>> entry : listMap.entrySet()) { for (Map.Entry<String, List<ResourcePageItemVO>> entry : listMap.entrySet()) {
fillResourceByType(entry.getValue(), true, entry.getKey()); fillResourceByType(entry.getValue(), wechatUserId, entry.getKey());
} }
return pageBeanNew; return pageBeanNew;
} }
...@@ -1561,7 +1643,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1561,7 +1643,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
} }
@Override @Override
public ResourcePageOneServe hasOneResource(Long bookGroupId, Long sceneId) { public ResourcePageOneServe hasOneResource(Long bookGroupId, Long sceneId, Long wechatUserId) {
ResourcePageOneServe pageOneServe = new ResourcePageOneServe(); ResourcePageOneServe pageOneServe = new ResourcePageOneServe();
pageOneServe.setBookGroupId(bookGroupId); pageOneServe.setBookGroupId(bookGroupId);
pageOneServe.setSceneId(sceneId); pageOneServe.setSceneId(sceneId);
...@@ -1584,7 +1666,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1584,7 +1666,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
ResourcePageItemVO itemVO = resourcePageItemDao.checkOneServeItemByPageId(resourcePageId); ResourcePageItemVO itemVO = resourcePageItemDao.checkOneServeItemByPageId(resourcePageId);
if (null != itemVO) { if (null != itemVO) {
pageOneServe.setOneServe(true); pageOneServe.setOneServe(true);
fillAppProductServe(Arrays.asList(itemVO), true); fillAppProductServe(Arrays.asList(itemVO), wechatUserId);
pageOneServe.setServeId(itemVO.getServeId()); pageOneServe.setServeId(itemVO.getServeId());
pageOneServe.setServeType(itemVO.getServeType()); pageOneServe.setServeType(itemVO.getServeType());
pageOneServe.setLinkUrl(itemVO.getLinkUrl()); pageOneServe.setLinkUrl(itemVO.getLinkUrl());
...@@ -1619,7 +1701,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1619,7 +1701,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
itemVO.setSceneId(s.getSceneId()); itemVO.setSceneId(s.getSceneId());
itemVOS.add(itemVO); itemVOS.add(itemVO);
}); });
fillAppProductServe(itemVOS, false); fillAppProductServe(itemVOS, null);
List<BookGroupServeDTO> serveDTOS = new ArrayList<>(); List<BookGroupServeDTO> serveDTOS = new ArrayList<>();
for (ResourcePageItemVO itemVO: itemVOS) { for (ResourcePageItemVO itemVO: itemVOS) {
BookGroupServeDTO serveDTO = new BookGroupServeDTO(); BookGroupServeDTO serveDTO = new BookGroupServeDTO();
......
...@@ -75,7 +75,7 @@ public class ResourcePageFacade { ...@@ -75,7 +75,7 @@ public class ResourcePageFacade {
@RequestParam("resourcePageId") Long resourcePageId, @RequestParam("resourcePageId") Long resourcePageId,
@RequestParam(value = "navigationId", required = false) Long navigationId){ @RequestParam(value = "navigationId", required = false) Long navigationId){
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID); SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId(resourcePageId, false, null, null, null, null, navigationId)); return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId(resourcePageId, null, null, null, null, null, navigationId));
} }
@ApiOperation("客户端-根据书刊查资源页基本配置") @ApiOperation("客户端-根据书刊查资源页基本配置")
...@@ -97,8 +97,8 @@ public class ResourcePageFacade { ...@@ -97,8 +97,8 @@ public class ResourcePageFacade {
@RequestParam(value = "channelId", required = false) Long channelId, @RequestParam(value = "channelId", required = false) Long channelId,
@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){
Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId(resourcePageId, true, bookId, adviserId, channelId, enableAdverting, navigationId)); return new ResponseDto<>(resourcePageBiz.getColumnAndServeListByPageId(resourcePageId, wechatUserId, bookId, adviserId, channelId, enableAdverting, navigationId));
} }
@ApiOperation("客户端分页查栏目资源") @ApiOperation("客户端分页查栏目资源")
...@@ -107,8 +107,8 @@ public class ResourcePageFacade { ...@@ -107,8 +107,8 @@ public class ResourcePageFacade {
@RequestParam("currentPage") Integer currentPage, @RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage, @RequestParam("numPerPage") Integer numPerPage,
@RequestParam("resourcePageColumnId") Long resourcePageColumnId) { @RequestParam("resourcePageColumnId") Long resourcePageColumnId) {
Cookie.getId(userInfo,Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(resourcePageBiz.listPageResourcePageItem(currentPage, numPerPage, resourcePageColumnId)); return new ResponseDto<>(resourcePageBiz.listPageResourcePageItem(currentPage, numPerPage, resourcePageColumnId, wechatUserId));
} }
@ApiOperation("获取栏目及资源类型") @ApiOperation("获取栏目及资源类型")
...@@ -163,9 +163,11 @@ public class ResourcePageFacade { ...@@ -163,9 +163,11 @@ public class ResourcePageFacade {
@ApiOperation("是否只有一个资源") @ApiOperation("是否只有一个资源")
@GetMapping("hasOneResource") @GetMapping("hasOneResource")
public ResponseDto<?> hasOneResource(@RequestParam(value = "bookGroupId", required = false) Long bookGroupId, public ResponseDto<?> hasOneResource(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "bookGroupId", required = false) Long bookGroupId,
@RequestParam(value = "sceneId", required = false) Long sceneId) { @RequestParam(value = "sceneId", required = false) Long sceneId) {
return new ResponseDto<>(resourcePageBiz.hasOneResource(bookGroupId, sceneId)); Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(resourcePageBiz.hasOneResource(bookGroupId, sceneId, wechatUserId));
} }
@ApiOperation("添加收藏记录") @ApiOperation("添加收藏记录")
......
...@@ -116,4 +116,8 @@ public class ResourcePageItemVO extends BaseDto{ ...@@ -116,4 +116,8 @@ public class ResourcePageItemVO extends BaseDto{
* 二维码公众号弹出状态 * 二维码公众号弹出状态
*/ */
private Boolean popupState; private Boolean popupState;
/**
* 是否购买
*/
private Boolean buyState;
} }
...@@ -1201,7 +1201,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1201,7 +1201,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null == resourcePageVO || null == resourcePageVO.getId()) { if (null == resourcePageVO || null == resourcePageVO.getId()) {
return; return;
} }
List<ResourceColumnAndServeVO> serveVOList = resourcePageBiz.getColumnAndServeListByPageId(resourcePageVO.getId(), false, null, null, null, null, null); List<ResourceColumnAndServeVO> serveVOList = resourcePageBiz.getColumnAndServeListByPageId(resourcePageVO.getId(), null, null, null, null, null, null);
UpdateResourceColumnVO columnVO = new UpdateResourceColumnVO(); UpdateResourceColumnVO columnVO = new UpdateResourceColumnVO();
columnVO.setColumnFormat(3); columnVO.setColumnFormat(3);
columnVO.setColumnName("精品资讯"); columnVO.setColumnName("精品资讯");
......
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