Commit a0f8ce79 by 吴博

feat: [1003730] 应用作品收藏功能

parent 2eef7612
......@@ -20,6 +20,7 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
......@@ -390,6 +391,13 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
}
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, appletRecordDTO.getLinkUrl());
appletAppOrProductDTO.setResultUrl(resultLinkUrl);
if (!StringUtil.isEmpty(appDto.getTurnUrl())){
appletAppOrProductDTO.setHasThirdLink(true);
} else {
appletAppOrProductDTO.setHasThirdLink(false);
}
appletAppOrProductDTO.setServeType(AppAndProductTypeEnum.APP.value);
appletAppOrProductDTO.setServeId(appletRecordDTO.getFromId());
appletRecordDTO.setAppletAppOrProductDTO(appletAppOrProductDTO);
}
......@@ -435,6 +443,13 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
} else {
appletAppOrProductDTO.setResultUrl(appletRecordDTO.getLinkUrl());
}
if (!StringUtil.isEmpty(productDto.getSkipUrl())){
appletAppOrProductDTO.setHasThirdLink(true);
} else {
appletAppOrProductDTO.setHasThirdLink(false);
}
appletAppOrProductDTO.setServeType(AppAndProductTypeEnum.PRODUCT.value);
appletAppOrProductDTO.setServeId(appletRecordDTO.getFromId());
appletRecordDTO.setAppletAppOrProductDTO(appletAppOrProductDTO);
}
......
......@@ -2,6 +2,7 @@ package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.map.MapUtil;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.entity.AppType;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.ServeCollectBiz;
import com.pcloud.book.applet.dao.ServeCollectDao;
......@@ -15,12 +16,14 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.skill.entity.PcloudResourceItem;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
......@@ -188,6 +191,13 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
}
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, serveCollect.getLinkUrl());
appletAppOrProductDTO.setResultUrl(resultLinkUrl);
if (!StringUtil.isEmpty(appDto.getTurnUrl())){
appletAppOrProductDTO.setHasThirdLink(true);
} else {
appletAppOrProductDTO.setHasThirdLink(false);
}
appletAppOrProductDTO.setServeType(AppAndProductTypeEnum.APP.value);
appletAppOrProductDTO.setServeId(serveCollect.getServeId());
serveCollect.setAppletAppOrProductDTO(appletAppOrProductDTO);
}
......@@ -233,6 +243,13 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
} else {
appletAppOrProductDTO.setResultUrl(serveCollect.getLinkUrl());
}
if (!StringUtil.isEmpty(productDto.getSkipUrl())){
appletAppOrProductDTO.setHasThirdLink(true);
} else {
appletAppOrProductDTO.setHasThirdLink(false);
}
appletAppOrProductDTO.setServeType(AppAndProductTypeEnum.PRODUCT.value);
appletAppOrProductDTO.setServeId(serveCollect.getServeId());
serveCollect.setAppletAppOrProductDTO(appletAppOrProductDTO);
}
......
......@@ -16,4 +16,10 @@ public class AppletAppOrProductDTO {
private String serveTypeCode;
@ApiModelProperty("结果链接")
private String resultUrl;
@ApiModelProperty("商品应用中有第三方链接")
private Boolean hasThirdLink;
@ApiModelProperty("商品应用类型")
private String serveType;
@ApiModelProperty("商品应用id")
private Long serveId;
}
......@@ -1300,7 +1300,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
Integer collage = 1;
List<RightsNowItem> items = Lists.newArrayList();
if (CollectionUtils.isEmpty(nowItems) && rightsSettingTitle.getCollageState()!= null && rightsSettingTitle.getCollageState().intValue() == collage.intValue()) {
if (CollectionUtils.isEmpty(nowItems) &&
rightsSettingTitle.getCollageState()!= null &&
rightsSettingTitle.getCollageState().intValue() == collage.intValue() &&
RightsServeTypeEnum.NEWS.name().equals(rightsSettingTitle.getServeType())) {
// 填充咨询
supplementNews(rightsSettingId, wechatUserId, rightsClassifyId, top, items,bookId, itemType.value, officialAccountsId);
// 处理权益中的应用/作品
......@@ -2143,101 +2146,170 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
// 获取抽奖权益
if (RightsNowItemTypeNew.DRAW.value.equals(type)) {
return setDraw(rightsSetting, wechatUserId, readType, bookId, officialAccountsId);
setDraw(rightsSetting, wechatUserId, readType, bookId, officialAccountsId);
}
// 获取学习工具权益
if (RightsNowItemTypeNew.LEARNING_TOOL.value.equals(type)) {
return setLearningTool(rightsSetting, wechatUserId, readType, bookId, officialAccountsId);
setLearningTool(rightsSetting, wechatUserId, readType, bookId, officialAccountsId);
}
// 获取线上网课权益
if (RightsNowItemTypeNew.ONLINE_COURSE.value.equals(type)) {
return setOnlineCourse(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage,officialAccountsId);
setOnlineCourse(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage,officialAccountsId);
}
// 获取专享礼券包权益
if (RightsNowItemTypeNew.GIFT_COUPON_PACKAGE.value.equals(type)) {
return setGiftCouponPackage(rightsSetting, wechatUserId, readType, bookId);
setGiftCouponPackage(rightsSetting, wechatUserId, readType, bookId);
}
// 获取专享社群
if (RightsNowItemTypeNew.GROUP_SERVICE.value.equals(type)) {
return setGroupService(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage,officialAccountsId);
setGroupService(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage,officialAccountsId);
}
// 老师1V1
if (RightsNowItemTypeNew.COACH.value.equals(type)) {
return setCoach1V1(rightsSetting, wechatUserId, readType, bookId, officialAccountsId);
setCoach1V1(rightsSetting, wechatUserId, readType, bookId, officialAccountsId);
}
// 获取线上专课
if (RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value.equals(type)) {
return setOnlineExclCourse(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage,officialAccountsId);
setOnlineExclCourse(rightsSetting, wechatUserId, readType, bookId, currentPage, numPerPage,officialAccountsId);
}
fillCollect(wechatUserId, rightsSetting, type);
return rightsSetting;
}
private void fillCollect(Long wechatUserId, RightsSetting rightsSetting4Serves, Integer type) {
if (null == wechatUserId) {
if (null == wechatUserId || null == rightsSetting4Serves) {
return;
}
List<RightsNowItem> rightsNowItemList = new ArrayList<>();
if (RightsNowItemTypeNew.SERVES.value.equals(type)) {
List<RightsItemGroup> rightsItemGroups = rightsSetting4Serves.getRightsItemGroups();
if (ListUtils.isEmpty(rightsItemGroups)) {
return;
if (fillCollect4Serve(wechatUserId, rightsSetting4Serves)) return;
} else if (RightsNowItemTypeNew.ONLINE_COURSE.value.equals(type)) {
if (null != rightsSetting4Serves.getOnlineRightsSettingTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getOnlineRightsSettingTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getOnlineRightsSettingTitle().getRightsSettingItemList();
}
List<RightsNowItem> rightsNowItems = new ArrayList<>();
rightsItemGroups.forEach(rightsItemGroup -> {
List<RightsNowItem> nowItems = rightsItemGroup.getRightsNowItems();
if (ListUtils.isEmpty(nowItems)) {
return;
}
List<RightsNowItem> productOrApps = nowItems.stream().filter(e -> Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ||
Objects.equals(e.getServeType(), AppAndProductTypeEnum.APP.value)).collect(Collectors.toList());
if (!ListUtils.isEmpty(productOrApps)) {
rightsNowItems.addAll(productOrApps);
}
});
if (ListUtils.isEmpty(rightsNowItems)) {
return;
} else if (RightsNowItemTypeNew.LEARNING_TOOL.value.equals(type)) {
if (null != rightsSetting4Serves.getLearningToolTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getLearningToolTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getLearningToolTitle().getRightsSettingItemList();
}
List<ServeCollect> serveCollects = new ArrayList<>();
rightsNowItems.forEach(e -> {
ServeCollect serveCollect = new ServeCollect();
serveCollect.setWechatUserId(wechatUserId);
serveCollect.setServeId(e.getServeId());
serveCollect.setServeType(Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ? AppletRecordTypeEnum.PRODUCT.value : AppletRecordTypeEnum.APP.value);
serveCollects.add(serveCollect);
});
List<ServeCollect> serveCollectList = serveCollectBiz.getList4RightsSetting(serveCollects);
if (ListUtils.isEmpty(serveCollectList)) {
} else if (RightsNowItemTypeNew.DRAW.value.equals(type)) {
if (null != rightsSetting4Serves.getDrawSettingTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getDrawSettingTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getDrawSettingTitle().getRightsSettingItemList();
}
} else if (RightsNowItemTypeNew.ONLINE_EXCL_COURSE.value.equals(type)) {
if (null != rightsSetting4Serves.getOnlineRightsSettingTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getOnlineRightsSettingTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getOnlineRightsSettingTitle().getRightsSettingItemList();
}
} else if (RightsNowItemTypeNew.COACH.value.equals(type)) {
if (null != rightsSetting4Serves.getLearningToolTitle() && !ListUtils.isEmpty(rightsSetting4Serves.getLearningToolTitle().getRightsSettingItemList())){
rightsNowItemList = rightsSetting4Serves.getLearningToolTitle().getRightsSettingItemList();
}
}
if (!ListUtils.isEmpty(rightsNowItemList)) {
fillCollect4RightsNowItem(wechatUserId,rightsNowItemList);
}
}
private boolean fillCollect4Serve(Long wechatUserId, RightsSetting rightsSetting4Serves) {
List<RightsItemGroup> rightsItemGroups = rightsSetting4Serves.getRightsItemGroups();
if (ListUtils.isEmpty(rightsItemGroups)) {
return true;
}
List<RightsNowItem> rightsNowItems = new ArrayList<>();
rightsItemGroups.forEach(rightsItemGroup -> {
List<RightsNowItem> nowItems = rightsItemGroup.getRightsNowItems();
if (ListUtils.isEmpty(nowItems)) {
return;
}
List<ServeCollect> collect4Product = serveCollectList.stream().filter(e -> Objects.equals(e.getServeType(), AppletRecordTypeEnum.PRODUCT.value)).collect(Collectors.toList());
List<ServeCollect> collect4App = serveCollectList.stream().filter(e -> Objects.equals(e.getServeType(), AppletRecordTypeEnum.APP.value)).collect(Collectors.toList());
Map<Long, ServeCollect> serveCollectMap4Product = new HashMap<>();
Map<Long, ServeCollect> serveCollectMap4App = new HashMap<>();
if (!ListUtils.isEmpty(collect4Product)) {
serveCollectMap4Product = collect4Product.stream().collect(Collectors.toMap(e -> e.getServeId(), a -> a, (k1, k2) -> k1));
List<RightsNowItem> productOrApps = nowItems.stream().filter(e -> Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ||
Objects.equals(e.getServeType(), AppAndProductTypeEnum.APP.value)).collect(Collectors.toList());
if (!ListUtils.isEmpty(productOrApps)) {
rightsNowItems.addAll(productOrApps);
}
if (!ListUtils.isEmpty(collect4App)) {
serveCollectMap4App = collect4App.stream().collect(Collectors.toMap(e -> e.getServeId(), a -> a, (k1, k2) -> k1));
});
if (ListUtils.isEmpty(rightsNowItems)) {
return true;
}
List<ServeCollect> serveCollects = new ArrayList<>();
rightsNowItems.forEach(e -> {
ServeCollect serveCollect = new ServeCollect();
serveCollect.setWechatUserId(wechatUserId);
serveCollect.setServeId(e.getServeId());
serveCollect.setServeType(Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ? AppletRecordTypeEnum.PRODUCT.value : AppletRecordTypeEnum.APP.value);
serveCollects.add(serveCollect);
});
List<ServeCollect> serveCollectList = serveCollectBiz.getList4RightsSetting(serveCollects);
if (ListUtils.isEmpty(serveCollectList)) {
return true;
}
List<ServeCollect> collect4Product = serveCollectList.stream().filter(e -> Objects.equals(e.getServeType(), AppletRecordTypeEnum.PRODUCT.value)).collect(Collectors.toList());
List<ServeCollect> collect4App = serveCollectList.stream().filter(e -> Objects.equals(e.getServeType(), AppletRecordTypeEnum.APP.value)).collect(Collectors.toList());
Map<Long, ServeCollect> serveCollectMap4Product = new HashMap<>();
Map<Long, ServeCollect> serveCollectMap4App = new HashMap<>();
if (!ListUtils.isEmpty(collect4Product)) {
serveCollectMap4Product = collect4Product.stream().collect(Collectors.toMap(e -> e.getServeId(), a -> a, (k1, k2) -> k1));
}
if (!ListUtils.isEmpty(collect4App)) {
serveCollectMap4App = collect4App.stream().collect(Collectors.toMap(e -> e.getServeId(), a -> a, (k1, k2) -> k1));
}
for (RightsItemGroup rightsItemGroup : rightsItemGroups) {
List<RightsNowItem> nowItems = rightsItemGroup.getRightsNowItems();
if (ListUtils.isEmpty(nowItems)) {
continue;
}
for (RightsItemGroup rightsItemGroup : rightsItemGroups) {
List<RightsNowItem> nowItems = rightsItemGroup.getRightsNowItems();
if (ListUtils.isEmpty(nowItems)) {
continue;
}
List<RightsNowItem> productOrApps = nowItems.stream().filter(e -> Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ||
Objects.equals(e.getServeType(), AppAndProductTypeEnum.APP.value)).collect(Collectors.toList());
if (!ListUtils.isEmpty(productOrApps)) {
for (RightsNowItem rightsNowItem : productOrApps) {
if (Objects.equals(rightsNowItem.getServeType(), AppAndProductTypeEnum.PRODUCT.value) && MapUtils.isNotEmpty(serveCollectMap4Product) &&
null != serveCollectMap4Product.get(rightsNowItem.getServeId())) {
rightsNowItem.setIsCollect(YesOrNoEnums.YES.getValue());
} else if (Objects.equals(rightsNowItem.getServeType(), AppAndProductTypeEnum.APP.value) && MapUtils.isNotEmpty(serveCollectMap4App) &&
null != serveCollectMap4App.get(rightsNowItem.getServeId())) {
rightsNowItem.setIsCollect(YesOrNoEnums.YES.getValue());
}
List<RightsNowItem> productOrApps = nowItems.stream().filter(e -> Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ||
Objects.equals(e.getServeType(), AppAndProductTypeEnum.APP.value)).collect(Collectors.toList());
if (!ListUtils.isEmpty(productOrApps)) {
for (RightsNowItem rightsNowItem : productOrApps) {
if (Objects.equals(rightsNowItem.getServeType(), AppAndProductTypeEnum.PRODUCT.value) && MapUtils.isNotEmpty(serveCollectMap4Product) &&
null != serveCollectMap4Product.get(rightsNowItem.getServeId())) {
rightsNowItem.setIsCollect(YesOrNoEnums.YES.getValue());
} else if (Objects.equals(rightsNowItem.getServeType(), AppAndProductTypeEnum.APP.value) && MapUtils.isNotEmpty(serveCollectMap4App) &&
null != serveCollectMap4App.get(rightsNowItem.getServeId())) {
rightsNowItem.setIsCollect(YesOrNoEnums.YES.getValue());
}
}
}
}
return false;
}
private void fillCollect4RightsNowItem(Long wechatUserId, List<RightsNowItem> rightsNowItems) {
log.info("为应用或作品填充是否收藏");
List<ServeCollect> serveCollects = new ArrayList<>();
rightsNowItems.forEach(e -> {
ServeCollect serveCollect = new ServeCollect();
serveCollect.setWechatUserId(wechatUserId);
serveCollect.setServeId(e.getServeId());
serveCollect.setServeType(Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ? AppletRecordTypeEnum.PRODUCT.value : AppletRecordTypeEnum.APP.value);
serveCollects.add(serveCollect);
});
List<ServeCollect> serveCollectList = serveCollectBiz.getList4RightsSetting(serveCollects);
if (ListUtils.isEmpty(serveCollectList)) {
return;
}
List<ServeCollect> collect4Product = serveCollectList.stream().filter(e -> Objects.equals(e.getServeType(), AppletRecordTypeEnum.PRODUCT.value)).collect(Collectors.toList());
List<ServeCollect> collect4App = serveCollectList.stream().filter(e -> Objects.equals(e.getServeType(), AppletRecordTypeEnum.APP.value)).collect(Collectors.toList());
Map<Long, ServeCollect> serveCollectMap4Product = new HashMap<>();
Map<Long, ServeCollect> serveCollectMap4App = new HashMap<>();
if (!ListUtils.isEmpty(collect4Product)) {
serveCollectMap4Product = collect4Product.stream().collect(Collectors.toMap(e -> e.getServeId(), a -> a, (k1, k2) -> k1));
}
if (!ListUtils.isEmpty(collect4App)) {
serveCollectMap4App = collect4App.stream().collect(Collectors.toMap(e -> e.getServeId(), a -> a, (k1, k2) -> k1));
}
List<RightsNowItem> productOrApps = rightsNowItems.stream().filter(e -> Objects.equals(e.getServeType(), AppAndProductTypeEnum.PRODUCT.value) ||
Objects.equals(e.getServeType(), AppAndProductTypeEnum.APP.value)).collect(Collectors.toList());
if (!ListUtils.isEmpty(productOrApps)) {
for (RightsNowItem rightsNowItem : productOrApps) {
if (Objects.equals(rightsNowItem.getServeType(), AppAndProductTypeEnum.PRODUCT.value) && MapUtils.isNotEmpty(serveCollectMap4Product) &&
null != serveCollectMap4Product.get(rightsNowItem.getServeId())) {
rightsNowItem.setIsCollect(YesOrNoEnums.YES.getValue());
} else if (Objects.equals(rightsNowItem.getServeType(), AppAndProductTypeEnum.APP.value) && MapUtils.isNotEmpty(serveCollectMap4App) &&
null != serveCollectMap4App.get(rightsNowItem.getServeId())) {
rightsNowItem.setIsCollect(YesOrNoEnums.YES.getValue());
}
}
}
}
@ParamLog(value = "填充专享社群", isAfterReturn = false)
......
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