Commit d78b9210 by pansy

feat: 1003185

parent fa7c0866
......@@ -44,6 +44,9 @@ public class PcloudBookGroupClassifyVO {
@ApiModelProperty("城市名称")
private String cityName;
@ApiModelProperty("社群名称")
private String groupQrcodeName;
public String getCityName() {
return cityName;
}
......@@ -148,6 +151,14 @@ public class PcloudBookGroupClassifyVO {
this.groupPic = groupPic;
}
public String getGroupQrcodeName() {
return groupQrcodeName;
}
public void setGroupQrcodeName(String groupQrcodeName) {
this.groupQrcodeName = groupQrcodeName;
}
@Override
public String toString() {
return "PcloudBookGroupClassifyVO{" +
......
......@@ -80,16 +80,19 @@ import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import java.util.Comparator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -281,6 +284,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("更新权益设置")
@Transactional(rollbackFor = Exception.class)
public void updateRightsSetting(RightsSetting rightsSetting) {
RightsSettingNow rightsSettingNow = rightsSetting.getRightsSettingNow();
if(null != rightsSettingNow && !ListUtils.isEmpty(rightsSettingNow.getNewRightsSettingTitles())){
List<RightsSettingTitle> newRightsSettingTitles= rightsSettingNow.getNewRightsSettingTitles();
Integer servesTitleType = 1;
List<RightsSettingTitle> rightsSettingTitles = new ArrayList<>();
if (!ListUtils.isEmpty(newRightsSettingTitles)){
newRightsSettingTitles.stream().forEach(
rightsSettingTitle -> {
if (servesTitleType.intValue() == rightsSettingTitle.getRightsSettingNowType().intValue()) {
rightsSettingNow.setServesTitle(rightsSettingTitle);
} else {
rightsSettingTitles.add(rightsSettingTitle);
}
}
);
}
rightsSettingNow.setRightsSettingTitles(rightsSettingTitles);
}
rightsSettingCheck.rightsSettingCheck(rightsSetting);
if (null == rightsSetting.getId()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少id!");
......@@ -708,6 +731,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSettingNow.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(), null, null, null, false, null));
rightsSettingNow.setServesTitle(servesTitle);
rightsSetting.setRightsSettingNow(rightsSettingNow);
List<RightsSettingTitle> newRightsSettingTitles = new ArrayList<> (rightsSettingTitles);
newRightsSettingTitles.add(servesTitle);
newRightsSettingTitles = newRightsSettingTitles.stream().sorted(Comparator.comparing(item -> item.getSeqNum(), Comparator.nullsLast(Integer::compareTo)))
.collect(Collectors.toList());
rightsSettingNow.setNewRightsSettingTitles(newRightsSettingTitles);
}
private void fillBookName(Long id, RightsSetting rightsSetting) {
......@@ -1017,7 +1047,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
// 此处只有资讯才会补充资讯
if (RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingTitle.getServeType())){
if (items.size() < top) {
Integer collage = 1;
if (items.size() < top && rightsSettingTitle.getCollageState().intValue() == collage.intValue()){
// 填充咨询
supplementNews(rightsSettingId, wechatUserId, rightsClassifyId, top - items.size(), items, bookId, itemType.value);
}
......@@ -1482,6 +1513,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId,
Integer readType, Long bookId, Long adviserId, Long channelId) {
List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType, readType);
Integer collage = 1; //拼群
if (ListUtils.isEmpty(list)) {
return new ArrayList<>();
}
......@@ -1492,19 +1525,38 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
// 筛选出没有选择 社群、方案、资讯 的数据
List<RightsSettingItem> needFillAppletNews = Lists.newArrayList();
for (RightsSettingItem rightsSettingItem : list) {
if (RightsServeTypeEnum.GROUP.name().equals(rightsSettingItem.getServeType()) && rightsSettingItem.getCollageState().intValue() == collage.intValue() && (ListUtils.isEmpty(rightsSettingItem.getGroupActivity4AppletList()) || rightsSettingItem.getGroupActivity4AppletList().size()<3)){
Integer top = 3;
if (!ListUtils.isEmpty(rightsSettingItem.getGroupActivity4AppletList())){
top = top - rightsSettingItem.getGroupActivity4AppletList().size();
}
// 填充群
List<RightsNowItem> items = new ArrayList<>();
List<GroupActivity4AppletDTO> collageList = supplementGroup(rightsSettingId, wechatUserId, rightsSettingItem.getRightsClassifyId(), top,items, bookId,rightsType);
if (!ListUtils.isEmpty(collageList)){
for (GroupActivity4AppletDTO item :collageList){
rightsSettingItem.getGroupActivity4AppletList().add(item);
// 填充头像
fillGroupActivityHead(Collections.singletonList(item));
}
}
}
if (rightsSettingItem.getServeType() == null
|| RightsServeTypeEnum.GROUP.name().equalsIgnoreCase(rightsSettingItem.getServeType()) && ListUtils
.isEmpty(rightsSettingItem.getGroupActivity4AppletList())
|| RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingItem.getServeType()) && ListUtils
.isEmpty(rightsSettingItem.getAppletNewsDTOS())) {
needFillAppletNews.add(rightsSettingItem);
|| RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingItem.getServeType())) {
if ((ListUtils.isEmpty(rightsSettingItem.getAppletNewsDTOS()) || rightsSettingItem.getAppletNewsDTOS().size() <3) && rightsSettingItem.getCollageState().intValue() == collage.intValue()){
needFillAppletNews.add(rightsSettingItem);
}
}
}
if (ListUtils.isEmpty(needFillAppletNews)) {
return list;
}
// 将未选择服务的数据补充资讯
setAppletNews4Week(rightsSettingId, rightsType, wechatUserId, needFillAppletNews);
setAppletNews4Week(rightsSettingId, rightsType, wechatUserId, needFillAppletNews,bookId);
/*
List<Long> rightsSettingItemIds =
......@@ -1616,7 +1668,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
private List<RightsSettingItem> setAppletNews4Week(Long rightsSettingId, String rightsType, Long wechatUserId,
List<RightsSettingItem> list) {
List<RightsSettingItem> list,Long bookId) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取
List<RightsSettingBookRelation> rightsSettingBookRelations =
......@@ -1624,7 +1676,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (ListUtils.isEmpty(rightsSettingBookRelations)) {
return new ArrayList<>();
}
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSettingBookRelations.get(0).getBookId());
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(bookId);
rightsSetting.setFirstClassify(adviserDto.getTempletId());
rightsSetting.setSecondClassify(adviserDto.getSecondTempletId());
rightsSetting.setGradeLabelId(adviserDto.getGraLabelId());
......@@ -1644,16 +1696,21 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
Map<Long, List<AppletNewsDTO>> map = appletNewsDTOS.stream().collect(Collectors.groupingBy(AppletNewsDTO::getRightsClassifyId));
for (RightsSettingItem item : list) {
int top = 3;
if(!ListUtils.isEmpty(item.getAppletNewsDTOS())){
top = top - item.getAppletNewsDTOS().size();
}
//用户-权益-权益分类
String key = "BOOK:RIGHTS_SETTING:USER_RIGHTS_ITEM" + wechatUserId + "-" + rightsSettingId + "-" + item.getRightsClassifyId();
//权益分类下资讯
List<AppletNewsDTO> newsDTOS = JedisClusterUtils.getJsonList(key, AppletNewsDTO.class);
if (ListUtils.isEmpty(newsDTOS) || newsDTOS.size() < 3) {//数据库取
if (ListUtils.isEmpty(newsDTOS) || newsDTOS.size() < top) {//数据库取
if (!MapUtils.isEmpty(map) && map.containsKey(item.getRightsClassifyId())) {
newsDTOS = map.get(item.getRightsClassifyId());
if (newsDTOS.size() > 3) {//随机取三条
if (newsDTOS.size() > top) {//随机取三条
List<AppletNewsDTO> dtos = new ArrayList<>();
while (dtos.size() < 3) {
while (dtos.size() < top) {
AppletNewsDTO dto = newsDTOS.get(new Random().nextInt(newsDTOS.size()));
if (!dtos.contains(dto)) {
dtos.add(dto);
......@@ -1664,7 +1721,11 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
JedisClusterUtils.setJsonList(key, newsDTOS, 60);
}
}
item.setAppletNewsDTOS(newsDTOS);
if (!ListUtils.isEmpty(newsDTOS)){
newsDTOS.forEach(newDto->{
item.getAppletNewsDTOS().add(newDto);
});
}
}
return list;
}
......@@ -1750,7 +1811,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
List<RightsNowItem> items = Lists.newArrayList();
if (CollectionUtils.isEmpty(nowItems)) {
// 填充群
supplementGroup(rightsSettingId, wechatUserId, rightsClassifyId, top, items,bookId);
supplementGroup(rightsSettingId, wechatUserId, rightsClassifyId, top, items,bookId,null);
// 处理权益中的应用/作品
fillProductAndApp(items);
rightsSettingTitle.setRightsSettingItemList(items);
......@@ -1763,16 +1824,17 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
items.add(nowItem);
}
}
if (items.size() < top) {
Integer collage = 1; //状态为拼群
if (items.size() < top && rightsSettingTitle.getCollageState().intValue() == collage.intValue()) {
// 填充咨询
supplementGroup(rightsSettingId, wechatUserId, rightsClassifyId, top, items, bookId);
supplementGroup(rightsSettingId, wechatUserId, rightsClassifyId, top, items, bookId,null);
}
// 处理权益中的应用/作品
fillProductAndApp(items);
rightsSettingTitle.setRightsSettingItemList(items);
}
private void supplementGroup(Long rightsSettingId, Long wechatUserId, Long rightsClassifyId, Integer top, List<RightsNowItem> items, Long bookId) {
private List<GroupActivity4AppletDTO> supplementGroup(Long rightsSettingId, Long wechatUserId, Long rightsClassifyId, Integer top, List<RightsNowItem> items, Long bookId,String rightsType) {
// 书刊分类
List<GroupActivity4AppletDTO> groupActivity4AppletDTOList = null;
BookAdviserDto bookAdviserDto = bookAdviserBiz.getOneMainBook(bookId);
......@@ -1795,9 +1857,38 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (ListUtils.isEmpty(groupActivity4AppletDTOList)) {
// 如果书刊没拿到群,则通过权益分类拿群
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
setClassifyAndLabel(rightsSetting);
if (NumberUtil.isNumber(rightsSetting.getFirstClassify())) {
groupActivity4AppletDTOList = pcloudGroupActivityBiz.getTishBookSchoolListWrap(rightsSetting, top);
//add by pansy 查询权益的拼群开关
boolean isCollage= false;
Integer collage= 1;
if(!StringUtil.isEmpty(rightsType)){ //长期权益
List<RightsSettingItem> rightsSettingItems = rightsSettingItemDao.getRightSettingInfo(RightsServeTypeEnum.GROUP.name(),rightsType,rightsSettingId);
Iterator<RightsSettingItem> it = rightsSettingItems.iterator();
while(it.hasNext()){
RightsSettingItem item= it.next();
if (item.getCollageState().intValue() == collage.intValue()){
isCollage = true;
break;
}
}
}else { //立享权益
RightsSettingTitle rightsSettingTitle = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSettingId, 6,null);
// List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSettingId, null);
// Iterator<RightsSettingTitle> it = rightsSettingTitles.iterator();
// while(it.hasNext()){
// RightsSettingTitle item= it.next();
if (rightsSettingTitle.getCollageState().intValue() == collage.intValue() && RightsServeTypeEnum.GROUP.name().equalsIgnoreCase(rightsSettingTitle.getServeType()) ){
isCollage = true;
// break;
}
// }
}
if(isCollage){
setClassifyAndLabel(rightsSetting);
if (NumberUtil.isNumber(rightsSetting.getFirstClassify())) {
groupActivity4AppletDTOList = pcloudGroupActivityBiz.getTishBookSchoolListWrap(rightsSetting, top);
}
}
}
if (!ListUtils.isEmpty(groupActivity4AppletDTOList)) {
......@@ -1814,6 +1905,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
items.add(rightsNowItem);
}
}
return groupActivity4AppletDTOList;
}
@ParamLog(value = "填充配套资料", isAfterReturn = false)
......
......@@ -51,4 +51,6 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{
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);
List<RightsSettingItem> getRightSettingInfo(String serveType, String rightsType, Long rightsSettingId);
}
\ No newline at end of file
......@@ -84,4 +84,13 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp
map.put("rightsClassifyId",rightsClassifyId);
return getSessionTemplate().selectList(getStatement("getItemsByClassify"), map);
}
@Override
public List<RightsSettingItem> getRightSettingInfo(String serveType, String rightsType, Long rightsSettingId){
Map<String,Object> map = new HashMap<>();
map.put("serveType",serveType);
map.put("rightsType",rightsType);
map.put("rightsSettingId",rightsSettingId);
return getSessionTemplate().selectList(getStatement("getRightSettingInfo"), map);
}
}
......@@ -101,4 +101,9 @@ public class RightsSettingItem extends BaseEntity {
* 阅读方式1轻松2高效3深度
*/
private Integer readType;
/**
* 拼群开关 0 不拼 1 拼
*/
private Integer collageState;
}
\ No newline at end of file
......@@ -63,4 +63,10 @@ public class RightsSettingNow {
private Boolean onlineCourseOpen;
/**
* 排序后的settingTitle集合
*/
@ApiModelProperty("排序后的settingTitle集合")
private List<RightsSettingTitle> newRightsSettingTitles;
}
\ No newline at end of file
......@@ -52,4 +52,10 @@ public class RightsSettingTitle implements Serializable {
*/
private Boolean deepRead;
/**
* 拼群开关 0 不拼 1 拼
*/
private Integer collageState;
private Integer seqNum;
}
\ No newline at end of file
......@@ -65,9 +65,9 @@ public class RightsSettingFacede {
@GetMapping("getRightsSetting")
public ResponseDto<RightsSetting> getRightsSetting(
// @RequestHeader("token") String token,
@RequestHeader("token") String token,
@RequestParam("id") Long id ) throws PermissionException {
// SessionUtil.getToken4Redis(token);
SessionUtil.getToken4Redis(token);
return new ResponseDto<RightsSetting>(rightsSettingBiz.getRightsSetting(id));
}
......
......@@ -5,8 +5,8 @@ server:
eureka:
instance:
status-page-url-path: /book/v1.0/swagger-ui.html
# client:
# register-with-eureka: false #禁止自己当做服务注册
client:
register-with-eureka: false #禁止自己当做服务注册
spring:
application:
......
......@@ -1126,6 +1126,7 @@
a.create_user as adviserId,
count(b.classify_id) AS groupCount,
c.agent_id as agentId,
c.group_qrcode_name as groupQrcodeName,
city_code cityCode
FROM
book_group_classify a
......
......@@ -17,6 +17,7 @@
<result property="easyRead" column="easy_read" jdbcType="TINYINT" />
<result property="efficientRead" column="efficient_read" jdbcType="TINYINT" />
<result property="deepRead" column="deep_read" jdbcType="TINYINT" />
<result property="collageState" column="collage_state" jdbcType="INTEGER" />
</resultMap>
<!--通过实体作为筛选条件查询-->
......@@ -25,7 +26,7 @@
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
c.book_id bookId, i.easy_read easyRead,i.efficient_read efficientRead,i.deep_read deepRead,i.collage_state collageState
from book.rights_setting_item i
LEFT JOIN rights_setting c ON c.id=i.rights_setting_id
<where>
......@@ -107,9 +108,9 @@
<!--新增所有列-->
<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,
easy_read,efficient_read,deep_read)
easy_read,efficient_read,deep_read,collage_state)
values (#{rightsSettingId}, #{rightsType}, #{rightsClassifyId}, #{description}, NOW(), #{title},#{uuid},#{openState},#{serviceDesc},#{serveType},
#{easyRead},#{efficientRead},#{deepRead})
#{easyRead},#{efficientRead},#{deepRead},#{collageState})
</insert>
<!--通过权益主键删除-->
......@@ -125,7 +126,7 @@
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
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,
easy_read,efficient_read,deep_read
easy_read,efficient_read,deep_read,collage_state
)
values
<foreach collection="list" item="item" index="index" separator="," >
......@@ -140,7 +141,8 @@
#{item.openState},
#{item.serviceDesc},
#{item.serveType},
#{item.easyRead},#{item.efficientRead},#{item.deepRead}
#{item.easyRead},#{item.efficientRead},#{item.deepRead},
#{item.collageState}
)
</foreach>
</insert>
......@@ -201,4 +203,19 @@
</where>
</select>
<select id="getRightSettingInfo" parameterType="list" resultMap="RightsSettingItemMap">
SELECT id, rights_setting_id, serve_type , rights_type ,collage_state
FROM rights_setting_item
WHERE 1=1
<if test="serveType!=null">
and serve_type=#{serveType}
</if>
<if test="rightsType!=null">
and rights_type=#{rightsType}
</if>
<if test="rightsSettingId!=null">
and rights_setting_id=#{rightsSettingId}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -14,12 +14,14 @@
<result column="easy_read" jdbcType="TINYINT" property="easyRead" />
<result column="efficient_read" jdbcType="TINYINT" property="efficientRead" />
<result column="deep_read" jdbcType="TINYINT" property="deepRead" />
<result column="seq_num" jdbcType="INTEGER" property="seqNum" />
<result column="collage_state" jdbcType="TINYINT" property="collageState" />
</resultMap>
<sql id="baseSql">
id, rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time,
update_time,rights_setting_now_type,serve_type,easy_read,efficient_read,deep_read
update_time,rights_setting_now_type,serve_type,easy_read,efficient_read,deep_read,seq_num,collage_state
</sql>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title (id, rights_setting_id, rights_setting_title,
......@@ -97,12 +99,12 @@
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle" useGeneratedKeys="true" keyProperty="id">
insert into rights_setting_title (rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time, update_time,rights_setting_now_type,serve_type,
easy_read,efficient_read,deep_read)
easy_read,efficient_read,deep_read,seq_num, collage_state)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.rightsSettingId,jdbcType=BIGINT}, #{item.rightsSettingTitle,jdbcType=VARCHAR},
#{item.rightsSettingDesc,jdbcType=VARCHAR}, #{item.openState,jdbcType=TINYINT}, now(), now(),#{item.rightsSettingNowType},#{item.serveType},
#{item.easyRead},#{item.efficientRead},#{item.deepRead})
#{item.easyRead},#{item.efficientRead},#{item.deepRead},#{item.seqNum}, #{item.collageState})
</foreach>
</insert>
......
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