Commit 29091089 by 高鹏

Merge branch 'zhengyongqiang' into 'master'

Zhengyongqiang

See merge request rays/pcloud-book!117
parents 9d807954 3d73fa9d
...@@ -66,6 +66,15 @@ public interface AdNewsBiz { ...@@ -66,6 +66,15 @@ public interface AdNewsBiz {
Long addAdNewsWechat(AdNewsWechat adNewsWechat); Long addAdNewsWechat(AdNewsWechat adNewsWechat);
/** /**
* 获取自有公众号
* @param adviserId
* @param currentPage
* @param numPerPage
* @return
*/
PageBeanNew<AdNewsWechat> getAdNewsWechatListForAdviser(Long adviserId, Integer currentPage, Integer numPerPage);
/**
* 获取所有的公众号列表 * 获取所有的公众号列表
* @param currentPage * @param currentPage
* @param numPerPage * @param numPerPage
...@@ -124,4 +133,5 @@ public interface AdNewsBiz { ...@@ -124,4 +133,5 @@ public interface AdNewsBiz {
* @return * @return
*/ */
Long addAdNewsClickRecord(AdNewsClickRecord adNewsClickRecord); Long addAdNewsClickRecord(AdNewsClickRecord adNewsClickRecord);
} }
...@@ -16,7 +16,6 @@ import com.pcloud.book.group.biz.WeixinQrcodeBiz; ...@@ -16,7 +16,6 @@ import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.group.dao.GroupQrcodeDao; import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.dto.BookWxQrcodeDTO; import com.pcloud.book.group.dto.BookWxQrcodeDTO;
import com.pcloud.book.group.dto.GroupQrcodeFoAdDTO; import com.pcloud.book.group.dto.GroupQrcodeFoAdDTO;
import com.pcloud.book.group.vo.BookGroupClassifyVO;
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;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
...@@ -40,7 +39,6 @@ import org.springframework.stereotype.Component; ...@@ -40,7 +39,6 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.security.cert.X509Certificate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -107,11 +105,24 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -107,11 +105,24 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsSetDao.insert(adNewsSet); adNewsSetDao.insert(adNewsSet);
buildAdNewsGroups(adNewsSet, adNewsSet.getCreateUser()); buildAdNewsGroups(adNewsSet, adNewsSet.getCreateUser());
adNewsGroupDao.batchInsert(adNewsSet.getAdNewsGroups()); adNewsGroupDao.batchInsert(adNewsSet.getAdNewsGroups());
buildAdNewsWechats(adNewsSet);
adNewsWechatDao.batchInsert(adNewsSet.getAdNewsWechats());
//创建定时任务 //创建定时任务
buildAdNewsSh(adNewsSet); buildAdNewsSh(adNewsSet);
return adNewsSet.getId(); return adNewsSet.getId();
} }
/**
* 构建自有公众号对象
*
* @param adNewsSet
*/
private void buildAdNewsWechats(AdNewsSet adNewsSet) {
for (AdNewsWechat adNewsWechat : adNewsSet.getAdNewsWechats()) {
adNewsWechat.setAdviserId(adNewsSet.getUpdateUser());
}
}
@ParamLog("创建编辑端早晚报定时任务") @ParamLog("创建编辑端早晚报定时任务")
private void buildAdNewsSh(AdNewsSet adNewsSet) { private void buildAdNewsSh(AdNewsSet adNewsSet) {
if (adNewsSet.getHasMorningOpen()) { if (adNewsSet.getHasMorningOpen()) {
...@@ -174,6 +185,12 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -174,6 +185,12 @@ public class AdNewsBizImpl implements AdNewsBiz {
//重新设置关联 //重新设置关联
buildAdNewsGroups(adNewsSet, adNewsSet.getUpdateUser()); buildAdNewsGroups(adNewsSet, adNewsSet.getUpdateUser());
adNewsGroupDao.batchInsert(adNewsSet.getAdNewsGroups()); adNewsGroupDao.batchInsert(adNewsSet.getAdNewsGroups());
// 判断是否增加自有过公众号,如果没有则将当前数据入库
if (!ListUtils.isEmpty(adNewsSet.getAdNewsWechats())
&& !adNewsWechatDao.existsAdNewsWechat(adNewsSet.getUpdateUser())) {
buildAdNewsWechats(adNewsSet);
adNewsWechatDao.batchInsert(adNewsSet.getAdNewsWechats());
}
//删除旧的定时任务 //删除旧的定时任务
deleteAdNewsSch(AD_MORNING_NEWS_SCHEDULE_PRE + adNewsSet.getId()); deleteAdNewsSch(AD_MORNING_NEWS_SCHEDULE_PRE + adNewsSet.getId());
deleteAdNewsSch(AD_EVENING_NEWS_SCHEDULE_PRE + adNewsSet.getId()); deleteAdNewsSch(AD_EVENING_NEWS_SCHEDULE_PRE + adNewsSet.getId());
...@@ -199,15 +216,16 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -199,15 +216,16 @@ public class AdNewsBizImpl implements AdNewsBiz {
//查询关联的群 //查询关联的群
List<GroupQrcodeFoAdDTO> groupQrcodeFoAdDTOS = groupQrcodeDao.GroupQrcodeFoAdDTOSByClassifyIds(classifyIds); List<GroupQrcodeFoAdDTO> groupQrcodeFoAdDTOS = groupQrcodeDao.GroupQrcodeFoAdDTOSByClassifyIds(classifyIds);
if (ListUtils.isEmpty(groupQrcodeFoAdDTOS)) { if (ListUtils.isEmpty(groupQrcodeFoAdDTOS)) {
LOGGER.info("没有关联任何群,无法发送早晚报!");
return; return;
} }
// 需要发送的早晚报内容 // 需要发送的早晚报内容
List<String> contents = new ArrayList<>(); List<String> contents = new ArrayList<>();
// 插入发送记录 // 需要入库的发送记录
List<AdNewsGroupRecord> adNewsGroupRecords = new ArrayList<>(); List<AdNewsGroupRecord> adNewsGroupRecords = new ArrayList<>();
// 插入消息统计信息 // 需要入库的消息统计信息
List<AdNewsMessageStatistic> adNewsMessageStatistics = new ArrayList<>(); List<AdNewsMessageStatistic> adNewsMessageStatistics = new ArrayList<>();
// for循环内的临时变量 // for循环内的临时变量
...@@ -216,10 +234,18 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -216,10 +234,18 @@ public class AdNewsBizImpl implements AdNewsBiz {
if (adNewsSet.getContentFrom() == AdContentFromEnum.WECHAT.key) { if (adNewsSet.getContentFrom() == AdContentFromEnum.WECHAT.key) {
//查询要发的记录 // 查询要发的记录
List<AdNews> adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser(adNewsSetId, adNewsSet.getCreateUser(), adNewsSet.getSendCount()); List<AdNews> adNewsList = null;
AdContentFromEnum adContentFromEnum = AdContentFromEnum.WECHAT_ADVISER;
adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser4Own(adNewsSetId, adNewsSet.getCreateUser(), adNewsSet.getSendCount());
if (ListUtils.isEmpty(adNewsList)) { if (ListUtils.isEmpty(adNewsList)) {
return; adContentFromEnum = AdContentFromEnum.WECHAT;
adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser(adNewsSetId, adNewsSet.getCreateUser(), adNewsSet.getSendCount());
if (ListUtils.isEmpty(adNewsList)) {
LOGGER.info("记录为空,没有可供发送的早晚报!");
return;
}
} }
// 构建记录对象 // 构建记录对象
...@@ -243,12 +269,13 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -243,12 +269,13 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsMessageStatistic.setClassifyId(groupQrcodeFoAdDTO.getClassifyId()); adNewsMessageStatistic.setClassifyId(groupQrcodeFoAdDTO.getClassifyId());
adNewsMessageStatistic.setQrcodeId(groupQrcodeFoAdDTO.getQrcodeId()); adNewsMessageStatistic.setQrcodeId(groupQrcodeFoAdDTO.getQrcodeId());
adNewsMessageStatistic.setCreateUser(adNewsSet.getCreateUser()); adNewsMessageStatistic.setCreateUser(adNewsSet.getCreateUser());
adNewsMessageStatistic.setContentFrom(adNewsSet.getContentFrom()); adNewsMessageStatistic.setContentFrom(adContentFromEnum.key);
adNewsMessageStatistic.setMessageCount(adNewsList.size()); adNewsMessageStatistic.setMessageCount(adNewsList.size());
adNewsMessageStatistic.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO)); adNewsMessageStatistic.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsMessageStatistics.add(adNewsMessageStatistic); adNewsMessageStatistics.add(adNewsMessageStatistic);
} }
// 因为拼短链接需要主键,所以需要先入库拿到主键后然后拼接Url,最后再发送微信消息;
// 记录入库 // 记录入库
this.insertRecord(adNewsGroupRecords, adNewsMessageStatistics); this.insertRecord(adNewsGroupRecords, adNewsMessageStatistics);
...@@ -330,7 +357,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -330,7 +357,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
*/ */
private void insertRecord(List<AdNewsGroupRecord> adNewsGroupRecords, List<AdNewsMessageStatistic> adNewsMessageStatistics) { private void insertRecord(List<AdNewsGroupRecord> adNewsGroupRecords, List<AdNewsMessageStatistic> adNewsMessageStatistics) {
adNewsMessageStatisticDao.batchInsert(adNewsMessageStatistics); adNewsMessageStatisticDao.batchInsert(adNewsMessageStatistics);
// 不会mybatis的主从表批量插入,所以只能这么做 // 将主键赋值给从表外键;(不会mybatis的主从表批量插入,所以只能这么做)
for (AdNewsMessageStatistic item : adNewsMessageStatistics) { for (AdNewsMessageStatistic item : adNewsMessageStatistics) {
adNewsGroupRecords.stream().filter(x -> x.getInsertMark() == item.getInsertMark()).forEach(x -> x.setMessageStatisticId(item.getId())); adNewsGroupRecords.stream().filter(x -> x.getInsertMark() == item.getInsertMark()).forEach(x -> x.setMessageStatisticId(item.getId()));
} }
...@@ -437,6 +464,10 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -437,6 +464,10 @@ public class AdNewsBizImpl implements AdNewsBiz {
List<Long> classifyIds = adNewsGroups.stream().filter(s -> s.getClassifyId() != null).map(AdNewsGroup::getClassifyId).collect(Collectors.toList()); List<Long> classifyIds = adNewsGroups.stream().filter(s -> s.getClassifyId() != null).map(AdNewsGroup::getClassifyId).collect(Collectors.toList());
adNewsSet.setClassifyIds(classifyIds); adNewsSet.setClassifyIds(classifyIds);
} }
// 自有公众号
List<AdNewsWechat> adNewsWechats = adNewsWechatDao.getListByAdviserId(adNewsSet.getUpdateUser());
adNewsSet.setAdNewsWechats(ListUtils.isEmpty(adNewsWechats) ? new ArrayList<>() : adNewsWechats);
} }
return adNewsSet; return adNewsSet;
} }
...@@ -481,6 +512,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -481,6 +512,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
map.put("hasBan", adNewsListParam.getHasBan()); map.put("hasBan", adNewsListParam.getHasBan());
map.put("hasUsed", adNewsListParam.getHasUsed()); map.put("hasUsed", adNewsListParam.getHasUsed());
map.put("adNewsWechatIds", adNewsListParam.getAdNewsWechatIds()); map.put("adNewsWechatIds", adNewsListParam.getAdNewsWechatIds());
map.put("contentFrom", adNewsListParam.getContentFrom());
PageBeanNew<AdNews> pageBeanNew = adNewsDao.listPageNew(pageParam, map, "getAdNewsList"); PageBeanNew<AdNews> pageBeanNew = adNewsDao.listPageNew(pageParam, map, "getAdNewsList");
return pageBeanNew; return pageBeanNew;
} }
...@@ -550,9 +582,31 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -550,9 +582,31 @@ public class AdNewsBizImpl implements AdNewsBiz {
@ParamLog("增加公众号反馈") @ParamLog("增加公众号反馈")
@Override @Override
public Long addAdNewsWechat(AdNewsWechat adNewsWechat) { public Long addAdNewsWechat(AdNewsWechat adNewsWechat) {
this.checkAdNewsWechat(adNewsWechat);
return adNewsWechatDao.insert(adNewsWechat); return adNewsWechatDao.insert(adNewsWechat);
} }
private void checkAdNewsWechat(AdNewsWechat adNewsWechat) {
if (adNewsWechat.getAdviserId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "编辑id不能为空!");
}
if (StringUtil.isEmpty(adNewsWechat.getWechatName())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "公众号不能为空!");
}
if (adNewsWechatDao.checkRepeat(adNewsWechat.getWechatName(), adNewsWechat.getAdviserId())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "该公众号已经存在!");
}
}
@Override
@ParamLog("获取编辑自有公众号")
public PageBeanNew<AdNewsWechat> getAdNewsWechatListForAdviser(Long adviserId, Integer currentPage, Integer numPerPage) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> map = new HashMap<>();
map.put("adviserId", adviserId);
return adNewsWechatDao.listPageNew(pageParam, map, "getAdNewsWechatListForAdviser");
}
@ParamLog("获取公众号列表") @ParamLog("获取公众号列表")
@Override @Override
public PageBeanNew<AdNewsWechat> getAdNewsWechatList(Integer currentPage, Integer numPerPage) { public PageBeanNew<AdNewsWechat> getAdNewsWechatList(Integer currentPage, Integer numPerPage) {
...@@ -587,7 +641,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -587,7 +641,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
} }
// 移除编辑之前的选择 // 移除编辑之前的选择
adNewsWechatChooseDao.deleteAdNewsWechatChooseByPartyId(partyId); adNewsWechatChooseDao.deleteAdNewsWechatChooseByPartyId(partyId);
if(!ListUtils.isEmpty(adNewsWechatChooses)){ if (!ListUtils.isEmpty(adNewsWechatChooses)) {
// 重新建立关系 // 重新建立关系
adNewsWechatChooseDao.batchInsert(adNewsWechatChooses); adNewsWechatChooseDao.batchInsert(adNewsWechatChooses);
} }
......
...@@ -26,7 +26,9 @@ public class AdNewsCheck { ...@@ -26,7 +26,9 @@ public class AdNewsCheck {
if (ListUtils.isEmpty(adNewsSet.getAdNewsGroups())) { if (ListUtils.isEmpty(adNewsSet.getAdNewsGroups())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "发送群分类不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "发送群分类不能为空!");
} }
if (adNewsSet.getSendCount() == null || adNewsSet.getSendCount() <= 0) { // 勾选 系统公众号 或者 自有公众号 并且 推送条数小于0则提示;
if ((adNewsSet.getContentFrom() == AdContentFromEnum.WECHAT.key || adNewsSet.getContentFrom() == AdContentFromEnum.WECHAT_ADVISER.key)
&& (adNewsSet.getSendCount() == null || adNewsSet.getSendCount() <= 0)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "推送条数不能为空且必须大于0!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "推送条数不能为空且必须大于0!");
} }
if (adNewsSet.getHasMorningOpen() == null) { if (adNewsSet.getHasMorningOpen() == null) {
...@@ -53,7 +55,9 @@ public class AdNewsCheck { ...@@ -53,7 +55,9 @@ public class AdNewsCheck {
if (adNewsSet.getHasEndContent() && StringUtil.isEmpty(adNewsSet.getEndContent())) { if (adNewsSet.getHasEndContent() && StringUtil.isEmpty(adNewsSet.getEndContent())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "结束语不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "结束语不能为空!");
} }
if (adNewsSet.getContentFrom() != AdContentFromEnum.WECHAT.key && adNewsSet.getContentFrom() != AdContentFromEnum.CUSTOM.key) { if (adNewsSet.getContentFrom() != AdContentFromEnum.WECHAT.key
&& adNewsSet.getContentFrom() != AdContentFromEnum.CUSTOM.key
&& adNewsSet.getContentFrom() != AdContentFromEnum.WECHAT_ADVISER.key) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请选择早晚报内容来源!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请选择早晚报内容来源!");
} }
for (AdNewsGroup adNewsGroup : adNewsSet.getAdNewsGroups()) { for (AdNewsGroup adNewsGroup : adNewsSet.getAdNewsGroups()) {
......
...@@ -9,4 +9,12 @@ public interface AdNewsDao extends BaseDao<AdNews> { ...@@ -9,4 +9,12 @@ public interface AdNewsDao extends BaseDao<AdNews> {
List<AdNews> getNewsToSendBySetIdAndAdviser(Long adNewsSetId, Long adviserId, Integer top); List<AdNews> getNewsToSendBySetIdAndAdviser(Long adNewsSetId, Long adviserId, Integer top);
/**
* 获取自有公众号的需要发送的新闻
* @param adNewsSetId
* @param adviserId
* @param top
* @return
*/
List<AdNews> getNewsToSendBySetIdAndAdviser4Own(Long adNewsSetId, Long adviserId, Integer top);
} }
...@@ -3,10 +3,34 @@ package com.pcloud.book.adnews.dao; ...@@ -3,10 +3,34 @@ package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsWechat; import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/** /**
* @author zhengyongqiang * @author zhengyongqiang
* @date 2019/8/7 11:46 * @date 2019/8/7 11:46
*/ */
public interface AdNewsWechatDao extends BaseDao<AdNewsWechat> { public interface AdNewsWechatDao extends BaseDao<AdNewsWechat> {
boolean checkRepeat(String wechatName, Long adviserId);
/**
* 批量新增自有公众号
* @param list
* @return
*/
Integer batchInsert(List<AdNewsWechat> list);
/**
* 检测是否存在自有公众号
* @param adviserId
* @return
*/
boolean existsAdNewsWechat(Long adviserId);
/**
* 获取自有公众号
* @param adviserId
* @return
*/
List<AdNewsWechat> getListByAdviserId(Long adviserId);
} }
...@@ -24,4 +24,13 @@ public class AdNewsDaoImpl extends BaseDaoImpl<AdNews> implements AdNewsDao { ...@@ -24,4 +24,13 @@ public class AdNewsDaoImpl extends BaseDaoImpl<AdNews> implements AdNewsDao {
map.put("top", top); map.put("top", top);
return super.getSqlSession().selectList(getStatement("getNewsToSendBySetIdAndAdviser"), map); return super.getSqlSession().selectList(getStatement("getNewsToSendBySetIdAndAdviser"), map);
} }
@Override
public List<AdNews> getNewsToSendBySetIdAndAdviser4Own(Long adNewsSetId, Long adviserId, Integer top) {
Map<String, Object> map = new HashMap<>();
map.put("adNewsSetId", adNewsSetId);
map.put("adviserId", adviserId);
map.put("top", top);
return super.getSqlSession().selectList(getStatement("getNewsToSendBySetIdAndAdviser4Own"), map);
}
} }
...@@ -5,10 +5,38 @@ import com.pcloud.book.adnews.entity.AdNewsWechat; ...@@ -5,10 +5,38 @@ import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author zhengyongqiang * @author zhengyongqiang
* @date 2019/8/7 11:52 * @date 2019/8/7 11:52
*/ */
@Repository("adNewsWechatDao") @Repository("adNewsWechatDao")
public class AdNewsWechatDaoImpl extends BaseDaoImpl<AdNewsWechat> implements AdNewsWechatDao { public class AdNewsWechatDaoImpl extends BaseDaoImpl<AdNewsWechat> implements AdNewsWechatDao {
@Override
public boolean checkRepeat(String wechatName, Long adviserId) {
Map<String,Object> map = new HashMap<>();
map.put("wechatName",wechatName);
map.put("adviserId",adviserId);
return super.getSqlSession().selectOne(getStatement("checkRepeat"),map);
}
@Override
public Integer batchInsert(List<AdNewsWechat> list) {
return super.getSqlSession().insert(getStatement("batchInsert"),list);
}
@Override
public boolean existsAdNewsWechat(Long adviserId) {
Map<String,Object> map = new HashMap<>();
map.put("adviserId",adviserId);
return super.getSqlSession().selectOne(getStatement("existsAdNewsWechat"),map);
}
@Override
public List<AdNewsWechat> getListByAdviserId(Long adviserId) {
return super.getSqlSession().selectList(getStatement("getListByAdviserId"),adviserId);
}
} }
...@@ -30,6 +30,9 @@ public class AdNewsListParam { ...@@ -30,6 +30,9 @@ public class AdNewsListParam {
@ApiModelProperty ("公众号id") @ApiModelProperty ("公众号id")
private List<Long> adNewsWechatIds; private List<Long> adNewsWechatIds;
@ApiModelProperty(value = "公众号来源;", dataType = "com.pcloud.book.adnews.enums.AdContentFromEnum")
private Integer contentFrom;
@ApiModelProperty("已被禁用;0:没禁用; 1:已禁用;") @ApiModelProperty("已被禁用;0:没禁用; 1:已禁用;")
private Integer hasBan; private Integer hasBan;
......
...@@ -68,4 +68,8 @@ public class AdNewsSet extends BaseEntity { ...@@ -68,4 +68,8 @@ public class AdNewsSet extends BaseEntity {
@ApiModelProperty("分类id集合") @ApiModelProperty("分类id集合")
private List<Long> classifyIds; private List<Long> classifyIds;
@ApiModelProperty("自有公众号")
private List<AdNewsWechat> adNewsWechats;
} }
...@@ -3,11 +3,13 @@ package com.pcloud.book.adnews.entity; ...@@ -3,11 +3,13 @@ package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity; 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;
/** /**
* @author zhengyongqiang * @author zhengyongqiang
* @date 2019/8/7 11:23 * @date 2019/8/7 11:23
*/ */
@Data
@ApiModel("新闻微信公众号") @ApiModel("新闻微信公众号")
public class AdNewsWechat extends BaseEntity { public class AdNewsWechat extends BaseEntity {
...@@ -34,52 +36,4 @@ public class AdNewsWechat extends BaseEntity { ...@@ -34,52 +36,4 @@ public class AdNewsWechat extends BaseEntity {
@ApiModelProperty("是否删除") @ApiModelProperty("是否删除")
private Boolean isDelete; private Boolean isDelete;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getNewsFrom() {
return newsFrom;
}
public void setNewsFrom(String newsFrom) {
this.newsFrom = newsFrom;
}
public String getWechatName() {
return wechatName;
}
public void setWechatName(String wechatName) {
this.wechatName = wechatName;
}
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public Boolean getDelete() {
return isDelete;
}
public void setDelete(Boolean delete) {
isDelete = delete;
}
@Override
public String toString() {
return "AdNewsWechat{" +
"newsFrom='" + newsFrom + '\'' +
", wechatName='" + wechatName + '\'' +
", adviserId=" + adviserId +
", isDelete=" + isDelete +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
} }
...@@ -11,8 +11,9 @@ import org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl; ...@@ -11,8 +11,9 @@ import org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl;
*/ */
public enum AdContentFromEnum { public enum AdContentFromEnum {
WECHAT(0, "微信公众号"), WECHAT(0, "系统推荐公众号"),
CUSTOM(1, "自定义内容 "); CUSTOM(1, "自定义内容 "),
WECHAT_ADVISER(2,"自有公众号"); // 目前只使用于 ad_news_message_statistic.content_from
public final Integer key; public final Integer key;
......
...@@ -3,6 +3,7 @@ package com.pcloud.book.adnews.facade; ...@@ -3,6 +3,7 @@ package com.pcloud.book.adnews.facade;
import com.pcloud.book.adnews.entity.AdNewsClickRecord; import com.pcloud.book.adnews.entity.AdNewsClickRecord;
import com.pcloud.book.adnews.entity.AdNewsSet; import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.book.adnews.dto.AdNewsListParam; import com.pcloud.book.adnews.dto.AdNewsListParam;
import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException; import com.pcloud.common.permission.PermissionException;
...@@ -58,12 +59,12 @@ public interface AdNewsFacade { ...@@ -58,12 +59,12 @@ public interface AdNewsFacade {
ResponseDto<?> getAdNewsChooseList( ResponseDto<?> getAdNewsChooseList(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title", required = false) @ApiParam("标题") String title, @RequestParam(value = "title", required = false) @ApiParam("标题") String title,
@RequestParam(value = "hasUsed", required = false) @ApiParam("标题") Boolean hasUsed, @RequestParam(value = "hasUsed", required = false) @ApiParam("是否已使用") Boolean hasUsed,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException; ) throws BizException, PermissionException;
@ApiOperation("早晚报素材库") @ApiOperation("早晚报素材库管理(只获取编辑已选公众号的素材)")
@PostMapping("/getAdNewsList") @PostMapping("/getAdNewsList")
ResponseDto<?> getAdNewsList( ResponseDto<?> getAdNewsList(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
...@@ -78,6 +79,21 @@ public interface AdNewsFacade { ...@@ -78,6 +79,21 @@ public interface AdNewsFacade {
@RequestParam("hasBan") @ApiParam("禁止推送") Integer hasBan @RequestParam("hasBan") @ApiParam("禁止推送") Integer hasBan
) throws BizException, PermissionException; ) throws BizException, PermissionException;
@ApiOperation("编辑反馈公众号")
@PostMapping("/addAdNewsWechat")
ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("AdNewsWechat") AdNewsWechat adNewsWechat
) throws BizException, PermissionException;
@ApiOperation("获取编辑自有公众号")
@GetMapping("/getAdNewsWechatList")
ResponseDto<?> getAdNewsWechatListForAdviser(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException;
@ApiOperation("添加编辑选择的公众号") @ApiOperation("添加编辑选择的公众号")
@PostMapping("/createAdNewsWechatChooseBatch") @PostMapping("/createAdNewsWechatChooseBatch")
ResponseDto<?> createAdNewsWechatChooseBatch( ResponseDto<?> createAdNewsWechatChooseBatch(
......
...@@ -171,6 +171,36 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -171,6 +171,36 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
return new ResponseDto<>(); return new ResponseDto<>();
} }
@Override
@ApiOperation("编辑反馈公众号")
@PostMapping("/addAdNewsWechat")
public ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("AdNewsWechat") AdNewsWechat adNewsWechat
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
adNewsWechat.setAdviserId(partyId);
return new ResponseDto<>(adNewsBiz.addAdNewsWechat(adNewsWechat));
}
@Override
@ApiOperation("获取编辑自有公众号")
@GetMapping("/getAdNewsWechatListForAdviser")
public ResponseDto<?> getAdNewsWechatListForAdviser(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage == null || currentPage < 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "当前页不能为空且不能小于0!");
}
if (numPerPage == null || numPerPage <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "每页条数不能为空且必须大于0!");
}
return new ResponseDto<>(adNewsBiz.getAdNewsWechatListForAdviser(partyId, currentPage, numPerPage));
}
@ApiOperation("添加编辑选择的公众号") @ApiOperation("添加编辑选择的公众号")
@PostMapping("/createAdNewsWechatChooseBatch") @PostMapping("/createAdNewsWechatChooseBatch")
@Override @Override
...@@ -277,7 +307,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -277,7 +307,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
Long channelId = (Long) map.get(Cookie._CHANNEL_ID); Long channelId = (Long) map.get(Cookie._CHANNEL_ID);
Long wechatUserId = (Long) map.get(Cookie._WECHAT_USER_ID); Long wechatUserId = (Long) map.get(Cookie._WECHAT_USER_ID);
LOGGER.info("addAdNewsClickRecord Map => "+map.toString()); LOGGER.info("addAdNewsClickRecord Map => " + map.toString());
adNewsClickRecord.setWechatUserId(wechatUserId); adNewsClickRecord.setWechatUserId(wechatUserId);
return new ResponseDto<>(adNewsBiz.addAdNewsClickRecord(adNewsClickRecord)); return new ResponseDto<>(adNewsBiz.addAdNewsClickRecord(adNewsClickRecord));
......
...@@ -32,15 +32,16 @@ ...@@ -32,15 +32,16 @@
SELECT SELECT
a.id, a.id,
a.ad_news_id adNewsId, a.ad_news_id adNewsId,
c.wechat_name wechatName, d.wechat_name wechatName,
b.title, c.title,
b.short_url shortUrl, c.short_url shortUrl,
a.custom_content customContent, a.custom_content customContent,
a.content_type contentType a.content_type contentType
FROM FROM
ad_news_group_record a ad_news_group_record a
LEFT JOIN ad_news b ON a.ad_news_id=b.id INNER JOIN ad_news_message_statistic b ON a.message_statistic_id=b.id
LEFT JOIN ad_news_wechat c ON b.news_from=c.news_from LEFT JOIN ad_news c ON a.ad_news_id=c.id
LEFT JOIN ad_news_wechat d ON d.news_from=c.news_from AND ((b.content_from=2 AND d.adviser_id=#{partyId,jdbcType=BIGINT}) OR b.content_from <![CDATA[<>]]> 2)
WHERE a.message_statistic_id=#{messageStatisticId,jdbcType=BIGINT} WHERE a.message_statistic_id=#{messageStatisticId,jdbcType=BIGINT}
AND a.create_user=#{partyId,jdbcType=BIGINT} AND a.create_user=#{partyId,jdbcType=BIGINT}
</select> </select>
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
</foreach> </foreach>
</insert> </insert>
<!--查找要发送的新闻--> <!--查找要发送的新闻(推荐公众号)-->
<!-- <!--
1、ad_news_ban 排除掉禁止发送的 1、ad_news_ban 排除掉禁止发送的
2、ad_news_group_record 排除掉已发送的 2、ad_news_group_record 排除掉已发送的
...@@ -123,6 +123,25 @@ ...@@ -123,6 +123,25 @@
LIMIT #{top} LIMIT #{top}
</select> </select>
<!--查找要发送的新闻(自有公众号)-->
<!--
1、ad_news_ban 排除掉禁止发送的
2、ad_news_group_record 排除掉已发送的
-->
<select id="getNewsToSendBySetIdAndAdviser4Own" parameterType="map" resultMap="BaseResultMap">
SELECT
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time
FROM
ad_news a
INNER JOIN ad_news_wechat b ON a.news_from = b.news_from AND b.is_delete = 0 AND b.adviser_id=#{adviserId}
WHERE
NOT EXISTS ( SELECT 1 FROM ad_news_ban e WHERE a.id = e.ad_news_id AND e.adviser_id = #{adviserId} )
AND NOT EXISTS (SELECT 1 from ad_news_group_record f WHERE f.ad_news_id=a.id and f.ad_news_set_id=#{adNewsSetId})
ORDER BY
a.id DESC
LIMIT #{top}
</select>
<!--获取素材库列表--> <!--获取素材库列表-->
<select id="getAdNewsList" parameterType="map" resultType="com.pcloud.book.adnews.entity.AdNews"> <select id="getAdNewsList" parameterType="map" resultType="com.pcloud.book.adnews.entity.AdNews">
SELECT SELECT
...@@ -141,13 +160,20 @@ ...@@ -141,13 +160,20 @@
FROM FROM
ad_news a ad_news a
INNER JOIN ad_news_wechat b on a.news_from=b.news_from and b.is_delete=0 INNER JOIN ad_news_wechat b on a.news_from=b.news_from and b.is_delete=0
<if test="adNewsWechatIds != null and adNewsWechatIds.size()>0"> <choose>
AND b.id IN <when test="contentFrom != null and contentFrom == 2">
<foreach collection="adNewsWechatIds" item="item" index="i" separator="," open="(" close=")"> AND b.adviser_id=#{partyId}
${item} </when>
</foreach> <otherwise>
</if> <if test="adNewsWechatIds != null and adNewsWechatIds.size()>0">
INNER JOIN ad_news_wechat_choose c ON b.id=c.ad_news_wechat_id and c.create_user=#{partyId} and c.is_delete=0 AND b.id IN
<foreach collection="adNewsWechatIds" item="item" index="i" separator="," open="(" close=")">
${item}
</foreach>
</if>
INNER JOIN ad_news_wechat_choose c ON b.id=c.ad_news_wechat_id and c.create_user=#{partyId} and c.is_delete=0
</otherwise>
</choose>
where 1=1 where 1=1
<if test="title!=null"> <if test="title!=null">
AND a.title like concat('%', #{title},'%') AND a.title like concat('%', #{title},'%')
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsWechatDaoImpl"> <mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsWechatDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsWechat"> <resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsWechat">
<id column="id" property="id" jdbcType="BIGINT"/> <id column="id" property="id" jdbcType="BIGINT"/>
...@@ -22,12 +22,34 @@ ...@@ -22,12 +22,34 @@
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</select> </select>
<select id="getListByAdviserId" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news_wechat
where adviser_id = #{adviserId,jdbcType=BIGINT}
AND is_delete=0
</select>
<!--获取公众号列表--> <!--获取公众号列表-->
<select id="getAdNewsWechatList" parameterType="map" resultMap="BaseResultMap"> <select id="getAdNewsWechatList" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> select
from ad_news_wechat <include refid="Base_Column_List"/>
from ad_news_wechat
where where
news_from IS NOT NULL news_from IS NOT NULL
AND adviser_id IS NULL
AND is_delete=0
order by id desc
</select>
<!--获取编辑自有公众号-->
<select id="getAdNewsWechatListForAdviser" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from ad_news_wechat
where
adviser_id=#{adviserId}
AND is_delete=0
order by id desc order by id desc
</select> </select>
...@@ -48,20 +70,52 @@ ...@@ -48,20 +70,52 @@
AND b.adviser_id = #{partyId} AND b.adviser_id = #{partyId}
WHERE WHERE
a.`news_from` IS NOT NULL a.`news_from` IS NOT NULL
AND a.adviser_id IS NULL
AND a.is_delete=0
</select> </select>
<select id="checkRepeat" parameterType="map" resultType="boolean">
SELECT count(1) FROM ad_news_wechat
WHERE (wechat_name=#{wechatName} AND adviser_id IS NULL)
OR (wechat_name=#{wechatName} AND adviser_id=#{adviserId})
</select>
<select id="existsAdNewsWechat" parameterType="map" resultType="boolean">
SELECT count(1) FROM ad_news_wechat
WHERE adviser_id=#{adviserId}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsWechat" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsWechat" useGeneratedKeys="true"
keyProperty="id">
insert into ad_news_wechat insert into ad_news_wechat
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
news_from, wechat_name, adviser_id, is_delete, create_time wechat_name, adviser_id, is_delete, create_time
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
#{newsFrom,jdbcType=VARCHAR},
#{wechatName,jdbcType=VARCHAR}, #{wechatName,jdbcType=VARCHAR},
#{adviserId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
#{isDelete,jdbcType=BOOLEAN}, 0,
NOW() NOW()
</trim> </trim>
</insert> </insert>
<insert id="batchInsert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_wechat(
wechat_name,
adviser_id,
is_delete,
create_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.wechatName,jdbcType=VARCHAR},
#{item.adviserId,jdbcType=BIGINT},
0,
NOW()
)
</foreach>
</insert>
</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