Commit ce0115a1 by 桂前礼

feat: [1003438] 权益板块里的线下活动以资讯形式地理位置标签

parent 711b5e2d
...@@ -80,12 +80,13 @@ public interface AppletNewsBiz { ...@@ -80,12 +80,13 @@ public interface AppletNewsBiz {
* @param currentPage * @param currentPage
* @param numPerPage * @param numPerPage
* @param name * @param name
* @param cityCode
* @return * @return
*/ */
PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name, PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify,Long secondClassify,Long gradeLabelId, Long firstClassify, Long secondClassify, Long gradeLabelId,
Long subjectLabelId,Long rightsClassifyId,String source,Integer showState, Long newsClassifyId, Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId,
Long customTagId); Long customTagId, String cityCode);
/** /**
* 获取所有资讯栏目 * 获取所有资讯栏目
......
package com.pcloud.book.applet.biz.impl; package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO; import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletNewsBiz; import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz; import com.pcloud.book.applet.biz.AppletUserBookcaseBiz;
...@@ -50,8 +51,10 @@ import com.pcloud.book.consumer.label.LabelConsr; ...@@ -50,8 +51,10 @@ import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr; import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.push.dao.PersonalAppletsDao; import com.pcloud.book.push.dao.PersonalAppletsDao;
import com.pcloud.book.push.entity.PersonalApplets; import com.pcloud.book.push.entity.PersonalApplets;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.entity.RegionMap;
import com.pcloud.book.record.mapper.RegionMapMapper;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dao.RightsNowItemDao;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -60,7 +63,6 @@ import com.pcloud.common.utils.ListUtils; ...@@ -60,7 +63,6 @@ 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.readercenter.wechat.entity.WechatUser; import com.pcloud.readercenter.wechat.entity.WechatUser;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -77,8 +79,6 @@ import java.util.Map; ...@@ -77,8 +79,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
/** /**
* 小程序资讯 * 小程序资讯
*/ */
...@@ -119,6 +119,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -119,6 +119,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
private AppletThirdResourcesRelationDao thirdResourcesRelationDao; private AppletThirdResourcesRelationDao thirdResourcesRelationDao;
@Autowired @Autowired
private AppletThirdResourcesDao thirdResourcesDao; private AppletThirdResourcesDao thirdResourcesDao;
@Autowired
private BookBrowseRecordBiz bookBrowseRecordBiz;
@Autowired
private RegionMapMapper regionMapMapper;
@Override @Override
public void deleteCategoryById(Long id) { public void deleteCategoryById(Long id) {
...@@ -211,12 +215,18 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -211,12 +215,18 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
} }
appletNewsCategoryDao.deletebyNewsId(newsId); appletNewsCategoryDao.deletebyNewsId(newsId);
List<AppletNewsCategory> list = new ArrayList<>();
for (AppletNewsCategory category : categoryList) { for (AppletNewsCategory category : categoryList) {
rightsSettingBiz.setClassifyAndLabel(category); if (Objects.nonNull(category.getFirstClassify())){
category.setAppletNewId(newsId); rightsSettingBiz.setClassifyAndLabel(category);
category.setAppletNewId(newsId);
list.add(category);
}
}
if (CollUtil.isNotEmpty(list)){
appletNewsCategoryDao.batchCreate(list);
} }
appletNewsCategoryDao.batchCreate(categoryList);
} }
...@@ -311,9 +321,9 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -311,9 +321,9 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
@Override @Override
public PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name, public PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify, Long secondClassify, Long gradeLabelId, Long firstClassify, Long secondClassify, Long gradeLabelId,
Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId, Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId,
Long customTagId) { Long customTagId, String cityCode) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("name", name); paramMap.put("name", name);
paramMap.put("rightsClassifyId", rightsClassifyId); paramMap.put("rightsClassifyId", rightsClassifyId);
...@@ -324,7 +334,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -324,7 +334,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
//是否有分类筛选 //是否有分类筛选
Boolean classifySelect = false; Boolean classifySelect = false;
//处理分类 //处理分类
if (null!=firstClassify){ if (null != firstClassify) {
classifySelect = true; classifySelect = true;
BaseTempletClassify classify = new BaseTempletClassify(); BaseTempletClassify classify = new BaseTempletClassify();
classify.setFirstClassify(firstClassify); classify.setFirstClassify(firstClassify);
...@@ -344,16 +354,51 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -344,16 +354,51 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
} }
} }
paramMap.put("classifySelect", classifySelect); paramMap.put("classifySelect", classifySelect);
List<String> cityCodes = null;
if (StrUtil.isNotBlank(name)) {
List<RegionMap> citysByPY = regionMapMapper.getCitysByPY(name);
if (CollUtil.isNotEmpty(citysByPY)){
cityCodes = citysByPY.stream().filter(x -> Objects.nonNull(x)).map(RegionMap::getRegionCode).distinct().collect(Collectors.toList());
}
}
paramMap.put("cityCodes", cityCodes);
paramMap.put("cityCode", cityCode);
PageBeanNew<AppletNewsDTO> pageBeanNew = appletNewsDao.listPageNew( PageBeanNew<AppletNewsDTO> pageBeanNew = appletNewsDao.listPageNew(
new PageParam(currentPage, numPerPage), paramMap, "listAppletNews"); new PageParam(currentPage, numPerPage), paramMap, "listAppletNews");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) { if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>()); return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
} }
//填充咨询分类 //填充咨询分类
fillCategory(pageBeanNew.getRecordList()); fillCategory(pageBeanNew.getRecordList());
// 填充城市名称
fillCity(pageBeanNew.getRecordList());
return pageBeanNew; return pageBeanNew;
} }
private void fillCity(List<AppletNewsDTO> recordList) {
if (CollUtil.isEmpty(recordList)){
return;
}
List<String> codeList = recordList.stream().filter(Objects::nonNull).map(AppletNewsDTO::getCityCode).distinct().collect(Collectors.toList());
if (CollUtil.isEmpty(codeList)) {
return;
}
Map<String, RegionMap> regionMapMap = bookBrowseRecordBiz.getCitysByCodes(codeList);
if (MapUtils.isNotEmpty(regionMapMap)){
recordList.forEach(record -> {
RegionMap regionMap = regionMapMap.get(record.getCityCode());
if (regionMapMap.containsKey(record.getCityCode()) && null != regionMap){
record.setCity(regionMap.getRegionName());
}
});
}
}
private void fillLabel(List<AppletNewsDTO> recordList) { private void fillLabel(List<AppletNewsDTO> recordList) {
if (ListUtils.isEmpty(recordList)) { if (ListUtils.isEmpty(recordList)) {
return; return;
...@@ -583,6 +628,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -583,6 +628,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
fillBusinessCard(appletNewsDTO); fillBusinessCard(appletNewsDTO);
// 填充城市信息
if (StrUtil.isNotBlank(appletNews.getCityCode())) {
appletNewsDTO.setCity(regionMapMapper.getCitysByCode(appletNews.getCityCode()));
}
return appletNewsDTO; return appletNewsDTO;
} }
...@@ -748,13 +797,13 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -748,13 +797,13 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if(appletNewsClassifyVO == null || ListUtils.isEmpty(appletNewsClassifyVO.getAppletNewsIds())){ if(appletNewsClassifyVO == null || ListUtils.isEmpty(appletNewsClassifyVO.getAppletNewsIds())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "参数为空"); throw new BizException(BizException.PARAM_IS_NULL.getCode(), "参数为空");
} }
if (ListUtils.isEmpty(appletNewsClassifyVO.getCategoryDTOList())) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "请选择分类");
}
rightsSettingBiz.setClassifyAndLabel(appletNewsClassifyVO); rightsSettingBiz.setClassifyAndLabel(appletNewsClassifyVO);
for (Long id : appletNewsClassifyVO.getAppletNewsIds()){ List<AppletNewsCategory> categoryDTOList = appletNewsClassifyVO.getCategoryDTOList();
this.saveAppletNewsCategory(appletNewsClassifyVO.getCategoryDTOList(), id); if (CollUtil.isNotEmpty(categoryDTOList)) {
for (Long id : appletNewsClassifyVO.getAppletNewsIds()) {
this.saveAppletNewsCategory(categoryDTOList, id);
}
} }
appletNewsDao.batchUpdateClassify(appletNewsClassifyVO); appletNewsDao.batchUpdateClassify(appletNewsClassifyVO);
} }
...@@ -1090,12 +1139,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz { ...@@ -1090,12 +1139,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
appletNewsDao.insert(appletNewsList); appletNewsDao.insert(appletNewsList);
for (AppletNews appletNews: appletNewsList){ for (AppletNews appletNews: appletNewsList){
AppletNewsCategory category = new AppletNewsCategory(); if (Objects.nonNull(appletNews.getFirstClassify()) && appletNews.getFirstClassify()!=0){
category.setFirstClassify(appletNews.getFirstClassify()); AppletNewsCategory category = new AppletNewsCategory();
category.setSecondClassify(appletNews.getSecondClassify()); category.setFirstClassify(appletNews.getFirstClassify());
category.setGradeLabelId(appletNews.getGradeLabelId()); category.setSecondClassify(appletNews.getSecondClassify());
category.setSubjectLabelId(appletNews.getSubjectLabelId()); category.setGradeLabelId(appletNews.getGradeLabelId());
saveAppletNewsCategory(Arrays.asList(category),appletNews.getId()); category.setSubjectLabelId(appletNews.getSubjectLabelId());
saveAppletNewsCategory(Arrays.asList(category),appletNews.getId());
}
} }
} }
......
package com.pcloud.book.applet.biz.impl; package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.util.PageUtil;
import com.alibaba.druid.sql.PagerUtils;
import com.pcloud.book.applet.biz.AppletNewsBiz; import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletNewsPoolBiz; import com.pcloud.book.applet.biz.AppletNewsPoolBiz;
import com.pcloud.book.applet.dao.AppletNewsDao; import com.pcloud.book.applet.dao.AppletNewsDao;
...@@ -9,12 +7,10 @@ import com.pcloud.book.applet.dao.AppletNewsPoolDAO; ...@@ -9,12 +7,10 @@ import com.pcloud.book.applet.dao.AppletNewsPoolDAO;
import com.pcloud.book.applet.dto.AppletNewsPoolDTO; import com.pcloud.book.applet.dto.AppletNewsPoolDTO;
import com.pcloud.book.applet.entity.AppletNews; import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletNewsPool; import com.pcloud.book.applet.entity.AppletNewsPool;
import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.applet.enums.NewsJumpTypeEnum; import com.pcloud.book.applet.enums.NewsJumpTypeEnum;
import com.pcloud.book.applet.enums.NewsTypeEnum; import com.pcloud.book.applet.enums.NewsTypeEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.constant.BookConstant; import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
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;
...@@ -26,7 +22,6 @@ import com.pcloud.readercenter.common.enums.YesOrNoNumEnum; ...@@ -26,7 +22,6 @@ import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import sun.security.krb5.internal.PAData;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -94,7 +89,7 @@ public class AppletNewsPoolBizImpl implements AppletNewsPoolBiz { ...@@ -94,7 +89,7 @@ public class AppletNewsPoolBizImpl implements AppletNewsPoolBiz {
return; return;
} }
appletNewsPoolIds.stream().forEach(id -> { appletNewsPoolIds.forEach(id -> {
AppletNews appletNews = new AppletNews(); AppletNews appletNews = new AppletNews();
BeanUtils.copyProperties(appletNewsPoolDTO, appletNews); BeanUtils.copyProperties(appletNewsPoolDTO, appletNews);
rightsSettingBiz.setClassifyAndLabel(appletNews); rightsSettingBiz.setClassifyAndLabel(appletNews);
...@@ -104,12 +99,16 @@ public class AppletNewsPoolBizImpl implements AppletNewsPoolBiz { ...@@ -104,12 +99,16 @@ public class AppletNewsPoolBizImpl implements AppletNewsPoolBiz {
} }
addResource(appletNewsPool.getSource()); addResource(appletNewsPool.getSource());
appletNews.setNewsName(appletNewsPool.getNewsName()); appletNews.setNewsName(appletNewsPool.getNewsName());
appletNews.setCityCode(appletNewsPoolDTO.getCityCode());
appletNews.setSource(appletNewsPool.getSource()); appletNews.setSource(appletNewsPool.getSource());
appletNews.setContent(appletNewsPool.getContent()); appletNews.setContent(appletNewsPool.getContent());
appletNews.setType(null == appletNewsPoolDTO.getNewsType() ? NewsTypeEnum.ONLY_PIC.code : appletNewsPoolDTO.getNewsType()); appletNews.setType(null == appletNewsPoolDTO.getNewsType() ? NewsTypeEnum.ONLY_PIC.code : appletNewsPoolDTO.getNewsType());
appletNews.setPic1(null == appletNewsPoolDTO.getPic1() ? BookConstant.DEFAULT_NEWS_PIC : appletNewsPoolDTO.getPic1()); appletNews.setPic1(null == appletNewsPoolDTO.getPic1() ? BookConstant.DEFAULT_NEWS_PIC : appletNewsPoolDTO.getPic1());
appletNews.setJumpType(NewsJumpTypeEnum.NEWS_EDIT.code); appletNews.setJumpType(NewsJumpTypeEnum.NEWS_EDIT.code);
appletNews.setShowSource(null == appletNewsPoolDTO.getShowSource() ? YesOrNoNumEnum.YES.getValue() : appletNewsPoolDTO.getShowSource()); appletNews.setShowSource(null == appletNewsPoolDTO.getShowSource() ? YesOrNoNumEnum.YES.getValue() : appletNewsPoolDTO.getShowSource());
if (appletNews.getFirstClassify()!=null&&appletNews.getFirstClassify()==0){
appletNews.setFirstClassify(null);
}
appletNewsList.add(appletNews); appletNewsList.add(appletNews);
}); });
if (!ListUtils.isEmpty(appletNewsList)) { if (!ListUtils.isEmpty(appletNewsList)) {
......
...@@ -7,6 +7,7 @@ import com.pcloud.book.applet.entity.AppletNewsCustomTag; ...@@ -7,6 +7,7 @@ import com.pcloud.book.applet.entity.AppletNewsCustomTag;
import com.pcloud.book.applet.vo.AppletNewsClassifyVO; import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO; import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -164,4 +165,10 @@ public interface AppletNewsDao extends BaseDao<AppletNews> { ...@@ -164,4 +165,10 @@ public interface AppletNewsDao extends BaseDao<AppletNews> {
* @param appletNews * @param appletNews
*/ */
void updateCardShowState(AppletNews appletNews); void updateCardShowState(AppletNews appletNews);
/**
* 根据城市获取对应资讯
* @param cityId
*/
List<AppletNewsDTO> listNewsByCityCode(String cityId);
} }
...@@ -8,7 +8,6 @@ import com.pcloud.book.applet.entity.AppletNewsCustomTag; ...@@ -8,7 +8,6 @@ import com.pcloud.book.applet.entity.AppletNewsCustomTag;
import com.pcloud.book.applet.vo.AppletNewsClassifyVO; import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO; import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
...@@ -99,6 +98,7 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet ...@@ -99,6 +98,7 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
map.put("subjectLabelId", appletNewsClassifyVO.getSubjectLabelId()); map.put("subjectLabelId", appletNewsClassifyVO.getSubjectLabelId());
map.put("rightsClassifyId", appletNewsClassifyVO.getRightsClassifyId()); map.put("rightsClassifyId", appletNewsClassifyVO.getRightsClassifyId());
map.put("newsClassifyId", appletNewsClassifyVO.getNewsClassifyId()); map.put("newsClassifyId", appletNewsClassifyVO.getNewsClassifyId());
map.put("cityCode", appletNewsClassifyVO.getCityCode());
getSessionTemplate().update(getStatement("batchUpdateClassify"), map); getSessionTemplate().update(getStatement("batchUpdateClassify"), map);
} }
...@@ -186,6 +186,12 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet ...@@ -186,6 +186,12 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
public void updateCardShowState(AppletNews appletNews) { public void updateCardShowState(AppletNews appletNews) {
getSessionTemplate().update(getStatement("updateCardShowState"),appletNews); getSessionTemplate().update(getStatement("updateCardShowState"),appletNews);
} }
@Override
public List<AppletNewsDTO> listNewsByCityCode(String cityId) {
return this.getSqlSession().selectList(getStatement("listNewsByCityCode"), cityId);
}
@Override @Override
public Integer listAppletNews4WechatCount(Map<String, Object> paramMap) { public Integer listAppletNews4WechatCount(Map<String, Object> paramMap) {
return getSessionTemplate().selectOne(getStatement("listAppletNews4WechatCount"), paramMap); return getSessionTemplate().selectOne(getStatement("listAppletNews4WechatCount"), paramMap);
......
...@@ -138,4 +138,9 @@ public class AppletNewsDTO extends BaseDto { ...@@ -138,4 +138,9 @@ public class AppletNewsDTO extends BaseDto {
@ApiModelProperty("第三方资源") @ApiModelProperty("第三方资源")
List<AppletThirdResources> thirdResourcesRelations; List<AppletThirdResources> thirdResourcesRelations;
@ApiModelProperty("城市编码")
private String cityCode;
@ApiModelProperty("城市名")
private String city;
} }
...@@ -99,4 +99,8 @@ public class AppletNewsPoolDTO extends BaseDto { ...@@ -99,4 +99,8 @@ public class AppletNewsPoolDTO extends BaseDto {
private Integer newsType; private Integer newsType;
@ApiModelProperty("素材池id)") @ApiModelProperty("素材池id)")
private List<Long> appletNewsPoolIds; private List<Long> appletNewsPoolIds;
@ApiModelProperty("城市编码")
private String cityCode;
@ApiModelProperty("城市名称")
private String city;
} }
package com.pcloud.book.applet.entity; package com.pcloud.book.applet.entity;
import javax.validation.constraints.NotNull;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
import org.hibernate.validator.constraints.Length;
@Data @Data
@ApiModel("小程序资讯") @ApiModel("小程序资讯")
public class AppletNews extends BaseTempletClassify { public class AppletNews extends BaseTempletClassify {
...@@ -98,6 +95,12 @@ public class AppletNews extends BaseTempletClassify { ...@@ -98,6 +95,12 @@ public class AppletNews extends BaseTempletClassify {
@ApiModelProperty("修改人") @ApiModelProperty("修改人")
private Long updator; private Long updator;
@ApiModelProperty("城市编码")
private String cityCode;
@ApiModelProperty("城市")
private String city;
@ApiModelProperty("选取的服务") @ApiModelProperty("选取的服务")
List<AppletNewsServe> appletNewsServeList; List<AppletNewsServe> appletNewsServeList;
......
...@@ -498,14 +498,15 @@ public class AppletHomeFacade { ...@@ -498,14 +498,15 @@ public class AppletHomeFacade {
@RequestParam(value = "source", required = false) @ApiParam("来源") String source, @RequestParam(value = "source", required = false) @ApiParam("来源") String source,
@RequestParam(value = "showState", required = false) @ApiParam("上架") Integer showState, @RequestParam(value = "showState", required = false) @ApiParam("上架") Integer showState,
@RequestParam(value = "newsClassifyId", required = false) @ApiParam("资讯栏目id") Long newsClassifyId, @RequestParam(value = "newsClassifyId", required = false) @ApiParam("资讯栏目id") Long newsClassifyId,
@RequestParam(value = "customTagId", required = false) @ApiParam("自定义标识id") Long customTagId @RequestParam(value = "customTagId", required = false) @ApiParam("自定义标识id") Long customTagId,
@RequestParam(value = "cityCode", required = false) @ApiParam("城市筛选") String cityCode
) throws PermissionException { ) throws PermissionException {
SessionUtil.getInfoToken4Redis(token); SessionUtil.getInfoToken4Redis(token);
if (null==currentPage || null == numPerPage){ if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
} }
return new ResponseDto<>(appletNewsBiz.listAppletNews(currentPage, numPerPage, name, firstClassify,secondClassify,gradeLabelId, return new ResponseDto<>(appletNewsBiz.listAppletNews(currentPage, numPerPage, name, firstClassify,secondClassify,gradeLabelId,
subjectLabelId,rightsClassifyId,source,showState,newsClassifyId,customTagId)); subjectLabelId,rightsClassifyId,source,showState,newsClassifyId,customTagId, cityCode));
} }
@ApiOperation("客户端资讯列表") @ApiOperation("客户端资讯列表")
......
package com.pcloud.book.applet.vo; package com.pcloud.book.applet.vo;
import com.pcloud.book.applet.dto.AppletNewsCategoryDTO;
import com.pcloud.book.applet.entity.AppletNewsCategory; import com.pcloud.book.applet.entity.AppletNewsCategory;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @ClassName com.pcloud.book.applet.vo.AppletNewsClassifyVO * @ClassName com.pcloud.book.applet.vo.AppletNewsClassifyVO
* @Author ZhengYongQiang * @Author ZhengYongQiang
...@@ -30,4 +29,7 @@ public class AppletNewsClassifyVO extends BaseTempletClassify { ...@@ -30,4 +29,7 @@ public class AppletNewsClassifyVO extends BaseTempletClassify {
@ApiModelProperty("分类集合") @ApiModelProperty("分类集合")
private List<AppletNewsCategory> categoryDTOList; private List<AppletNewsCategory> categoryDTOList;
@ApiModelProperty("地区编码")
private String cityCode;
} }
package com.pcloud.book.record.biz;
import com.pcloud.book.record.entity.IpData;
public interface IpDataBiz {
/**
* 根据IP获取位置信息
*
* @param ipAddress ip
* @return {@link IpData}
*/
IpData getAreaByIp(String ipAddress);
}
package com.pcloud.book.record.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.record.biz.IpDataBiz;
import com.pcloud.book.record.entity.IpData;
import com.pcloud.book.record.entity.IpData4Third;
import com.pcloud.book.record.entity.IpResponse;
import com.pcloud.book.record.mapper.IpDataMapper;
import com.pcloud.book.util.common.HttpUtils;
import com.pcloud.common.utils.json.JSONUtils;
import com.pcloud.common.utils.string.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @author guiq
* @since 2020年8月21日
*/
@Service
@Slf4j
public class IpDataBizImpl implements IpDataBiz {
private static final String HOST = "https://api01.aliyun.venuscn.com";
private static final String PATH = "/ip";
private static final String METHOD = "GET";
@Autowired
private IpDataMapper ipDataMapper;
@Value("${ip.appcode}")
private String appCode;
@Override
public IpData getAreaByIp(String ipAddress) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appCode);
Map<String, String> queries = new HashMap<String, String>();
queries.put("ip", ipAddress);
//先从数据库查询,没有再查询第三方
IpData ipData = ipDataMapper.selectByIp(ipAddress);
if (null == ipData) {
try {
HttpResponse response = HttpUtils.doGet(HOST, PATH, METHOD, headers, queries);
log.info("查询ip返回的数据是response:{}", response);
String entityString = EntityUtils.toString(response.getEntity());
IpResponse ipResponse;
if (StringUtil.isEmpty(entityString)) {
return null;
}
ipResponse = JSONUtils.jsonToBean(entityString, IpResponse.class);
if (null == ipResponse || null == ipResponse.getData()) {
return null;
}
IpData4Third ipData4Third = ipResponse.getData();
if (!Objects.equals("200", ipResponse.getRet())) {
return null;
}
if (null == ipData4Third || null == ipData4Third.getCity_id()) {
return null;
}
ipData = new IpData();
ipData.setIp(ipAddress);
ipData.setRegion(ipData4Third.getRegion());
ipData.setRegionId(ipData4Third.getRegion_id());
ipData.setCity(ipData4Third.getCity());
ipData.setCityId(ipData4Third.getCity_id());
ipDataMapper.insert(ipData);
} catch (Exception e) {
log.error("获取ip失败,ip:{}", ipAddress);
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "获取ip失败");
}
}
return ipData;
}
}
...@@ -2,10 +2,12 @@ package com.pcloud.book.record.mapper; ...@@ -2,10 +2,12 @@ package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.IpData; import com.pcloud.book.record.entity.IpData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@Mapper @Mapper
@Component
public interface IpDataMapper { public interface IpDataMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
...@@ -22,4 +24,5 @@ public interface IpDataMapper { ...@@ -22,4 +24,5 @@ public interface IpDataMapper {
IpData selectByIp(String ip); IpData selectByIp(String ip);
List<IpData> listCityByIp(List<String> ips); List<IpData> listCityByIp(List<String> ips);
} }
\ No newline at end of file
package com.pcloud.book.record.mapper; package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.RegionMap; import com.pcloud.book.record.entity.RegionMap;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.MapKey;
...@@ -25,4 +27,6 @@ public interface RegionMapMapper { ...@@ -25,4 +27,6 @@ public interface RegionMapMapper {
@MapKey("regionCode") @MapKey("regionCode")
Map<String, RegionMap> getCitysByCodes(List<String> cityCodes); Map<String, RegionMap> getCitysByCodes(List<String> cityCodes);
String getCitysByCode(@Param("cityCode") String cityCode);
} }
\ No newline at end of file
...@@ -45,9 +45,11 @@ public interface RightsSettingBiz { ...@@ -45,9 +45,11 @@ public interface RightsSettingBiz {
* 每周/长期权益查询 * 每周/长期权益查询
* @param rightsSettingId * @param rightsSettingId
* @param rightsType * @param rightsType
* @param currentPage
* @param numPerPage
* @return * @return
*/ */
List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType); List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType, Integer currentPage, Integer numPerPage);
/** /**
* 小程序首页权益查询 * 小程序首页权益查询
...@@ -60,21 +62,27 @@ public interface RightsSettingBiz { ...@@ -60,21 +62,27 @@ public interface RightsSettingBiz {
/** /**
* 小程序首页本周/长期权益查询 * 小程序首页本周/长期权益查询
* @param cilentIp
* @param rightsSettingId * @param rightsSettingId
* @param wechatUserId * @param wechatUserId
* @param rightsType * @param rightsType
* @param currentPage
* @param numPerPage
* @return * @return
*/ */
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId); RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId, Integer currentPage, Integer numPerPage);
/** /**
* 每周/长期权益查询--小程序 * 每周/长期权益查询--小程序
* @param rightsSettingId * @param rightsSettingId
* @param rightsType * @param rightsType
* @param wechatUserId * @param wechatUserId
* @param cityCode
* @param currentPage
* @param numPerPage
* @return * @return
*/ */
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType, Long bookId, Long adviserId, Long channelId); List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType, Long bookId, Long adviserId, Long channelId, String cityCode, Integer currentPage, Integer numPerPage);
/** /**
* 查所有权益分类 * 查所有权益分类
......
...@@ -2,6 +2,7 @@ package com.pcloud.book.rightsSetting.biz.impl; ...@@ -2,6 +2,7 @@ package com.pcloud.book.rightsSetting.biz.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO; import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
...@@ -33,6 +34,8 @@ import com.pcloud.book.consumer.channel.QrcodeSceneConsr; ...@@ -33,6 +34,8 @@ import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.erp.ErpConsr; import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.consumer.reader.ReaderConsr; import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr; import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.user.MerchantConsr;
import com.pcloud.book.cultivate.enums.ReadTypeEnum; import com.pcloud.book.cultivate.enums.ReadTypeEnum;
import com.pcloud.book.custom.biz.CustomPlanBiz; import com.pcloud.book.custom.biz.CustomPlanBiz;
import com.pcloud.book.custom.entity.CustomPlan; import com.pcloud.book.custom.entity.CustomPlan;
...@@ -937,12 +940,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -937,12 +940,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (ListUtils.isEmpty(rightsSettingItemList)) { if (ListUtils.isEmpty(rightsSettingItemList)) {
return; return;
} }
List<Long> itemIds = rightsSettingItemList.stream().map(x -> x.getId()).collect(Collectors.toList()); List<Long> itemIds = rightsSettingItemList.stream().map(RightsSettingItem::getId).collect(Collectors.toList());
// 查询周、长期权益的列表子项 // 查询周、长期权益的列表子项
List<RightsSettingItemDetail> allItemDetailList = rightsSettingItemDetailDao.getByItemIds(itemIds); List<RightsSettingItemDetail> allItemDetailList = rightsSettingItemDetailDao.getByItemIds(itemIds);
// 按 rightsSettingItemId 分组 // 按 rightsSettingItemId 分组
Map<Long, List<RightsSettingItemDetail>> itemDetailMap = allItemDetailList.stream() Map<Long, List<RightsSettingItemDetail>> itemDetailMap = allItemDetailList.stream()
.collect(Collectors.groupingBy(x -> x.getRightsSettingItemId())); .collect(Collectors.groupingBy(RightsSettingItemDetail::getRightsSettingItemId));
List<Long> groupIds = new ArrayList<>(); List<Long> groupIds = new ArrayList<>();
List<Long> appletNewsId = new ArrayList<>(); List<Long> appletNewsId = new ArrayList<>();
...@@ -1713,7 +1716,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1713,7 +1716,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
@Override @Override
public List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType) { public List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType, Integer currentPage, Integer numPerPage) {
RightsSettingItem item = new RightsSettingItem(); RightsSettingItem item = new RightsSettingItem();
item.setRightsSettingId(rightsSettingId); item.setRightsSettingId(rightsSettingId);
item.setRightsType(rightsType); item.setRightsType(rightsType);
...@@ -1748,15 +1751,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1748,15 +1751,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override @Override
@ParamLog(value = "小程序首页本周/长期权益查询", isAfterReturn = false) @ParamLog(value = "小程序首页本周/长期权益查询", isAfterReturn = false)
public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType,
Integer readType, Long bookId, Long adviserId, Long channelId) { Integer readType, Long bookId, Long adviserId, Long channelId, Integer currentPage, Integer numPerPage) {
RightsSettingDto rightsSettingDto = new RightsSettingDto(); RightsSettingDto rightsSettingDto = new RightsSettingDto();
//每周/长期权益 //每周/长期权益
if (RightsTypeEnum.WEEK.value.equals(rightsType)) { if (RightsTypeEnum.WEEK.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingWeekItems( rightsSettingDto.setRightsSettingWeekItems(
getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId, readType, bookId, adviserId, channelId)); getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId, readType, bookId, adviserId, channelId, null, currentPage, numPerPage));
} else if (RightsTypeEnum.LONG_TERM.value.equals(rightsType)) { } else if (RightsTypeEnum.LONG_TERM.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingLongTermItems( String cityCode = readerConsr.getCityCodeByWechatUserId(wechatUserId);
getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId, readType, bookId, adviserId, channelId)); rightsSettingDto.setRightsSettingLongTermItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId, readType, bookId, adviserId, channelId, cityCode, currentPage, numPerPage));
} }
return rightsSettingDto; return rightsSettingDto;
} }
...@@ -1764,8 +1767,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1764,8 +1767,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override @Override
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId,
Integer readType, Long bookId, Long adviserId, Long channelId) { Integer readType, Long bookId, Long adviserId, Long channelId, String cityCode, Integer currentPage, Integer numPerPage) {
List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType, readType); List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType, readType, currentPage, numPerPage);
Integer collage = 1; //拼群 Integer collage = 1; //拼群
if (ListUtils.isEmpty(list)) { if (ListUtils.isEmpty(list)) {
...@@ -1774,22 +1777,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1774,22 +1777,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
// 加载平台端自己选择的社群、方案、资讯等数据 // 加载平台端自己选择的社群、方案、资讯等数据
fillRightsSettingItemDetail(list); fillRightsSettingItemDetail(list);
// 线上学习/阅读提醒 // 线上学习/阅读提醒
fillReadPlan(list, rightsType,readType, bookId, adviserId, channelId); fillReadPlan(list, rightsType, readType, bookId, adviserId, channelId);
// 筛选出没有选择 社群、方案、资讯 的数据 // 筛选出没有选择 社群、方案、资讯 的数据
List<RightsSettingItem> needFillAppletNews = Lists.newArrayList(); List<RightsSettingItem> needFillAppletNews = Lists.newArrayList();
for (RightsSettingItem rightsSettingItem : list) { for (RightsSettingItem rightsSettingItem : list) {
if (RightsServeTypeEnum.GROUP.name().equals(rightsSettingItem.getServeType()) && rightsSettingItem.getCollageState()!= null && rightsSettingItem.getCollageState().intValue() == collage.intValue() && (ListUtils.isEmpty(rightsSettingItem.getGroupActivity4AppletList()) || rightsSettingItem.getGroupActivity4AppletList().size()<3)){ if (RightsServeTypeEnum.GROUP.name().equals(rightsSettingItem.getServeType()) && rightsSettingItem.getCollageState() != null
&& rightsSettingItem.getCollageState().intValue() == collage.intValue()
&& (ListUtils.isEmpty(rightsSettingItem.getGroupActivity4AppletList())
|| rightsSettingItem.getGroupActivity4AppletList().size() < 3)) {
Integer top = 3; Integer top = 3;
if (!ListUtils.isEmpty(rightsSettingItem.getGroupActivity4AppletList())){ if (!ListUtils.isEmpty(rightsSettingItem.getGroupActivity4AppletList())) {
top = top - rightsSettingItem.getGroupActivity4AppletList().size(); top = top - rightsSettingItem.getGroupActivity4AppletList().size();
} }
// 填充群 // 填充群
List<RightsNowItem> items = new ArrayList<>(); List<RightsNowItem> items = new ArrayList<>();
List<GroupActivity4AppletDTO> collageList = supplementGroup(rightsSettingId, wechatUserId, rightsSettingItem.getRightsClassifyId(), top,items, bookId,rightsType, List<GroupActivity4AppletDTO> collageList = supplementGroup(rightsSettingId, wechatUserId, rightsSettingItem.getRightsClassifyId(), top, items, bookId, rightsType,
readType); readType);
if (!ListUtils.isEmpty(collageList)){ if (!ListUtils.isEmpty(collageList)) {
for (GroupActivity4AppletDTO item :collageList){ for (GroupActivity4AppletDTO item : collageList) {
rightsSettingItem.getGroupActivity4AppletList().add(item); rightsSettingItem.getGroupActivity4AppletList().add(item);
// 填充头像 // 填充头像
...@@ -1801,16 +1808,20 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1801,16 +1808,20 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
|| RightsServeTypeEnum.GROUP.name().equalsIgnoreCase(rightsSettingItem.getServeType()) && ListUtils || RightsServeTypeEnum.GROUP.name().equalsIgnoreCase(rightsSettingItem.getServeType()) && ListUtils
.isEmpty(rightsSettingItem.getGroupActivity4AppletList()) .isEmpty(rightsSettingItem.getGroupActivity4AppletList())
|| RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingItem.getServeType())) { || RightsServeTypeEnum.NEWS.name().equalsIgnoreCase(rightsSettingItem.getServeType())) {
if ((ListUtils.isEmpty(rightsSettingItem.getAppletNewsDTOS()) || rightsSettingItem.getAppletNewsDTOS().size() <3) && rightsSettingItem.getCollageState()!= null && rightsSettingItem.getCollageState().intValue() == collage.intValue()){ if ((ListUtils.isEmpty(rightsSettingItem.getAppletNewsDTOS()) || rightsSettingItem.getAppletNewsDTOS().size() <3)
&& rightsSettingItem.getCollageState()!= null && rightsSettingItem.getCollageState().intValue() == collage.intValue()){
needFillAppletNews.add(rightsSettingItem); needFillAppletNews.add(rightsSettingItem);
} }
} }
} }
if (ListUtils.isEmpty(needFillAppletNews)) {
// 有分页参数时,只有首页需要补充
if ((Objects.nonNull(currentPage)&&Objects.nonNull(numPerPage)&&currentPage!=0) || ListUtils.isEmpty(needFillAppletNews)) {
fillPageParam(list,currentPage,numPerPage);
return list; return list;
} }
// 将未选择服务的数据补充资讯 // 将未选择服务的数据补充资讯
setAppletNews4Week(rightsSettingId, rightsType, wechatUserId, needFillAppletNews,bookId); setAppletNews4Week(rightsSettingId, rightsType, wechatUserId, needFillAppletNews,bookId,cityCode);
/* /*
List<Long> rightsSettingItemIds = List<Long> rightsSettingItemIds =
...@@ -1831,10 +1842,23 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1831,10 +1842,23 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
setGroupActivity(list, rightsSettingItemIds); setGroupActivity(list, rightsSettingItemIds);
} }
*/ */
fillPageParam(list,currentPage,numPerPage);
return list; return list;
} }
private void fillPageParam(List<RightsSettingItem> list, Integer currentPage, Integer numPerPage) {
if (Objects.nonNull(currentPage)&&Objects.nonNull(numPerPage)){
for (RightsSettingItem rightsSettingItem : list) {
if (Objects.nonNull(rightsSettingItem) && RightsWeekTypeEnum.OFFLINE_READING_ACTIVITY.getKey() == rightsSettingItem.getRightsClassifyId().intValue()) {
List<AppletNewsDTO> appletNewsDTOS = rightsSettingItem.getAppletNewsDTOS();
if (CollUtil.isNotEmpty(appletNewsDTOS)) {
rightsSettingItem.setAppletNewsDTOS4Page(new PageBeanNew<>(currentPage, numPerPage, appletNewsDTOS));
}
}
}
}
}
// 线上学习/阅读提醒(方案特殊处理) // 线上学习/阅读提醒(方案特殊处理)
private void fillReadPlan(List<RightsSettingItem> list, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId) { private void fillReadPlan(List<RightsSettingItem> list, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId) {
List<RightsSettingItem> needFillPlanItems = Lists.newArrayList(); List<RightsSettingItem> needFillPlanItems = Lists.newArrayList();
...@@ -1922,7 +1946,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1922,7 +1946,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
} }
private List<RightsSettingItem> setAppletNews4Week(Long rightsSettingId, String rightsType, Long wechatUserId, private List<RightsSettingItem> setAppletNews4Week(Long rightsSettingId, String rightsType, Long wechatUserId,
List<RightsSettingItem> list,Long bookId) { List<RightsSettingItem> list, Long bookId, String cityCode) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId); RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取 if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取
List<RightsSettingBookRelation> rightsSettingBookRelations = List<RightsSettingBookRelation> rightsSettingBookRelations =
...@@ -1944,11 +1968,18 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1944,11 +1968,18 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
//没有则根据书刊分类和标签获取 //没有则根据书刊分类和标签获取
appletNewsDTOS = appletNewsBiz.getNewsByTempletLabel(rightsSetting.getFirstClassify(), rightsSetting.getSecondClassify(), appletNewsDTOS = appletNewsBiz.getNewsByTempletLabel(rightsSetting.getFirstClassify(), rightsSetting.getSecondClassify(),
rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId(), null); rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId(), null);
if (ListUtils.isEmpty(appletNewsDTOS)) {
return list;
}
} }
Map<Long, List<AppletNewsDTO>> map = appletNewsDTOS.stream().collect(Collectors.groupingBy(AppletNewsDTO::getRightsClassifyId)); // 查询IP所在城市
List<AppletNewsDTO> appletNews4Area = null;
if (StrUtil.isNotBlank(cityCode)){
// 查询城市对应资讯
appletNews4Area = appletNewsDao.listNewsByCityCode(cityCode);
}
Map<Long, List<AppletNewsDTO>> map = null;
if (CollUtil.isNotEmpty(appletNewsDTOS)) {
map = appletNewsDTOS.stream().collect(Collectors.groupingBy(AppletNewsDTO::getRightsClassifyId));
}
for (RightsSettingItem item : list) { for (RightsSettingItem item : list) {
int top = 3; int top = 3;
if(!ListUtils.isEmpty(item.getAppletNewsDTOS())){ if(!ListUtils.isEmpty(item.getAppletNewsDTOS())){
...@@ -1959,19 +1990,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1959,19 +1990,26 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
String key = "BOOK:RIGHTS_SETTING:USER_RIGHTS_ITEM" + wechatUserId + "-" + rightsSettingId + "-" + item.getRightsClassifyId(); String key = "BOOK:RIGHTS_SETTING:USER_RIGHTS_ITEM" + wechatUserId + "-" + rightsSettingId + "-" + item.getRightsClassifyId();
//权益分类下资讯 //权益分类下资讯
List<AppletNewsDTO> newsDTOS = JedisClusterUtils.getJsonList(key, AppletNewsDTO.class); List<AppletNewsDTO> newsDTOS = JedisClusterUtils.getJsonList(key, AppletNewsDTO.class);
if (ListUtils.isEmpty(newsDTOS) || newsDTOS.size() < top) {//数据库取 //数据库取
if (!MapUtils.isEmpty(map) && map.containsKey(item.getRightsClassifyId())) { if (ListUtils.isEmpty(newsDTOS) || newsDTOS.size() < top) {
if (item.getRightsClassifyId() == 13){
newsDTOS = appletNews4Area;
}else if(!MapUtils.isEmpty(map) && map.containsKey(item.getRightsClassifyId())) {
newsDTOS = map.get(item.getRightsClassifyId()); newsDTOS = map.get(item.getRightsClassifyId());
if (newsDTOS.size() > top) {//随机取三条 }
List<AppletNewsDTO> dtos = new ArrayList<>(); //随机取三条
while (dtos.size() < top) { if (Objects.nonNull(newsDTOS) && newsDTOS.size() > top) {
AppletNewsDTO dto = newsDTOS.get(new Random().nextInt(newsDTOS.size())); List<AppletNewsDTO> dtos = new ArrayList<>();
if (!dtos.contains(dto)) { while (dtos.size() < top) {
dtos.add(dto); AppletNewsDTO dto = newsDTOS.get(new Random().nextInt(newsDTOS.size()));
} if (!dtos.contains(dto)) {
dtos.add(dto);
} }
newsDTOS = dtos;
} }
newsDTOS = dtos;
}
// 地理位置匹配时,不进行缓存
if (item.getRightsClassifyId() != 13){
JedisClusterUtils.setJsonList(key, newsDTOS, 60); JedisClusterUtils.setJsonList(key, newsDTOS, 60);
} }
} }
......
...@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.entity; ...@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.entity;
import com.pcloud.book.applet.dto.AppletNewsServeDTO; import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.entity.AppletNewsServe; import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.common.entity.BaseEntity; import com.pcloud.common.entity.BaseEntity;
import com.pcloud.common.page.PageBeanNew;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
......
...@@ -10,6 +10,7 @@ import com.pcloud.common.entity.BaseEntity; ...@@ -10,6 +10,7 @@ import com.pcloud.common.entity.BaseEntity;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.pcloud.common.page.PageBeanNew;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -61,6 +62,10 @@ public class RightsSettingItem extends BaseEntity { ...@@ -61,6 +62,10 @@ public class RightsSettingItem extends BaseEntity {
* 资讯 * 资讯
*/ */
private List<AppletNewsDTO> appletNewsDTOS; private List<AppletNewsDTO> appletNewsDTOS;
/**
* 咨询
*/
private PageBeanNew<AppletNewsDTO> appletNewsDTOS4Page;
@ApiModelProperty("本书阅读计划开关 0关闭 1开启") @ApiModelProperty("本书阅读计划开关 0关闭 1开启")
private Integer isOpen; private Integer isOpen;
......
...@@ -14,6 +14,7 @@ import com.pcloud.common.permission.PermissionException; ...@@ -14,6 +14,7 @@ import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.SessionUtil; import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie; import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.nginx.NginxUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
...@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import java.util.List; import java.util.List;
...@@ -130,13 +132,14 @@ public class RightsSettingFacede { ...@@ -130,13 +132,14 @@ public class RightsSettingFacede {
@RequestParam(value = "adviserId", required = false) Long adviserId, @RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId, @RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "rightsType", required = false) String rightsType, @RequestParam(value = "rightsType", required = false) String rightsType,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType @RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType,
) { @RequestParam(value = "currentPage",required = false) Integer currentPage,
@RequestParam(value = "numPerPage",required = false) Integer numPerPage) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) { if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
} }
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType, bookId, adviserId, channelId)); return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType, bookId, adviserId, channelId, currentPage, numPerPage));
} }
@ApiOperation("所有权益分类") @ApiOperation("所有权益分类")
......
...@@ -32,12 +32,13 @@ ...@@ -32,12 +32,13 @@
<result column="business_card_id" property="businessCardId" jdbcType="BIGINT" /> <result column="business_card_id" property="businessCardId" jdbcType="BIGINT" />
<result column="business_card_type" property="businessCardType" jdbcType="TINYINT" /> <result column="business_card_type" property="businessCardType" jdbcType="TINYINT" />
<result column="business_card_isOpen" property="businessCardIsOpen" jdbcType="TINYINT" /> <result column="business_card_isOpen" property="businessCardIsOpen" jdbcType="TINYINT" />
<result column="city_code" property="cityCode" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
news.id, news.news_name, news.source, news.news_classify_id, news.pro_label_id, news.dep_label_id, news.pur_label_id, news.type, news.digest, news.id, news.news_name, news.source, news.news_classify_id, news.pro_label_id, news.dep_label_id, news.pur_label_id, news.type, news.digest,
pic1, pic2, pic3, news.content, show_state, news.create_time, news.update_time, news.first_classify, news.second_classify, news.grade_label_id, news.subject_label_id, news.rights_classify_id, pic1, pic2, pic3, news.content, show_state, news.create_time, news.update_time, news.first_classify, news.second_classify, news.grade_label_id, news.subject_label_id, news.rights_classify_id,
news.jump_type, news.jump_url, news.url_number, news.custom_tag_id, news.show_source, news.show_link,news.business_card_id,news.business_card_type,news.business_card_isOpen news.jump_type, news.jump_url, news.url_number, news.custom_tag_id, news.show_source, news.show_link,news.business_card_id,news.business_card_type,news.business_card_isOpen,city_code
</sql> </sql>
<sql id="sql_news"> <sql id="sql_news">
m.id, m.id,
...@@ -64,20 +65,21 @@ ...@@ -64,20 +65,21 @@
jumpUrl, jumpUrl,
urlNumber, urlNumber,
showSource, showSource,
showLink showLink,
cityCode
</sql> </sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletNews" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletNews" useGeneratedKeys="true" keyProperty="id">
insert into applet_news( insert into applet_news(
news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest, news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest,
pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id, subject_label_id, rights_classify_id, pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id, subject_label_id, rights_classify_id,
jump_type, jump_url,url_number, custom_tag_id, show_source, show_link,business_card_id,business_card_type,business_card_isOpen jump_type, jump_url,url_number, custom_tag_id, show_source, show_link,business_card_id,business_card_type,business_card_isOpen,city_code
) )
values ( values (
#{newsName}, #{source}, #{newsClassifyId}, #{proLabelId}, #{depLabelId}, #{purLabelId}, #{type}, #{digest}, #{newsName}, #{source}, #{newsClassifyId}, #{proLabelId}, #{depLabelId}, #{purLabelId}, #{type}, #{digest},
#{pic1}, #{pic2}, #{pic3}, #{content}, #{showState}, NOW(), NOW(), #{firstClassify,jdbcType=BIGINT}, #{secondClassify,jdbcType=BIGINT}, #{pic1}, #{pic2}, #{pic3}, #{content}, #{showState}, NOW(), NOW(), #{firstClassify,jdbcType=BIGINT}, #{secondClassify,jdbcType=BIGINT},
#{gradeLabelId,jdbcType=BIGINT}, #{subjectLabelId,jdbcType=BIGINT}, #{rightsClassifyId,jdbcType=BIGINT}, #{gradeLabelId,jdbcType=BIGINT}, #{subjectLabelId,jdbcType=BIGINT}, #{rightsClassifyId,jdbcType=BIGINT},
#{jumpType}, #{jumpUrl}, #{urlNumber}, #{customTagId}, #{showSource}, #{showLink}, #{businessCardId}, #{businessCardType}, #{businessCardIsOpen} #{jumpType}, #{jumpUrl}, #{urlNumber}, #{customTagId}, #{showSource}, #{showLink}, #{businessCardId}, #{businessCardType}, #{businessCardIsOpen}, #{cityCode}
) )
</insert> </insert>
...@@ -121,6 +123,9 @@ ...@@ -121,6 +123,9 @@
<if test="showLink != null"> <if test="showLink != null">
show_link = #{showLink}, show_link = #{showLink},
</if> </if>
<if test="cityCode != null">
city_code = #{cityCode},
</if>
jump_url = #{jumpUrl}, jump_url = #{jumpUrl},
url_number = #{urlNumber}, url_number = #{urlNumber},
business_card_id = #{businessCardId}, business_card_id = #{businessCardId},
...@@ -214,6 +219,7 @@ ...@@ -214,6 +219,7 @@
n.jump_url jumpUrl, n.jump_url jumpUrl,
n.url_number urlNumber, n.url_number urlNumber,
n.custom_tag_id customTagId, n.custom_tag_id customTagId,
n.city_code cityCode,
t.custom_tag customTag, t.custom_tag customTag,
IF(n.business_card_id is null,2,n.business_card_isOpen) businessCardIsOpen IF(n.business_card_id is null,2,n.business_card_isOpen) businessCardIsOpen
FROM applet_news n FROM applet_news n
...@@ -224,8 +230,19 @@ ...@@ -224,8 +230,19 @@
LEFT JOIN applet_news_category category on n.id = category.applet_news_id LEFT JOIN applet_news_category category on n.id = category.applet_news_id
</if> </if>
WHERE 1=1 WHERE 1=1
<if test="cityCode != null">
AND n.city_code = #{cityCode}
</if>
<if test="name != null"> <if test="name != null">
AND (n.news_name LIKE CONCAT("%",#{name},"%") OR n.url_number LIKE CONCAT("%",#{name},"%")) AND (n.news_name LIKE CONCAT("%",#{name},"%")
OR n.url_number LIKE CONCAT("%",#{name},"%")
<if test="cityCodes != null">
OR n.city_code IN
<foreach collection="cityCodes" item="item" open="(" close=")" separator=",">
${item}
</foreach>
</if>
)
</if> </if>
<if test="newsClassifyId >0"> <if test="newsClassifyId >0">
AND n.news_classify_id = #{newsClassifyId} AND n.news_classify_id = #{newsClassifyId}
...@@ -363,6 +380,7 @@ ...@@ -363,6 +380,7 @@
<if test="newsClassifyId != null"> <if test="newsClassifyId != null">
news_classify_id = #{newsClassifyId}, news_classify_id = #{newsClassifyId},
</if> </if>
city_code = #{cityCode},
update_time=NOW() update_time=NOW()
WHERE id IN WHERE id IN
<foreach collection="ids" item="item" separator="," open="(" close=")"> <foreach collection="ids" item="item" separator="," open="(" close=")">
...@@ -737,7 +755,8 @@ ...@@ -737,7 +755,8 @@
n.jump_url jumpUrl, n.jump_url jumpUrl,
n.url_number urlNumber, n.url_number urlNumber,
n.show_source showSource, n.show_source showSource,
n.show_link showLink n.show_link showLink,
n.city_code cityCode
FROM FROM
applet_news n applet_news n
LEFT JOIN rights_setting_item_detail d ON d.serve_id = n.id LEFT JOIN rights_setting_item_detail d ON d.serve_id = n.id
...@@ -776,6 +795,7 @@ ...@@ -776,6 +795,7 @@
news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest, news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest,
pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id, pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id,
subject_label_id, rights_classify_id, subject_label_id, rights_classify_id,
city_code,
jump_type, jump_url,url_number, custom_tag_id, show_source, show_link jump_type, jump_url,url_number, custom_tag_id, show_source, show_link
) )
values values
...@@ -785,6 +805,7 @@ ...@@ -785,6 +805,7 @@
#{item.pic1}, #{item.pic2}, #{item.pic3}, #{item.content}, #{item.showState}, NOW(), NOW(), #{item.firstClassify,jdbcType=BIGINT}, #{item.pic1}, #{item.pic2}, #{item.pic3}, #{item.content}, #{item.showState}, NOW(), NOW(), #{item.firstClassify,jdbcType=BIGINT},
#{item.secondClassify,jdbcType=BIGINT}, #{item.secondClassify,jdbcType=BIGINT},
#{item.gradeLabelId,jdbcType=BIGINT}, #{item.subjectLabelId,jdbcType=BIGINT}, #{item.rightsClassifyId,jdbcType=BIGINT}, #{item.gradeLabelId,jdbcType=BIGINT}, #{item.subjectLabelId,jdbcType=BIGINT}, #{item.rightsClassifyId,jdbcType=BIGINT},
#{item.cityCode},
#{item.jumpType}, #{item.jumpUrl}, #{item.urlNumber}, #{item.customTagId}, #{item.showSource}, #{item.showLink} #{item.jumpType}, #{item.jumpUrl}, #{item.urlNumber}, #{item.customTagId}, #{item.showSource}, #{item.showLink}
) )
</foreach> </foreach>
...@@ -807,4 +828,38 @@ ...@@ -807,4 +828,38 @@
</if> </if>
</select> </select>
<select id="listNewsByCityCode" resultType="com.pcloud.book.applet.dto.AppletNewsDTO">
SELECT
n.id,
n.news_name newsName,
n.source,
n.news_classify_id newsClassifyId,
n.pro_label_id proLabelId,
n.dep_label_id depLabelId,
n.pur_label_id purLabelId,
n.type,
n.digest,
n.pic1,
n.pic2,
n.pic3,
n.show_state showState,
n.create_time createTime,
n.first_classify firstClassify,
n.second_classify secondClassify,
n.grade_label_id gradeLabelId,
n.subject_label_id subjectLabelId,
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl,
n.url_number urlNumber,
n.show_source showSource,
n.city_code cityCode,
n.show_link showLink
FROM applet_news n
WHERE n.show_state = 1
AND n.city_code = #{cityId}
ORDER BY n.update_time DESC
</select>
</mapper> </mapper>
...@@ -141,4 +141,5 @@ ...@@ -141,4 +141,5 @@
</foreach> </foreach>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#{item} #{item}
</foreach> </foreach>
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" > <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from region_map delete from region_map
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</delete> </delete>
...@@ -138,4 +138,8 @@ ...@@ -138,4 +138,8 @@
short_name = #{shortName,jdbcType=VARCHAR} short_name = #{shortName,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<select id="getCitysByCode" resultType="java.lang.String">
select region_name from region_map where region_code =#{cityCode}
</select>
</mapper> </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