Commit 2a5bf72d by 田超

Merge branch 'fixbug/h5New' into 'master'

feat: [none]H5优化

See merge request rays/pcloud-book!1316
parents 7c666a44 c6a08d48
...@@ -16,6 +16,7 @@ import com.pcloud.book.applet.enums.AppletRankTypeEnum; ...@@ -16,6 +16,7 @@ import com.pcloud.book.applet.enums.AppletRankTypeEnum;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum; import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.applet.enums.AppletSourceTypeEnum; import com.pcloud.book.applet.enums.AppletSourceTypeEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr; import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.group.biz.ResourcePageBiz; import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.book.group.constant.ResourcePageConstants; import com.pcloud.book.group.constant.ResourcePageConstants;
...@@ -30,6 +31,7 @@ import com.pcloud.common.utils.ListUtils; ...@@ -30,6 +31,7 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum; import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.readercenter.userlabel.dto.UserGradeLabelIdDTO;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -74,6 +76,8 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz ...@@ -74,6 +76,8 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz
private AppletRecordSevenDayDao appletRecordSevenDayDao; private AppletRecordSevenDayDao appletRecordSevenDayDao;
@Autowired @Autowired
private ReaderConsr readerConsr; private ReaderConsr readerConsr;
@Autowired
private LabelConsr labelConsr;
@Override @Override
public PageBeanNew getAggrStatis(Long wechatUserId, String keyword, Integer sourceType, Integer rankType, Integer currentPage, Integer numPerPage) { public PageBeanNew getAggrStatis(Long wechatUserId, String keyword, Integer sourceType, Integer rankType, Integer currentPage, Integer numPerPage) {
...@@ -363,10 +367,25 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz ...@@ -363,10 +367,25 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz
countList = appletRecordCHMapper.getAggrStatis4H5(paramMap); countList = appletRecordCHMapper.getAggrStatis4H5(paramMap);
} else { } else {
//无关键词-根据学龄段搜索 //无关键词-根据学龄段搜索,序优先匹配同年级的资源
Long gradeLabel = resourcePageBiz.getUserGrade(wechatUserId, officialAccountsId); UserGradeLabelIdDTO userGradeLabelIdDTO = readerConsr.getUserGrade(wechatUserId, officialAccountsId);
List<Long> gradeLabelIds = readerConsr.getUserGradeIdByParentId(gradeLabel); //学龄段标签, 年级标签
countList = appletRecordSevenDayDao.getResourceByGrade4H5(sourceType, gradeLabelIds, maxCount); Long parentLabel = 1L;
Long gradeLabelId = null;
if (null != userGradeLabelIdDTO && null != userGradeLabelIdDTO.getLabelId()) {
parentLabel = (null == userGradeLabelIdDTO.getParentId() || userGradeLabelIdDTO.getParentId() == 0) ?
userGradeLabelIdDTO.getLabelId() : userGradeLabelIdDTO.getParentId();
gradeLabelId = userGradeLabelIdDTO.getLabelId();
}
//年龄段下所有年级
List<Long> gradeLabelIds = readerConsr.getUserGradeIdByParentId(parentLabel);
//年级排序,当前年级在前
List<Long> orderFieldIds = new ArrayList<>(Arrays.asList(gradeLabelId));
if (!ListUtils.isEmpty(gradeLabelIds) && gradeLabelIds.contains(gradeLabelId)) {
gradeLabelIds.remove(gradeLabelId);
}
orderFieldIds.addAll(gradeLabelIds);
countList = appletRecordSevenDayDao.getResourceByGrade4H5(sourceType, orderFieldIds, maxCount);
} }
if (ListUtils.isEmpty(countList)) { if (ListUtils.isEmpty(countList)) {
return new PageBeanNew(currentPage, numPerPage, 0, Lists.newArrayList()); return new PageBeanNew(currentPage, numPerPage, 0, Lists.newArrayList());
...@@ -377,8 +396,43 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz ...@@ -377,8 +396,43 @@ public class AppletRecordAggrStatisBizImpl implements AppletRecordAggrStatisBiz
return new PageBeanNew(currentPage, numPerPage, 0, Lists.newArrayList()); return new PageBeanNew(currentPage, numPerPage, 0, Lists.newArrayList());
} }
List<AppletRecordDTO> recordDTOS = countList.stream().skip(currentPage * numPerPage).limit(numPerPage).collect(Collectors.toList()); List<AppletRecordDTO> recordDTOS = countList.stream().skip(currentPage * numPerPage).limit(numPerPage).collect(Collectors.toList());
fillLabel(recordDTOS);
PageBeanNew pageBeanNew = new PageBeanNew<>(currentPage, numPerPage, countList.size(), recordDTOS); PageBeanNew pageBeanNew = new PageBeanNew<>(currentPage, numPerPage, countList.size(), recordDTOS);
return pageBeanNew; return pageBeanNew;
} }
private void fillLabel(List<AppletRecordDTO> recordList) {
if (ListUtils.isEmpty(recordList)) {
return;
}
List<Long> labelIds = new ArrayList<>();
for (AppletRecordDTO appletRecordDTO : recordList) {
if (null != appletRecordDTO.getProLabelId()) {
labelIds.add(appletRecordDTO.getProLabelId());
}
if (null != appletRecordDTO.getDepLabelId()) {
labelIds.add(appletRecordDTO.getDepLabelId());
}
if (null != appletRecordDTO.getPurLabelId()) {
labelIds.add(appletRecordDTO.getPurLabelId());
}
}
if (!ListUtils.isEmpty(labelIds)) {
Map<Long, String> labelMap = labelConsr.getLabelName(labelIds);
if (!MapUtils.isEmpty(labelMap)) {
for(AppletRecordDTO appletRecordDTO : recordList){
if (null != appletRecordDTO.getProLabelId() && labelMap.containsKey(appletRecordDTO.getProLabelId())) {
appletRecordDTO.setProLabelName(labelMap.get(appletRecordDTO.getProLabelId()));
}
if (null != appletRecordDTO.getDepLabelId() && labelMap.containsKey(appletRecordDTO.getDepLabelId())) {
appletRecordDTO.setDepLabelName(labelMap.get(appletRecordDTO.getDepLabelId()));
}
if (null != appletRecordDTO.getPurLabelId() && labelMap.containsKey(appletRecordDTO.getPurLabelId())) {
appletRecordDTO.setPurLabelName(labelMap.get(appletRecordDTO.getPurLabelId()));
}
}
}
}
}
} }
...@@ -112,4 +112,8 @@ public class AppletRecordDTO { ...@@ -112,4 +112,8 @@ public class AppletRecordDTO {
* 目的标签 * 目的标签
*/ */
private Long purLabelId; private Long purLabelId;
private String proLabelName;
private String depLabelName;
private String purLabelName;
} }
...@@ -23,6 +23,7 @@ import com.pcloud.book.consumer.advsertising.AdvertisingConsr; ...@@ -23,6 +23,7 @@ import com.pcloud.book.consumer.advsertising.AdvertisingConsr;
import com.pcloud.book.consumer.analysisengine.BrowseRecordConsr; import com.pcloud.book.consumer.analysisengine.BrowseRecordConsr;
import com.pcloud.book.consumer.app.AppConsr; import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr; import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.label.LabelConsr;
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;
...@@ -161,8 +162,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -161,8 +162,6 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
@Autowired @Autowired
private WechatGroupConsr wechatGroupConsr; private WechatGroupConsr wechatGroupConsr;
@Autowired @Autowired
private BookGroupServeDao bookGroupServeDao;
@Autowired
private ResourcePageCollectDao resourcePageCollectDao; private ResourcePageCollectDao resourcePageCollectDao;
@Autowired @Autowired
private AdviserTaskConsr adviserTaskConsr; private AdviserTaskConsr adviserTaskConsr;
...@@ -180,6 +179,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -180,6 +179,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
private BrowseRecordConsr browseRecordConsr; private BrowseRecordConsr browseRecordConsr;
@Autowired @Autowired
private ChannelConsr channelConsr; private ChannelConsr channelConsr;
@Autowired
private LabelConsr labelConsr;
@Override @Override
public Long updateResourcePage(UpdateResourcePageVO updateResourcePageVO) { public Long updateResourcePage(UpdateResourcePageVO updateResourcePageVO) {
...@@ -1558,6 +1559,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1558,6 +1559,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
List<ResourcePageCourseDTO> dtos = pageBeanNew.getRecordList(); List<ResourcePageCourseDTO> dtos = pageBeanNew.getRecordList();
List<Long> appIds = new ArrayList<>(); List<Long> appIds = new ArrayList<>();
List<Long> productIds = new ArrayList<>(); List<Long> productIds = new ArrayList<>();
List<Long> labelIds = new ArrayList<>();
for (ResourcePageCourseDTO dto : dtos) { for (ResourcePageCourseDTO dto : dtos) {
Long serveId = dto.getServeId(); Long serveId = dto.getServeId();
if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(dto.getServeType()) && !appIds.contains(serveId)) { if (ResourcePageConstants.ServeTypeEnum.APP.getValue().equals(dto.getServeType()) && !appIds.contains(serveId)) {
...@@ -1566,11 +1568,21 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1566,11 +1568,21 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(dto.getServeType()) && !productIds.contains(serveId)) { if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(dto.getServeType()) && !productIds.contains(serveId)) {
productIds.add(serveId); productIds.add(serveId);
} }
if (null != dto.getProLabelId() && !labelIds.contains(dto.getProLabelId())) {
labelIds.add(dto.getProLabelId());
}
if (null != dto.getDepLabelId() && !labelIds.contains(dto.getDepLabelId())) {
labelIds.add(dto.getDepLabelId());
}
if (null != dto.getPurLabelId() && !labelIds.contains(dto.getPurLabelId())) {
labelIds.add(dto.getPurLabelId());
}
} }
Map<Long, AppDto> appDtoMap = appConsr.mapBaseByIds(appIds); Map<Long, AppDto> appDtoMap = appConsr.mapBaseByIds(appIds);
Map<Long, ProductDto> productDtoMap = productConsr.getProBasesByIds(productIds); Map<Long, ProductDto> productDtoMap = productConsr.getProBasesByIds(productIds);
Long accountSettingId = BookProps.getOperateOfficalId(); Long accountSettingId = BookProps.getOperateOfficalId();
AccountSetting accountSetting = channelConsr.getAppInfo(accountSettingId); AccountSetting accountSetting = channelConsr.getAppInfo(accountSettingId);
Map<Long, String> labelMap = labelConsr.getLabelName(labelIds);
for (ResourcePageCourseDTO courseDTO : dtos) { for (ResourcePageCourseDTO courseDTO : dtos) {
Long serveId = courseDTO.getServeId(); Long serveId = courseDTO.getServeId();
String serveType = courseDTO.getServeType(); String serveType = courseDTO.getServeType();
...@@ -1586,9 +1598,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1586,9 +1598,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
accountSetting.getProtocol(), accountSetting.getDomain(), accountSetting.getFirstDomain(), accountSetting.getProtocol(), accountSetting.getDomain(), accountSetting.getFirstDomain(),
null != accountSetting.getRandom() ? accountSetting.getRandom().toString() : null); null != accountSetting.getRandom() ? accountSetting.getRandom().toString() : null);
courseDTO.setResultUrl(turnUrl); courseDTO.setResultUrl(turnUrl);
continue;
} } else if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)
if (ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)
&& !MapUtils.isEmpty(productDtoMap) && productDtoMap.containsKey(serveId)) { && !MapUtils.isEmpty(productDtoMap) && productDtoMap.containsKey(serveId)) {
ProductDto productDto = productDtoMap.get(courseDTO.getServeId()); ProductDto productDto = productDtoMap.get(courseDTO.getServeId());
courseDTO.setServeName(productDto.getProductName()); courseDTO.setServeName(productDto.getProductName());
...@@ -1601,7 +1612,17 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1601,7 +1612,17 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
accountSetting.getProtocol(), accountSetting.getDomain(), accountSetting.getFirstDomain(), accountSetting.getProtocol(), accountSetting.getDomain(), accountSetting.getFirstDomain(),
null != accountSetting.getRandom() ? accountSetting.getRandom().toString() : null); null != accountSetting.getRandom() ? accountSetting.getRandom().toString() : null);
courseDTO.setResultUrl(turnUrl); courseDTO.setResultUrl(turnUrl);
continue; }
if (!MapUtils.isEmpty(labelMap)) {
if (null != courseDTO.getProLabelId() && labelMap.containsKey(courseDTO.getProLabelId())) {
courseDTO.setProLabelName(labelMap.get(courseDTO.getProLabelId()));
}
if (null != courseDTO.getDepLabelId() && labelMap.containsKey(courseDTO.getDepLabelId())) {
courseDTO.setDepLabelName(labelMap.get(courseDTO.getDepLabelId()));
}
if (null != courseDTO.getPurLabelId() && labelMap.containsKey(courseDTO.getPurLabelId())) {
courseDTO.setPurLabelName(labelMap.get(courseDTO.getPurLabelId()));
}
} }
} }
return pageBeanNew; return pageBeanNew;
......
...@@ -46,4 +46,20 @@ public class ResourcePageCourseDTO extends BaseDto { ...@@ -46,4 +46,20 @@ public class ResourcePageCourseDTO extends BaseDto {
*/ */
private String resultUrl; private String resultUrl;
/**
* 专业标签
*/
private Long proLabelId;
/**
* 深度标签
*/
private Long depLabelId;
/**
* 目的标签
*/
private Long purLabelId;
private String proLabelName;
private String depLabelName;
private String purLabelName;
} }
\ No newline at end of file
...@@ -120,7 +120,14 @@ ...@@ -120,7 +120,14 @@
a.record_type, a.record_type,
a.from_id a.from_id
ORDER BY ORDER BY
a.click_count DESC <if test="gradeLabelIds != null and gradeLabelIds.size>0">
FIELD(g.user_grade_label_id
<foreach collection="gradeLabelIds" item="item" open=" " separator=" " close=" ">
,${item}
</foreach>
),
</if>
a.user_count DESC
<if test="limit != null"> <if test="limit != null">
limit #{limit} limit #{limit}
</if> </if>
......
...@@ -102,7 +102,10 @@ ...@@ -102,7 +102,10 @@
c.serve_type serveType, c.serve_type serveType,
c.type_code typeCode, c.type_code typeCode,
c.channel_id channelId, c.channel_id channelId,
c.type_name typeName c.type_name typeName,
c.pro_label_id proLabelId,
c.dep_lable_id depLabelId,
c.pur_label_id purLabelId
FROM FROM
resource_page_course c resource_page_course c
INNER JOIN resource_page_grade_label g ON c.dep_lable_id = g.dep_label_id INNER JOIN resource_page_grade_label g ON c.dep_lable_id = g.dep_label_id
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<select id="getByBookGroupId" parameterType="long" resultMap="ResourcePageMap"> <select id="getByBookGroupId" parameterType="long" resultMap="ResourcePageMap">
select select
id, book_group_id, style, show_book, open_rays, qrcode_url, official_scene_id, book_cover, book_id, channel_id, create_user id, book_group_id, style, show_book, open_rays, qrcode_url, official_scene_id, book_cover, book_id, channel_id, create_user
from book.resource_page
where book_group_id = #{bookGroupId} where book_group_id = #{bookGroupId}
limit 1 limit 1
</select> </select>
......
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