Commit 8baf1905 by 朱亚洁

合并-广告位数据统计

parent f725f7e2
...@@ -72,7 +72,7 @@ public interface BmBiz { ...@@ -72,7 +72,7 @@ public interface BmBiz {
* @param wechatUserId * @param wechatUserId
* @return * @return
*/ */
Long userSubmit(AdvertisingBmRegister bmRegister, Long wechatUserId, Long qrcodeId); Long userSubmit(AdvertisingBmRegister bmRegister, Long wechatUserId);
/** /**
* 微信端获取个人报名详情 * 微信端获取个人报名详情
* @param adId 应用ID * @param adId 应用ID
...@@ -87,7 +87,7 @@ public interface BmBiz { ...@@ -87,7 +87,7 @@ public interface BmBiz {
* @param adId * @param adId
* @return * @return
*/ */
public Long getRegisterCountByAdId(Long adId, String statisMonth); public Long getRegisterCountByAdId(Long adId, String statisMonth, Long bookId, Long adviserId, Long channelId);
/** /**
* 获取微信群报名次数 * 获取微信群报名次数
...@@ -109,5 +109,14 @@ public interface BmBiz { ...@@ -109,5 +109,14 @@ public interface BmBiz {
* 导出报名表单 * 导出报名表单
* @param adId * @param adId
*/ */
Map<String, Object> exportRegisterInfoByAdId(Long adId,Long qrcodeId); Map<String, Object> exportRegisterInfoByAdId(Long adId, Long qrcodeId, String statisMonth, Long bookId, Long adviserId, Long channelId);
/**
* 获取微信群报名人数
* @param qrcodeId
* @param adId
* @param statisMonth
* @return
*/
Long getRegisterUserNumByAdIdQrcodeId(Long qrcodeId, Long adId, String statisMonth);
} }
...@@ -14,8 +14,13 @@ import com.pcloud.book.advertising.entity.AdvertisingBmOption; ...@@ -14,8 +14,13 @@ import com.pcloud.book.advertising.entity.AdvertisingBmOption;
import com.pcloud.book.advertising.entity.AdvertisingBmOptionItem; import com.pcloud.book.advertising.entity.AdvertisingBmOptionItem;
import com.pcloud.book.advertising.entity.AdvertisingBmRegister; import com.pcloud.book.advertising.entity.AdvertisingBmRegister;
import com.pcloud.book.advertising.entity.AdvertisingBmRegisterItem; import com.pcloud.book.advertising.entity.AdvertisingBmRegisterItem;
import com.pcloud.book.advertising.entity.AdvertisingSpace;
import com.pcloud.book.advertising.enums.AdPositionEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.reader.ReaderConsr; import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.ChannelConsr;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.util.common.ExcelUtils; import com.pcloud.book.util.common.ExcelUtils;
import com.pcloud.common.entity.UploadResultInfo; import com.pcloud.common.entity.UploadResultInfo;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -23,7 +28,6 @@ import com.pcloud.common.exceptions.ExportException; ...@@ -23,7 +28,6 @@ import com.pcloud.common.exceptions.ExportException;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.aliyun.OssUtils; import com.pcloud.common.utils.aliyun.OssUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.validate.ValidateUtils;
import com.pcloud.readercenter.wechat.entity.WechatUser; import com.pcloud.readercenter.wechat.entity.WechatUser;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
...@@ -49,6 +53,7 @@ import java.util.ArrayList; ...@@ -49,6 +53,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
/** /**
...@@ -74,6 +79,10 @@ public class BmBizImpl implements BmBiz { ...@@ -74,6 +79,10 @@ public class BmBizImpl implements BmBiz {
private BmRegisterItemDao bmRegisterItemDao; private BmRegisterItemDao bmRegisterItemDao;
@Autowired @Autowired
private AdvertisingSpaceDao advertisingSpaceDao; private AdvertisingSpaceDao advertisingSpaceDao;
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private ChannelConsr channelConsr;
/** /**
* 获取报名商品选项类型 * 获取报名商品选项类型
...@@ -252,21 +261,48 @@ public class BmBizImpl implements BmBiz { ...@@ -252,21 +261,48 @@ public class BmBizImpl implements BmBiz {
} }
@Override @Override
public Long userSubmit(AdvertisingBmRegister bmRegister, Long wechatUserId, Long qrcodeId) { public Long userSubmit(AdvertisingBmRegister bmRegister, Long wechatUserId) {
// 检测参数 // 检测参数
Long adId = bmRegister.getAdId(); Long adId = bmRegister.getAdId();
if (adId == null) { if (adId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
} }
AdvertisingSpace space = advertisingSpaceDao.getById(adId);
// 获取用户昵称 if (null == space) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "广告位不存在或已删除!");
}
List<AdvertisingBmRegisterItem> items = bmRegister.getBmRegisterItemList();
if (ListUtils.isEmpty(items)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请填写表单");
}
Long mobilePhoneOptionId = bmOptionDao.getMobilePhoneOptionIdByAd(adId);
Optional<AdvertisingBmRegisterItem> itemOptional = items.stream().filter(s -> s != null && s.getOptionId() == mobilePhoneOptionId).findFirst();
if (itemOptional.isPresent()) {// 存在
AdvertisingBmRegisterItem registerItem = itemOptional.get();
if (null != registerItem && !StringUtil.isEmpty(registerItem.getOptionValue())) {
Integer count = bmRegisterItemDao.checkMobilePhone(adId, bmRegister.getFromType(), bmRegister.getFromId(), registerItem.getOptionValue());
if (count > 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "手机号已存在");
}
}
}
if ("WECHAT_GROUP".equals(bmRegister.getFromType())) {
BookGroup bookGroup = bookGroupDao.getById(bmRegister.getBookGroupId());
if (null == bookGroup) {
return 0L;
}
bmRegister.setBookId(bookGroup.getBookId());
bmRegister.setChannelId(bookGroup.getChannelId());
bmRegister.setAdviserId(bookGroup.getCreateUser());
}
Long agentId = channelConsr.getParentId(bmRegister.getChannelId());
bmRegister.setAgentId(agentId);
WechatUser wechat = readerConsr.getWechatUser(wechatUserId); WechatUser wechat = readerConsr.getWechatUser(wechatUserId);
bmRegister.setNickName(wechat == null ? "" : wechat.getWechatUserNickname()); bmRegister.setNickName(wechat == null ? "" : wechat.getWechatUserNickname());
bmRegister.setQrcodeId(qrcodeId);
bmRegisterDao.insert(bmRegister); bmRegisterDao.insert(bmRegister);
Long registerId = bmRegister.getId(); Long registerId = bmRegister.getId();
// 添加用户选项 // 添加用户选项
addRegisterItem(bmRegister.getBmRegisterItemList(), adId, wechatUserId, registerId); addRegisterItem(items, adId, wechatUserId, registerId);
return registerId; return registerId;
} }
...@@ -320,8 +356,8 @@ public class BmBizImpl implements BmBiz { ...@@ -320,8 +356,8 @@ public class BmBizImpl implements BmBiz {
} }
@Override @Override
public Long getRegisterCountByAdId(Long adId,String statisMonth) { public Long getRegisterCountByAdId(Long adId, String statisMonth, Long bookId, Long adviserId, Long channelId) {
return bmRegisterDao.getRegisterCountByAdId(adId,statisMonth); return bmRegisterDao.getRegisterCountByAdId(adId, statisMonth, bookId, adviserId, channelId);
} }
@Override @Override
...@@ -338,18 +374,23 @@ public class BmBizImpl implements BmBiz { ...@@ -338,18 +374,23 @@ public class BmBizImpl implements BmBiz {
} }
@Override @Override
public Map<String, Object> exportRegisterInfoByAdId(Long adId,Long qrcodeId) { public Map<String, Object> exportRegisterInfoByAdId(Long adId, Long qrcodeId, String statisMonth, Long bookId, Long adviserId, Long channelId){
Map<String, Object> result = new HashMap<>(); AdvertisingSpaceDTO spaceDTO = advertisingSpaceDao.getDTOById(adId);
Long registerCount = bmRegisterDao.getRegisterCountByAdId(adId,null); if (null == spaceDTO) {
if (registerCount == 0) { throw new BookBizException(BookBizException.PARAM_IS_ERROR, "广告位不存在!");
}
List<BmRegisterDTO> registerDtos = new ArrayList<>();
if (AdPositionEnum.WECHAT_GROUP_MSG.positionCode.equals(spaceDTO.getAdPosition())) {
registerDtos = bmRegisterDao.getRegisterInfoListByAdIdQrcodeId(adId, statisMonth, qrcodeId);
} else {
registerDtos = bmRegisterDao.getRegisterInfoListByAdId(adId, statisMonth, bookId, adviserId, channelId);
}
if (ListUtils.isEmpty(registerDtos)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "无报名信息!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "无报名信息!");
} }
Map<String, Object> result = new HashMap<>();
try { try {
String title = "报名用户信息"; String title = spaceDTO.getAdName() + "-客户信息";
AdvertisingSpaceDTO advertisingSpaceDTO = advertisingSpaceDao.getDTOById(adId);
if (null != advertisingSpaceDTO) {
title = advertisingSpaceDTO.getAdName() + "-" + title;
}
List<AdvertisingBmOption> optionList = bmOptionDao.getByAdId(adId); List<AdvertisingBmOption> optionList = bmOptionDao.getByAdId(adId);
List<String> rowsNameList = new ArrayList<>(); List<String> rowsNameList = new ArrayList<>();
rowsNameList.add("序号"); rowsNameList.add("序号");
...@@ -360,9 +401,7 @@ public class BmBizImpl implements BmBiz { ...@@ -360,9 +401,7 @@ public class BmBizImpl implements BmBiz {
rowsNameList.add(option.getItemTitle()); rowsNameList.add(option.getItemTitle());
} }
String[] rowsName = rowsNameList.toArray(new String[0]); String[] rowsName = rowsNameList.toArray(new String[0]);
String fileUrl = ""; String filePath = exportRegisterInfo(title, rowsName, optionList, registerDtos);
//异步导出
String filePath = exportRegisterInfo(title, rowsName, adId, optionList, qrcodeId);
result.put("fileName", title); result.put("fileName", title);
result.put("filePath", filePath); result.put("filePath", filePath);
return result; return result;
...@@ -376,8 +415,11 @@ public class BmBizImpl implements BmBiz { ...@@ -376,8 +415,11 @@ public class BmBizImpl implements BmBiz {
} }
} }
private String exportRegisterInfo(String title, String[] rowsName, Long adId, List<AdvertisingBmOption> optionList, Long qrcodeId) { /**
LOGGER.info("导出相关信息:adId=" + adId + ",optionList=" + optionList); * excel数据导出
*/
private String exportRegisterInfo(String title, String[] rowsName, List<AdvertisingBmOption> optionList,List<BmRegisterDTO> registerDtos) {
LOGGER.info("导出相关信息:registerDtos=" + registerDtos + ",optionList=" + optionList);
SXSSFWorkbook wb = new SXSSFWorkbook(200); SXSSFWorkbook wb = new SXSSFWorkbook(200);
int columnNum = rowsName.length; int columnNum = rowsName.length;
int rowIndex = 0; int rowIndex = 0;
...@@ -407,7 +449,6 @@ public class BmBizImpl implements BmBiz { ...@@ -407,7 +449,6 @@ public class BmBizImpl implements BmBiz {
//准备初始数据 //准备初始数据
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int k = 1; int k = 1;
List<BmRegisterDTO> registerDtos = bmRegisterDao.exportRegisterInfoById(adId, qrcodeId);
if (!ListUtils.isEmpty(registerDtos)) { if (!ListUtils.isEmpty(registerDtos)) {
//excel数据准备 //excel数据准备
this.exportExcelByDataList(registerDtos, dataStyle, k, rowIndex, sheet, optionList, df); this.exportExcelByDataList(registerDtos, dataStyle, k, rowIndex, sheet, optionList, df);
...@@ -438,15 +479,8 @@ public class BmBizImpl implements BmBiz { ...@@ -438,15 +479,8 @@ public class BmBizImpl implements BmBiz {
/** /**
* excel数据导出 * excel数据导出
* @param registerDtos
* @param dataStyle
* @param k
* @param rowIndex
* @param sheet
* @param optionList
* @param df
*/ */
private void exportExcelByDataList(List<BmRegisterDTO> registerDtos,CellStyle dataStyle,int k,int rowIndex,SXSSFSheet sheet,List<AdvertisingBmOption> optionList,SimpleDateFormat df){ private void exportExcelByDataList(List<BmRegisterDTO> registerDtos, CellStyle dataStyle, int k, int rowIndex, SXSSFSheet sheet, List<AdvertisingBmOption> optionList, SimpleDateFormat df) {
LOGGER.info("excel数据导出"); LOGGER.info("excel数据导出");
for (BmRegisterDTO registerDto : registerDtos) { for (BmRegisterDTO registerDto : registerDtos) {
SXSSFRow srow = sheet.createRow(++rowIndex); SXSSFRow srow = sheet.createRow(++rowIndex);
...@@ -478,4 +512,10 @@ public class BmBizImpl implements BmBiz { ...@@ -478,4 +512,10 @@ public class BmBizImpl implements BmBiz {
} }
} }
} }
@Override
public Long getRegisterUserNumByAdIdQrcodeId(Long qrcodeId, Long adId, String statisMonth) {
return bmRegisterDao.getRegisterUserNumByAdIdQrcodeId(qrcodeId,adId,statisMonth);
}
} }
...@@ -19,4 +19,31 @@ public interface AdvertisingClickRecordDao extends BaseDao<AdvertisingClickRecor ...@@ -19,4 +19,31 @@ public interface AdvertisingClickRecordDao extends BaseDao<AdvertisingClickRecor
* @return * @return
*/ */
List<WechatGroupClickUserDTO> clickUserList4AdvertisingWechatGroup(Map<String, Object> paramMap); List<WechatGroupClickUserDTO> clickUserList4AdvertisingWechatGroup(Map<String, Object> paramMap);
/**
* 获得点击人数
* @param masterId
* @return
*/
public Long getClickUserNumByMasterId(Long masterId);
/**
* 微信群点击人数
* @param qrcodeId
* @param adId
* @param statisMonth
* @return
*/
Long getClickUserNumByQrcode(Long qrcodeId, Long adId, String statisMonth);
/**
* 广告点击人数
* @param adId
* @param bookId
*@param adviserId
* @param channelId
* @param statisMonth @return
*/
Long getClickUserNumByAdId(Long adId, Long bookId, Long adviserId, Long channelId, String statisMonth);
} }
...@@ -33,4 +33,11 @@ public interface BmOptionDao extends BaseDao<AdvertisingBmOption> { ...@@ -33,4 +33,11 @@ public interface BmOptionDao extends BaseDao<AdvertisingBmOption> {
* @return * @return
*/ */
List<Long> getOptionIdsByAdId(Long adId); List<Long> getOptionIdsByAdId(Long adId);
/**
* 查手机号选项id
* @param adId
* @return
*/
Long getMobilePhoneOptionIdByAd(Long adId);
} }
...@@ -27,7 +27,7 @@ public interface BmRegisterDao extends BaseDao<AdvertisingBmRegister> { ...@@ -27,7 +27,7 @@ public interface BmRegisterDao extends BaseDao<AdvertisingBmRegister> {
* @param adId * @param adId
* @return * @return
*/ */
Long getRegisterCountByAdId(Long adId, String statisMonth); public Long getRegisterCountByAdId(Long adId, String statisMonth, Long bookId, Long adviserId, Long channelId);;
/** /**
* 报名数量 * 报名数量
...@@ -37,18 +37,40 @@ public interface BmRegisterDao extends BaseDao<AdvertisingBmRegister> { ...@@ -37,18 +37,40 @@ public interface BmRegisterDao extends BaseDao<AdvertisingBmRegister> {
Long getRegisterCountByAdIds(List<Long> adIdList); Long getRegisterCountByAdIds(List<Long> adIdList);
/** /**
* 查报名信息 * 获取微信群报名次数
* @param adId * @param adId
* @param statisMonth
* @param qrcodeId
* @return * @return
*/ */
List<BmRegisterDTO> exportRegisterInfoById(Long adId, Long qrcodeId); Long getRegisterCountByAdIdQrcodeId(Long adId, String statisMonth, Long qrcodeId);
/** /**
* 获取微信群报名次数 * 获取微信群报名人数
* @param qrcodeId
* @param adId
* @param statisMonth
* @return
*/
Long getRegisterUserNumByAdIdQrcodeId(Long qrcodeId, Long adId, String statisMonth);
/**
* 查微信群报名用户信息
* @param adId * @param adId
* @param statisMonth * @param statisMonth
* @param qrcodeId * @param qrcodeId
* @return * @return
*/ */
Long getRegisterCountByAdIdQrcodeId(Long adId, String statisMonth, Long qrcodeId); List<BmRegisterDTO> getRegisterInfoListByAdIdQrcodeId(Long adId, String statisMonth, Long qrcodeId);
/**
* 查报名用户信息
* @param adId
* @param statisMonth
* @param bookId
* @param adviserId
* @param channelId
* @return
*/
List<BmRegisterDTO> getRegisterInfoListByAdId(Long adId, String statisMonth, Long bookId, Long adviserId, Long channelId);
} }
...@@ -10,4 +10,13 @@ import com.pcloud.common.core.dao.BaseDao; ...@@ -10,4 +10,13 @@ import com.pcloud.common.core.dao.BaseDao;
* @版本:1.0 * @版本:1.0
*/ */
public interface BmRegisterItemDao extends BaseDao<AdvertisingBmRegisterItem> { public interface BmRegisterItemDao extends BaseDao<AdvertisingBmRegisterItem> {
/**
* 手机号是否有重复
* @param adId
* @param fromType
* @param optionValue
* @return
*/
Integer checkMobilePhone(Long adId, String fromType, Long fromId, String optionValue);
} }
package com.pcloud.book.advertising.dao.impl; package com.pcloud.book.advertising.dao.impl;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.pcloud.book.advertising.dao.AdvertisingClickRecordDao; import com.pcloud.book.advertising.dao.AdvertisingClickRecordDao;
import com.pcloud.book.advertising.dto.WechatGroupClickUserDTO; import com.pcloud.book.advertising.dto.WechatGroupClickUserDTO;
import com.pcloud.book.advertising.entity.AdvertisingClickRecord; import com.pcloud.book.advertising.entity.AdvertisingClickRecord;
import com.pcloud.common.core.dao.BaseDaoImpl; 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 广告位点击记录数据访问层接口实现类 * Description 广告位点击记录数据访问层接口实现类
* @author PENG * @author PENG
...@@ -23,4 +26,32 @@ public class AdvertisingClickRecordDaoImpl extends BaseDaoImpl<AdvertisingClickR ...@@ -23,4 +26,32 @@ public class AdvertisingClickRecordDaoImpl extends BaseDaoImpl<AdvertisingClickR
public List<WechatGroupClickUserDTO> clickUserList4AdvertisingWechatGroup(Map<String, Object> paramMap) { public List<WechatGroupClickUserDTO> clickUserList4AdvertisingWechatGroup(Map<String, Object> paramMap) {
return super.getSqlSession().selectList(getStatement("clickUserList4AdvertisingWechatGroup"), paramMap); return super.getSqlSession().selectList(getStatement("clickUserList4AdvertisingWechatGroup"), paramMap);
} }
@Override
public Long getClickUserNumByMasterId(Long masterId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("masterId", masterId);
Long clickNum = super.getSqlSession().selectOne(getStatement("getClickUserNumByMasterId"),paramMap);
return null == clickNum ? 0L : clickNum;
}
@Override
public Long getClickUserNumByQrcode(Long qrcodeId, Long adId, String statisMonth) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("qrcodeId", qrcodeId);
paramMap.put("adId", adId);
paramMap.put("statisMonth", statisMonth);
return getSessionTemplate().selectOne(getStatement("getClickUserNumByGroupQrcodeId"), paramMap);
}
@Override
public Long getClickUserNumByAdId(Long adId, Long bookId, Long adviserId, Long channelId, String statisMonth) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("adId", adId);
paramMap.put("statisMonth", statisMonth);
paramMap.put("adviserId", adviserId);
paramMap.put("channelId", channelId);
paramMap.put("statisMonth", statisMonth);
return getSessionTemplate().selectOne(getStatement("getClickUserNumByAdId"), paramMap);
}
} }
...@@ -30,4 +30,9 @@ public class BmOptionDaoImpl extends BaseDaoImpl<AdvertisingBmOption> implements ...@@ -30,4 +30,9 @@ public class BmOptionDaoImpl extends BaseDaoImpl<AdvertisingBmOption> implements
public List<Long> getOptionIdsByAdId(Long adId) { public List<Long> getOptionIdsByAdId(Long adId) {
return getSessionTemplate().selectList(getStatement("getOptionIdsByAdId"), adId); return getSessionTemplate().selectList(getStatement("getOptionIdsByAdId"), adId);
} }
@Override
public Long getMobilePhoneOptionIdByAd(Long adId) {
return getSessionTemplate().selectOne(getStatement("getMobilePhoneOptionIdByAd"),adId);
}
} }
...@@ -25,11 +25,14 @@ public class BmRegisterDaoImpl extends BaseDaoImpl<AdvertisingBmRegister> implem ...@@ -25,11 +25,14 @@ public class BmRegisterDaoImpl extends BaseDaoImpl<AdvertisingBmRegister> implem
} }
@Override @Override
public Long getRegisterCountByAdId(Long adId,String statisMonth) { public Long getRegisterCountByAdId(Long adId, String statisMonth, Long bookId, Long adviserId, Long channelId) {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("adId",adId); map.put("adId", adId);
map.put("statisMonth",statisMonth); map.put("statisMonth", statisMonth);
return getSessionTemplate().selectOne(getStatement("getRegisterCountByAdId"),map); map.put("bookId", bookId);
map.put("adviserId", adviserId);
map.put("channelId", channelId);
return getSessionTemplate().selectOne(getStatement("getRegisterCountByAdId"), map);
} }
@Override @Override
...@@ -38,19 +41,42 @@ public class BmRegisterDaoImpl extends BaseDaoImpl<AdvertisingBmRegister> implem ...@@ -38,19 +41,42 @@ public class BmRegisterDaoImpl extends BaseDaoImpl<AdvertisingBmRegister> implem
} }
@Override @Override
public List<BmRegisterDTO> exportRegisterInfoById(Long adId, Long qrcodeId) { public Long getRegisterCountByAdIdQrcodeId(Long adId, String statisMonth, Long qrcodeId) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("adId", adId); map.put("adId", adId);
map.put("statisMonth", statisMonth);
map.put("qrcodeId", qrcodeId); map.put("qrcodeId", qrcodeId);
return getSessionTemplate().selectList(getStatement("exportRegisterInfoById"), map); return getSessionTemplate().selectOne(getStatement("getRegisterCountByAdIdQrcodeId"), map);
} }
@Override @Override
public Long getRegisterCountByAdIdQrcodeId(Long adId, String statisMonth, Long qrcodeId) { public Long getRegisterUserNumByAdIdQrcodeId(Long qrcodeId, Long adId, String statisMonth) {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("adId",adId); map.put("adId", adId);
map.put("statisMonth",statisMonth); map.put("statisMonth", statisMonth);
map.put("qrcodeId",qrcodeId); map.put("qrcodeId", qrcodeId);
return getSessionTemplate().selectOne(getStatement("getRegisterCountByAdIdQrcodeId"),map); return getSessionTemplate().selectOne(getStatement("getRegisterUserNumByAdIdQrcodeId"), map);
}
@Override
public List<BmRegisterDTO> getRegisterInfoListByAdIdQrcodeId(Long adId, String statisMonth, Long qrcodeId) {
Map<String, Object> map = new HashMap<>();
map.put("adId", adId);
map.put("statisMonth", statisMonth);
map.put("qrcodeId", qrcodeId);
return getSessionTemplate().selectList(getStatement("getRegisterInfoListByAdIdQrcodeId"),map);
}
@Override
public List<BmRegisterDTO> getRegisterInfoListByAdId(Long adId, String statisMonth, Long bookId, Long adviserId, Long channelId) {
Map<String, Object> map = new HashMap<>();
map.put("adId", adId);
map.put("statisMonth", statisMonth);
map.put("bookId", bookId);
map.put("adviserId", adviserId);
map.put("channelId", channelId);
return getSessionTemplate().selectList(getStatement("getRegisterInfoListByAdId"),map);
} }
} }
...@@ -6,6 +6,9 @@ import com.pcloud.common.core.dao.BaseDaoImpl; ...@@ -6,6 +6,9 @@ import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/** /**
* @描述:报名选项记录 * @描述:报名选项记录
* @作者:zhuyajie * @作者:zhuyajie
...@@ -14,4 +17,14 @@ import org.springframework.stereotype.Component; ...@@ -14,4 +17,14 @@ import org.springframework.stereotype.Component;
*/ */
@Component("bmRegisterItemDao") @Component("bmRegisterItemDao")
public class BmRegisterItemDaoImpl extends BaseDaoImpl<AdvertisingBmRegisterItem> implements BmRegisterItemDao { public class BmRegisterItemDaoImpl extends BaseDaoImpl<AdvertisingBmRegisterItem> implements BmRegisterItemDao {
@Override
public Integer checkMobilePhone(Long adId,String fromType, Long fromId, String optionValue) {
Map<String, Object> map = new HashMap<>();
map.put("adId", adId);
map.put("fromType", fromType);
map.put("fromId",fromId);
map.put("optionValue", optionValue);
return getSessionTemplate().selectOne(getStatement("checkMobilePhone"), map);
}
} }
...@@ -38,6 +38,57 @@ public class AdvertisingBmRegister extends BaseEntity{ ...@@ -38,6 +38,57 @@ public class AdvertisingBmRegister extends BaseEntity{
*/ */
private Long qrcodeId; private Long qrcodeId;
/**
* 二维码ID
*/
private Long sceneId;
/**
* 编辑ID
*/
private Long adviserId;
/**
* 出版社ID
*/
private Long agentId;
/**
* 运营ID
*/
private Long channelId;
/**
* 公众号ID
*/
private Long officialAccountId;
/**
*来源类型
*/
private String fromType;
/**
* 来源ID
*/
private Long fromId;
/**
* 书刊ID
*/
private Long bookId;
/**
* 创建日期
*/
private Date createDay;
/**
* 创建月份
*/
private String createMonth;
/**
* 社群码ID
*/
private Long bookGroupId;
public Long getUserId() { public Long getUserId() {
return userId; return userId;
...@@ -87,6 +138,94 @@ public class AdvertisingBmRegister extends BaseEntity{ ...@@ -87,6 +138,94 @@ public class AdvertisingBmRegister extends BaseEntity{
this.qrcodeId = qrcodeId; this.qrcodeId = qrcodeId;
} }
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public Long getAgentId() {
return agentId;
}
public void setAgentId(Long agentId) {
this.agentId = agentId;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public Long getOfficialAccountId() {
return officialAccountId;
}
public void setOfficialAccountId(Long officialAccountId) {
this.officialAccountId = officialAccountId;
}
public String getFromType() {
return fromType;
}
public void setFromType(String fromType) {
this.fromType = fromType;
}
public Long getFromId() {
return fromId;
}
public void setFromId(Long fromId) {
this.fromId = fromId;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Date getCreateDay() {
return createDay;
}
public void setCreateDay(Date createDay) {
this.createDay = createDay;
}
public String getCreateMonth() {
return createMonth;
}
public void setCreateMonth(String createMonth) {
this.createMonth = createMonth;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
@Override @Override
public String toString() { public String toString() {
return "AdvertisingBmRegister{" + return "AdvertisingBmRegister{" +
...@@ -96,6 +235,17 @@ public class AdvertisingBmRegister extends BaseEntity{ ...@@ -96,6 +235,17 @@ public class AdvertisingBmRegister extends BaseEntity{
", createTime=" + createTime + ", createTime=" + createTime +
", bmRegisterItemList=" + bmRegisterItemList + ", bmRegisterItemList=" + bmRegisterItemList +
", qrcodeId=" + qrcodeId + ", qrcodeId=" + qrcodeId +
", sceneId=" + sceneId +
", adviserId=" + adviserId +
", agentId=" + agentId +
", channelId=" + channelId +
", officialAccountId=" + officialAccountId +
", fromType='" + fromType + '\'' +
", fromId=" + fromId +
", bookId=" + bookId +
", createDay=" + createDay +
", createMonth='" + createMonth + '\'' +
", bookGroupId=" + bookGroupId +
'}'; '}';
} }
} }
\ No newline at end of file
...@@ -92,13 +92,20 @@ public interface BmFacade { ...@@ -92,13 +92,20 @@ public interface BmFacade {
* @throws BizException * @throws BizException
* @throws JsonParseException * @throws JsonParseException
*/ */
@ApiOperation(value = "导出报名信息",httpMethod = "GET") @ApiOperation(value = "导出报名信息", httpMethod = "GET")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "adId",value = "广告位id",required = false,dataType = "Long",paramType = "query"), @ApiImplicitParam(name = "adId", value = "广告位id", required = false, dataType = "Long", paramType = "query"),
@ApiImplicitParam(name = "qrcodeId",value = "群二维码id",required = false,dataType = "Long",paramType = "query") @ApiImplicitParam(name = "qrcodeId", value = "群二维码id", required = false, dataType = "Long", paramType = "query"),
@ApiImplicitParam(name = "statisMonth", value = "月份", required = false, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "bookId", value = "bookId", required = false, dataType = "Long", paramType = "query"),
@ApiImplicitParam(name = "adviserId", value = "adviserId", required = false, dataType = "Long", paramType = "query"),
@ApiImplicitParam(name = "channelId", value = "channelId", required = false, dataType = "Long", paramType = "query")
}) })
@RequestMapping(value = "/exportRegisterInfoByAdId",method = RequestMethod.GET) @RequestMapping(value = "/exportRegisterInfoByAdId", method = RequestMethod.GET)
ResponseDto<Map<String, Object>> exportRegisterInfoByAdId(@RequestHeader("token")String token, @RequestParam("adId") Long adId, ResponseDto<Map<String, Object>> exportRegisterInfoByAdId(
@RequestParam(value = "qrcodeId",required = false) Long qrcodeId) @RequestHeader("token") String token, @RequestParam("adId") Long adId,
@RequestParam(value = "qrcodeId", required = false) Long qrcodeId, @RequestParam(value = "statisMonth", required = false) String statisMonth,
@RequestParam(value = "bookId", required = false) Long bookId, @RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId)
throws PermissionException, BizException, JsonParseException; throws PermissionException, BizException, JsonParseException;
} }
package com.pcloud.book.advertising.facade.impl; package com.pcloud.book.advertising.facade.impl;
import com.pcloud.book.advertising.biz.BmBiz; import com.pcloud.book.advertising.biz.BmBiz;
import com.pcloud.book.advertising.entity.AdvertisingBmOption;
import com.pcloud.book.advertising.entity.AdvertisingBmRegister; import com.pcloud.book.advertising.entity.AdvertisingBmRegister;
import com.pcloud.book.advertising.facade.BmFacade; import com.pcloud.book.advertising.facade.BmFacade;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
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;
import com.pcloud.common.utils.SessionUtil; import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie; import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil;
import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.JsonParseException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -24,8 +23,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -24,8 +23,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/** /**
* 报名 * 报名
*/ */
...@@ -63,16 +60,33 @@ public class BmFacadeImpl implements BmFacade { ...@@ -63,16 +60,33 @@ public class BmFacadeImpl implements BmFacade {
*/ */
@Override @Override
@RequestMapping(value = "/userSubmit4Wechat",method = RequestMethod.POST) @RequestMapping(value = "/userSubmit4Wechat",method = RequestMethod.POST)
public ResponseDto<?> userSubmit4Wechat(@CookieValue("userInfo") String userInfo, public ResponseDto<?> userSubmit4Wechat(@CookieValue("userInfo") String userInfo, @RequestBody AdvertisingBmRegister bmRegister)
@RequestBody AdvertisingBmRegister bmRegister)
throws PermissionException, BizException, JsonParseException { throws PermissionException, BizException, JsonParseException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID); if (null == bmRegister || null == bmRegister.getAdId()) {
Long qrcodeId = Cookie.getId(userInfo, Cookie.QRCODE_ID); throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
if (bmRegister == null) { }
if (StringUtil.isEmpty(bmRegister.getFromType()) || null == bmRegister.getFromId()) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
} }
Long qrcodeId = Cookie.getId(userInfo, Cookie.QRCODE_ID);
Long sceneId = Cookie.getId(userInfo, Cookie._SCENE_ID);
Long adviserId = Cookie.getId(userInfo, Cookie._ADVISER_ID);
Long channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID);
Long officialAccountsId = Cookie.getId(userInfo, Cookie._OFFICIAL_ACCOUNTS_ID);
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
Long bookGroupId = Cookie.getId(userInfo, Cookie.BOOK_GROUP_ID);
if ((null == bmRegister.getBookId() && !"WECHAT_GROUP".equals(bmRegister.getFromType()))
|| (null == bookGroupId && "WECHAT_GROUP".equals(bmRegister.getFromType()))) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
}
bmRegister.setQrcodeId(qrcodeId);
bmRegister.setSceneId(sceneId);
bmRegister.setAdviserId(adviserId);
bmRegister.setChannelId(channelId);
bmRegister.setOfficialAccountId(officialAccountsId);
bmRegister.setUserId(wechatUserId); bmRegister.setUserId(wechatUserId);
Long result = bmBiz.userSubmit(bmRegister, wechatUserId, qrcodeId); bmRegister.setBookGroupId(bookGroupId);
Long result = bmBiz.userSubmit(bmRegister, wechatUserId);
return new ResponseDto<>(result); return new ResponseDto<>(result);
} }
...@@ -95,15 +109,18 @@ public class BmFacadeImpl implements BmFacade { ...@@ -95,15 +109,18 @@ public class BmFacadeImpl implements BmFacade {
* 报名信息导出 * 报名信息导出
*/ */
@Override @Override
@RequestMapping(value = "/exportRegisterInfoByAdId",method = RequestMethod.GET) @RequestMapping(value = "/exportRegisterInfoByAdId", method = RequestMethod.GET)
public ResponseDto<Map<String, Object>> exportRegisterInfoByAdId( public ResponseDto<Map<String, Object>> exportRegisterInfoByAdId(
@RequestHeader("token")String token, @RequestParam("adId")Long adId, @RequestHeader("token") String token, @RequestParam("adId") Long adId,
@RequestParam(value = "qrcodeId",required = false) Long qrcodeId) throws PermissionException, BizException, JsonParseException { @RequestParam(value = "qrcodeId", required = false) Long qrcodeId,
if (null == adId){ @RequestParam(value = "statisMonth", required = false) String statisMonth,
@RequestParam(value = "bookId", required = false) Long bookId, @RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId) throws PermissionException, BizException, JsonParseException {
if (null == adId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
} }
SessionUtil.getInfoToken4Redis(token); SessionUtil.getInfoToken4Redis(token);
Map<String, Object> map =bmBiz.exportRegisterInfoByAdId(adId, qrcodeId); Map<String, Object> map = bmBiz.exportRegisterInfoByAdId(adId, qrcodeId, statisMonth, bookId, adviserId, channelId);
return new ResponseDto<>(map); return new ResponseDto<>(map);
} }
......
...@@ -86,4 +86,18 @@ ...@@ -86,4 +86,18 @@
WHERE ad_id = #{adId,jdbcType=BIGINT} WHERE ad_id = #{adId,jdbcType=BIGINT}
</select> </select>
<select id="getMobilePhoneOptionIdByAd" parameterType="Long" resultType="Long">
SELECT
id
FROM
advertising_bm_option
WHERE
ad_id = #{adId,jdbcType=BIGINT}
AND item_title = '手机号'
AND item_input_type = 'input'
AND item_data_type = 'mobile'
AND required = 1
LIMIT 1
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -50,5 +50,20 @@ ...@@ -50,5 +50,20 @@
b.seq ASC, b.seq ASC,
b.id ASC b.id ASC
</select> </select>
<select id="checkMobilePhone" resultType="Integer" parameterType="map">
SELECT
COUNT(1)
FROM
advertising_bm_register_item i
LEFT JOIN advertising_bm_register r ON i.register_id = r.id
LEFT JOIN advertising_bm_option o ON i.option_id = o.id
WHERE
i.ad_id = #{adId}
AND r.from_type = #{fromType}
AND r.from_id = #{fromId}
AND o.item_title = '手机号'
AND i.option_value = #{optionValue}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -8,6 +8,16 @@ ...@@ -8,6 +8,16 @@
<result column="nick_name" property="nickName" jdbcType="VARCHAR" /> <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT" /> <result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT" />
<result column="scene_id" property="sceneId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="agent_id" property="agentId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="official_account_id" property="officialAccountId" jdbcType="BIGINT"/>
<result column="from_type" property="fromType" jdbcType="VARCHAR"/>
<result column="from_id" property="fromId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="create_day" property="createDay" jdbcType="DATE"/>
<result column="create_month" property="createMonth" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<!-- 微信端用户详细信息 --> <!-- 微信端用户详细信息 -->
...@@ -25,14 +35,46 @@ ...@@ -25,14 +35,46 @@
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
id, user_id, ad_id, nick_name, create_time, qrcode_id id, user_id, ad_id, nick_name, create_time, qrcode_id, scene_id, adviser_id, agent_id, channel_id, official_account_id, from_type,
from_id,book_id,create_day, create_month
</sql> </sql>
<insert id="insert" parameterType="com.pcloud.book.advertising.entity.AdvertisingBmRegister" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.pcloud.book.advertising.entity.AdvertisingBmRegister" useGeneratedKeys="true" keyProperty="id">
insert into advertising_bm_register (user_id, ad_id, INSERT INTO advertising_bm_register (
nick_name, create_time, qrcode_id) user_id,
values (#{userId,jdbcType=BIGINT}, #{adId,jdbcType=BIGINT}, ad_id,
#{nickName,jdbcType=VARCHAR}, NOW(), #{qrcodeId}) nick_name,
create_time,
qrcode_id,
scene_id,
adviser_id,
agent_id,
channel_id,
official_account_id,
from_type,
from_id,
book_id,
create_day,
create_month
)
VALUES
(
#{userId,jdbcType=BIGINT},
#{adId,jdbcType=BIGINT},
#{nickName,jdbcType=VARCHAR},
NOW(),
#{qrcodeId},
#{sceneId,jdbcType=BIGINT},
#{adviserId,jdbcType=BIGINT},
#{agentId,jdbcType=BIGINT},
#{channelId,jdbcType=BIGINT},
#{officialAccountId,jdbcType=BIGINT},
#{fromType,jdbcType=VARCHAR},
#{fromId,jdbcType=BIGINT},
#{bookId,jdbcType=BIGINT},
NOW(),
DATE_FORMAT(NOW(), '%Y-%m')
)
</insert> </insert>
<!-- 微信端获取个人报名信息 --> <!-- 微信端获取个人报名信息 -->
...@@ -50,19 +92,24 @@ ...@@ -50,19 +92,24 @@
<select id="getRegisterCountByAdId" parameterType="map" resultType="Long"> <select id="getRegisterCountByAdId" parameterType="map" resultType="Long">
SELECT SELECT
IFNULL(COUNT(1), 0) COUNT(1)
FROM FROM
advertising_bm_register advertising_bm_register
WHERE WHERE
ad_id = #{adId,jdbcType=BIGINT} ad_id = #{adId,jdbcType=BIGINT}
<if test="statisMonth != null"> <if test="bookId != null">
AND DATE_FORMAT(create_time, "%Y-%m") = #{statisMonth} AND book_id = #{bookId}
</if> AND adviser_id = #{adviserId}
AND channel_id = #{channelId}
</if>
<if test="statisMonth != null">
and create_month = #{statisMonth}
</if>
</select> </select>
<select id="getRegisterCountByAdIds" parameterType="list" resultType="Long"> <select id="getRegisterCountByAdIds" parameterType="list" resultType="Long">
SELECT SELECT
IFNULL(COUNT(1), 0) COUNT(1)
FROM FROM
advertising_bm_register advertising_bm_register
WHERE ad_id in WHERE ad_id in
...@@ -71,28 +118,69 @@ ...@@ -71,28 +118,69 @@
</foreach> </foreach>
</select> </select>
<select id="exportRegisterInfoById" parameterType="map" resultMap="wechatDetailMap">
select
<include refid="Base_Column_List" />
from advertising_bm_register
where ad_id = #{adId}
<if test="qrcodeId != null">
AND qrcode_id = #{qrcodeId}
</if>
ORDER BY create_time DESC
</select>
<select id="getRegisterCountByAdIdQrcodeId" parameterType="map" resultType="Long"> <select id="getRegisterCountByAdIdQrcodeId" parameterType="map" resultType="Long">
SELECT SELECT
IFNULL(COUNT(1), 0) COUNT(1)
FROM FROM
advertising_bm_register advertising_bm_register
WHERE WHERE
ad_id = #{adId,jdbcType=BIGINT} from_id = #{qrcodeId}
AND qrcode_id = #{qrcodeId} AND from_type = 'WECHAT_GROUP'
<if test="adId != null">
AND ad_id = #{adId,jdbcType=BIGINT}
</if>
<if test="statisMonth != null"> <if test="statisMonth != null">
AND DATE_FORMAT(create_time, "%Y-%m") = #{statisMonth} AND create_month = #{statisMonth}
</if> </if>
</select> </select>
<select id="getRegisterUserNumByAdIdQrcodeId" resultType="Long" parameterType="map">
SELECT
COUNT(DISTINCT user_id)
FROM
advertising_bm_register
WHERE
from_id = #{qrcodeId}
AND from_type = 'WECHAT_GROUP'
<if test="adId != null">
AND ad_id = #{adId,jdbcType=BIGINT}
</if>
<if test="statisMonth != null">
AND create_month = #{statisMonth}
</if>
</select>
<select id="getRegisterInfoListByAdIdQrcodeId" parameterType="map" resultMap="wechatDetailMap">
SELECT
<include refid="Base_Column_List"/>
FROM advertising_bm_register
WHERE
ad_id = #{adId}
<if test="qrcodeId != null">
AND from_id = #{qrcodeId}
AND from_type = 'WECHAT_GROUP'
</if>
<if test="statisMonth != null">
AND create_month = #{statisMonth}
</if>
ORDER BY create_time DESC
</select>
<select id="getRegisterInfoListByAdId" parameterType="map" resultMap="wechatDetailMap">
SELECT
<include refid="Base_Column_List" />
FROM advertising_bm_register
WHERE
ad_id = #{adId}
<if test="bookId != null">
AND book_id = #{bookId}
AND adviser_id = #{adviserId}
AND channel_id = #{channelId}
</if>
<if test="statisMonth != null">
AND create_month = #{statisMonth}
</if>
ORDER BY create_time DESC
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -86,21 +86,28 @@ ...@@ -86,21 +86,28 @@
</if> </if>
</select> </select>
<!--计算点击人数-包含userId=null-->
<select id="getClickUserNumByGroupQrcodeId" parameterType="map" resultType="Long"> <select id="getClickUserNumByGroupQrcodeId" parameterType="map" resultType="Long">
SELECT SELECT
count(DISTINCT wechat_user_id) count(1)
FROM
(
SELECT
wechat_user_id
FROM FROM
advertising_click_record advertising_click_record
WHERE WHERE
from_id = #{qrcodeId} from_id = #{qrcodeId}
AND from_type = 'WECHAT_GROUP' AND from_type = 'WECHAT_GROUP'
<if test="adId != null"> <if test="adId != null">
AND ad_id = #{adId} AND ad_id = #{adId}
</if> </if>
<if test="statisMonth != null"> <if test="statisMonth != null">
AND create_month = #{statisMonth} AND create_month = #{statisMonth}
</if> </if>
AND wechat_user_id IS NOT NULL GROUP BY
wechat_user_id
) AS a
</select> </select>
<select id="getTotalClickNum" resultType="Long"> <select id="getTotalClickNum" resultType="Long">
...@@ -212,4 +219,40 @@ ...@@ -212,4 +219,40 @@
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<select id="getClickUserNumByMasterId" parameterType="map" resultType="Long">
SELECT
COUNT(DISTINCT wechat_user_id)
FROM
advertising_click_record r
INNER JOIN advertising_space s ON r.ad_id = s.id
WHERE
s.master_id = #{masterId}
</select>
<!--计算点击人数-包含userId=null-->
<select id="getClickUserNumByAdId" parameterType="map" resultType="Long">
SELECT
COUNT(1)
FROM
(
SELECT
wechat_user_id
FROM
advertising_click_record
WHERE
ad_id = #{adId}
<if test="bookId != null">
AND book_id = #{bookId}
AND adviser_id = #{adviserId}
AND channel_id = #{channelId}
</if>
<if test="statisMonth != null">
and create_month = #{statisMonth}
</if>
GROUP BY
wechat_user_id
) AS a
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -230,16 +230,22 @@ ...@@ -230,16 +230,22 @@
AND cr.channel_id = b.channel_id AND cr.channel_id = b.channel_id
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
ad_id, ad_id,
COUNT(id) register_num book_id,
channel_id,
COUNT(id) register_num
FROM FROM
advertising_bm_register advertising_bm_register
WHERE WHERE
DATE_FORMAT(create_time, '%Y-%m-%d') = #{createDay} create_day = #{createDay}
AND qrcode_id IS NULL AND from_type != 'WECHAT_GROUP'
GROUP BY GROUP BY
ad_id ad_id,
book_id,
channel_id
) br ON br.ad_id = b.ad_id ) br ON br.ad_id = b.ad_id
AND br.book_id = b.book_id
AND br.channel_id = b.channel_id
WHERE WHERE
b.ad_id = s.id b.ad_id = s.id
AND s.id = m.ad_id AND s.id = m.ad_id
...@@ -345,20 +351,26 @@ ...@@ -345,20 +351,26 @@
AND cr.channel_id = b.channel_id AND cr.channel_id = b.channel_id
AND cr.from_id = b.qrcode_id AND cr.from_id = b.qrcode_id
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
ad_id, ad_id,
qrcode_id, book_id,
COUNT(id) register_num channel_id,
FROM from_id,
advertising_bm_register COUNT(id) register_num
WHERE FROM
DATE_FORMAT(create_time, '%Y-%m-%d') = #{createDay} advertising_bm_register
AND qrcode_id IS NOT NULL WHERE
GROUP BY create_day = #{createDay}
ad_id, AND from_type = 'WECHAT_GROUP'
qrcode_id GROUP BY
ad_id,
book_id,
channel_id,
from_id
) br ON br.ad_id = b.ad_id ) br ON br.ad_id = b.ad_id
AND br.qrcode_id = b.qrcode_id AND br.book_id = b.book_id
AND br.channel_id = b.channel_id
AND br.from_id = b.qrcode_id
WHERE WHERE
b.ad_id = s.id b.ad_id = s.id
AND s.id = m.ad_id AND s.id = m.ad_id
......
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