Commit f725f7e2 by 宋祥

Merge branch 'mymaster' into 'master'

【ID1000886】广告位,支持定时多次投放到微信群

See merge request rays/pcloud-book!46
parents 495d4287 29e05e5b
package com.pcloud.book.advertising.service; package com.pcloud.book.advertising.service;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.Map;
@FeignClient(value = "pcloud-service-book", qualifier = "advertisingSpaceServiceCloud", path = "book/v1.0/advertisingSpaceService") @FeignClient(value = "pcloud-service-book", qualifier = "advertisingSpaceServiceCloud", path = "book/v1.0/advertisingSpaceService")
@Api(description = "广告位内部接口") @Api(description = "广告位内部接口")
public interface AdvertisingSpaceService { public interface AdvertisingSpaceService {
...@@ -18,4 +22,8 @@ public interface AdvertisingSpaceService { ...@@ -18,4 +22,8 @@ public interface AdvertisingSpaceService {
@ApiOperation(value = "每日凌晨计算昨日广告位收益", httpMethod = "GET") @ApiOperation(value = "每日凌晨计算昨日广告位收益", httpMethod = "GET")
@RequestMapping(value = "calculateAdvertisingIncomeYesterday", method = RequestMethod.GET) @RequestMapping(value = "calculateAdvertisingIncomeYesterday", method = RequestMethod.GET)
void calculateAdvertisingIncomeYesterday() throws BizException; void calculateAdvertisingIncomeYesterday() throws BizException;
@ApiOperation("发送广告计划")
@PostMapping("sendAdvertisingPlan")
void sendAdvertisingPlan(@RequestBody Map<String, Object> map) throws BizException;
} }
package com.pcloud.book.advertising.biz; package com.pcloud.book.advertising.biz;
import java.util.List;
import java.util.Map;
import com.pcloud.book.advertising.dto.AdvertisingMasterDTO; import com.pcloud.book.advertising.dto.AdvertisingMasterDTO;
import com.pcloud.book.advertising.dto.AdvertisingSpaceDTO; import com.pcloud.book.advertising.dto.AdvertisingSpaceDTO;
import com.pcloud.book.advertising.dto.QrcodeAdvertisingSpaceCountDTO; import com.pcloud.book.advertising.dto.QrcodeAdvertisingSpaceCountDTO;
...@@ -10,9 +12,6 @@ import com.pcloud.common.page.PageBean; ...@@ -10,9 +12,6 @@ import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
import java.util.List;
import java.util.Map;
/** /**
* Description 广告位业务逻辑层接口 * Description 广告位业务逻辑层接口
* @author PENG * @author PENG
...@@ -62,9 +61,10 @@ public interface AdvertisingSpaceBiz { ...@@ -62,9 +61,10 @@ public interface AdvertisingSpaceBiz {
/** /**
* 投放微信群 * 投放微信群
* @param book 广告位书刊实体 * @param book 广告位书刊实体
* @param isPlan 是否广告位计划
* @throws BizException * @throws BizException
*/ */
void distributeWechatGroup(AdvertisingDistributionBook book) throws BizException; void distributeWechatGroup(AdvertisingDistributionBook book, Boolean isPlan) throws BizException;
/** /**
* 获取出版社书刊权限 * 获取出版社书刊权限
...@@ -409,4 +409,38 @@ public interface AdvertisingSpaceBiz { ...@@ -409,4 +409,38 @@ public interface AdvertisingSpaceBiz {
* @param id * @param id
*/ */
public void updateTestStatus(Boolean isTest, Long id); public void updateTestStatus(Boolean isTest, Long id);
/**
* 创建广告位计划
* @param advertisingPlan
* @return
*/
Long createAdvertisingPlan(AdvertisingPlan advertisingPlan);
/**
* 修改广告位计划
* @param advertisingPlan
*/
void updateAdvertisingPlan(AdvertisingPlan advertisingPlan);
/**
* 发送广告位计划
*/
void sendAdvertisingPlan(Long advertisingPutId);
/**
* 删除广告位计划
*/
void deleteAdvertisingPlan(Long advertisingPlanId, Long partyId);
/**
* 获取广告位计划
*/
AdvertisingPlan getAdvertisingPlan(Long advertisingPlanId);
/**
* 获取广告位计划列表
*/
PageBeanNew<AdvertisingPlan> getAdvertisingPlanList(String keyword, Long partyId, Integer currentPage, Integer numPerPage);
} }
...@@ -4,6 +4,7 @@ import com.pcloud.appcenter.app.dto.AppTypeDto; ...@@ -4,6 +4,7 @@ import com.pcloud.appcenter.app.dto.AppTypeDto;
import com.pcloud.appcenter.app.service.AppTypeService; import com.pcloud.appcenter.app.service.AppTypeService;
import com.pcloud.book.advertising.biz.AdvertisingSpaceBiz; import com.pcloud.book.advertising.biz.AdvertisingSpaceBiz;
import com.pcloud.book.advertising.biz.BmBiz; import com.pcloud.book.advertising.biz.BmBiz;
import com.pcloud.book.advertising.check.AdvertisingPlanCheck;
import com.pcloud.book.advertising.dao.*; import com.pcloud.book.advertising.dao.*;
import com.pcloud.book.advertising.dto.*; import com.pcloud.book.advertising.dto.*;
import com.pcloud.book.advertising.entity.*; import com.pcloud.book.advertising.entity.*;
...@@ -50,6 +51,9 @@ import com.pcloud.common.utils.ResponseHandleUtil; ...@@ -50,6 +51,9 @@ import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.aliyun.OssUtils; import com.pcloud.common.utils.aliyun.OssUtils;
import com.pcloud.common.utils.httpclient.UrlUtils; import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.facade.quartz.entity.CallBackParam;
import com.pcloud.facade.quartz.entity.ScheduleJob;
import com.pcloud.facade.quartz.service.ScheduleService;
import com.pcloud.readercenter.wechat.entity.WechatUser; import com.pcloud.readercenter.wechat.entity.WechatUser;
import com.pcloud.resourcecenter.product.service.ProductService; import com.pcloud.resourcecenter.product.service.ProductService;
import com.sdk.wxgroup.SendArticleMessageVO; import com.sdk.wxgroup.SendArticleMessageVO;
...@@ -142,6 +146,16 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -142,6 +146,16 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
@Autowired @Autowired
private ConvertQueueBiz convertQueueBiz; private ConvertQueueBiz convertQueueBiz;
@Autowired @Autowired
private AdvertisingPlanCheck advertisingPlanCheck;
@Autowired
private AdvertisingPlanDao advertisingPlanDao;
@Autowired
private AdvertisingPlanGroupDao advertisingPlanGroupDao;
@Autowired
private AdvertisingPutDao advertisingPutDao;
@Autowired
private ScheduleService scheduleService;
@Autowired
private BmBiz bmBiz; private BmBiz bmBiz;
...@@ -523,7 +537,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -523,7 +537,7 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ParamLog(value = "投放微信群", isAfterReturn = false) @ParamLog(value = "投放微信群", isAfterReturn = false)
public void distributeWechatGroup(AdvertisingDistributionBook book) throws BizException { public void distributeWechatGroup(AdvertisingDistributionBook book, Boolean isPlan) throws BizException {
if (null == book.getAdId() || ListUtils.isEmpty(book.getGroups())) { if (null == book.getAdId() || ListUtils.isEmpty(book.getGroups())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
} }
...@@ -803,10 +817,12 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -803,10 +817,12 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
Object objectlist = (Object) objs; Object objectlist = (Object) objs;
List<GroupQrcodeVO> groupQrcodeVOList = (List<GroupQrcodeVO>) objectlist; List<GroupQrcodeVO> groupQrcodeVOList = (List<GroupQrcodeVO>) objectlist;
List<Long> labelIds = new ArrayList<>(); List<Long> labelIds = new ArrayList<>();
List<Long> proLabels = groupQrcodeVOList.stream().filter(s->s.getProLabelId()!=null).map(GroupQrcodeVO::getProLabelId).distinct().collect(Collectors.toList()); List<Long> proLabels = groupQrcodeVOList.stream().filter(s -> s.getProLabelId() != null).map(GroupQrcodeVO::getProLabelId).distinct().collect(Collectors.toList());
List<Long> depLabels = groupQrcodeVOList.stream().filter(s->s.getDepLabelId()!=null).map(GroupQrcodeVO::getDepLabelId).distinct().collect(Collectors.toList()); List<Long> depLabels = groupQrcodeVOList.stream().filter(s -> s.getDepLabelId() != null).map(GroupQrcodeVO::getDepLabelId).distinct().collect(Collectors.toList());
List<Long> purLabels = groupQrcodeVOList.stream().filter(s->s.getPurLabelId()!=null).map(GroupQrcodeVO::getPurLabelId).distinct().collect(Collectors.toList()); List<Long> purLabels = groupQrcodeVOList.stream().filter(s -> s.getPurLabelId() != null).map(GroupQrcodeVO::getPurLabelId).distinct().collect(Collectors.toList());
if (!ListUtils.isEmpty(proLabels)){ List<Long> qrcodeIds = groupQrcodeVOList.stream().filter(s -> s.getGroupQrcodeId() != null).map(GroupQrcodeVO::getGroupQrcodeId).distinct().collect(Collectors.toList());
Map<Long, Integer> weekActiveMap = wechatGroupConsr.get7DayActiveUserCountByQrcode(qrcodeIds);
if (!ListUtils.isEmpty(proLabels)) {
labelIds.addAll(proLabels); labelIds.addAll(proLabels);
} }
if (!ListUtils.isEmpty(depLabels)) { if (!ListUtils.isEmpty(depLabels)) {
...@@ -832,6 +848,11 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -832,6 +848,11 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
} }
} }
} }
for (Object object : objs) {
GroupQrcodeVO qrcodeVO = (GroupQrcodeVO) object;
//填充7天活跃人数
qrcodeVO.setWeekActiveCount(weekActiveMap.get(qrcodeVO.getGroupQrcodeId()));
}
return pageBean; return pageBean;
} }
...@@ -2183,4 +2204,399 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -2183,4 +2204,399 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
advertisingSpaceDao.updateTestStatus(isTest, id); advertisingSpaceDao.updateTestStatus(isTest, id);
} }
@Transactional(rollbackFor = Exception.class)
@ParamLog("创建广告位计划")
@Override
public Long createAdvertisingPlan(AdvertisingPlan advertisingPlan) {
advertisingPlanCheck.checkCreateAdvertisingPlan(advertisingPlan);
//插入计划
advertisingPlanDao.insert(advertisingPlan);
buildPutAndGroup(advertisingPlan);
//插入计划广告位
advertisingPutDao.batchInsert(advertisingPlan.getAdvertisingPuts());
//插入关联想
advertisingPlanGroupDao.batchInsert(advertisingPlan.getAdvertisingPlanGroups());
//设定定时任务
for (AdvertisingPut advertisingPut : advertisingPlan.getAdvertisingPuts()) {
createAdvertisingPlanQuartz(advertisingPut);
}
return advertisingPlan.getId();
}
@ParamLog("设置定时任务")
private void createAdvertisingPlanQuartz(AdvertisingPut advertisingPut) {
Integer putType = advertisingPut.getPutType();
if (PutTypeEnum.ONE.value.equals(putType)) {
putOne(advertisingPut);
} else if (PutTypeEnum.DAY.value.equals(putType)) {
putDay(advertisingPut);
} else if (PutTypeEnum.WEEK.value.equals(putType)) {
putWeek(advertisingPut);
}
}
@ParamLog("按周设置定时任务")
private void putWeek(AdvertisingPut advertisingPut) {
String cron;
String putTime = advertisingPut.getPutTime();
try {
int hour = Integer.parseInt(putTime.substring(0, 2));
int minute = Integer.parseInt(putTime.substring(3, 5));
int second = Integer.parseInt(putTime.substring(6, 8));
String weekS = "";
int weekDay = advertisingPut.getWeekDay();
if (weekDay == 1) {
weekS = "MON";
}
if (weekDay == 2) {
weekS = "TUE";
}
if (weekDay == 3) {
weekS = "WED";
}
if (weekDay == 4) {
weekS = "THU";
}
if (weekDay == 5) {
weekS = "FRI";
}
if (weekDay == 6) {
weekS = "SAT";
}
if (weekDay == 7) {
weekS = "SUN";
}
cron = second + " " + minute + " " + hour + " ? * " + weekS;
} catch (Exception e) {
throw new BookBizException(BookBizException.ERROR, "时间格式错误");
}
ScheduleJob scheduleJob = new ScheduleJob();
scheduleJob.setJobGroup("book");
scheduleJob.setJobName(ADVERTISING_PUT_PLAN_SCHEDULE_PRE + advertisingPut.getId());
scheduleJob.setCronExpression(cron);
CallBackParam callBackParam = new CallBackParam();
Map<String, Object> paramMap = new HashMap<>();
//定时任务调用时用到的参数
paramMap.put("advertisingPutId", advertisingPut.getId());
callBackParam.setParamMap(paramMap);
callBackParam.setMethodName("sendAdvertisingPlan");
callBackParam.setBeanName("advertisingSpaceService");
Map<String, Object> scheduleMap = new HashMap<>();
scheduleMap.put("scheduleJob", scheduleJob);
scheduleMap.put("callBackParam", callBackParam);
try {
scheduleService.addCronJob(scheduleMap);
} catch (Exception e) {
LOGGER.error("设置定时任务失败" + e.getMessage(), e);
throw new BookBizException(BookBizException.ERROR, "定时任务设置失败");
}
}
@ParamLog("按天设置定时任务")
private void putDay(AdvertisingPut advertisingPut) {
String cron;
String putTime = advertisingPut.getPutTime();
try {
int hour = Integer.parseInt(putTime.substring(0, 2));
int minute = Integer.parseInt(putTime.substring(3, 5));
int second = Integer.parseInt(putTime.substring(6, 8));
cron = second + " " + minute + " " + hour + " * * ?";
} catch (Exception e) {
throw new BookBizException(BookBizException.ERROR, "时间格式错误");
}
ScheduleJob scheduleJob = new ScheduleJob();
scheduleJob.setJobGroup("book");
scheduleJob.setJobName(ADVERTISING_PUT_PLAN_SCHEDULE_PRE + advertisingPut.getId());
scheduleJob.setCronExpression(cron);
CallBackParam callBackParam = new CallBackParam();
Map<String, Object> paramMap = new HashMap<>();
//定时任务调用时用到的参数
paramMap.put("advertisingPutId", advertisingPut.getId());
callBackParam.setParamMap(paramMap);
callBackParam.setMethodName("sendAdvertisingPlan");
callBackParam.setBeanName("advertisingSpaceService");
Map<String, Object> scheduleMap = new HashMap<>();
scheduleMap.put("scheduleJob", scheduleJob);
scheduleMap.put("callBackParam", callBackParam);
try {
scheduleService.addCronJob(scheduleMap);
} catch (Exception e) {
LOGGER.error("设置定时任务失败" + e.getMessage(), e);
throw new BookBizException(BookBizException.ERROR, "定时任务设置失败");
}
}
@ParamLog("单次设置定时任务")
private void putOne(AdvertisingPut advertisingPut) {
Long second = (DateUtils.StringToDateTime(advertisingPut.getPutTime()).getTime() - System.currentTimeMillis()) / 1000;
ScheduleJob scheduleJob = new ScheduleJob();
scheduleJob.setJobGroup("book");
scheduleJob.setStartTimeFormat("ss");
scheduleJob.setStartTime(second.intValue());
scheduleJob.setRepeatCount(0);
scheduleJob.setIntervalTime(0);
scheduleJob.setIntervalTimeFormat("dd");
scheduleJob.setJobName(ADVERTISING_PUT_PLAN_SCHEDULE_PRE + advertisingPut.getId());
CallBackParam callBackParam = new CallBackParam();
Map<String, Object> paramMap = new HashMap<>();
//定时任务调用时用到的参数
paramMap.put("advertisingPutId", advertisingPut.getId());
callBackParam.setParamMap(paramMap);
callBackParam.setMethodName("sendAdvertisingPlan");
callBackParam.setBeanName("advertisingSpaceService");
Map<String, Object> scheduleMap = new HashMap<>();
scheduleMap.put("scheduleJob", scheduleJob);
scheduleMap.put("callBackParam", callBackParam);
try {
scheduleService.addSimpleJob(scheduleMap);
} catch (Exception e) {
LOGGER.error("设置定时任务失败" + e.getMessage(), e);
throw new BookBizException(BookBizException.ERROR, "定时任务设置失败");
}
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("修改广告位计划")
@Override
public void updateAdvertisingPlan(AdvertisingPlan advertisingPlan) {
advertisingPlanCheck.checkCreateAdvertisingPlan(advertisingPlan);
Long planId = advertisingPlan.getId();
AdvertisingPlan advertisingPlanOld = advertisingPlanDao.getById(planId);
if (advertisingPlanOld == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "没有找到该计划");
}
Long partyId = advertisingPlan.getUpdateUser();
List<AdvertisingPut> oldAdvertisingPuts = advertisingPutDao.getListByPlanId(planId);
//先删除旧的定时任务
deleteAdvertisingPlanQuartz(oldAdvertisingPuts);
//处理计划项
List<Long> oldAdvertisingPutIds = oldAdvertisingPuts.stream().map(AdvertisingPut::getId).collect(Collectors.toList());
List<Long> advertisingPutIdsToDelete = oldAdvertisingPutIds;
for (AdvertisingPut advertisingPut : advertisingPlan.getAdvertisingPuts()) {
if (advertisingPut.getId() == null) {
advertisingPut.setCreateUser(partyId);
advertisingPut.setUpdateUser(partyId);
advertisingPut.setAdvertisingPlanId(planId);
//新增
advertisingPutDao.insert(advertisingPut);
} else {
//修改
advertisingPut.setUpdateUser(partyId);
advertisingPutDao.update(advertisingPut);
advertisingPutIdsToDelete.remove(advertisingPut.getId());
}
}
if (!ListUtils.isEmpty(advertisingPutIdsToDelete)) {
advertisingPutDao.deleteByIds(advertisingPutIdsToDelete, partyId);
}
//处理关联关系
List<AdvertisingPlanGroup> advertisingPlanGroupsOld = advertisingPlanGroupDao.getListByPlanId(planId);
List<Long> oldAdvertisingPlanGroupIds = advertisingPlanGroupsOld.stream().map(AdvertisingPlanGroup::getId).collect(Collectors.toList());
List<Long> advertisingPlanGroupIdsToDelete = oldAdvertisingPlanGroupIds;
for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlan.getAdvertisingPlanGroups()) {
Long planGroupId = advertisingPlanGroup.getId();
if (planGroupId == null) {
advertisingPlanGroup.setCreateUser(partyId);
advertisingPlanGroup.setUpdateUser(partyId);
advertisingPlanGroup.setAdvertisingPlanId(planId);
//新增
advertisingPlanGroupDao.insert(advertisingPlanGroup);
} else {
//修改
advertisingPlanGroup.setUpdateUser(partyId);
advertisingPlanGroupDao.update(advertisingPlanGroup);
advertisingPlanGroupIdsToDelete.remove(planGroupId);
}
}
if (!ListUtils.isEmpty(advertisingPlanGroupIdsToDelete)) {
advertisingPlanGroupDao.deleteByIds(advertisingPlanGroupIdsToDelete, partyId);
}
//设置新的定时任务
for (AdvertisingPut advertisingPut : advertisingPlan.getAdvertisingPuts()) {
createAdvertisingPlanQuartz(advertisingPut);
}
}
@ParamLog("发送广告位计划")
@Override
public void sendAdvertisingPlan(Long advertisingPutId) {
AdvertisingPut advertisingPut = advertisingPutDao.getById(advertisingPutId);
if (advertisingPut == null) {
return;
}
//判断时间范围
if (PutTypeEnum.WEEK.value.equals(advertisingPut.getPutType()) || PutTypeEnum.DAY.value.equals(advertisingPut.getPutType())) {
Date dateNow = new Date();
Date startTime = advertisingPut.getStartTime();
Date endTime = advertisingPut.getEndTime();
if (startTime != null && dateNow.before(startTime)) {
return;
}
if (endTime != null && dateNow.after(endTime)) {
return;
}
}
Long planId = advertisingPut.getAdvertisingPlanId();
Long spaceId = advertisingPut.getAdvertisingSpaceId();
//查询关联群
List<AdvertisingPlanGroup> planGroups = advertisingPlanGroupDao.getListByPlanId(planId);
if (ListUtils.isEmpty(planGroups)) {
return;
}
//要发送的广告
AdvertisingSpace advertisingSpace = advertisingSpaceDao.getById(spaceId);
if (advertisingSpace == null) {
return;
}
List<Long> bookGroupIds = planGroups.stream().filter(s -> s.getBookGroupId() != null).map(AdvertisingPlanGroup::getBookGroupId).distinct().collect(Collectors.toList());
List<BookGroupDTO> bookGroupDTOS = bookGroupDao.getDTOByIds(bookGroupIds);
Map<Long, BookGroupDTO> map = new HashMap<>();
for (BookGroupDTO bookGroupDTO : bookGroupDTOS) {
map.put(bookGroupDTO.getId(), bookGroupDTO);
}
AdvertisingDistributionBook adBook = new AdvertisingDistributionBook();
adBook.setAdId(spaceId);
List<DistributionWechatGroup> groups = new ArrayList<>();
for (AdvertisingPlanGroup advertisingPlanGroup : planGroups) {
DistributionWechatGroup distributionWechatGroup = new DistributionWechatGroup();
distributionWechatGroup.setBookId(advertisingPlanGroup.getBookId());
distributionWechatGroup.setClassifyId(advertisingPlanGroup.getClassifyId());
distributionWechatGroup.setQrcodeId(advertisingPlanGroup.getQrcodeId());
BookGroupDTO bookGroupDTO = map.get(advertisingPlanGroup.getBookGroupId());
if (bookGroupDTO != null) {
distributionWechatGroup.setChannelId(bookGroupDTO.getChannelId());
distributionWechatGroup.setAdviserId(bookGroupDTO.getCreateUser());
groups.add(distributionWechatGroup);
}
}
adBook.setGroups(groups);
//投放微信群
distributeWechatGroup(adBook, true);
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("删除广告位计划")
@Override
public void deleteAdvertisingPlan(Long advertisingPlanId, Long partyId) {
//删除计划
advertisingPlanDao.deleteById(advertisingPlanId);
//删除关联
advertisingPlanGroupDao.deleteByPlanId(advertisingPlanId, partyId);
List<AdvertisingPut> oldAdvertisingPuts = advertisingPutDao.getListByPlanId(advertisingPlanId);
//先删除旧的定时任务
deleteAdvertisingPlanQuartz(oldAdvertisingPuts);
List<Long> putIds = oldAdvertisingPuts.stream().map(AdvertisingPut::getId).collect(Collectors.toList());
//批量删除广告位定时投放
advertisingPutDao.deleteByIds(putIds, partyId);
}
@ParamLog("获取广告位计划")
@Override
public AdvertisingPlan getAdvertisingPlan(Long advertisingPlanId) {
AdvertisingPlan advertisingPlan = advertisingPlanDao.getById(advertisingPlanId);
if (advertisingPlan == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "没有该广告位计划");
}
List<AdvertisingPut> advertisingPuts = advertisingPutDao.getListByPlanId(advertisingPlanId);
List<AdvertisingPlanGroup> advertisingPlanGroups = advertisingPlanGroupDao.getListByPlanId(advertisingPlanId);
advertisingPlan.setAdvertisingPlanGroups(advertisingPlanGroups);
List<Long> spaceIds = advertisingPuts.stream().map(AdvertisingPut::getAdvertisingSpaceId).collect(Collectors.toList());
List<AdvertisingSpace> advertisingSpaces = advertisingSpaceDao.getByIds(spaceIds);
Map<Long, AdvertisingSpace> map = new HashMap<>();
for (AdvertisingSpace advertisingSpace : advertisingSpaces) {
map.put(advertisingSpace.getId(), advertisingSpace);
}
//填充广告位
for (AdvertisingPut advertisingPut : advertisingPuts) {
Long spaceId = advertisingPut.getAdvertisingSpaceId();
advertisingPut.setAdvertisingSpace(map.get(spaceId));
}
advertisingPlan.setAdvertisingPuts(advertisingPuts);
return advertisingPlan;
}
@ParamLog("获取广告位计划列表")
@Override
public PageBeanNew<AdvertisingPlan> getAdvertisingPlanList(String keyword, Long partyId, Integer currentPage, Integer numPerPage) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> map = new HashMap<>();
map.put("keyword", keyword);
map.put("partyId", partyId);
PageBeanNew<AdvertisingPlan> page = advertisingPlanDao.listPageNew(pageParam, map, "getAdvertisingPlanList");
List<AdvertisingPlan> advertisingPlans = page.getRecordList();
if (!ListUtils.isEmpty(advertisingPlans)) {
//填充一些信息
List<Long> planIds = advertisingPlans.stream().map(AdvertisingPlan::getId).collect(Collectors.toList());
List<AdvertisingPut> advertisingPuts = advertisingPutDao.getListByPlanIds(planIds);
List<Long> spaceIds = advertisingPuts.stream().filter(s -> s.getAdvertisingSpaceId() != null).map(AdvertisingPut::getAdvertisingSpaceId).distinct().collect(Collectors.toList());
List<AdvertisingSpace> advertisingSpaces = advertisingSpaceDao.getByIds(spaceIds);
Map<Long, AdvertisingSpace> spaceMap = new HashMap<>();
for (AdvertisingSpace advertisingSpace : advertisingSpaces) {
spaceMap.put(advertisingSpace.getId(), advertisingSpace);
}
//填充广告位
for (AdvertisingPut advertisingPut : advertisingPuts) {
Long spaceId = advertisingPut.getAdvertisingSpaceId();
advertisingPut.setAdvertisingSpace(spaceMap.get(spaceId));
}
//每个计划对应的广告项集合
Map<Long, List<AdvertisingPut>> planPutMap = advertisingPuts.stream().collect(Collectors.groupingBy(AdvertisingPut::getAdvertisingPlanId));
List<AdvertisingPlanGroup> advertisingPlanGroups = advertisingPlanGroupDao.getListByPlanIds(planIds);
List<Long> qrcodeIds = advertisingPlanGroups.stream().map(AdvertisingPlanGroup::getQrcodeId).collect(Collectors.toList());
List<WeixinClassifyInfoDTO> weixinClassifyInfoDTOS = groupQrcodeDao.getGroupInfoByQrcodeId(qrcodeIds);
Map<Long, WeixinClassifyInfoDTO> infoMap = new HashMap<>();
for (WeixinClassifyInfoDTO weixinClassifyInfoDTO : weixinClassifyInfoDTOS) {
infoMap.put(weixinClassifyInfoDTO.getQrcodeId(), weixinClassifyInfoDTO);
}
for (AdvertisingPlanGroup advertisingPlanGroup : advertisingPlanGroups) {
Long qrcodeId = advertisingPlanGroup.getQrcodeId();
WeixinClassifyInfoDTO weixinClassifyInfoDTO = infoMap.get(qrcodeId);
if (weixinClassifyInfoDTO != null) {
advertisingPlanGroup.setBookName(weixinClassifyInfoDTO.getBookName());
advertisingPlanGroup.setGroupQrcodeName(weixinClassifyInfoDTO.getGroupQrcodeName());
advertisingPlanGroup.setClassify(weixinClassifyInfoDTO.getClassify());
advertisingPlanGroup.setWeixinGroupName(weixinClassifyInfoDTO.getWeixinGroupName());
}
}
Map<Long, List<AdvertisingPlanGroup>> planGroupMap = advertisingPlanGroups.stream().collect(Collectors.groupingBy(AdvertisingPlanGroup::getAdvertisingPlanId));
for (AdvertisingPlan advertisingPlan : advertisingPlans) {
Long planId = advertisingPlan.getId();
advertisingPlan.setAdvertisingPuts(planPutMap.get(planId));
advertisingPlan.setAdvertisingPlanGroups(planGroupMap.get(planId));
}
}
return page;
}
@ParamLog("删除定时任务")
private void deleteAdvertisingPlanQuartz(List<AdvertisingPut> advertisingPuts) {
for (AdvertisingPut advertisingPut : advertisingPuts) {
try {
scheduleService.deleteJob(ADVERTISING_PUT_PLAN_SCHEDULE_PRE + advertisingPut.getId(), "book");
} catch (Exception e) {
LOGGER.error("删除定时任务失败");
}
}
}
@ParamLog("填充一些参数")
private void buildPutAndGroup(AdvertisingPlan advertisingPlan) {
Long planId = advertisingPlan.getId();
Long partId = advertisingPlan.getCreateUser();
for (AdvertisingPut advertisingPut : advertisingPlan.getAdvertisingPuts()) {
advertisingPut.setAdvertisingPlanId(planId);
advertisingPut.setCreateUser(partId);
advertisingPut.setUpdateUser(partId);
}
for (AdvertisingPlanGroup advertisingPutGroup : advertisingPlan.getAdvertisingPlanGroups()) {
advertisingPutGroup.setAdvertisingPlanId(planId);
advertisingPutGroup.setCreateUser(partId);
advertisingPutGroup.setUpdateUser(partId);
}
}
} }
package com.pcloud.book.advertising.check;
import com.pcloud.book.advertising.entity.AdvertisingPlan;
import com.pcloud.book.advertising.entity.AdvertisingPut;
import com.pcloud.book.advertising.entity.AdvertisingPlanGroup;
import com.pcloud.book.advertising.enums.PutTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils;
import org.springframework.stereotype.Component;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 16:13
**/
@Component("advertisingPlanCheck")
public class AdvertisingPlanCheck {
@ParamLog("新增广告位计划参数校验")
public void checkCreateAdvertisingPlan(AdvertisingPlan advertisingPlan) {
if (ListUtils.isEmpty(advertisingPlan.getAdvertisingPuts())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "广告位定时投放不能为空!");
}
if (ListUtils.isEmpty(advertisingPlan.getAdvertisingPlanGroups())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "关联群不能为空!");
}
for (AdvertisingPut advertisingPut : advertisingPlan.getAdvertisingPuts()) {
if (advertisingPut == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "广告位定时投放不能为空!");
}
if (advertisingPut.getAdvertisingSpaceId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "广告位id不能为空!");
}
if (advertisingPut.getPutType() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "投放类型不能为空!");
}
if (advertisingPut.getPutTime() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "投放时间不能为空!");
}
if (PutTypeEnum.DAY.value.equals(advertisingPut.getPutType()) || PutTypeEnum.DAY.value.equals(advertisingPut.getPutType())) {
if (advertisingPut.getStartTime() == null || advertisingPut.getEndTime() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "开始时间结束时间不能为空!");
}
}
}
for (AdvertisingPlanGroup advertisingPutGroup : advertisingPlan.getAdvertisingPlanGroups()) {
if (advertisingPutGroup == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "广告位计划关联不能为空!");
}
if (advertisingPutGroup.getBookId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "bookId不能为空!");
}
if (advertisingPutGroup.getBookGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "bookGroupId不能为空!");
}
if (advertisingPutGroup.getClassifyId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "分类不能为空!");
}
if (advertisingPutGroup.getQrcodeId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "群id不能为空!");
}
if (advertisingPutGroup.getWeixinGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "微信群号不能为空!");
}
}
}
}
package com.pcloud.book.advertising.dao;
import com.pcloud.book.advertising.entity.AdvertisingPlan;
import com.pcloud.common.core.dao.BaseDao;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 15:36
**/
public interface AdvertisingPlanDao extends BaseDao<AdvertisingPlan> {
}
package com.pcloud.book.advertising.dao;
import com.pcloud.book.advertising.entity.AdvertisingPlanGroup;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface AdvertisingPlanGroupDao extends BaseDao<AdvertisingPlanGroup> {
Integer batchInsert(List<AdvertisingPlanGroup> advertisingPlanGroups);
/**
* 根据计划id查询
*/
List<AdvertisingPlanGroup> getListByPlanId(Long planId);
/**
* 批量删除
*/
void deleteByIds(List<Long> ids, Long partyId);
/**
* 根据计划id删除
*/
void deleteByPlanId(Long planId, Long partyId);
/**
* 根据计划id集合查询
*/
List<AdvertisingPlanGroup> getListByPlanIds(List<Long> planIds);
}
package com.pcloud.book.advertising.dao;
import com.pcloud.book.advertising.entity.AdvertisingPut;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface AdvertisingPutDao extends BaseDao<AdvertisingPut> {
Integer batchInsert(List<AdvertisingPut> advertisingPuts);
/**
* 根据计划id查询
*/
List<AdvertisingPut> getListByPlanId(Long planId);
/**
* 根据id集合删除
*/
void deleteByIds(List<Long> ids, Long partyId);
/**
* 根据计划id结合查询
*/
List<AdvertisingPut> getListByPlanIds(List<Long> planIds);
}
package com.pcloud.book.advertising.dao.impl;
import com.pcloud.book.advertising.dao.AdvertisingPlanDao;
import com.pcloud.book.advertising.entity.AdvertisingPlan;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 15:37
**/
@Repository("advertisingPlanDao")
public class AdvertisingPlanDaoImpl extends BaseDaoImpl<AdvertisingPlan> implements AdvertisingPlanDao {
}
package com.pcloud.book.advertising.dao.impl;
import com.pcloud.book.advertising.dao.AdvertisingPlanGroupDao;
import com.pcloud.book.advertising.entity.AdvertisingPlanGroup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 15:37
**/
@Repository("advertisingPlanGroupDao")
public class AdvertisingPlanGroupDaoImpl extends BaseDaoImpl<AdvertisingPlanGroup> implements AdvertisingPlanGroupDao {
@Override
public Integer batchInsert(List<AdvertisingPlanGroup> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public List<AdvertisingPlanGroup> getListByPlanId(Long planId) {
return super.getSqlSession().selectList(getStatement("getListByPlanId"), planId);
}
@Override
public void deleteByIds(List<Long> ids, Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("ids", ids);
map.put("partyId", partyId);
super.getSqlSession().delete(getStatement("deleteByIds"), map);
}
@Override
public void deleteByPlanId(Long planId, Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("planId", planId);
map.put("partyId", partyId);
super.getSqlSession().delete(getStatement("deleteByPlanId"), map);
}
@Override
public List<AdvertisingPlanGroup> getListByPlanIds(List<Long> planIds) {
Map<String, Object> map = new HashMap<>();
map.put("planIds", planIds);
return super.getSqlSession().selectList(getStatement("getListByPlanIds"), map);
}
}
package com.pcloud.book.advertising.dao.impl;
import com.pcloud.book.advertising.dao.AdvertisingPutDao;
import com.pcloud.book.advertising.entity.AdvertisingPut;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 15:37
**/
@Repository("advertisingPutDao")
public class AdvertisingPutDaoImpl extends BaseDaoImpl<AdvertisingPut> implements AdvertisingPutDao {
@Override
public Integer batchInsert(List<AdvertisingPut> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public List<AdvertisingPut> getListByPlanId(Long planId) {
return super.getSqlSession().selectList(getStatement("getListByPlanId"), planId);
}
@Override
public void deleteByIds(List<Long> ids, Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("ids", ids);
map.put("partyId", partyId);
super.getSqlSession().delete(getStatement("deleteByIds"), map);
}
@Override
public List<AdvertisingPut> getListByPlanIds(List<Long> planIds) {
Map<String, Object> map = new HashMap<>();
map.put("planIds", planIds);
return super.getSqlSession().selectList(getStatement("getListByPlanIds"), map);
}
}
package com.pcloud.book.advertising.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/28 17:24
**/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WeixinClassifyInfoDTO implements Serializable {
private static final long serialVersionUID = 6382137896580487792L;
@ApiModelProperty("书id")
private Long bookId;
@ApiModelProperty("书名")
private String bookName;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("分类名称")
private String classify;
@ApiModelProperty("社群id")
private Long bookGroupId;
@ApiModelProperty("社群码名称")
private String groupQrcodeName;
@ApiModelProperty("社群书群id")
private Long qrcodeId;
@ApiModelProperty("微信群id")
private String weixinGroupId;
@ApiModelProperty("微信群名称")
private String weixinGroupName;
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public String getGroupQrcodeName() {
return groupQrcodeName;
}
public void setGroupQrcodeName(String groupQrcodeName) {
this.groupQrcodeName = groupQrcodeName;
}
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public String getWeixinGroupId() {
return weixinGroupId;
}
public void setWeixinGroupId(String weixinGroupId) {
this.weixinGroupId = weixinGroupId;
}
public String getWeixinGroupName() {
return weixinGroupName;
}
public void setWeixinGroupName(String weixinGroupName) {
this.weixinGroupName = weixinGroupName;
}
@Override
public String toString() {
return "WeixinClassifyInfoDTO{" +
"bookId=" + bookId +
", bookName='" + bookName + '\'' +
", classifyId=" + classifyId +
", classify='" + classify + '\'' +
", bookGroupId=" + bookGroupId +
", groupQrcodeName='" + groupQrcodeName + '\'' +
", qrcodeId=" + qrcodeId +
", weixinGroupId='" + weixinGroupId + '\'' +
", weixinGroupName='" + weixinGroupName + '\'' +
'}';
}
}
package com.pcloud.book.advertising.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 15:02
**/
@ApiModel("广告位投放计划id")
public class AdvertisingPlan extends BaseEntity {
private static final long serialVersionUID = 6433715659057254836L;
@ApiModelProperty("是否删除")
private Boolean isDelete;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
private List<AdvertisingPut> advertisingPuts;
private List<AdvertisingPlanGroup> advertisingPlanGroups;
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
public List<AdvertisingPut> getAdvertisingPuts() {
return advertisingPuts;
}
public void setAdvertisingPuts(List<AdvertisingPut> advertisingPuts) {
this.advertisingPuts = advertisingPuts;
}
public List<AdvertisingPlanGroup> getAdvertisingPlanGroups() {
return advertisingPlanGroups;
}
public void setAdvertisingPlanGroups(List<AdvertisingPlanGroup> advertisingPlanGroups) {
this.advertisingPlanGroups = advertisingPlanGroups;
}
@Override
public String toString() {
return "AdvertisingPlan{" +
"isDelete=" + isDelete +
", createUser=" + createUser +
", updateUser=" + updateUser +
", advertisingPuts=" + advertisingPuts +
", advertisingPlanGroups=" + advertisingPlanGroups +
"} " + super.toString();
}
}
package com.pcloud.book.advertising.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 15:06
**/
@ApiModel("广告位投放关联")
public class AdvertisingPlanGroup extends BaseEntity {
private static final long serialVersionUID = 6369920743164721663L;
@ApiModelProperty("广告位计划id")
private Long advertisingPlanId;
@ApiModelProperty("书id")
private Long bookId;
@ApiModelProperty("社群id")
private Long bookGroupId;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("社群书群id")
private Long qrcodeId;
@ApiModelProperty("微信群id")
private String weixinGroupId;
@ApiModelProperty("是否删除")
private Boolean isDelete;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
@ApiModelProperty("书名")
private String bookName;
@ApiModelProperty("社群码名称")
private String groupQrcodeName;
@ApiModelProperty("分类名称")
private String classify;
@ApiModelProperty("微信群名称")
private String weixinGroupName;
public Long getAdvertisingPlanId() {
return advertisingPlanId;
}
public void setAdvertisingPlanId(Long advertisingPlanId) {
this.advertisingPlanId = advertisingPlanId;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public String getWeixinGroupId() {
return weixinGroupId;
}
public void setWeixinGroupId(String weixinGroupId) {
this.weixinGroupId = weixinGroupId;
}
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getGroupQrcodeName() {
return groupQrcodeName;
}
public void setGroupQrcodeName(String groupQrcodeName) {
this.groupQrcodeName = groupQrcodeName;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
public String getWeixinGroupName() {
return weixinGroupName;
}
public void setWeixinGroupName(String weixinGroupName) {
this.weixinGroupName = weixinGroupName;
}
@Override
public String toString() {
return "AdvertisingPlanGroup{" +
"advertisingPlanId=" + advertisingPlanId +
", bookId=" + bookId +
", bookGroupId=" + bookGroupId +
", classifyId=" + classifyId +
", qrcodeId=" + qrcodeId +
", weixinGroupId='" + weixinGroupId + '\'' +
", isDelete=" + isDelete +
", createUser=" + createUser +
", updateUser=" + updateUser +
", bookName='" + bookName + '\'' +
", groupQrcodeName='" + groupQrcodeName + '\'' +
", classify='" + classify + '\'' +
", weixinGroupName='" + weixinGroupName + '\'' +
"} " + super.toString();
}
}
package com.pcloud.book.advertising.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/6/27 14:55
**/
@ApiModel("广告位定时投放模型")
public class AdvertisingPut extends BaseEntity {
private static final long serialVersionUID = 6433715659057254836L;
@ApiModelProperty("广告位id")
private Long advertisingSpaceId;
@ApiModelProperty("广告位计划id")
private Long advertisingPlanId;
@ApiModelProperty("投放时间类型(1:单次发送 2:每天发送 3:每周发送)")
private Integer putType;
@ApiModelProperty("投放时间")
private String putTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("开始时间")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("结束时间")
private Date endTime;
@ApiModelProperty("周几")
private Integer weekDay;
@ApiModelProperty("是否删除")
private Boolean isDelete;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
@ApiModelProperty("广告位")
private AdvertisingSpace advertisingSpace;
public Long getAdvertisingSpaceId() {
return advertisingSpaceId;
}
public void setAdvertisingSpaceId(Long advertisingSpaceId) {
this.advertisingSpaceId = advertisingSpaceId;
}
public Long getAdvertisingPlanId() {
return advertisingPlanId;
}
public void setAdvertisingPlanId(Long advertisingPlanId) {
this.advertisingPlanId = advertisingPlanId;
}
public Integer getPutType() {
return putType;
}
public void setPutType(Integer putType) {
this.putType = putType;
}
public String getPutTime() {
return putTime;
}
public void setPutTime(String putTime) {
this.putTime = putTime;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Integer getWeekDay() {
return weekDay;
}
public void setWeekDay(Integer weekDay) {
this.weekDay = weekDay;
}
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
public AdvertisingSpace getAdvertisingSpace() {
return advertisingSpace;
}
public void setAdvertisingSpace(AdvertisingSpace advertisingSpace) {
this.advertisingSpace = advertisingSpace;
}
@Override
public String toString() {
return "AdvertisingPut{" +
"advertisingSpaceId=" + advertisingSpaceId +
", advertisingPlanId=" + advertisingPlanId +
", putType=" + putType +
", putTime='" + putTime + '\'' +
", startTime=" + startTime +
", endTime=" + endTime +
", weekDay=" + weekDay +
", isDelete=" + isDelete +
", createUser=" + createUser +
", updateUser=" + updateUser +
", advertisingSpace=" + advertisingSpace +
"} " + super.toString();
}
}
package com.pcloud.book.advertising.enums;
public enum PutTypeEnum {
/**
* 单次发送
*/
ONE(1),
/**
* 每天发送
*/
DAY(2),
/**
* 每周
*/
WEEK(3);
public final Integer value;
PutTypeEnum(Integer value) {
this.value = value;
}
}
...@@ -858,4 +858,41 @@ public interface AdvertisingSpaceFacade { ...@@ -858,4 +858,41 @@ public interface AdvertisingSpaceFacade {
@PostMapping("updateTestStatus") @PostMapping("updateTestStatus")
public ResponseDto<?> updateTestStatus(@RequestHeader("token") String token, @RequestBody @ApiParam TestParamDTO testParamDTO) throws PermissionException; public ResponseDto<?> updateTestStatus(@RequestHeader("token") String token, @RequestBody @ApiParam TestParamDTO testParamDTO) throws PermissionException;
@ApiOperation("创建广告位计划")
@PostMapping("createAdvertisingPlan")
ResponseDto<?> createAdvertisingPlan(
@RequestHeader("token") String token,
@RequestBody @ApiParam("广告位计划") AdvertisingPlan advertisingPlan
) throws PermissionException, BizException, JsonParseException;
@ApiOperation("修改广告位计划")
@PostMapping("updateAdvertisingPlan")
ResponseDto<?> updateAdvertisingPlan(
@RequestHeader("token") String token,
@RequestBody @ApiParam("广告位计划") AdvertisingPlan advertisingPlan
) throws PermissionException, BizException, JsonParseException;
@ApiOperation("删除广告位计划")
@GetMapping("deleteAdvertisingPlan")
ResponseDto<?> deleteAdvertisingPlan(
@RequestHeader("token") String token,
@RequestParam @ApiParam("广告位计划id") Long advertisingPlanId
) throws PermissionException, BizException, JsonParseException;
@ApiOperation("获取广告位计划")
@GetMapping("getAdvertisingPlan")
ResponseDto<?> getAdvertisingPlan(
@RequestHeader("token") String token,
@RequestParam @ApiParam("广告位计划id") Long advertisingPlanId
) throws PermissionException, BizException, JsonParseException;
@ApiOperation("获取广告位计划列表")
@GetMapping("getAdvertisingPlanList")
ResponseDto<?> getAdvertisingPlanList(
@RequestHeader("token") String token,
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws PermissionException, BizException, JsonParseException;
} }
...@@ -133,7 +133,7 @@ public class AdvertisingSpaceFacadeImpl implements AdvertisingSpaceFacade { ...@@ -133,7 +133,7 @@ public class AdvertisingSpaceFacadeImpl implements AdvertisingSpaceFacade {
if (null == advertisingDistributionBook) { if (null == advertisingDistributionBook) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!"); throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
} }
advertisingSpaceBiz.distributeWechatGroup(advertisingDistributionBook); advertisingSpaceBiz.distributeWechatGroup(advertisingDistributionBook, false);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -701,4 +701,84 @@ public class AdvertisingSpaceFacadeImpl implements AdvertisingSpaceFacade { ...@@ -701,4 +701,84 @@ public class AdvertisingSpaceFacadeImpl implements AdvertisingSpaceFacade {
return new ResponseDto<>(); return new ResponseDto<>();
} }
@ApiOperation("创建广告位计划")
@PostMapping("createAdvertisingPlan")
@Override
public ResponseDto<?> createAdvertisingPlan(
@RequestHeader("token") String token,
@RequestBody @ApiParam("广告位计划") AdvertisingPlan advertisingPlan
) throws PermissionException, BizException, JsonParseException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == advertisingPlan) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
}
advertisingPlan.setCreateUser(partyId);
advertisingPlan.setUpdateUser(partyId);
return new ResponseDto<>(advertisingSpaceBiz.createAdvertisingPlan(advertisingPlan));
}
@ApiOperation("修改广告位计划")
@PostMapping("updateAdvertisingPlan")
@Override
public ResponseDto<?> updateAdvertisingPlan(
@RequestHeader("token") String token,
@RequestBody @ApiParam("广告位计划") AdvertisingPlan advertisingPlan
) throws PermissionException, BizException, JsonParseException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == advertisingPlan) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
}
if (advertisingPlan.getId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "计划id不能为空!");
}
advertisingPlan.setUpdateUser(partyId);
advertisingSpaceBiz.updateAdvertisingPlan(advertisingPlan);
return new ResponseDto<>();
}
@ApiOperation("删除广告位计划")
@GetMapping("deleteAdvertisingPlan")
@Override
public ResponseDto<?> deleteAdvertisingPlan(
@RequestHeader("token") String token,
@RequestParam @ApiParam("广告位计划id") Long advertisingPlanId
) throws PermissionException, BizException, JsonParseException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == advertisingPlanId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
}
advertisingSpaceBiz.deleteAdvertisingPlan(advertisingPlanId,partyId);
return new ResponseDto<>();
}
@ApiOperation("获取广告位计划")
@GetMapping("getAdvertisingPlan")
@Override
public ResponseDto<?> getAdvertisingPlan(
@RequestHeader("token") String token,
@RequestParam @ApiParam("广告位计划id") Long advertisingPlanId
) throws PermissionException, BizException, JsonParseException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == advertisingPlanId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
}
return new ResponseDto<>(advertisingSpaceBiz.getAdvertisingPlan(advertisingPlanId));
}
@ApiOperation("获取广告位计划列表")
@GetMapping("getAdvertisingPlanList")
@Override
public ResponseDto<?> getAdvertisingPlanList(
@RequestHeader("token") String token,
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws PermissionException, BizException, JsonParseException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage==null||currentPage<0||numPerPage==null||numPerPage<=0){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"分页参数错误");
}
return new ResponseDto<>(advertisingSpaceBiz.getAdvertisingPlanList(keyword,partyId,currentPage,numPerPage));
}
} }
package com.pcloud.book.advertising.service.impl; package com.pcloud.book.advertising.service.impl;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.pcloud.book.advertising.biz.AdvertisingSpaceBiz; import com.pcloud.book.advertising.biz.AdvertisingSpaceBiz;
import com.pcloud.book.advertising.service.AdvertisingSpaceService; import com.pcloud.book.advertising.service.AdvertisingSpaceService;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import java.util.Map;
/** /**
* Description 广告位内部接口实现类 * Description 广告位内部接口实现类
* Created by PENG on 2019/5/6. * Created by PENG on 2019/5/6.
...@@ -16,6 +19,8 @@ import com.pcloud.common.exceptions.BizException; ...@@ -16,6 +19,8 @@ import com.pcloud.common.exceptions.BizException;
@RequestMapping("advertisingSpaceService") @RequestMapping("advertisingSpaceService")
public class AdvertisingSpaceServiceImpl implements AdvertisingSpaceService { public class AdvertisingSpaceServiceImpl implements AdvertisingSpaceService {
private static final Logger LOGGER = LoggerFactory.getLogger(AdvertisingSpaceServiceImpl.class);
@Autowired @Autowired
private AdvertisingSpaceBiz advertisingSpaceBiz; private AdvertisingSpaceBiz advertisingSpaceBiz;
...@@ -27,4 +32,12 @@ public class AdvertisingSpaceServiceImpl implements AdvertisingSpaceService { ...@@ -27,4 +32,12 @@ public class AdvertisingSpaceServiceImpl implements AdvertisingSpaceService {
public void calculateAdvertisingIncomeYesterday() throws BizException { public void calculateAdvertisingIncomeYesterday() throws BizException {
advertisingSpaceBiz.calculateAdvertisingIncomeYesterday(); advertisingSpaceBiz.calculateAdvertisingIncomeYesterday();
} }
@ApiOperation("发送广告计划")
@PostMapping("sendAdvertisingPlan")
@Override
public void sendAdvertisingPlan(@RequestBody Map<String, Object> map) throws BizException {
LOGGER.info("内部接口群发广告被调用"+map.toString());
advertisingSpaceBiz.sendAdvertisingPlan(new Long(map.get("advertisingPutId").toString()));
}
} }
...@@ -253,4 +253,18 @@ public class WechatGroupConsr { ...@@ -253,4 +253,18 @@ public class WechatGroupConsr {
} }
return map; return map;
} }
@ParamLog(value = "根据群id集合最近7天活跃人数")
public Map<Long,Integer> get7DayActiveUserCountByQrcode(List<Long> qrcodeIds) {
Map<Long, Integer> map = new HashMap<>();
try {
map = ResponseHandleUtil.parseMapResponse(messageService.get7DayActiveUserCountByQrcode(qrcodeIds), Long.class, Integer.class);
} catch (Exception e) {
log.error("根据群id集合最近7天活跃人数.[get7DayActiveUserCountByQrcode]:" + e.getMessage(), e);
}
if (map == null) {
return new HashMap<>();
}
return map;
}
} }
package com.pcloud.book.group.dao; package com.pcloud.book.group.dao;
import com.pcloud.book.advertising.dto.WeixinClassifyInfoDTO;
import com.pcloud.book.group.dto.ChangeGroupNameDTO; import com.pcloud.book.group.dto.ChangeGroupNameDTO;
import com.pcloud.book.group.dto.GroupAndUserNumberDTO; import com.pcloud.book.group.dto.GroupAndUserNumberDTO;
import com.pcloud.book.group.dto.GroupQrcodeDTO; import com.pcloud.book.group.dto.GroupQrcodeDTO;
...@@ -185,6 +186,11 @@ public interface GroupQrcodeDao extends BaseDao<GroupQrcode> { ...@@ -185,6 +186,11 @@ public interface GroupQrcodeDao extends BaseDao<GroupQrcode> {
List<Long> listQrcodeIdsByLabelQuery(Map<String, Object> paramMap); List<Long> listQrcodeIdsByLabelQuery(Map<String, Object> paramMap);
/** /**
* 根据id集合查询微信群相关信息
*/
List<WeixinClassifyInfoDTO> getGroupInfoByQrcodeId(List<Long> ids);
/**
* 过滤删除的群二维码id * 过滤删除的群二维码id
* @param wxGroupIdList * @param wxGroupIdList
* @return * @return
......
...@@ -2,6 +2,7 @@ package com.pcloud.book.group.dao.impl; ...@@ -2,6 +2,7 @@ package com.pcloud.book.group.dao.impl;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.pcloud.book.advertising.dto.WeixinClassifyInfoDTO;
import com.pcloud.book.group.dao.GroupQrcodeDao; import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.dto.ChangeGroupNameDTO; import com.pcloud.book.group.dto.ChangeGroupNameDTO;
import com.pcloud.book.group.dto.GroupAndUserNumberDTO; import com.pcloud.book.group.dto.GroupAndUserNumberDTO;
...@@ -176,6 +177,12 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou ...@@ -176,6 +177,12 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
return this.getSqlSession().selectList(getStatement("listQrcodeIdsByLabelQuery"),paramMap); return this.getSqlSession().selectList(getStatement("listQrcodeIdsByLabelQuery"),paramMap);
} }
@Override
public List<WeixinClassifyInfoDTO> getGroupInfoByQrcodeId(List<Long> ids) {
Map<String, Object> map = new HashMap<>();
map.put("ids", ids);
return this.getSqlSession().selectList(getStatement("getGroupInfoByQrcodeId"),map);
}
@Override @Override
public List<Long> filterDeleteQrcodeId(List<String> wxGroupIdList) { public List<Long> filterDeleteQrcodeId(List<String> wxGroupIdList) {
......
...@@ -66,6 +66,18 @@ public class GroupQrcodeVO implements Serializable { ...@@ -66,6 +66,18 @@ public class GroupQrcodeVO implements Serializable {
@ApiModelProperty("目的标签名称") @ApiModelProperty("目的标签名称")
private String purLabelName; private String purLabelName;
@ApiModelProperty("用户数量")
private Integer userNumber;
@ApiModelProperty("7天活跃人数")
private Integer weekActiveCount;
@ApiModelProperty("ISBN编号")
private String isbn;
@ApiModelProperty("微信群名称")
private String weixinGroupId;
public Long getClassifyId() { public Long getClassifyId() {
return classifyId; return classifyId;
...@@ -211,6 +223,38 @@ public class GroupQrcodeVO implements Serializable { ...@@ -211,6 +223,38 @@ public class GroupQrcodeVO implements Serializable {
this.purLabelName = purLabelName; this.purLabelName = purLabelName;
} }
public Integer getUserNumber() {
return userNumber;
}
public void setUserNumber(Integer userNumber) {
this.userNumber = userNumber;
}
public Integer getWeekActiveCount() {
return weekActiveCount;
}
public void setWeekActiveCount(Integer weekActiveCount) {
this.weekActiveCount = weekActiveCount;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getWeixinGroupId() {
return weixinGroupId;
}
public void setWeixinGroupId(String weixinGroupId) {
this.weixinGroupId = weixinGroupId;
}
@Override @Override
public String toString() { public String toString() {
return "GroupQrcodeVO{" + return "GroupQrcodeVO{" +
...@@ -231,6 +275,10 @@ public class GroupQrcodeVO implements Serializable { ...@@ -231,6 +275,10 @@ public class GroupQrcodeVO implements Serializable {
", depLabelName='" + depLabelName + '\'' + ", depLabelName='" + depLabelName + '\'' +
", purLabelId=" + purLabelId + ", purLabelId=" + purLabelId +
", purLabelName='" + purLabelName + '\'' + ", purLabelName='" + purLabelName + '\'' +
", userNumber=" + userNumber +
", weekActiveCount=" + weekActiveCount +
", isbn='" + isbn + '\'' +
", weixinGroupId='" + weixinGroupId + '\'' +
'}'; '}';
} }
} }
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.advertising.dao.impl.AdvertisingPlanGroupDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.advertising.entity.AdvertisingPlanGroup">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="advertising_plan_id" property="advertisingPlanId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/>
<result column="weixin_group_id" property="weixinGroupId" jdbcType="VARCHAR"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, advertising_plan_id, book_id, book_group_id, classify_id, qrcode_id,
weixin_group_id, is_delete, create_user, create_time, update_user, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from advertising_plan_group
where id = #{id}
</select>
<update id="deleteById" parameterType="java.lang.Long">
update advertising_plan_group
set is_delete=1
where id = #{id}
</update>
<insert id="insert" parameterType="com.pcloud.book.advertising.entity.AdvertisingPlanGroup"
useGeneratedKeys="true" keyProperty="id">
insert into advertising_plan_group
<trim prefix="(" suffix=")" suffixOverrides=",">
advertising_plan_id,
book_id,
book_group_id,
classify_id,
qrcode_id,
weixin_group_id,
is_delete,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{advertisingPlanId,jdbcType=BIGINT},
#{bookId,jdbcType=BIGINT},
#{bookGroupId,jdbcType=BIGINT},
#{classifyId,jdbcType=BIGINT},
#{qrcodeId,jdbcType=BIGINT},
#{weixinGroupId,jdbcType=VARCHAR},
0,
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.advertising.entity.AdvertisingPlanGroup">
update advertising_plan_group
<set>
<if test="advertisingPlanId != null">
advertising_plan_id = #{advertisingPlanId,jdbcType=BIGINT},
</if>
<if test="bookId != null">
book_id = #{bookId,jdbcType=BIGINT},
</if>
<if test="bookGroupId != null">
book_group_id = #{bookGroupId,jdbcType=INTEGER},
</if>
<if test="classifyId != null">
classify_id = #{classifyId,jdbcType=VARCHAR},
</if>
<if test="qrcodeId != null">
qrcode_id = #{qrcodeId,jdbcType=TIMESTAMP},
</if>
<if test="weixinGroupId != null">
weixin_group_id = #{weixinGroupId,jdbcType=TIMESTAMP},
</if>
<if test="isDelete != null">
is_delete = #{isDelete,jdbcType=BOOLEAN},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=BIGINT},
</if>
update_time=now()
</set>
where id = #{id}
</update>
<!--批量插入-->
<insert id="batchInsert" parameterType="com.pcloud.book.advertising.entity.AdvertisingPlanGroup" useGeneratedKeys="true" keyProperty="id">
insert into advertising_plan_group (
advertising_plan_id,
book_id,
book_group_id,
classify_id,
qrcode_id,
weixin_group_id,
is_delete,
create_user,
create_time,
update_user,
update_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.advertisingPlanId,jdbcType=BIGINT},
#{item.bookId,jdbcType=BIGINT},
#{item.bookGroupId,jdbcType=BIGINT},
#{item.classifyId,jdbcType=BIGINT},
#{item.qrcodeId,jdbcType=BIGINT},
#{item.weixinGroupId,jdbcType=VARCHAR},
0,
#{item.createUser,jdbcType=BIGINT},
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
<!--根据计划id查询 -->
<select id="getListByPlanId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from advertising_plan_group
where is_delete=0 and advertising_plan_id=#{planId}
</select>
<!--批量删除-->
<update id="deleteByIds" parameterType="Long">
UPDATE
advertising_plan_group
SET is_delete = 1,
update_user = #{partyId},
update_time = now()
WHERE id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
</update>
<!--根据计划id删除-->
<update id="deleteByPlanId" parameterType="map">
UPDATE
advertising_plan_group
SET is_delete = 1,
update_user = #{partyId},
update_time = now()
WHERE advertising_plan_id=#{planId}
</update>
<!--根据计划id集合查询-->
<select id="getListByPlanIds" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from advertising_plan_group t
where t.is_delete=0 and advertising_plan_id in
<foreach collection="planIds" item="item" open="(" separator="," close=")">
${item}
</foreach>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.advertising.dao.impl.AdvertisingPlanDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.advertising.entity.AdvertisingPlan">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, is_delete, create_user, create_time, update_user, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from advertising_plan
where is_delete=0 and id = #{id}
</select>
<update id="deleteById" parameterType="java.lang.Long">
update advertising_plan
set is_delete=1
where id = #{id}
</update>
<insert id="insert" parameterType="com.pcloud.book.advertising.entity.AdvertisingPlan"
useGeneratedKeys="true" keyProperty="id">
insert into advertising_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
is_delete,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
0,
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<!--查询列表-->
<select id="getAdvertisingPlanList" parameterType="map" resultMap="BaseResultMap">
SELECT
t1.id,
t1.is_delete,
t1.create_user,
t1.create_time,
t1.update_user,
t1.update_time
FROM
advertising_plan t1
<if test="keyword!=null">
LEFT JOIN advertising_put t2 ON t1.id = t2.advertising_plan_id
LEFT JOIN advertising_plan_group t3 ON t1.id = t3.advertising_plan_id
LEFT JOIN advertising_space t4 ON t2.advertising_space_id = t4.id
LEFT JOIN book t5 ON t3.book_id = t5.BOOK_ID
LEFT JOIN book_group_qrcode t6 ON qrcode_id = t6.id
</if>
WHERE
t1.is_delete = 0
AND t1.create_user=#{partyId}
<if test="keyword!=null">
AND (
t5.BOOK_NAME LIKE concat('%', #{keyword}, '%')
OR t6.group_name LIKE concat('%', #{keyword}, '%')
OR t4.ad_name LIKE concat('%', #{keyword}, '%')
)
</if>
GROUP BY t1.id
order by t1.create_time desc
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.advertising.dao.impl.AdvertisingPutDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.advertising.entity.AdvertisingPut">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="advertising_space_id" property="advertisingSpaceId" jdbcType="BIGINT"/>
<result column="advertising_plan_id" property="advertisingPlanId" jdbcType="BIGINT"/>
<result column="put_type" property="putType" jdbcType="INTEGER"/>
<result column="put_time" property="putTime" jdbcType="VARCHAR"/>
<result column="start_time" property="startTime" jdbcType="TIMESTAMP"/>
<result column="end_time" property="endTime" jdbcType="TIMESTAMP"/>
<result column="week_day" property="weekDay" jdbcType="INTEGER"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, advertising_space_id, advertising_plan_id, put_type, put_time, start_time,
end_time, week_day, is_delete, create_user, create_time, update_user, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from advertising_put
where id = #{id}
</select>
<update id="deleteById" parameterType="java.lang.Long">
update advertising_put
set is_delete=1
where id = #{id}
</update>
<insert id="insert" parameterType="com.pcloud.book.advertising.entity.AdvertisingPut"
useGeneratedKeys="true" keyProperty="id">
insert into advertising_put
<trim prefix="(" suffix=")" suffixOverrides=",">
advertising_space_id,
advertising_plan_id,
put_type,
put_time,
start_time,
end_time,
week_day,
is_delete,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{advertisingSpaceId,jdbcType=BIGINT},
#{advertisingPlanId,jdbcType=BIGINT},
#{putType,jdbcType=INTEGER},
#{putTime,jdbcType=VARCHAR},
#{startTime,jdbcType=TIMESTAMP},
#{endTime,jdbcType=TIMESTAMP},
#{weekDay,jdbcType=INTEGER},
0,
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.advertising.entity.AdvertisingPut">
update advertising_put
<set>
<if test="advertisingSpaceId != null">
advertising_space_id = #{advertisingSpaceId,jdbcType=BIGINT},
</if>
<if test="advertisingPlanId != null">
advertising_plan_id = #{advertisingPlanId,jdbcType=BIGINT},
</if>
<if test="putType != null">
put_type = #{putType,jdbcType=INTEGER},
</if>
<if test="putTime != null">
put_time = #{putTime,jdbcType=VARCHAR},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
<if test="weekDay != null">
week_day = #{weekDay,jdbcType=INTEGER},
</if>
<if test="isDelete != null">
is_delete = #{isDelete,jdbcType=BOOLEAN},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=BIGINT},
</if>
update_time=now()
</set>
where id = #{id}
</update>
<!--批量插入-->
<insert id="batchInsert" parameterType="com.pcloud.book.advertising.entity.AdvertisingPut" useGeneratedKeys="true" keyProperty="id">
insert into advertising_put (
advertising_space_id,
advertising_plan_id,
put_type,
put_time,
start_time,
end_time,
week_day,
is_delete,
create_user,
create_time,
update_user,
update_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.advertisingSpaceId,jdbcType=BIGINT},
#{item.advertisingPlanId,jdbcType=BIGINT},
#{item.putType,jdbcType=INTEGER},
#{item.putTime,jdbcType=VARCHAR},
#{item.startTime,jdbcType=TIMESTAMP},
#{item.endTime,jdbcType=TIMESTAMP},
#{item.weekDay,jdbcType=INTEGER},
0,
#{item.createUser,jdbcType=BIGINT},
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
<!--根据计划id查询-->
<select id="getListByPlanId" parameterType="Long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from advertising_put t
where t.is_delete=0 and advertising_plan_id=#{planId}
</select>
<!--批量删除-->
<update id="deleteByIds" parameterType="Long">
UPDATE
advertising_put
SET is_delete = 1,
update_user = #{partyId},
update_time = now()
WHERE id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
</update>
<!--根据计划id集合查询-->
<select id="getListByPlanIds" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from advertising_put t
where t.is_delete=0 and advertising_plan_id in
<foreach collection="planIds" item="item" open="(" separator="," close=")">
${item}
</foreach>
</select>
</mapper>
\ No newline at end of file
...@@ -409,11 +409,14 @@ ...@@ -409,11 +409,14 @@
SELECT SELECT
g.id groupQrcodeId, g.id groupQrcodeId,
g.group_name groupName, g.group_name groupName,
g.user_number userNumber,
g.weixin_group_id weixinGroupId,
c.id classifyId, c.id classifyId,
c.book_id bookId, c.book_id bookId,
c.channel_id channelId, c.channel_id channelId,
c.create_user adviserId, c.create_user adviserId,
b.BOOK_NAME bookName, b.BOOK_NAME bookName,
b.ISBN isbn,
c.classify, c.classify,
c.book_group_id bookGroupId, c.book_group_id bookGroupId,
g.group_name groupQrcodeName, g.group_name groupQrcodeName,
...@@ -453,6 +456,7 @@ ...@@ -453,6 +456,7 @@
book_name LIKE CONCAT('%', #{name},'%') book_name LIKE CONCAT('%', #{name},'%')
OR group_name LIKE CONCAT('%', #{name},'%') OR group_name LIKE CONCAT('%', #{name},'%')
OR classify LIKE CONCAT('%', #{name},'%') OR classify LIKE CONCAT('%', #{name},'%')
OR b.ISBN like CONCAT('%', #{name},'%')
) )
</if> </if>
<if test="depLabelId != null"> <if test="depLabelId != null">
......
...@@ -415,6 +415,27 @@ ...@@ -415,6 +415,27 @@
AND g.weixin_group_id != "" AND g.weixin_group_id != ""
</select> </select>
<!--根据id集合查询微信群相关信息-->
<select id="getGroupInfoByQrcodeId" parameterType="map" resultType="com.pcloud.book.advertising.dto.WeixinClassifyInfoDTO">
SELECT
t.id qrcodeId,
t.group_name weixinGroupName,
t1.id classifyId,
t1.classify classify,
t2.id bookGroupId,
t2.group_qrcode_name groupQrcodeName,
t3.BOOK_ID bookId,
t3.BOOK_NAME bookName
FROM
book_group_qrcode t
INNER JOIN book_group_classify t1 ON t.classify_id = t1.id
INNER JOIN book_group t2 ON t1.book_group_id = t2.id
INNER JOIN book t3 ON t2.book_id = t3.BOOK_ID
where t.id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
${item}
</foreach>
</select>
<select id="filterDeleteQrcodeId" resultType="Long" parameterType="list"> <select id="filterDeleteQrcodeId" resultType="Long" parameterType="list">
SELECT SELECT
......
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