Commit 7bb402ec by 吴博

feat_wb_1002944 1002944书刊权益配置录入支持的结构优化

parent 6889c146
......@@ -334,4 +334,10 @@ public class BookConstant {
public static final String TIME_CONTROL_SEND = "TIME_CONTROL_SEND_";
public static final String DEFAULT_COVER_PIC="https://oss.5rs.me/oss/uploadfe/jpg/b10f42694d17429fe9ebd8dfd85704e0.jpg";
public static final Integer MAX_NEWS_COUNT = 3;
public static final String APP_PRODUCT = "APP/PRODUCT";
public static final String[] APPANDPRODUCT = {"APP","PRODUCT"};
}
......@@ -100,7 +100,7 @@ public interface RightsSettingBiz {
RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId, Integer readType);
FillRightsSettingAppletsDTO getFillRightsSettingApplets(Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
Integer top);
Integer top, Long bookId);
List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy, Integer readType);
......
package com.pcloud.book.rightsSetting.check;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.cultivate.enums.ReadTypeEnum;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.rightsSetting.enums.RightsNowItemTypeNew;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.enums.RightsWeekTypeEnum;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import java.util.Collections;
import java.util.Map.Entry;
import org.apache.commons.collections.MapUtils;
import org.apache.lucene.analysis.util.CharArrayMap.EntrySet;
import org.springframework.stereotype.Component;
import java.util.List;
......@@ -22,32 +31,38 @@ import lombok.extern.slf4j.Slf4j;
public class RightsSettingCheck {
public void rightsSettingCheck(RightsSetting rightsSetting) {
log.info("新增权益设置参数校验");
log.info("更新权益设置参数校验");
if (null == rightsSetting){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
if (StringUtil.isEmpty(rightsSetting.getIntroduce())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益简介为空!");
}
if (StringUtil.isEmpty(rightsSetting.getDetail())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益详情为空!");
}
if (null == rightsSetting.getCount()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益个数为空!");
}
if (null==rightsSetting.getRightsSettingType()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益类型为空!");
}
if (rightsSetting.getRightsSettingType() == 2 &&ListUtils.isEmpty(rightsSetting.getRightsSettingBookRelations())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"RightsSettingBookRelations不能为空!");
if (RightsTypeEnum.BASE.code.equals(rightsSetting.getStepType())){
if (StringUtil.isEmpty(rightsSetting.getIntroduce())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益简介为空!");
}
if (StringUtil.isEmpty(rightsSetting.getDetail())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益详情为空!");
}
if (null == rightsSetting.getCount()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益个数为空!");
}
if (null==rightsSetting.getRightsSettingType()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益类型为空!");
}
if (rightsSetting.getRightsSettingType() == 2 &&ListUtils.isEmpty(rightsSetting.getRightsSettingBookRelations())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"RightsSettingBookRelations不能为空!");
}
if (rightsSetting.getRightsSettingType()==1 && null == rightsSetting.getFirstClassify()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!");
}
}
if (rightsSetting.getRightsSettingType()==1 && null == rightsSetting.getFirstClassify()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!");
if (RightsTypeEnum.NOW.code.equals(rightsSetting.getStepType())){
checkRightNowItem(rightsSetting);
checkRightItemGroups(rightsSetting);
} else if (RightsTypeEnum.WEEK.code.equals(rightsSetting.getStepType())){
checkRightItem(rightsSetting.getRightsSettingWeekItems());
} else if (RightsTypeEnum.WEEK.code.equals(rightsSetting.getStepType())){
checkRightItem(rightsSetting.getRightsSettingLongTermItems());
}
checkRightNowItem(rightsSetting);
checkRightItemGroups(rightsSetting);
checkRightItem(rightsSetting.getRightsSettingWeekItems());
checkRightItem(rightsSetting.getRightsSettingLongTermItems());
}
private void checkRightItem(List<RightsSettingItem> list) {
......@@ -123,11 +138,14 @@ public class RightsSettingCheck {
}
}
private void checkRightNowItemApp(List<RightsNowItem> items) {
public void checkRightNowItemApp(List<RightsNowItem> items) {
if (ListUtils.isEmpty(items)){
return;
}
for (RightsNowItem item : items) {
if (RightsNowItemTypeNew.GIFT_COUPON_PACKAGE.value.equals(item.getType())){
continue;
}
if (item.getServeId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "作品或应用id为空!");
}
......@@ -139,4 +157,73 @@ public class RightsSettingCheck {
}
}
}
public void checkRightNowItems(List<RightsNowItem> items) {
if (ListUtils.isEmpty(items)) {
return;
}
this.checkRightNowItemApp(items);
}
public void checkRightNowTitles(List<RightsSettingTitle> rightsSettingTitleList) {
if (ListUtils.isEmpty(rightsSettingTitleList)) {
return;
}
Map<Integer, List<RightsSettingTitle>> titleMap =
rightsSettingTitleList.stream().collect(Collectors.groupingBy(RightsSettingTitle::getRightsSettingNowType));
if (MapUtils.isEmpty(titleMap)) {
return;
}
for (List<RightsSettingTitle> rightsSettingTitles : titleMap.values()) {
if (ListUtils.isEmpty(rightsSettingTitles)) {
continue;
}
if (rightsSettingTitles.size() > RightsSettingConstant.MAX_ITEM_COUNT) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "单种类型的权限不可超过3个");
}
int easyReadCount = 0;
int efficientReadCount = 0;
int deepReadCount = 0;
for (RightsSettingTitle rightsSettingTitle : rightsSettingTitles) {
if (null != rightsSettingTitle.getEasyRead() && rightsSettingTitle.getEasyRead()) {
++easyReadCount;
}
if (null != rightsSettingTitle.getEfficientRead() && rightsSettingTitle.getEfficientRead()) {
++efficientReadCount;
}
if (null != rightsSettingTitle.getDeepRead() && rightsSettingTitle.getDeepRead()) {
++deepReadCount;
}
}
if (easyReadCount > 1 || efficientReadCount > 1 || deepReadCount > 1) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "查询到对应的权益阅读方式有重复配置,请修改权益");
}
}
}
public void rightsSettingCheck4Insert(RightsSetting rightsSetting) {
log.info("新增权益设置参数校验");
if (null == rightsSetting) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数为空!");
}
if (StringUtil.isEmpty(rightsSetting.getIntroduce())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "权益简介为空!");
}
if (StringUtil.isEmpty(rightsSetting.getDetail())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "权益详情为空!");
}
if (null == rightsSetting.getCount()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "权益个数为空!");
}
if (null == rightsSetting.getRightsSettingType()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "权益类型为空!");
}
if (rightsSetting.getRightsSettingType() == 2 && ListUtils.isEmpty(rightsSetting.getRightsSettingBookRelations())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "RightsSettingBookRelations不能为空!");
}
if (rightsSetting.getRightsSettingType() == 1 && null == rightsSetting.getFirstClassify()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "分类为空!");
}
}
}
......@@ -33,4 +33,6 @@ public class RightsSettingConstant {
public static final String[] APPLET_PRODUCT_NOT_SUPPORT = {ProductTypeConstant.QA,ProductTypeConstant.TOOL,
ProductTypeConstant.TUTORIAL,ProductTypeConstant.ATTENDANCE_TASK, ProductTypeConstant.MEMBER,
ProductTypeConstant.THIRDPARTY,ProductTypeConstant.LINK};
public static final Integer MAX_ITEM_COUNT = 3;
}
......@@ -21,4 +21,8 @@ public interface RightsNowItemDao extends BaseDao<RightsNowItem> {
List<RightsNowItem> getGiftCouponListByRightsSettingId(Long id);
List<RightsNowItem> getListByGroupIds(List<Long> groupIds);
List<RightsNowItem> getListByRightsSettingTitleId(Long rightsSettingTitleId, List<Integer> types);
List<RightsNowItem> getGiftCouponListByRightsSettingTitleId(Long id);
}
......@@ -47,4 +47,19 @@ public class RightsNowItemDaoImpl extends BaseDaoImpl<RightsNowItem> implements
map.put("groupIds",groupIds);
return super.getSqlSession().selectList(getStatement("getListByGroupIds"),map);
}
@Override
public List<RightsNowItem> getListByRightsSettingTitleId(Long rightsSettingTitleId, List<Integer> types) {
Map<String,Object> map=new HashMap<>();
map.put("rightsSettingTitleId",rightsSettingTitleId);
map.put("types",types);
return super.getSqlSession().selectList(getStatement("getListByRightsSettingTitleId"),map);
}
@Override
public List<RightsNowItem> getGiftCouponListByRightsSettingTitleId(Long rightsSettingTitleId) {
Map<String,Object> map=new HashMap<>();
map.put("rightsSettingTitleId",rightsSettingTitleId);
return super.getSqlSession().selectList(getStatement("getGiftCouponListByRightsSettingTitleId"),map);
}
}
......@@ -83,5 +83,7 @@ public class RightsNowItem extends BaseEntity {
private String newsSource;
@ApiModelProperty("来源")
private String source;
@ApiModelProperty("即享权益")
private Long rightsSettingTitleId;
}
......@@ -61,6 +61,12 @@ public class RightsSetting extends BaseTempletClassify {
@ApiModelProperty("配套资料集合")
private RightsSettingTitle servesTitle;
@ApiModelProperty("本书立享权益")
private RightsSettingNow rightsSettingNow;
@ApiModelProperty("更新步骤类型 0 基本信息,1、本书立享权益,2,周,3,长期")
private Integer stepType;
@ApiModelProperty("启用专享社群服务")
private Integer enableGroupService = 0;
......
package com.pcloud.book.rightsSetting.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.Data;
import lombok.NonNull;
import org.springframework.cloud.netflix.ribbon.RibbonHttpRequest;
/**
......@@ -12,6 +16,7 @@ import org.springframework.cloud.netflix.ribbon.RibbonHttpRequest;
* @Date 2020/4/22 17:07
* @Version 1.0
**/
@Data
public class RightsSettingNow {
private Long id;
......@@ -46,7 +51,16 @@ public class RightsSettingNow {
*/
private List<RightsSettingItem> rightsSettingItemList;
@ApiModelProperty("除配套资料权益以外的五个")
private List<RightsSettingTitle> rightsSettingTitles;
private Boolean onlineCourseOpen;
@ApiModelProperty("权益配套资料分组集合")
private List<RightsItemGroup> rightsItemGroups;
@NotNull
@ApiModelProperty("配套资料权益")
private RightsSettingTitle servesTitle;
private Boolean onlineCourseOpen;
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.enums;
public enum RightsNowItemTypeNew {
/**
* 1 配套资料
*/
SERVES(1),
/**
* 2线上网课
*/
ONLINE_COURSE(2),
/**
* 3学习工具
*/
LEARNING_TOOL(3),
/**
* 4抽奖
*/
DRAW(4),
/**
* 5专享礼包券
*/
GIFT_COUPON_PACKAGE(5),
/**
* 6社群服务
*/
GROUP_SERVICE(6),
/*
*
* 7线上学习/阅读提醒
*/
ONLINE_REMIND(7),
/**
* 线上读书活动
*/
ONLINE_READING_ACTIVITY(8);
public final Integer value;
RightsNowItemTypeNew(Integer value) {
this.value = value;
}
}
......@@ -7,19 +7,28 @@ package com.pcloud.book.rightsSetting.enums;
* @版本:1.0
*/
public enum RightsTypeEnum {
/**
* 立享
*/
BASE("BASE", 0),
/**
* 立享
*/
NOW("NOW", 1),
/**
* 每周
*/
WEEK("WEEK"),
WEEK("WEEK", 2),
/**
* 长期
*/
LONG_TERM("LONG_TERM");
LONG_TERM("LONG_TERM", 3);
public final String value;
public final Integer code;
RightsTypeEnum(String value) {
RightsTypeEnum(String value, Integer code) {
this.value = value;
this.code = code;
}
}
......@@ -4,19 +4,16 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsReadType;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CookieValue;
......@@ -196,7 +193,7 @@ public class RightsSettingFacede {
if (null == rightsSettingId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getFillRightsSettingApplets(rightsSettingId, wechatUserId, null, null));
return new ResponseDto<>(rightsSettingBiz.getFillRightsSettingApplets(rightsSettingId, wechatUserId, null, null, null));
}
@ApiOperation("根据权益id获取即享权益配套资料分组集合")
......
......@@ -12,10 +12,12 @@
<result property="giftCouponPackageId" column="gift_coupon_package_id" jdbcType="BIGINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="rightsItemGroupId" column="rights_item_group_id" jdbcType="BIGINT"/>
<result property="rightsSettingTitleId" column="rights_setting_title_id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
id, rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time, rights_item_group_id
id, rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time,
rights_item_group_id,rights_setting_title_id
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -49,7 +51,8 @@
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowItem" useGeneratedKeys="true" keyProperty="id">
insert into rights_now_item (
rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time, rights_item_group_id
rights_setting_id, serve_id, serve_type, link_url, type, gift_coupon_package_id, create_time, rights_item_group_id,
rights_setting_title_id
) values
<foreach collection="list" item="item" index="index" separator=",">
(
......@@ -60,7 +63,8 @@
#{item.type,jdbcType=INTEGER},
#{item.giftCouponPackageId,jdbcType=BIGINT},
NOW(),
#{item.rightsItemGroupId,jdbcType=BIGINT}
#{item.rightsItemGroupId,jdbcType=BIGINT},
#{item.rightsSettingTitleId}
)
</foreach>
</insert>
......@@ -120,4 +124,44 @@
</foreach>
</select>
<select id="getListByRightsSettingTitleId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from
rights_now_item
where rights_setting_title_id=#{rightsSettingTitleId}
<if test="types!=null and types.size()>0">
and type in
<foreach collection="types" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
</select>
<select id="getGiftCouponListByRightsSettingTitleId" parameterType="map" resultType="com.pcloud.book.rightsSetting.entity.RightsNowItem">
SELECT
t.id,
t.rights_setting_id rightsSettingId,
t.serve_id serveId,
t.serve_type serveType,
t.link_url linkUrl,
t.type,
t.gift_coupon_package_id giftCouponPackageId,
t.create_time createTime,
t1.title giftCouponTitle,
t1.cover_pic giftCouponCoverPic,
t1.denomination giftCouponDenomination,
t1.valid_date_begin giftCouponValidDateBegin,
t1.valid_date_end giftCouponValidDateEnd,
t1.coupon_type couponType,
t1.instructions instructions,
t1.use_type useType,
t1.exchange_address exchangeAddress
FROM
rights_now_item t
INNER JOIN gift_coupon_package t1 ON t.gift_coupon_package_id = t1.id
WHERE
t1.is_delete = 0
AND t.rights_setting_title_id = #{rightsSettingTitleId}
and now() <![CDATA[ <= ]]> t1.valid_date_end
</select>
</mapper>
\ No newline at end of file
......@@ -94,13 +94,13 @@
rights_setting_id = #{rightsSettingId}
</delete>
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title (id, rights_setting_id, rights_setting_title,
<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)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id,jdbcType=BIGINT}, #{item.rightsSettingId,jdbcType=BIGINT}, #{item.rightsSettingTitle,jdbcType=VARCHAR},
(#{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})
</foreach>
......
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