Commit 4ccdc742 by 田超

Merge branch 'feature/1003658' into 'master'

feat: [1003658] 答案向其他资源和权益引流

See merge request rays/pcloud-book!991
parents ba38a53f 17b02671
......@@ -832,6 +832,8 @@ public interface BookGroupBiz {
*/
PageBeanNew<BookServeDTO> getBookAndBookGroupServeList(Long adviserId, Long bookId, Long channelId, Long wechatUserId);
void fillCollect4Book(Long wechatUserId, List<BookServeDTO> serveDTOList);
void removeCanNotBuy( List<BookServeDTO> list );
/**
......
......@@ -5001,7 +5001,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
return pageBeanNew;
}
private void fillCollect4Book(Long wechatUserId, List<BookServeDTO> serveDTOList) {
@Override
public void fillCollect4Book(Long wechatUserId, List<BookServeDTO> serveDTOList) {
if (ListUtils.isEmpty(serveDTOList) || null == wechatUserId) {
return;
}
......
......@@ -4,10 +4,12 @@ import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.PopupResourceInfoDTO;
import com.pcloud.book.rightsSetting.dto.ResourceList4Answer;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsNowPopup;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
......@@ -179,4 +181,12 @@ public interface RightsSettingBiz {
* * @param null
*/
void addPopupRecord(RightsNowPopup rightsNowPopup);
/**
* 答案引流资源和权益
* @author:zhuyajie
* @date:2020/9/30 14:09
* * @param null
*/
ResourceList4Answer getResourceListByBook4Answer(Long wechatUserId, Long bookId, Long channelId, Long adviserId, Long sceneId);
}
package com.pcloud.book.rightsSetting.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto;
......@@ -68,6 +65,7 @@ import com.pcloud.book.rightsSetting.dao.RightsSettingItemDetailDao;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.PopupResourceInfoDTO;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.dto.ResourceList4Answer;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
......@@ -97,9 +95,11 @@ import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
......@@ -135,6 +135,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -1480,6 +1481,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (productDto != null) {
item.setServeName(productDto.getProductName());
item.setServePic(productDto.getCoverImg());
item.setTransverseImg(productDto.getPicture1());
if (productDto.getProductTypeDto() != null) {
item.setServeTypeCode(productDto.getProductTypeDto().getTypeCode());
item.setServeTypeName(productDto.getProductTypeDto().getTypeName());
......@@ -1521,6 +1523,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
item.setServePic(appDto.getSquareImg());
item.setServeTypeCode(appDto.getTypeCode());
item.setServeTypeName(appDto.getTypeName());
item.setTransverseImg(appDto.getTransverseImg());
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
if (null == accountSettingDto){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "运营平台未配置公众号");
......@@ -3032,18 +3035,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
return answerList;
}
answerList = new ArrayList<>();
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(adviserId, bookId, channelId);
List<RightsNowItem> itemList = new ArrayList<>();
if (!ListUtils.isEmpty(bookServeVOS)) {
for (BookServeDTO vo : bookServeVOS) {
RightsNowItem item = new RightsNowItem();
item.setType(RightsNowItemTypeNew.SERVES.value);
item.setServeId(vo.getServeId());
item.setServeType(vo.getTypeCode());
item.setLinkUrl(vo.getUrl());
itemList.add(item);
}
}
List<RightsNowItem> itemList = getOriginServeRightsNowItem(bookId, channelId, adviserId, false, null);
fillProductAndApp(itemList);
removeCanNotBuy(itemList);
if (!ListUtils.isEmpty(itemList)){
......@@ -3071,4 +3063,94 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
rightsNowPopupDao.insert(rightsNowPopup);
}
@Override
public ResourceList4Answer getResourceListByBook4Answer(
Long wechatUserId, Long bookId, Long channelId, Long adviserId, Long sceneId) {
if (null == bookId && null == sceneId){
return new ResourceList4Answer();
}
if (null != sceneId){
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getById(sceneId);
if (null != qrcodeSceneDto){
bookId = qrcodeSceneDto.getAdviserBookId();
channelId = qrcodeSceneDto.getChannelPartyId();
adviserId = qrcodeSceneDto.getCreatedByUserLogin();
}
}
if (null == bookId || null == channelId || null == adviserId){
return new ResourceList4Answer();
}
ResourceList4Answer resourceList4Answer = new ResourceList4Answer();
resourceList4Answer.setBookId(bookId);
resourceList4Answer.setChannelId(channelId);
resourceList4Answer.setAdviserId(adviserId);
//本书原版资料
String coursekey = RightsSettingConstant.ANSWER_COURSE;
String field = bookId + "-" + adviserId + "-" + channelId;
List<RightsNowItem> courseList = JedisClusterUtils.hgetJson2List(coursekey, field, RightsNowItem.class);
if (ListUtils.isEmpty(courseList)){
courseList = new ArrayList<>();
List<RightsNowItem> itemList = getOriginServeRightsNowItem(bookId, channelId, adviserId, false, wechatUserId);
if (!ListUtils.isEmpty(itemList)) {
for (RightsNowItem rightsNowItem : itemList) {
String typeCode = rightsNowItem.getServeTypeCode();
//视频课直播课
if (typeCode.equals(AppTypeEnum.VIDEO.value) || typeCode.equals(ProductTypeConstant.VIDEO)
|| typeCode.equals(ProductTypeConstant.VIDEO_SCHEDULE) || typeCode.equals(AppTypeEnum.LIVE_TIMETABLE.value)
|| typeCode.equals(ProductTypeConstant.LIVE) || typeCode.equals(ProductTypeConstant.SCHEDULE)) {
courseList.add(rightsNowItem);
}
}
}
fillProductAndApp(courseList);
removeCanNotBuy(courseList);
JedisClusterUtils.hset2Json(coursekey, field, courseList);
JedisClusterUtils.expire(coursekey, 20);
}
resourceList4Answer.setCourseList(courseList);
//小睿书 有权益
String groupkey = RightsSettingConstant.ANSWER_GROUP;
List<RightsNowItem> groupList = JedisClusterUtils.hgetJson2List(groupkey, field, RightsNowItem.class);
if (ListUtils.isEmpty(groupList)){
groupList = new ArrayList<>();
RightsSettingDto rightsSettingDto = this.getRightsSettingByBookId4AppletHome(bookId, adviserId, channelId);
if (null != rightsSettingDto) {
//专享社群服务
groupList = rightsNowItemDao.getItemListByRightsSettingId(rightsSettingDto.getId(), RightsNowItemTypeNew.GROUP_SERVICE.value, null, 1, RightsServeTypeEnum.GROUP.name());
fillProductAndApp(groupList);
JedisClusterUtils.hset2Json(groupkey, field, groupList);
JedisClusterUtils.expire(groupkey, 20);
}
}
resourceList4Answer.setGroupList(groupList);
return resourceList4Answer;
}
/**
* 获取立享权益本书配套原版资源
* @author:zhuyajie
* @date:2020/9/30 14:26
* * @param null
*/
private List<RightsNowItem> getOriginServeRightsNowItem(Long bookId, Long channelId, Long adviserId, Boolean fillCollect, Long wechatUserId){
List<RightsNowItem> itemList = new ArrayList<>();
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(adviserId, bookId, channelId);
if (fillCollect && null != wechatUserId){
bookGroupBiz.fillCollect4Book(wechatUserId, bookServeVOS);
}
if (!ListUtils.isEmpty(bookServeVOS)) {
for (BookServeDTO vo : bookServeVOS) {
RightsNowItem item = new RightsNowItem();
item.setType(RightsNowItemTypeNew.SERVES.value);
item.setServeId(vo.getServeId());
item.setServeType(vo.getTypeCode());
item.setLinkUrl(vo.getUrl());
item.setIsCollect(vo.getIsCollect());
item.setServeTypeCode(vo.getFromType());
itemList.add(item);
}
}
return itemList;
}
}
......@@ -51,4 +51,12 @@ public class RightsSettingConstant {
* 品牌方课程弹窗-线上网课
*/
public static final String COURSE_POPUP = CacheConstant.BOOK +"RIGHTS_SETTING:course_popup";
/**
* 答案课程中视频课直播课引流
*/
public static final String ANSWER_COURSE = CacheConstant.BOOK +"RIGHTS_SETTING:answer_course";
/**
* 答案课程中专享社群引流
*/
public static final String ANSWER_GROUP = CacheConstant.BOOK +"RIGHTS_SETTING:answer_group";
}
......@@ -58,4 +58,12 @@ public interface RightsNowItemDao extends BaseDao<RightsNowItem> {
* @param activityIds
*/
void deleteInvalidActivityGroups(List<Long> activityIds);
/**
* 查模块立享权益
* @author:zhuyajie
* @date:2020/10/9 14:35
* * @param null
*/
List<RightsNowItem> getItemListByRightsSettingId(Long rightsSettingId, Integer rightsNowItemType, Integer readType, Integer openState, String serveType);
}
......@@ -94,4 +94,16 @@ public class RightsNowItemDaoImpl extends BaseDaoImpl<RightsNowItem> implements
getSessionTemplate().delete(getStatement("deleteInvalidActivityGroups"), activityIds);
}
@Override
public List<RightsNowItem> getItemListByRightsSettingId(Long rightsSettingId, Integer rightsNowItemType, Integer readType, Integer openState, String serveType) {
Map<String, Object> map = new HashMap<>();
map.put("rightsSettingId", rightsSettingId);
map.put("rightsNowItemType", rightsNowItemType);
map.put("readType", readType);
map.put("openState", openState);
map.put("serveType", serveType);
return getSessionTemplate().selectList(getStatement("getItemListByRightsSettingId"), map);
}
}
package com.pcloud.book.rightsSetting.dto;
import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.common.dto.BaseDto;
import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName com.pcloud.book.rightsSetting.dto.ResourceList4Answer
* @Author zhuyajie
* @Description 答案引流
* @Date 2020/10/9 13:41
* @Version 1.0
**/
@Data
public class ResourceList4Answer extends BaseDto {
@ApiModelProperty("课程资源")
private List<RightsNowItem> courseList;
@ApiModelProperty("专享社群服务")
private List<RightsNowItem> groupList;
@ApiModelProperty("书刊id")
private Long bookId;
@ApiModelProperty("渠道id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
}
......@@ -127,4 +127,6 @@ public class RightsNowItem extends BaseEntity {
@ApiModelProperty("资讯浏览量")
private Integer borwseCount;
@ApiModelProperty("应用/资讯/作品图片-大图")
private String transverseImg;
}
......@@ -74,5 +74,13 @@ public class RightsNowPopup extends BaseEntity {
* 阅读类型
*/
private Integer readType;
/**
* 弹窗来源资源id
*/
private Long baseServeId;
/**
* 弹窗来源资源类型APP/PRODUCT
*/
private String baseServeType;
}
\ No newline at end of file
......@@ -8,7 +8,15 @@ public enum RightsNowPopupType {
/**
* 2线上网课
*/
ONLINE_COURSE(2);
ONLINE_COURSE(2),
/**
* 3答案引流资源权益
*/
ANSWER_SERVES(3),
/**
* 4十一假期期间弹窗
*/
NATIONAL_DAY_POPUP(4);
public final Integer value;
......
......@@ -352,4 +352,16 @@ public class RightsSettingFacede {
rightsSettingBiz.addPopupRecord(rightsNowPopup);
return new ResponseDto<>();
}
@ApiOperation("答案引流资源和权益")
@GetMapping("getResourceListByBook4Answer")
public ResponseDto<?> getResourceListByBook4Answer(
@CookieValue("userInfo") String userInfo,
@RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "channelId", required = false)Long channelId,
@RequestParam(value = "adviserId", required = false)Long adviserId,
@RequestParam(value = "sceneId", required = false) Long sceneId){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(rightsSettingBiz.getResourceListByBook4Answer(wechatUserId,bookId,channelId,adviserId,sceneId));
}
}
\ No newline at end of file
......@@ -270,4 +270,38 @@
#{item}
</foreach>
</delete>
<select id="getItemListByRightsSettingId" parameterType="map" resultMap="BaseResultMap">
SELECT
d.id, d.rights_setting_id, d.serve_id, d.serve_type, d.link_url, d.type, d.gift_coupon_package_id, d.create_time,
d.rights_item_group_id,d.rights_setting_title_id,d.group_type, d.is_show, d.show_url
FROM
rights_now_item d
LEFT JOIN rights_setting_title t ON d.rights_setting_title_id = t.id
WHERE
t.rights_setting_id = #{rightsSettingId}
<if test="openState != null">
AND t.open_state = #{openState}
</if>
<if test="rightsNowItemType != null">
AND t.rights_setting_now_type = #{rightsNowItemType}
</if>
<choose>
<when test="readType==1">
and t.easy_read=1
</when>
<when test="readType==2">
and it.efficient_read=1
</when>
<when test="readType==3">
and it.deep_read=1
</when>
</choose>
<if test="serveType != null">
AND d.serve_type=#{serveType}
</if>
GROUP BY d.serve_id, d.serve_type
ORDER BY d.id
</select>
</mapper>
\ No newline at end of file
......@@ -16,13 +16,15 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="readType" column="read_type" jdbcType="INTEGER"/>
<result property="baseServeId" column="base_serve_id" jdbcType="INTEGER"/>
<result property="baseServeType" column="base_serve_type" jdbcType="VARCHAR"/>
</resultMap>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.rights_now_popup(wechat_user_id, book_id, channel_id, adviser_id, rights_setting_id, popup_type, serve_id, serve_type, record_type, create_time, update_time, read_type)
values (#{wechatUserId}, #{bookId}, #{channelId}, #{adviserId}, #{rightsSettingId}, #{popupType}, #{serveId}, #{serveType}, #{recordType}, now(), now(), #{readType})
insert into book.rights_now_popup(wechat_user_id, book_id, channel_id, adviser_id, rights_setting_id, popup_type, serve_id, serve_type, record_type, create_time, update_time, read_type, base_serve_id, base_serve_type)
values (#{wechatUserId}, #{bookId}, #{channelId}, #{adviserId}, #{rightsSettingId}, #{popupType}, #{serveId}, #{serveType}, #{recordType}, now(), now(), #{readType}, #{baseServeId}, #{baseServeType})
</insert>
<select id="getUserPopupClickCount" parameterType="map" resultType="integer">
......
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