Commit 68c46e81 by 田超

Merge branch 'feature/1003059' into 'master'

feat: [1003059] 分类权益每周线上学习提醒模块修改拼入方式

See merge request rays/pcloud-book!769
parents aab61f65 68a0c160
......@@ -4,6 +4,7 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.erp.project.service.ProjectService;
......@@ -62,4 +63,16 @@ public class ErpConsr {
}
}
@ParamLog("通过项目id获取bookId")
public Long getProjectIdByBookId(Long bookId,Long adviserId,Long channelId){
if(!NumberUtil.isNumber(bookId)){
return null;
}
try {
return ResponseHandleUtil.parseResponse(projectService.getProjectIdByBookId(bookId, adviserId, channelId), Long.class);
} catch (Exception e) {
LOGGER.error("通过项目id获取bookId[projectService.getBookIdByProjectId]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过项目id获取bookId 错误");
}
}
}
......@@ -41,4 +41,6 @@ public interface CustomPlanMapper {
CustomPlan getLastCustomPlanByBookIds(@Param("bookIds") List<Long> bookIds);
List<CustomPlan> getCustomPlanByIds(@Param("customPlanIds") List<Long> customPlanIds);
CustomPlan getLastCustomPlanByClassifyId(@Param("classifyId")Long classifyId,@Param("readType")Integer readType);
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ public interface RightsSettingBiz {
* @param rightsType
* @return
*/
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType);
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId);
/**
* 每周/长期权益查询--小程序
......@@ -69,7 +69,7 @@ public interface RightsSettingBiz {
* @param wechatUserId
* @return
*/
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType);
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType, Long bookId, Long adviserId, Long channelId);
/**
* 查所有权益分类
......
......@@ -15,6 +15,7 @@ import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookAdviserBiz;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.biz.BookRaysClassifyBiz;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dto.BookAdviserDto;
......@@ -23,6 +24,7 @@ import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.cultivate.enums.ReadTypeEnum;
......@@ -67,6 +69,7 @@ import com.pcloud.book.rightsSetting.enums.RightsItemGroupType;
import com.pcloud.book.rightsSetting.enums.RightsNowItemTypeNew;
import com.pcloud.book.rightsSetting.enums.RightsServeTypeEnum;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.enums.RightsWeekTypeEnum;
import com.pcloud.book.rightsSetting.mapper.RightsReadTypeMapper;
import com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
......@@ -173,6 +176,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private RightsSettingBookRelationMapper rightsSettingBookRelationMapper;
@Autowired
private GroupQrcodeBiz groupQrcodeBiz;
@Autowired
private ErpConsr erpConsr;
@Autowired
private BookRaysClassifyBiz bookRaysClassifyBiz;
@Override
@ParamLog("新增权益设置")
......@@ -1423,15 +1430,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override
@ParamLog(value = "小程序首页本周/长期权益查询", isAfterReturn = false)
public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType,
Integer readType) {
Integer readType, Long bookId, Long adviserId, Long channelId) {
RightsSettingDto rightsSettingDto = new RightsSettingDto();
//每周/长期权益
if (RightsTypeEnum.WEEK.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingWeekItems(
getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId, readType));
getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId, readType, bookId, adviserId, channelId));
} else if (RightsTypeEnum.LONG_TERM.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingLongTermItems(
getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId, readType));
getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId, readType, bookId, adviserId, channelId));
}
return rightsSettingDto;
}
......@@ -1439,13 +1446,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId,
Integer readType) {
Integer readType, Long bookId, Long adviserId, Long channelId) {
List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType, readType);
if (ListUtils.isEmpty(list)) {
return new ArrayList<>();
}
// 加载平台端自己选择的社群、方案、资讯等数据
fillRightsSettingItemDetail(list);
// 线上学习/阅读提醒
fillReadPlan(list, rightsType,readType, bookId, adviserId, channelId);
// 筛选出没有选择 社群、方案、资讯 的数据
List<RightsSettingItem> needFillAppletNews = Lists.newArrayList();
for (RightsSettingItem rightsSettingItem : list) {
......@@ -1486,6 +1495,60 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
return list;
}
// 线上学习/阅读提醒(方案特殊处理)
private void fillReadPlan(List<RightsSettingItem> list, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId) {
List<RightsSettingItem> needFillPlanItems = Lists.newArrayList();
boolean existsOnlineRemind = false;
// 筛选点击方案单选框,并没有选具体方案的数据
for (RightsSettingItem rightsSettingItem : list) {
if(rightsSettingItem.getRightsClassifyId() != RightsWeekTypeEnum.ONLINE_REMIND.key.longValue()){
continue;
}
existsOnlineRemind = true;
if (RightsServeTypeEnum.PLAN.name().equalsIgnoreCase(rightsSettingItem.getServeType())
&& ListUtils.isEmpty(rightsSettingItem.getCustomPlanList())) {
needFillPlanItems.add(rightsSettingItem);
}
}
// 如果书刊权益的线上学习的方案为空,那么取分类权益的对应的方案
if(ListUtils.isEmpty(needFillPlanItems) && !existsOnlineRemind){
// 根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
if (null == adviserDto) {
return;
}
// 处理分类信息
BaseTempletClassify classify = new BaseTempletClassify();
classify.setFirstClassify(adviserDto.getTempletId());
classify.setSecondClassify(adviserDto.getSecondTempletId());
classify.setGradeLabelId(adviserDto.getGraLabelId());
classify.setSubjectLabelId(adviserDto.getSubLabelId());
classify.setVolLabelId(adviserDto.getVolLabelId());
setClassifyAndLabel(classify);
// 匹配分类下的分类权益所对应的方案
List<RightsSettingItem> itemList = rightsSettingItemDao.getItemsByClassify(classify.getFirstClassify(),classify.getSecondClassify(),classify.getGradeLabelId(),classify.getSubjectLabelId(),classify.getVolLabelId(),rightsType, readType, RightsWeekTypeEnum.ONLINE_REMIND.key.longValue());
if(ListUtils.isEmpty(itemList)){
return;
}
needFillPlanItems.add(itemList.get(0));
list.add(itemList.get(0));
}
if(ListUtils.isEmpty(needFillPlanItems) || !NumberUtil.isNumber(bookId)|| !NumberUtil.isNumber(readType)){ return; }
// 匹配ERP数据
CustomPlan customPlan = null;
// 根据 bookId 拿到 erp 的 projectId,再根据erp的bookId 在 custom_plan 匹配方案
Long projectId = erpConsr.getProjectIdByBookId(bookId, adviserId, channelId);
if(NumberUtil.isNumber(projectId)){
customPlan = customPlanMapper.getLastCustomPlan(Lists.newArrayList(projectId), readType);
}
if(customPlan != null && NumberUtil.isNumber(customPlan.getId())){
for (RightsSettingItem rightsSettingItem : needFillPlanItems) {
rightsSettingItem.setCustomPlanList(Lists.newArrayList(customPlan));
}
}
}
private List<RightsSettingItem> setReadPlan4Week(List<RightsCustomRelation> rightsCustomRelations, List<RightsSettingItem> list) {
log.info("为每周权益设置读书计划");
if (ListUtils.isEmpty(list) || ListUtils.isEmpty(rightsCustomRelations)) {
......
......@@ -49,4 +49,6 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{
ReadTypeCountDTO getCount4Item(Long rightsSettingId);
Map<Long, RightsSettingClassify> getRightsClassifyMap(ArrayList<Long> longs);
List<RightsSettingItem> getItemsByClassify(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId, String rightsType, Integer readType, Long rightsClassifyId);
}
\ No newline at end of file
......@@ -70,4 +70,18 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp
}
return getSessionTemplate().selectMap(getStatement("getRightsClassifyMap"),ids,"id");
}
@Override
public List<RightsSettingItem> getItemsByClassify(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId, String rightsType, Integer readType, Long rightsClassifyId) {
Map<String,Object> map = new HashMap<>();
map.put("firstClassify",firstClassify);
map.put("secondClassify",secondClassify);
map.put("gradeLabelId",gradeLabelId);
map.put("subjectLabelId",subjectLabelId);
map.put("volLabelId",volLabelId);
map.put("rightsType",rightsType);
map.put("readType",readType);
map.put("rightsClassifyId",rightsClassifyId);
return getSessionTemplate().selectList(getStatement("getItemsByClassify"), map);
}
}
......@@ -123,6 +123,9 @@ public class RightsSettingFacede {
public ResponseDto<?> getItemByRightsSettingId4AppletHome(
@CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId,
@RequestParam(value = "bookId", required = false) Long bookId,
@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "rightsType", required = false) String rightsType,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType
) {
......@@ -130,7 +133,7 @@ public class RightsSettingFacede {
if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType));
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType, bookId, adviserId, channelId));
}
@ApiOperation("所有权益分类")
......
......@@ -250,6 +250,16 @@
LIMIT 1
</select>
<select id="getLastCustomPlanByClassifyId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from custom_plan
where read_type = #{readType}
AND robot_type = #{classifyId}
ORDER BY id DESC
LIMIT 1
</select>
<select id="getLastCustomPlanByBookIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
......
......@@ -56,6 +56,54 @@
order by i.id asc
</select>
<select id="getItemsByClassify" resultType="com.pcloud.book.rightsSetting.entity.RightsSettingItem">
select
i.id, i.rights_setting_id rightsSettingId,
i.rights_type rightsType, i.rights_classify_id rightsClassifyId,
i.description, i.create_time createTime, i.title,i.uuid,i.open_state openState,i.service_desc serviceDesc,i.serve_type serveType,
c.book_id bookId, i.easy_read easyRead,i.efficient_read efficientRead,i.deep_read deepRead
from book.rights_setting_item i
LEFT JOIN rights_setting c ON c.id=i.rights_setting_id
<where>
<if test="rightsSettingType != null">
and c.rights_setting_type = #{rightsSettingType}
</if>
<if test="firstClassify != null">
and c.first_classify = #{firstClassify}
</if>
<if test="secondClassify != null">
and c.second_classify = #{secondClassify}
</if>
<if test="gradeLabelId != null">
and c.grade_label_id = #{gradeLabelId}
</if>
<if test="subjectLabelId != null">
and c.subject_label_id = #{subjectLabelId}
</if>
<if test="volLabelId != null" >
and c.vol_label_id = #{volLabelId}
</if>
<if test="rightsType != null and rightsType != ''">
and i.rights_type = #{rightsType}
</if>
<if test="rightsClassifyId != null ">
and i.rights_classify_id = #{rightsClassifyId}
</if>
<choose>
<when test="readType==1">
and i.easy_read=1
</when>
<when test="readType==2">
and i.efficient_read=1
</when>
<when test="readType==3">
and i.deep_read=1
</when>
</choose>
</where>
order by i.id asc
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.rights_setting_item(rights_setting_id, rights_type, rights_classify_id, description, create_time,title,uuid,open_state,service_desc,serve_type,
......
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