Commit ef4da83b by 吴博

1002795

parent 088aa326
...@@ -34,9 +34,12 @@ import com.pcloud.book.rightsSetting.entity.RightsNowItem; ...@@ -34,9 +34,12 @@ import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify; import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem; import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.rightsSetting.enums.RightsNowItemType; import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum; import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.util.common.CommonUtils; import com.pcloud.book.util.common.CommonUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -45,6 +48,9 @@ import com.pcloud.common.utils.ListUtils; ...@@ -45,6 +48,9 @@ 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.resourcecenter.product.dto.ProductDto; import com.pcloud.resourcecenter.product.dto.ProductDto;
import io.swagger.annotations.ApiModelProperty;
import java.util.function.Function;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
...@@ -94,6 +100,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -94,6 +100,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private AppletNewsDao appletNewsDao; private AppletNewsDao appletNewsDao;
@Autowired @Autowired
private BookBiz bookBiz; private BookBiz bookBiz;
@Autowired
private RightsSettingTitleMapper rightsSettingTitleMapper;
@Override @Override
@ParamLog("新增权益设置") @ParamLog("新增权益设置")
...@@ -178,88 +186,196 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -178,88 +186,196 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
@ParamLog("更新权益的即享权益项集合") @ParamLog("更新权益的即享权益项集合")
private void updateRightNowItemByRightId(RightsSetting rightsSetting){ private void updateRightNowItemByRightId(RightsSetting rightsSetting) {
if (rightsSetting==null){ if (rightsSetting == null) {
return; return;
} }
Long rightsSettingId=rightsSetting.getId(); Long rightsSettingId = rightsSetting.getId();
List<RightsNowItem> items=new ArrayList<>(); List<RightsNowItem> items = new ArrayList<>();
if (!ListUtils.isEmpty(rightsSetting.getOnlineCourseNowItems())){ List<RightsSettingTitle> rightsSettingTitles = new ArrayList<>();
for (RightsNowItem item:rightsSetting.getOnlineCourseNowItems()){ //给每个权益设置id
setRightsSettingId(rightsSetting, rightsSettingId, rightsSettingTitles);
//设置每个权益详情
setNowItems(rightsSetting, rightsSettingId, items);
//根据权益id删除原来的
rightsNowItemDao.deleteByRightsSettingId(rightsSettingId);
if (!ListUtils.isEmpty(items)) {
rightsNowItemDao.batchInsert(items);
}
if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitles.stream().forEach(e -> e.setRightsSettingId(rightsSettingId));
}
if (null != rightsSetting.getOnlineRightsSettingTitle() && null == rightsSetting.getOnlineRightsSettingTitle().getId()) {
rightsSettingTitleMapper.deleteByRightSettingId(rightsSettingId);
if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitleMapper.batchInsert(rightsSettingTitles);
}
} else if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitleMapper.batchUpdate(rightsSettingTitles);
}
}
private void setNowItems(RightsSetting rightsSetting, Long rightsSettingId, List<RightsNowItem> items) {
log.info("填充即享权益具体项目的的基本参数");
if (null != rightsSetting.getOnlineRightsSettingTitle() && !ListUtils
.isEmpty(rightsSetting.getOnlineRightsSettingTitle().getRightsSettingItemList())) {
for (RightsNowItem item : rightsSetting.getOnlineRightsSettingTitle().getRightsSettingItemList()) {
item.setType(RightsNowItemType.ONLINE_COURSE.value); item.setType(RightsNowItemType.ONLINE_COURSE.value);
item.setRightsSettingId(rightsSettingId); item.setRightsSettingId(rightsSettingId);
items.add(item); items.add(item);
} }
} }
if (!ListUtils.isEmpty(rightsSetting.getLearningToolNowItems())){ if (null != rightsSetting.getLearningToolTitle() && !ListUtils
for (RightsNowItem item:rightsSetting.getLearningToolNowItems()){ .isEmpty(rightsSetting.getLearningToolTitle().getRightsSettingItemList())) {
for (RightsNowItem item : rightsSetting.getLearningToolTitle().getRightsSettingItemList()) {
item.setType(RightsNowItemType.LEARNING_TOOL.value); item.setType(RightsNowItemType.LEARNING_TOOL.value);
item.setRightsSettingId(rightsSettingId); item.setRightsSettingId(rightsSettingId);
items.add(item); items.add(item);
} }
} }
if (!ListUtils.isEmpty(rightsSetting.getDrawNowItems())){ if (null != rightsSetting.getDrawSettingTitle() && !ListUtils
for (RightsNowItem item:rightsSetting.getDrawNowItems()){ .isEmpty(rightsSetting.getDrawSettingTitle().getRightsSettingItemList())) {
for (RightsNowItem item : rightsSetting.getDrawSettingTitle().getRightsSettingItemList()) {
item.setType(RightsNowItemType.DRAW.value); item.setType(RightsNowItemType.DRAW.value);
item.setRightsSettingId(rightsSettingId); item.setRightsSettingId(rightsSettingId);
items.add(item); items.add(item);
} }
} }
if (!ListUtils.isEmpty(rightsSetting.getGiftCouponPackageNowItems())){ if (null != rightsSetting.getGiftCouponPackageTitle() && !ListUtils
for (RightsNowItem item:rightsSetting.getGiftCouponPackageNowItems()){ .isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())) {
for (RightsNowItem item : rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList()) {
item.setType(RightsNowItemType.GIFT_COUPON_PACKAGE.value); item.setType(RightsNowItemType.GIFT_COUPON_PACKAGE.value);
item.setRightsSettingId(rightsSettingId); item.setRightsSettingId(rightsSettingId);
items.add(item); items.add(item);
} }
} }
//根据权益id删除原来的 }
rightsNowItemDao.deleteByRightsSettingId(rightsSettingId);
if (!ListUtils.isEmpty(items)){ private void setRightsSettingId(RightsSetting rightsSetting, Long rightsSettingId, List<RightsSettingTitle> rightsSettingTitles) {
rightsNowItemDao.batchInsert(items); log.info("填充即享权益的基本参数");
RightsSettingTitle onlineRightsSettingTitle = rightsSetting.getOnlineRightsSettingTitle();
RightsSettingTitle learningToolTitle = rightsSetting.getLearningToolTitle();
RightsSettingTitle drawSettingTitle = rightsSetting.getDrawSettingTitle();
RightsSettingTitle giftCouponPackageTitle = rightsSetting.getGiftCouponPackageTitle();
RightsSettingTitle groupServiceTitle = rightsSetting.getGroupServiceTitle();
RightsSettingTitle servesTitle = rightsSetting.getServesTitle();
if (null != onlineRightsSettingTitle) {
onlineRightsSettingTitle.setRightsSettingId(rightsSettingId);
onlineRightsSettingTitle.setRightsSettingNowType(RightsNowItemType.ONLINE_COURSE.value);
rightsSettingTitles.add(onlineRightsSettingTitle);
}
if (null != learningToolTitle) {
learningToolTitle.setRightsSettingId(rightsSettingId);
learningToolTitle.setRightsSettingNowType(RightsNowItemType.LEARNING_TOOL.value);
rightsSettingTitles.add(learningToolTitle);
}
if (null != drawSettingTitle) {
drawSettingTitle.setRightsSettingId(rightsSettingId);
drawSettingTitle.setRightsSettingNowType(RightsNowItemType.DRAW.value);
rightsSettingTitles.add(drawSettingTitle);
}
if (null != giftCouponPackageTitle) {
giftCouponPackageTitle.setRightsSettingId(rightsSettingId);
giftCouponPackageTitle.setRightsSettingNowType(RightsNowItemType.GIFT_COUPON_PACKAGE.value);
rightsSettingTitles.add(giftCouponPackageTitle);
}
if (null != groupServiceTitle) {
groupServiceTitle.setRightsSettingId(rightsSettingId);
groupServiceTitle.setRightsSettingNowType(RightsNowItemType.GROUP_SERVICE.value);
rightsSettingTitles.add(groupServiceTitle);
}
if (null != servesTitle) {
servesTitle.setRightsSettingId(rightsSettingId);
servesTitle.setRightsSettingNowType(RightsNowItemType.SERVES.value);
servesTitle.setOpenState(Boolean.TRUE);
rightsSettingTitles.add(servesTitle);
} }
} }
@Override @Override
@ParamLog("获取权益设置") @ParamLog("获取权益设置")
public RightsSetting getRightsSetting(Long id) { public RightsSetting getRightsSetting(Long id) {
RightsSetting rightsSetting=rightsSettingDAO.selectByPrimaryKey(id); RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(id);
if (null==rightsSetting){ if (null == rightsSetting) {
return new RightsSetting(); return new RightsSetting();
} }
if (rightsSetting.getRightsSettingType()==2 && null != rightsSetting.getBookId()){ if (rightsSetting.getRightsSettingType() == 2 && null != rightsSetting.getBookId()) {
BookDto bookDto = bookBiz.getBaseById(rightsSetting.getBookId()); BookDto bookDto = bookBiz.getBaseById(rightsSetting.getBookId());
rightsSetting.setBookName(bookDto==null?"":bookDto.getBookName()); rightsSetting.setBookName(bookDto == null ? "" : bookDto.getBookName());
} }
fillRightsNowItems(rightsSetting); fillRightsNowItems(rightsSetting);
fillGiftCouponPack(rightsSetting); fillGiftCouponPack(rightsSetting);
rightsSetting.setRightsSettingWeekItems(getItemsByRightsSettingId(id, RightsTypeEnum.WEEK.value)); rightsSetting.setRightsSettingWeekItems(getItemsByRightsSettingId(id, RightsTypeEnum.WEEK.value));
rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id,RightsTypeEnum.LONG_TERM.value)); rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value));
return rightsSetting; return rightsSetting;
} }
@ParamLog("填充资源") @ParamLog("填充资源")
private void fillRightsNowItems(RightsSetting rightsSetting) { private void fillRightsNowItems(RightsSetting rightsSetting) {
List<Integer> types=new ArrayList<>(); List<Integer> types = new ArrayList<>();
types.add(RightsNowItemType.ONLINE_COURSE.value); types.add(RightsNowItemType.ONLINE_COURSE.value);
types.add(RightsNowItemType.LEARNING_TOOL.value); types.add(RightsNowItemType.LEARNING_TOOL.value);
types.add(RightsNowItemType.DRAW.value); types.add(RightsNowItemType.DRAW.value);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(),types); List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSetting.getId());
if (ListUtils.isEmpty(nowItems)){ RightsSettingTitle rightsSettingTitler4Online = new RightsSettingTitle();
return; RightsSettingTitle rightsSettingTitler4Learningtool = new RightsSettingTitle();
} RightsSettingTitle rightsSettingTitler4Draw = new RightsSettingTitle();
List<Long> productIds = new ArrayList<>(); RightsSettingTitle rightsSettingTitler4Serves = new RightsSettingTitle();
List<Long> appIds = new ArrayList<>(); rightsSettingTitler4Serves.setOpenState(Boolean.TRUE);
for (RightsNowItem item:nowItems){ rightsSettingTitler4Serves.setRightsSettingNowType(RightsNowItemType.SERVES.value);
if (item.getServeId()!=null&&AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType()) Map<Integer, RightsSettingTitle> rightsSettingTitleMap = new HashMap<>();
&&!productIds.contains(item.getServeId())){ if (!ListUtils.isEmpty(rightsSettingTitles)) {
productIds.add(item.getServeId()); rightsSettingTitleMap =
} rightsSettingTitles.stream()
if (item.getServeId()!=null&&AppAndProductTypeEnum.APP.value.equals(item.getServeType()) .collect(Collectors.toMap(RightsSettingTitle::getRightsSettingNowType, Function.identity()));
&&!productIds.contains(item.getServeId())){ }
appIds.add(item.getServeId()); if (null != rightsSettingTitleMap.get(RightsNowItemType.ONLINE_COURSE.value)) {
rightsSettingTitler4Online = rightsSettingTitleMap.get(RightsNowItemType.ONLINE_COURSE.value);
}
if (null != rightsSettingTitleMap.get(RightsNowItemType.LEARNING_TOOL.value)) {
rightsSettingTitler4Learningtool = rightsSettingTitleMap.get(RightsNowItemType.LEARNING_TOOL.value);
}
if (null != rightsSettingTitleMap.get(RightsNowItemType.DRAW.value)) {
rightsSettingTitler4Draw = rightsSettingTitleMap.get(RightsNowItemType.DRAW.value);
}
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), types);
if (!ListUtils.isEmpty(nowItems)) {
List<Long> productIds = new ArrayList<>();
List<Long> appIds = new ArrayList<>();
for (RightsNowItem item : nowItems) {
if (item.getServeId() != null && AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
productIds.add(item.getServeId());
}
if (item.getServeId() != null && AppAndProductTypeEnum.APP.value.equals(item.getServeType())
&& !productIds.contains(item.getServeId())) {
appIds.add(item.getServeId());
}
} }
} fillProductAndApp(nowItems, productIds, appIds);
rightsSettingTitler4Online.setRightsSettingItemList(
nowItems.stream().filter(s -> RightsNowItemType.ONLINE_COURSE.value.equals(s.getType())).collect(Collectors.toList()));
rightsSettingTitler4Learningtool.setRightsSettingItemList(
nowItems.stream().filter(s -> RightsNowItemType.LEARNING_TOOL.value.equals(s.getType())).collect(Collectors.toList()));
rightsSettingTitler4Draw.setRightsSettingItemList(
nowItems.stream().filter(s -> RightsNowItemType.DRAW.value.equals(s.getType())).collect(Collectors.toList()));
}
rightsSetting.setOnlineRightsSettingTitle(rightsSettingTitler4Online);
rightsSetting.setLearningToolTitle(rightsSettingTitler4Learningtool);
rightsSetting.setDrawSettingTitle(rightsSettingTitler4Draw);
rightsSetting.setGroupServiceTitle(null == rightsSettingTitleMap.get(RightsNowItemType.GROUP_SERVICE.value) ?
new RightsSettingTitle() : rightsSettingTitleMap.get(RightsNowItemType.GROUP_SERVICE.value));
rightsSetting.setGiftCouponPackageTitle(null == rightsSettingTitleMap.get(RightsNowItemType.GIFT_COUPON_PACKAGE.value) ?
new RightsSettingTitle() : rightsSettingTitleMap.get(RightsNowItemType.GIFT_COUPON_PACKAGE.value));
rightsSetting.setServesTitle(null == rightsSettingTitleMap.get(RightsNowItemType.SERVES.value) ?
rightsSettingTitler4Serves: rightsSettingTitleMap.get(RightsNowItemType.SERVES.value));
}
private void fillProductAndApp(List<RightsNowItem> nowItems, List<Long> productIds, List<Long> appIds) {
log.info("即享权益填充产品和app内容");
Map<Long, ProductDto> productDtoMap = new HashMap<>(); Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, AppDto> appDtoMap = new HashMap<>(); Map<Long, AppDto> appDtoMap = new HashMap<>();
if (!ListUtils.isEmpty(productIds)) { if (!ListUtils.isEmpty(productIds)) {
...@@ -269,10 +385,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -269,10 +385,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
appDtoMap = appConsr.mapByIds(appIds); appDtoMap = appConsr.mapByIds(appIds);
} }
for (RightsNowItem item : nowItems) { for (RightsNowItem item : nowItems) {
Integer type=item.getType(); Integer type = item.getType();
if (RightsNowItemType.ONLINE_COURSE.value.equals(type) if (RightsNowItemType.ONLINE_COURSE.value.equals(type)
||RightsNowItemType.LEARNING_TOOL.value.equals(type) || RightsNowItemType.LEARNING_TOOL.value.equals(type)
||RightsNowItemType.DRAW.value.equals(type)){ || RightsNowItemType.DRAW.value.equals(type)) {
AccountSettingDto accountSettingDto; AccountSettingDto accountSettingDto;
if (AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())) { if (AppAndProductTypeEnum.PRODUCT.value.equals(item.getServeType())) {
ProductDto productDto = productDtoMap.get(item.getServeId()); ProductDto productDto = productDtoMap.get(item.getServeId());
...@@ -286,14 +402,14 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -286,14 +402,14 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
//获取channelId,/C1404/product/display/10234028?adviserId=1001587&proType=MEMBER&source_type=QRCODE //获取channelId,/C1404/product/display/10234028?adviserId=1001587&proType=MEMBER&source_type=QRCODE
Long channelId = null; Long channelId = null;
String url = item.getLinkUrl(); String url = item.getLinkUrl();
if (url.contains("/C") && !url.startsWith("https")){ if (url.contains("/C") && !url.startsWith("https")) {
url = url.substring(url.indexOf("/C")+2); url = url.substring(url.indexOf("/C") + 2);
url = url.substring(0,url.indexOf("/")); url = url.substring(0, url.indexOf("/"));
if (!StringUtil.isEmpty(url)){ if (!StringUtil.isEmpty(url)) {
channelId = Long.valueOf(url); channelId = Long.valueOf(url);
} }
} }
if (null!=channelId){ if (null != channelId) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId); accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, item.getLinkUrl()); String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, item.getLinkUrl());
item.setResultUrl(resultLinkUrl); item.setResultUrl(resultLinkUrl);
...@@ -316,14 +432,16 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -316,14 +432,16 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
} }
} }
rightsSetting.setOnlineCourseNowItems(nowItems.stream().filter(s->RightsNowItemType.ONLINE_COURSE.value.equals(s.getType())).collect(Collectors.toList()));
rightsSetting.setLearningToolNowItems(nowItems.stream().filter(s->RightsNowItemType.LEARNING_TOOL.value.equals(s.getType())).collect(Collectors.toList()));
rightsSetting.setDrawNowItems(nowItems.stream().filter(s->RightsNowItemType.DRAW.value.equals(s.getType())).collect(Collectors.toList()));
} }
private void fillGiftCouponPack(RightsSetting rightsSetting){ private void fillGiftCouponPack(RightsSetting rightsSetting){
List<RightsNowItem> giftCouponPackItems = rightsNowItemDao.getGiftCouponListByRightsSettingId(rightsSetting.getId()); List<RightsNowItem> giftCouponPackItems = rightsNowItemDao.getGiftCouponListByRightsSettingId(rightsSetting.getId());
rightsSetting.setGiftCouponPackageNowItems(giftCouponPackItems); RightsSettingTitle rightsSettingTitler4Gift = new RightsSettingTitle();
if (null != rightsSetting.getGiftCouponPackageTitle()){
rightsSettingTitler4Gift = rightsSetting.getGiftCouponPackageTitle();
}
rightsSettingTitler4Gift.setRightsSettingItemList(giftCouponPackItems);
rightsSetting.setGiftCouponPackageTitle(rightsSettingTitler4Gift);
} }
@Override @Override
...@@ -622,14 +740,14 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -622,14 +740,14 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("用户是否领取专享礼包券") @ParamLog("用户是否领取专享礼包券")
private void fillUserGiftReceiveStatus(RightsSetting rightsSetting,Long wechatUserId) { private void fillUserGiftReceiveStatus(RightsSetting rightsSetting,Long wechatUserId) {
if (rightsSetting==null||wechatUserId==null||ListUtils.isEmpty(rightsSetting.getGiftCouponPackageNowItems())){ if (rightsSetting==null||wechatUserId==null||ListUtils.isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())){
return; return;
} }
List<Long> list = giftReceiveDao.getUserReceiveGiftId(wechatUserId); List<Long> list = giftReceiveDao.getUserReceiveGiftId(wechatUserId);
if (ListUtils.isEmpty(list)){ if (ListUtils.isEmpty(list)){
list=new ArrayList<>(); list=new ArrayList<>();
} }
for (RightsNowItem item:rightsSetting.getGiftCouponPackageNowItems()){ for (RightsNowItem item:rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList()){
if (list.contains(item.getGiftCouponPackageId())){ if (list.contains(item.getGiftCouponPackageId())){
item.setUserGiftReceive(true); item.setUserGiftReceive(true);
}else { }else {
......
...@@ -40,15 +40,21 @@ public class RightsSettingCheck { ...@@ -40,15 +40,21 @@ public class RightsSettingCheck {
checkRightNowItem(rightsSetting); checkRightNowItem(rightsSetting);
} }
private void checkRightNowItem(RightsSetting rightsSetting){ private void checkRightNowItem(RightsSetting rightsSetting) {
if (rightsSetting == null) { if (rightsSetting == null) {
return; return;
} }
checkRightNowItemApp(rightsSetting.getOnlineCourseNowItems()); if (null != rightsSetting.getOnlineRightsSettingTitle()) {
checkRightNowItemApp(rightsSetting.getLearningToolNowItems()); checkRightNowItemApp(rightsSetting.getOnlineRightsSettingTitle().getRightsSettingItemList());
checkRightNowItemApp(rightsSetting.getDrawNowItems()); }
if (!ListUtils.isEmpty(rightsSetting.getGiftCouponPackageNowItems())){ if (null != rightsSetting.getLearningToolTitle()) {
for (RightsNowItem item : rightsSetting.getGiftCouponPackageNowItems()) { checkRightNowItemApp(rightsSetting.getLearningToolTitle().getRightsSettingItemList());
}
if (null != rightsSetting.getDrawSettingTitle()) {
checkRightNowItemApp(rightsSetting.getDrawSettingTitle().getRightsSettingItemList());
}
if (null != rightsSetting.getGiftCouponPackageTitle() && !ListUtils.isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())) {
for (RightsNowItem item : rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList()) {
if (item.getGiftCouponPackageId() == null) { if (item.getGiftCouponPackageId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "专享礼包券id为空!"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "专享礼包券id为空!");
} }
......
...@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
import lombok.Data; import lombok.Data;
import lombok.NonNull;
@Data @Data
public class RightsSetting extends BaseTempletClassify { public class RightsSetting extends BaseTempletClassify {
...@@ -33,18 +34,29 @@ public class RightsSetting extends BaseTempletClassify { ...@@ -33,18 +34,29 @@ public class RightsSetting extends BaseTempletClassify {
@ApiModelProperty("抽奖是否开启") @ApiModelProperty("抽奖是否开启")
private Boolean drawNowOpen; private Boolean drawNowOpen;
@NonNull
@ApiModelProperty("线上网课集合") @ApiModelProperty("线上网课集合")
private List<RightsNowItem> onlineCourseNowItems; private RightsSettingTitle onlineRightsSettingTitle;
@NonNull
@ApiModelProperty("学习工具集合") @ApiModelProperty("学习工具集合")
private List<RightsNowItem> learningToolNowItems; private RightsSettingTitle learningToolTitle;
@NonNull
@ApiModelProperty("抽奖集合") @ApiModelProperty("抽奖集合")
private List<RightsNowItem> drawNowItems; private RightsSettingTitle drawSettingTitle;
@NonNull
@ApiModelProperty("专享礼包券集合") @ApiModelProperty("专享礼包券集合")
private List<RightsNowItem> giftCouponPackageNowItems; private RightsSettingTitle giftCouponPackageTitle;
@NonNull
@ApiModelProperty("社群集合")
private RightsSettingTitle groupServiceTitle;
@NonNull
@ApiModelProperty("配套资料集合")
private RightsSettingTitle servesTitle;
@ApiModelProperty("启用专享社群服务") @ApiModelProperty("启用专享社群服务")
private Integer enableGroupService = 0; private Integer enableGroupService = 0;
...@@ -73,4 +85,8 @@ public class RightsSetting extends BaseTempletClassify { ...@@ -73,4 +85,8 @@ public class RightsSetting extends BaseTempletClassify {
* 长期权益 * 长期权益
*/ */
private List<RightsSettingItem> rightsSettingLongTermItems; private List<RightsSettingItem> rightsSettingLongTermItems;
public RightsSetting() {
}
} }
\ No newline at end of file
package com.pcloud.book.rightsSetting.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
import org.springframework.cloud.netflix.ribbon.RibbonHttpRequest;
/**
* @ClassName com.pcloud.book.rightsSetting.entity.RightsSettingNow
* @Author 吴博
* @Description 即享权益
* @Date 2020/4/22 17:07
* @Version 1.0
**/
public class RightsSettingNow {
private Long id;
/**
* 权益id
*/
private Long rightsSettingId;
/**
* 权益分类
*/
private Long rightsClassifyId;
/**
* 权益描述
*/
private String rightsSettingDesc;
/**
* 创建时间
*/
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 权益标题
*/
private String rightsSettingTitle;
/**
* 列表
*/
private List<RightsSettingItem> rightsSettingItemList;
private Boolean onlineCourseOpen;
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
import lombok.Data;
@Data
public class RightsSettingTitle {
private Long id;
private Long rightsSettingId;
private String rightsSettingTitle;
private String rightsSettingDesc;
private Boolean openState;
private Integer rightsSettingNowType;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date updateTime;
/**
* 列表
*/
private List<RightsNowItem> rightsSettingItemList;
}
\ No newline at end of file
...@@ -17,10 +17,22 @@ public enum RightsNowItemType { ...@@ -17,10 +17,22 @@ public enum RightsNowItemType {
/** /**
* 4专享礼包券 * 4专享礼包券
*/ */
GIFT_COUPON_PACKAGE(4); GIFT_COUPON_PACKAGE(4),
/**
* 5专享礼包券
*/
GROUP_SERVICE(5),
/**
* 6 配套资料
*/
SERVES(6);
/** /**
* 值 * 值
*/ */
public final Integer value; public final Integer value;
RightsNowItemType(Integer value) { RightsNowItemType(Integer value) {
......
package com.pcloud.book.rightsSetting.mapper;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import java.util.List;
import org.springframework.stereotype.Component;
@Component
public interface RightsSettingTitleMapper {
int insert(RightsSettingTitle record);
int insertSelective(RightsSettingTitle record);
void deleteByRightSettingId(Long rightsSettingId);
void batchInsert(List<RightsSettingTitle> rightsSettingTitles);
void batchUpdate(List<RightsSettingTitle> rightsSettingTitles);
List<RightsSettingTitle> getByRightSettingId(Long rightsSettingId);
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<generatorConfiguration> <generatorConfiguration>
<classPathEntry <classPathEntry
location="E:\work\respository\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar"/> location="D:\maven\repository\mysql\mysql-connector-java\5.1.47\mysql-connector-java-5.1.47.jar"/>
<context id="my" targetRuntime="MyBatis3"> <context id="my" targetRuntime="MyBatis3">
<commentGenerator> <commentGenerator>
<property name="suppressDate" value="false"/> <property name="suppressDate" value="false"/>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
selectByExampleQueryId="false"> selectByExampleQueryId="false">
</table>--> </table>-->
<table tableName="rights_setting" domainObjectName="RightsSetting" <table tableName="rights_setting_title" domainObjectName="RightsSettingTitle"
enableCountByExample="false" enableUpdateByExample="false" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"> selectByExampleQueryId="false">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper">
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
<result column="id" jdbcType="BIGINT" property="id" />
<result column="rights_setting_id" jdbcType="BIGINT" property="rightsSettingId" />
<result column="rights_setting_title" jdbcType="VARCHAR" property="rightsSettingTitle" />
<result column="rights_setting_desc" jdbcType="VARCHAR" property="rightsSettingDesc" />
<result column="open_state" jdbcType="TINYINT" property="openState" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="rights_setting_now_type" jdbcType="TINYINT" property="rightsSettingNowType" />
</resultMap>
<sql id="baseSql">
id, rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time,
update_time,rights_setting_now_type
</sql>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title (id, rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time,
update_time,rights_setting_now_type)
values (#{id,jdbcType=BIGINT}, #{rightsSettingId,jdbcType=BIGINT}, #{rightsSettingTitle,jdbcType=VARCHAR},
#{rightsSettingDesc,jdbcType=VARCHAR}, #{openState,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},#{rightsSettingNowType})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="rightsSettingId != null">
rights_setting_id,
</if>
<if test="rightsSettingTitle != null">
rights_setting_title,
</if>
<if test="rightsSettingDesc != null">
rights_setting_desc,
</if>
<if test="openState != null">
open_state,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="rightsSettingId != null">
#{rightsSettingId,jdbcType=BIGINT},
</if>
<if test="rightsSettingTitle != null">
#{rightsSettingTitle,jdbcType=VARCHAR},
</if>
<if test="rightsSettingDesc != null">
#{rightsSettingDesc,jdbcType=VARCHAR},
</if>
<if test="openState != null">
#{openState,jdbcType=TINYINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<delete id="deleteByRightSettingId" parameterType="long">
delete
from
rights_setting_title
where
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,
rights_setting_desc, open_state, create_time, update_time,rights_setting_now_type)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id,jdbcType=BIGINT}, #{item.rightsSettingId,jdbcType=BIGINT}, #{item.rightsSettingTitle,jdbcType=VARCHAR},
#{item.rightsSettingDesc,jdbcType=VARCHAR}, #{item.openState,jdbcType=TINYINT}, now(), now(),#{item.rightsSettingNowType})
</foreach>
</insert>
<update id="batchUpdate" parameterType="list">
update rights_setting_title
<trim prefix="set" suffixOverrides=",">
<trim prefix="rights_setting_title =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.rightsSettingTitle}
</foreach>
</trim>
<trim prefix="rights_setting_desc =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.rightsSettingDesc}
</foreach>
</trim>
<trim prefix="open_state =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.openState}
</foreach>
</trim>
</trim>
where id in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<select id="getByRightSettingId" resultMap="BaseResultMap" parameterType="long">
select
<include refid="baseSql"/>
from
rights_setting_title
where
rights_setting_id = #{rightsSettingId}
</select>
</mapper>
\ No newline at end of file
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