Commit ebc391d0 by 郑勇

feat: [1005530] 只扫一个二维码即可实现版本保护

parent fa552b51
...@@ -72,7 +72,11 @@ public enum BookStatusEnum { ...@@ -72,7 +72,11 @@ public enum BookStatusEnum {
/** /**
* 不正确 * 不正确
*/ */
NOT_RIGHT(2); NOT_RIGHT(2),
/**
* 满了
*/
FULL(3);
public final Integer value; public final Integer value;
......
...@@ -162,6 +162,11 @@ public class BookConstant { ...@@ -162,6 +162,11 @@ public class BookConstant {
public static final String BOOK_HOT_APP = "BOOK_CHANNEL:HOT_APP_TOP_5_KEY:"; public static final String BOOK_HOT_APP = "BOOK_CHANNEL:HOT_APP_TOP_5_KEY:";
/** /**
* 图书生成授权保护码
*/
public static final String BOOK_AUTH_CODE_CACHE = CacheConstant.BOOK + "BOOK_AUTH_CODE_CACHE:";
/**
* 微信群默认头像 * 微信群默认头像
*/ */
public static final List<String> DEFAULT_HEADURL =Arrays.asList( public static final List<String> DEFAULT_HEADURL =Arrays.asList(
......
...@@ -60,6 +60,19 @@ public class BookAuthCodeDTO extends BaseDto { ...@@ -60,6 +60,19 @@ public class BookAuthCodeDTO extends BaseDto {
@ApiModelProperty("使用授权码的用户") @ApiModelProperty("使用授权码的用户")
private List<BookAuthUserDTO> bookAuthUserList; private List<BookAuthUserDTO> bookAuthUserList;
/**
* 新版 授权码链接
*/
private String qrcodeUrl;
public String getQrcodeUrl() {
return qrcodeUrl;
}
public void setQrcodeUrl(String qrcodeUrl) {
this.qrcodeUrl = qrcodeUrl;
}
public String getFullCode() { public String getFullCode() {
return fullCode; return fullCode;
} }
......
package com.pcloud.book.copyright.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 二维码授权码列表查询返回dto
*/
@ApiModel
@Data
public class SceneAuthCodeResponseDTO {
@ApiModelProperty("运营标识")
private Long sceneId;
@ApiModelProperty("最多激活人数")
private Integer maxUserCount;
@ApiModelProperty("激活次数用完后提示")
private String fullUseTips;
@ApiModelProperty("授权码个数")
private Integer counts;
}
package com.pcloud.book.copyright.dto;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 二维码授权码列表查询
*/
@ApiModel
@Data
public class SceneAuthCodeSearchDTO{
private Long bookId;
@ApiModelProperty("运营标识")
private Long channelId;
@ApiModelProperty("编辑标识")
private Long adviserId;
private List<Long> sceneIds;
}
...@@ -3,6 +3,8 @@ package com.pcloud.book.copyright.service; ...@@ -3,6 +3,8 @@ package com.pcloud.book.copyright.service;
import com.pcloud.book.copyright.dto.BookAuthInfoCountDTO; import com.pcloud.book.copyright.dto.BookAuthInfoCountDTO;
import com.pcloud.book.copyright.dto.BookAuthTotalCountDTO; import com.pcloud.book.copyright.dto.BookAuthTotalCountDTO;
import com.pcloud.book.copyright.dto.CheckUserAuthDTO; import com.pcloud.book.copyright.dto.CheckUserAuthDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeResponseDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeSearchDTO;
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 io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -52,5 +54,8 @@ public interface BookAuthInfoService { ...@@ -52,5 +54,8 @@ public interface BookAuthInfoService {
ResponseEntity<ResponseDto<BigDecimal>> getGroupBookAuthPrice(@RequestParam("bookId") Long bookId, @RequestParam("channelId")Long channelId, ResponseEntity<ResponseDto<BigDecimal>> getGroupBookAuthPrice(@RequestParam("bookId") Long bookId, @RequestParam("channelId")Long channelId,
@RequestParam("adviserId")Long adviserId) throws BizException; @RequestParam("adviserId")Long adviserId) throws BizException;
@ApiOperation(value = "获取二维码授权码信息", httpMethod = "POST")
@RequestMapping(value = "/getSceneAuthInfo", method = RequestMethod.POST)
ResponseEntity<ResponseDto<List<SceneAuthCodeResponseDTO>>> getSceneAuthInfo(@RequestBody SceneAuthCodeSearchDTO sceneAuthCodeSearchDTO) throws BizException;
} }
...@@ -86,7 +86,7 @@ public interface BookAuthCodeBiz { ...@@ -86,7 +86,7 @@ public interface BookAuthCodeBiz {
Map<String, Object> getCodeExcel(Long bookId, String codeIds, Long channelId, Long status, String systemCode, Long partyId, Integer authBookType); Map<String, Object> getCodeExcel(Long bookId, String codeIds, Long channelId, Long status, String systemCode, Long partyId, Integer authBookType);
/** /**
*一键删除未使用的授权码 * 一键清空未使用的授权码
*/ */
void deleteNoUsedAuthCode(DeleteAuthCodeDTO deleteAuthCodeDTO, Long adviserId); void deleteNoUsedAuthCode(DeleteAuthCodeDTO deleteAuthCodeDTO, Long adviserId);
} }
...@@ -2,6 +2,7 @@ package com.pcloud.book.copyright.biz; ...@@ -2,6 +2,7 @@ package com.pcloud.book.copyright.biz;
import com.pcloud.book.copyright.dto.BookAuthInfoCountDTO; import com.pcloud.book.copyright.dto.BookAuthInfoCountDTO;
import com.pcloud.book.copyright.dto.BookAuthTotalCountDTO; import com.pcloud.book.copyright.dto.BookAuthTotalCountDTO;
import com.pcloud.book.copyright.vo.AuthOpenVO;
import com.pcloud.book.copyright.vo.BookAuthInfoAndServesVO; import com.pcloud.book.copyright.vo.BookAuthInfoAndServesVO;
import com.pcloud.book.copyright.vo.BookAuthInfoVO; import com.pcloud.book.copyright.vo.BookAuthInfoVO;
import com.pcloud.book.copyright.vo.BookAuthInfoWechatVO; import com.pcloud.book.copyright.vo.BookAuthInfoWechatVO;
...@@ -27,6 +28,8 @@ public interface BookAuthInfoBiz { ...@@ -27,6 +28,8 @@ public interface BookAuthInfoBiz {
*/ */
void setBookAuthOpen(SetAuthOpenParam setAuthOpenParam, Long adviserId); void setBookAuthOpen(SetAuthOpenParam setAuthOpenParam, Long adviserId);
void sendLetter(Long adviserId, String bookName, String url, String commitTime);
/** /**
* 设置授权后付费查看 * 设置授权后付费查看
*/ */
...@@ -99,4 +102,8 @@ public interface BookAuthInfoBiz { ...@@ -99,4 +102,8 @@ public interface BookAuthInfoBiz {
*/ */
Boolean isHaveExport(Long bookId, Long channelId, Long adviserId); Boolean isHaveExport(Long bookId, Long channelId, Long adviserId);
/**
* 升级版权保护
*/
void setBookCodeAuth(AuthOpenVO authOpenVO, Long adviserId);
} }
...@@ -45,7 +45,7 @@ public interface BookAuthUserBiz { ...@@ -45,7 +45,7 @@ public interface BookAuthUserBiz {
/** /**
* 校验用户是否已经授权 * 校验用户是否已经授权
*/ */
Boolean checkIsHaveAuth(Long bookId, Long channelId, Long adviserId, Long wechatUserId, Integer authBookType); Boolean checkIsHaveAuth(Long bookId, Long channelId, Long adviserId, Long wechatUserId, Integer authBookType,Long sceneId,Long bookAuthCodeId);
/** /**
* 校验用户针对指定的服务是否被授权 * 校验用户针对指定的服务是否被授权
...@@ -75,5 +75,5 @@ public interface BookAuthUserBiz { ...@@ -75,5 +75,5 @@ public interface BookAuthUserBiz {
/** /**
* 获取使用授权码的用户 * 获取使用授权码的用户
*/ */
Map<Long, List<BookAuthUserDTO>> getByAuthCodeIds(List<Long> authCodeIds); Map<Long, List<BookAuthUserDTO>> getByAuthCodeIds(List<Long> authCodeIds,Long sceneId);
} }
...@@ -37,5 +37,10 @@ public interface BookExportRecordBiz { ...@@ -37,5 +37,10 @@ public interface BookExportRecordBiz {
/** /**
* 查看授权码生成记录 * 查看授权码生成记录
*/ */
PageBeanNew<BookExportRecordDTO> getGenerateCodeHistory(Long bookId, Long adviserId, Long channelId, PageParam pageParam); PageBeanNew<BookExportRecordDTO> getGenerateCodeHistory(Long bookId, Long adviserId, Long channelId,Long sceneId, PageParam pageParam);
/**
* 获取最后一次导出的地址
*/
String getExportUrl(Long bookId, Long channelId, Long adviserId,Long sceneId);
} }
package com.pcloud.book.copyright.biz;
import com.pcloud.book.copyright.dto.BookAuthCodeDTO;
import com.pcloud.book.copyright.dto.DeleteAuthCodeDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeResponseDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeSearchDTO;
import com.pcloud.book.copyright.entity.BookSceneAuth;
import com.pcloud.book.copyright.vo.CheckAuthCodeVO;
import com.pcloud.book.copyright.vo.GenerateCodeVO;
import com.pcloud.book.copyright.vo.UseAuthCodeVO;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
import java.util.Map;
/**
* 书籍二维码授权表(BookSceneAuth)表服务接口
*
* @author makejava
* @since 2021-10-19 14:14:22
*/
public interface BookSceneAuthBiz {
/**
* 自动创建授权码
*/
void autoGenerateAuthCode(GenerateCodeVO generateCodeVO, Long adviserId);
/**
* 二维码下授权码列表
*/
PageBeanNew<BookAuthCodeDTO> listSceneAuthCode(Long bookId, Long channelId, Long sceneId, String keyword, Integer state, Integer authBookType, Integer currentPage, Integer numPerPage, Long adviserId);
/**
* 删除授权码
*/
void deleteSceneAuthCode(List<Long> ids);
/**
* 一键清空未使用的授权码
*/
void clearNoUsedAuthCode(DeleteAuthCodeDTO deleteAuthCodeDTO, Long adviserId);
/**
* 升级用户扫描授权码之后
*/
CheckAuthCodeVO checkSceneAuthCode(UseAuthCodeVO useAuthCodeVO, Long channelId, Long wechatUserId);
/**
* 修改二维码授权信息
*/
void setBookCodeAuth(BookSceneAuth bookSceneAuth, Long adviserId);
/**
* 保存二维码授权信息
*/
void saveSceneAuthInfo(List<BookSceneAuth> list, Long adviserId);
/**
* 获取二维码授权码信息
*/
List<SceneAuthCodeResponseDTO> getSceneAuthInfo(SceneAuthCodeSearchDTO sceneAuthCodeSearchDTO);
/**
* 升级用户扫描授权码之后
*/
Map<String, Object> exportSceneAuthCode(Long bookId, String codeIds, Long channelId,Long sceneId, Long status, String systemCode, Long partyId, Integer authBookType);
}
\ No newline at end of file
...@@ -152,7 +152,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz { ...@@ -152,7 +152,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
Long bookId = authBookInfo.getBookId(); Long bookId = authBookInfo.getBookId();
Long adviserId = authBookInfo.getAdviserId(); Long adviserId = authBookInfo.getAdviserId();
//校验用户是否已经授权过 //校验用户是否已经授权过
Boolean isHaveAuth = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId, authBookType); Boolean isHaveAuth = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId, authBookType,null,null);
if (isHaveAuth) { if (isHaveAuth) {
return BookStatusEnum.CodeUseTypeEnum.RIGHT.value; return BookStatusEnum.CodeUseTypeEnum.RIGHT.value;
} }
...@@ -196,7 +196,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz { ...@@ -196,7 +196,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
return false; return false;
} }
//校验用户是否已经授权过 //校验用户是否已经授权过
Boolean isHaveAuth = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId,null); Boolean isHaveAuth = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId,null,null,null);
return !isHaveAuth; return !isHaveAuth;
} }
...@@ -367,7 +367,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz { ...@@ -367,7 +367,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
return; return;
} }
// 查询使用码的使用情况 // 查询使用码的使用情况
Map<Long, List<BookAuthUserDTO>> authUserMap = bookAuthUserBiz.getByAuthCodeIds(authCodeIds); Map<Long, List<BookAuthUserDTO>> authUserMap = bookAuthUserBiz.getByAuthCodeIds(authCodeIds,null);
for (BookAuthCodeDTO bookAuthCodeDTO : recordList) { for (BookAuthCodeDTO bookAuthCodeDTO : recordList) {
bookAuthCodeDTO.setBookAuthUserList(authUserMap.getOrDefault(bookAuthCodeDTO.getId(), Lists.newArrayList())); bookAuthCodeDTO.setBookAuthUserList(authUserMap.getOrDefault(bookAuthCodeDTO.getId(), Lists.newArrayList()));
} }
......
...@@ -27,6 +27,7 @@ import com.pcloud.book.copyright.entity.BookAuthInfo; ...@@ -27,6 +27,7 @@ import com.pcloud.book.copyright.entity.BookAuthInfo;
import com.pcloud.book.copyright.entity.BookExportRecord; import com.pcloud.book.copyright.entity.BookExportRecord;
import com.pcloud.book.copyright.enums.AuthBookTypeEnum; import com.pcloud.book.copyright.enums.AuthBookTypeEnum;
import com.pcloud.book.copyright.tools.CopyrightTools; import com.pcloud.book.copyright.tools.CopyrightTools;
import com.pcloud.book.copyright.vo.AuthOpenVO;
import com.pcloud.book.copyright.vo.BookAuthCodeUserVO; import com.pcloud.book.copyright.vo.BookAuthCodeUserVO;
import com.pcloud.book.copyright.vo.BookAuthInfoAndServesVO; import com.pcloud.book.copyright.vo.BookAuthInfoAndServesVO;
import com.pcloud.book.copyright.vo.BookAuthInfoVO; import com.pcloud.book.copyright.vo.BookAuthInfoVO;
...@@ -64,6 +65,8 @@ import java.math.BigDecimal; ...@@ -64,6 +65,8 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.util.ObjectUtil;
/** /**
* @author lily * @author lily
* @date 2018/12/3 11:39 * @date 2018/12/3 11:39
...@@ -287,7 +290,8 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz { ...@@ -287,7 +290,8 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
} }
@ParamLog("发送站内信") @ParamLog("发送站内信")
private void sendLetter(Long adviserId, String bookName, String url, String commitTime) { @Override
public void sendLetter(Long adviserId, String bookName, String url, String commitTime) {
SendNotifyDto sendNotifyDto = new SendNotifyDto(); SendNotifyDto sendNotifyDto = new SendNotifyDto();
sendNotifyDto.setCreatedTime(new Date()); sendNotifyDto.setCreatedTime(new Date());
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
...@@ -663,4 +667,35 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz { ...@@ -663,4 +667,35 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
bookAuthInfo.setIsGroupBook(1); bookAuthInfo.setIsGroupBook(1);
} }
} }
@Override
public void setBookCodeAuth(AuthOpenVO authOpenVO, Long adviserId) {
if(ObjectUtil.hasEmpty(authOpenVO,authOpenVO.getBookId(),authOpenVO.getChannelId())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少参数");
}
BookAuthInfoVO bookAuthInfoVO = bookAuthInfoDao.getInfoByBook(authOpenVO.getBookId(), authOpenVO.getChannelId(), adviserId,
authOpenVO.getAuthBookType());
BookAuthInfo bookAuthInfo = new BookAuthInfo();
bookAuthInfo.setBookId(authOpenVO.getBookId());
bookAuthInfo.setChannelId(authOpenVO.getChannelId());
bookAuthInfo.setAuthType(2);
if (bookAuthInfoVO == null) {
this.setAuthBookType(bookAuthInfo, authOpenVO.getAuthBookType());
bookAuthInfo.setAdviserId(adviserId);
try {
bookAuthInfoDao.insert(bookAuthInfo);
} catch (DataIntegrityViolationException e) {
LOGGER.error("您已经设置过这本图书!"+e.getMessage(), e);
throw new BookBizException(BookBizException.DB_DML_FAIL, "您已经设置过这本图书!");
}
} else {
bookAuthInfo.setId(bookAuthInfoVO.getId());
bookAuthInfo.setAdviserId(adviserId);
bookAuthInfoDao.updateBaseInfo(bookAuthInfo);
}
Integer authBookType = authOpenVO.getAuthBookType() == null ? 0 : authOpenVO.getAuthBookType();
String key = CopyrightConstants.BOOK_AUTH_INFO + bookAuthInfo.getBookId() + "-" + bookAuthInfo.getChannelId() + "-" + adviserId + "-" + authBookType;
BookAuthInfoVO bookAuth = bookAuthInfoDao.getInfoByBook(authOpenVO.getBookId(), authOpenVO.getChannelId(), adviserId, authOpenVO.getAuthBookType());
JedisClusterUtils.setJson(key, bookAuth);
}
} }
...@@ -180,9 +180,9 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz { ...@@ -180,9 +180,9 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
@Override @Override
@ParamLog("校验用户是否已经授权") @ParamLog("校验用户是否已经授权")
public Boolean checkIsHaveAuth(Long bookId, Long channelId, Long adviserId, Long wechatUserId, Integer authBookType) { public Boolean checkIsHaveAuth(Long bookId, Long channelId, Long adviserId, Long wechatUserId, Integer authBookType,Long sceneId,Long bookAuthCodeId) {
List<Long> wechatUserIdList = readerConsr.getAllUnionUser(wechatUserId); List<Long> wechatUserIdList = readerConsr.getAllUnionUser(wechatUserId);
return bookAuthUserDao.getIsHaveAuth(bookId, channelId, adviserId, wechatUserIdList, authBookType); return bookAuthUserDao.getIsHaveAuth(bookId, channelId, adviserId, wechatUserIdList, authBookType,sceneId,bookAuthCodeId);
} }
@Override @Override
...@@ -216,7 +216,7 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz { ...@@ -216,7 +216,7 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
private Boolean checkIsHaveAuthWithServer(Long bookId, Long channelId, Long adviserId, Long wecharUserId, Long serverId) { private Boolean checkIsHaveAuthWithServer(Long bookId, Long channelId, Long adviserId, Long wecharUserId, Long serverId) {
// 书类型指定为is_paper_book // 书类型指定为is_paper_book
Boolean isUserAuth = checkIsHaveAuth(bookId,channelId,adviserId,wecharUserId,0); Boolean isUserAuth = checkIsHaveAuth(bookId,channelId,adviserId,wecharUserId,0,null,null);
if(isUserAuth){ if(isUserAuth){
List<Long> serverIds = new ArrayList<>(); List<Long> serverIds = new ArrayList<>();
serverIds.add(serverId); serverIds.add(serverId);
...@@ -345,11 +345,11 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz { ...@@ -345,11 +345,11 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
} }
@Override @Override
public Map<Long, List<BookAuthUserDTO>> getByAuthCodeIds(List<Long> authCodeIds) { public Map<Long, List<BookAuthUserDTO>> getByAuthCodeIds(List<Long> authCodeIds,Long sceneId) {
if(CollectionUtils.isEmpty(authCodeIds)){ if(CollectionUtils.isEmpty(authCodeIds)){
return new HashMap<>(); return new HashMap<>();
} }
List<BookAuthUserDTO> bookAuthUserList = bookAuthUserDao.getByAuthCodeIds(authCodeIds); List<BookAuthUserDTO> bookAuthUserList = bookAuthUserDao.getByAuthCodeIds(authCodeIds,sceneId);
if(CollectionUtils.isEmpty(bookAuthUserList)){ if(CollectionUtils.isEmpty(bookAuthUserList)){
return new HashMap<>(); return new HashMap<>();
} }
......
...@@ -51,11 +51,12 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz { ...@@ -51,11 +51,12 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz {
} }
@Override @Override
public PageBeanNew<BookExportRecordDTO> getGenerateCodeHistory(Long bookId, Long adviserId, Long channelId, PageParam pageParam) { public PageBeanNew<BookExportRecordDTO> getGenerateCodeHistory(Long bookId, Long adviserId, Long channelId,Long sceneId, PageParam pageParam) {
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId); paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId); paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId); paramMap.put("adviserId",adviserId);
paramMap.put("sceneId",sceneId);
PageBeanNew<BookExportRecordDTO> pageBeanNew = bookExportRecordDao.listPageNew(pageParam, paramMap, "getGenerateCodeHistory"); PageBeanNew<BookExportRecordDTO> pageBeanNew = bookExportRecordDao.listPageNew(pageParam, paramMap, "getGenerateCodeHistory");
if(pageBeanNew == null || CollectionUtils.isEmpty(pageBeanNew.getRecordList())){ if(pageBeanNew == null || CollectionUtils.isEmpty(pageBeanNew.getRecordList())){
...@@ -82,4 +83,9 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz { ...@@ -82,4 +83,9 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz {
default: return ""; default: return "";
} }
} }
@Override
public String getExportUrl(Long bookId, Long channelId, Long adviserId, Long sceneId) {
return bookExportRecordDao.getExportUrl(bookId,channelId,adviserId,sceneId);
}
} }
...@@ -22,6 +22,8 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> { ...@@ -22,6 +22,8 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> {
*/ */
BookAuthCodeUserVO getAuthUserCount(Long bookId, Long channelId, Long adviserId, Integer authBookType); BookAuthCodeUserVO getAuthUserCount(Long bookId, Long channelId, Long adviserId, Integer authBookType);
Integer getSceneAuthUserCount(Long bookId, Long channelId, Long adviserId, Integer authBookType,Long sceneId,Long codeId);
/** /**
* 30天趋势图 * 30天趋势图
*/ */
...@@ -36,7 +38,7 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> { ...@@ -36,7 +38,7 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> {
/** /**
* 校验是否已经授权 * 校验是否已经授权
*/ */
Boolean getIsHaveAuth(Long bookId, Long channelId, Long adviserId, List<Long> wechatUserIdList, Integer authBookType); Boolean getIsHaveAuth(Long bookId, Long channelId, Long adviserId, List<Long> wechatUserIdList, Integer authBookType,Long sceneId,Long bookAuthCodeId);
/** /**
* 根据月份获取授权用户信息 * 根据月份获取授权用户信息
...@@ -71,5 +73,5 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> { ...@@ -71,5 +73,5 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> {
/** /**
* 获取使用授权码的用户 * 获取使用授权码的用户
*/ */
List<BookAuthUserDTO> getByAuthCodeIds(List<Long> authCodeIds); List<BookAuthUserDTO> getByAuthCodeIds(List<Long> authCodeIds,Long sceneId);
} }
...@@ -28,4 +28,9 @@ public interface BookExportRecordDao extends BaseDao<BookExportRecord> { ...@@ -28,4 +28,9 @@ public interface BookExportRecordDao extends BaseDao<BookExportRecord> {
* 处理导出 * 处理导出
*/ */
void handleExportFail(); void handleExportFail();
/**
* 获取最后一次导出的地址
*/
String getExportUrl(Long bookId, Long channelId, Long adviserId,Long sceneId);
} }
package com.pcloud.book.copyright.dao;
import com.pcloud.book.copyright.dto.BookAuthCodeDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeResponseDTO;
import com.pcloud.book.copyright.entity.BookSceneAuthCode;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* 书籍二维码授权码记录表(BookSceneAuthCode)表数据库访问层
*
* @author makejava
* @since 2021-10-19 14:14:47
*/
public interface BookSceneAuthCodeDao extends BaseDao<BookSceneAuthCode> {
Integer getMaxBatchNum(Long bookId, Long channelId,Long sceneId, Long adviserId, Integer authBookType);
void deleteSceneAuthCode(List<Long> ids);
List<Long> getCodeIdList(Long bookId, Long channelId, Long adviserId, String keyWord, Integer authBookType, Long sceneId);
BookSceneAuthCode getByCode(String code);
void updateUseCount(Long id);
List<SceneAuthCodeResponseDTO> getCodeCount(Long bookId, List<Long> sceneIds);
void batchUpdate(List<BookSceneAuthCode> list);
List<BookAuthCodeDTO> getBookSceneAuthCodeList(Map<String, Object> paramMap);
}
\ No newline at end of file
package com.pcloud.book.copyright.dao;
import com.pcloud.book.copyright.entity.BookSceneAuth;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* 书籍二维码授权表(BookSceneAuth)表数据库访问层
*
* @author makejava
* @since 2021-10-19 14:14:22
*/
public interface BookSceneAuthDao extends BaseDao<BookSceneAuth> {
BookSceneAuth getAuthSceneInfo(Long bookId, Long sceneId);
List<BookSceneAuth> getAuthSceneIds(Long bookId, List<Long> sceneIds);
void batchUpdate(List<BookSceneAuth> updateList);
}
\ No newline at end of file
...@@ -41,6 +41,22 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo ...@@ -41,6 +41,22 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo
} }
@Override @Override
public Integer getSceneAuthUserCount(Long bookId, Long channelId, Long adviserId, Integer authBookType,Long sceneId,Long bookAuthCodeId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId", bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId",adviserId);
paramMap.put("sceneId",sceneId);
paramMap.put("bookAuthCodeId",bookAuthCodeId);
if(authBookType == null || authBookType.equals(0)) {
paramMap.put("isPaperBook", 1);
} else {
paramMap.put("isGroupBook", 1);
}
return this.getSqlSession().selectOne(this.getStatement("getSceneAuthUserCount"), paramMap);
}
@Override
public List<ThirtyDayCountVO> listThirtyDay(Map<String, Object> paramMap) { public List<ThirtyDayCountVO> listThirtyDay(Map<String, Object> paramMap) {
return this.getSqlSession().selectList(this.getStatement("listThirtyDay"), paramMap); return this.getSqlSession().selectList(this.getStatement("listThirtyDay"), paramMap);
} }
...@@ -51,11 +67,13 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo ...@@ -51,11 +67,13 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo
} }
@Override @Override
public Boolean getIsHaveAuth(Long bookId, Long channelId, Long adviserId, List<Long> wechatUserIdList, Integer authBookType) { public Boolean getIsHaveAuth(Long bookId, Long channelId, Long adviserId, List<Long> wechatUserIdList, Integer authBookType,Long sceneId,Long bookAuthCodeId) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId", bookId); paramMap.put("bookId", bookId);
paramMap.put("channelId", channelId); paramMap.put("channelId", channelId);
paramMap.put("adviserId",adviserId); paramMap.put("adviserId",adviserId);
paramMap.put("sceneId",sceneId);
paramMap.put("bookAuthCodeId",bookAuthCodeId);
paramMap.put("wechatUserIdList",wechatUserIdList); paramMap.put("wechatUserIdList",wechatUserIdList);
if(authBookType == null || authBookType.equals(0)) { if(authBookType == null || authBookType.equals(0)) {
paramMap.put("isPaperBook", 1); paramMap.put("isPaperBook", 1);
...@@ -119,7 +137,10 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo ...@@ -119,7 +137,10 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo
} }
@Override @Override
public List<BookAuthUserDTO> getByAuthCodeIds(List<Long> authCodeIds) { public List<BookAuthUserDTO> getByAuthCodeIds(List<Long> authCodeIds,Long sceneId) {
return this.getSessionTemplate().selectList(this.getStatement("getByAuthCodeIds"), authCodeIds); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("authCodeIds", authCodeIds);
paramMap.put("sceneId", sceneId);
return this.getSessionTemplate().selectList(this.getStatement("getByAuthCodeIds"), paramMap);
} }
} }
...@@ -38,4 +38,14 @@ public class BookExportRecordDaoImpl extends BaseDaoImpl<BookExportRecord> imple ...@@ -38,4 +38,14 @@ public class BookExportRecordDaoImpl extends BaseDaoImpl<BookExportRecord> imple
public void handleExportFail() { public void handleExportFail() {
this.getSqlSession().update(this.getStatement("handleExportFail")); this.getSqlSession().update(this.getStatement("handleExportFail"));
} }
@Override
public String getExportUrl(Long bookId, Long channelId, Long adviserId, Long sceneId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId);
paramMap.put("sceneId",sceneId);
return this.getSqlSession().selectOne(this.getStatement("getExportUrl"), paramMap);
}
} }
package com.pcloud.book.copyright.dao.impl;
import com.pcloud.book.copyright.dto.BookAuthCodeDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeResponseDTO;
import com.pcloud.book.copyright.entity.BookSceneAuthCode;
import com.pcloud.book.copyright.dao.BookSceneAuthCodeDao;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 书籍二维码授权码记录表(BookSceneAuthCode)表数据库访问层
*
* @author makejava
* @since 2021-10-19 14:14:47
*/
@Repository("bookSceneAuthCodeDaoImpl")
public class BookSceneAuthCodeDaoImpl extends BaseDaoImpl<BookSceneAuthCode> implements BookSceneAuthCodeDao {
@Override
public Integer getMaxBatchNum(Long bookId, Long channelId, Long sceneId, Long adviserId, Integer authBookType) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId);
paramMap.put("sceneId",sceneId);
if(authBookType == null || authBookType.equals(0)) {
paramMap.put("isPaperBook", 1);
} else {
paramMap.put("isGroupBook", 1);
}
return this.getSqlSession().selectOne(this.getStatement("getMaxBatchNum"), paramMap);
}
@Override
public void deleteSceneAuthCode(List<Long> ids) {
this.getSqlSession().delete(this.getStatement("deleteSceneAuthCode"), ids);
}
@Override
public List<Long> getCodeIdList(Long bookId, Long channelId, Long adviserId, String keyWord, Integer authBookType, Long sceneId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId);
paramMap.put("keyword",keyWord);
paramMap.put("sceneId",sceneId);
if(authBookType == null || authBookType.equals(0)) {
paramMap.put("isPaperBook", 1);
} else {
paramMap.put("isGroupBook", 1);
}
return this.getSqlSession().selectList(this.getStatement("getCodeIdList"), paramMap);
}
@Override
public BookSceneAuthCode getByCode(String code) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("code",code);
return this.getSqlSession().selectOne(this.getStatement("getByCode"), paramMap);
}
@Override
public void updateUseCount(Long id) {
this.getSqlSession().update(this.getStatement("updateUseCount"), id);
}
@Override
public List<SceneAuthCodeResponseDTO> getCodeCount(Long bookId, List<Long> sceneIds) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("sceneIds",sceneIds);
return this.getSqlSession().selectList(this.getStatement("getCodeCount"), paramMap);
}
@Override
public void batchUpdate(List<BookSceneAuthCode> list) {
this.getSqlSession().update(this.getStatement("batchUpdate"), list);
}
@Override
public List<BookAuthCodeDTO> getBookSceneAuthCodeList(Map<String, Object> paramMap) {
return this.getSqlSession().selectList(this.getStatement("getBookSceneAuthCodeList"), paramMap);
}
}
\ No newline at end of file
package com.pcloud.book.copyright.dao.impl;
import com.pcloud.book.copyright.entity.BookSceneAuth;
import com.pcloud.book.copyright.dao.BookSceneAuthDao;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 书籍二维码授权表(BookSceneAuth)表数据库访问层
*
* @author makejava
* @since 2021-10-19 14:14:22
*/
@Repository("bookSceneAuthDaoImpl")
public class BookSceneAuthDaoImpl extends BaseDaoImpl<BookSceneAuth> implements BookSceneAuthDao {
@Override
public BookSceneAuth getAuthSceneInfo(Long bookId, Long sceneId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("sceneId",sceneId);
return this.getSqlSession().selectOne(this.getStatement("getAuthSceneInfo"), paramMap);
}
@Override
public List<BookSceneAuth> getAuthSceneIds(Long bookId, List<Long> sceneIds) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("sceneIds",sceneIds);
return this.getSqlSession().selectList(this.getStatement("getAuthSceneIds"), paramMap);
}
@Override
public void batchUpdate(List<BookSceneAuth> list) {
this.getSqlSession().update(this.getStatement("batchUpdate"), list);
}
}
\ No newline at end of file
...@@ -17,5 +17,9 @@ public class DeleteAuthCodeDTO { ...@@ -17,5 +17,9 @@ public class DeleteAuthCodeDTO {
@ApiModelProperty("书刊类型") @ApiModelProperty("书刊类型")
private Integer authBookType; private Integer authBookType;
@ApiModelProperty("二维码id")
private Long sceneId;
} }
...@@ -74,4 +74,7 @@ public class BookAuthInfo extends BaseEntity { ...@@ -74,4 +74,7 @@ public class BookAuthInfo extends BaseEntity {
@ApiModelProperty("打开支付功能;0:关闭;1:开启;") @ApiModelProperty("打开支付功能;0:关闭;1:开启;")
private Integer openPay; private Integer openPay;
@ApiModelProperty("授权类型(1-旧版-二维码+授权码,2-升级,二维码)")
private Integer authType;
} }
...@@ -63,6 +63,28 @@ public class BookAuthUser extends BaseEntity { ...@@ -63,6 +63,28 @@ public class BookAuthUser extends BaseEntity {
@ApiModelProperty("授权码id") @ApiModelProperty("授权码id")
private Long bookAuthCodeId; private Long bookAuthCodeId;
@ApiModelProperty("二维码id")
private Long sceneId;
@ApiModelProperty("授权类型(1-旧版-二维码+授权码,2-升级,二维码)")
private Integer bookAuthType;
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public Integer getBookAuthType() {
return bookAuthType;
}
public void setBookAuthType(Integer bookAuthType) {
this.bookAuthType = bookAuthType;
}
@Override @Override
public Long getId() { public Long getId() {
return id; return id;
......
...@@ -53,4 +53,7 @@ public class BookExportRecord extends BaseEntity { ...@@ -53,4 +53,7 @@ public class BookExportRecord extends BaseEntity {
@ApiModelProperty("导出格式") @ApiModelProperty("导出格式")
private Integer isHaveBarCode; private Integer isHaveBarCode;
@ApiModelProperty("二维码id")
private Long sceneId;
} }
package com.pcloud.book.copyright.entity;
import java.util.Date;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 书籍二维码授权表(BookSceneAuth)实体类
*
* @author makejava
* @since 2021-10-19 14:14:22
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BookSceneAuth extends BaseEntity {
private static final long serialVersionUID = 208406932124753490L;
@ApiModelProperty("主键标识")
private Long id;
@ApiModelProperty("图书标识")
private Long bookId;
@ApiModelProperty("二维码id")
private Long sceneId;
@ApiModelProperty("运营标识")
private Long channelId;
@ApiModelProperty("编辑标识")
private Long adviserId;
@ApiModelProperty("最多激活人数")
private Integer maxUserCount;
@ApiModelProperty("激活次数用完后提示")
private String fullUseTips;
@ApiModelProperty("创建人")
private Long createdUser;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.copyright.entity;
import java.util.Date;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 书籍二维码授权码记录表(BookSceneAuthCode)实体类
*
* @author makejava
* @since 2021-10-19 14:14:47
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BookSceneAuthCode extends BaseEntity {
private static final long serialVersionUID = 501026115036847009L;
@ApiModelProperty("主键标识")
private Long id;
@ApiModelProperty("图书标识")
private Long bookId;
@ApiModelProperty("二维码id")
private Long sceneId;
@ApiModelProperty("运营标识")
private Long channelId;
@ApiModelProperty("编辑标识")
private Long adviserId;
@ApiModelProperty("授权码")
private String authCode;
@ApiModelProperty("批次号")
private String batchNum;
@ApiModelProperty("完整校验码")
private String fullCode;
@ApiModelProperty("使用次数")
private Integer useCount;
@ApiModelProperty("创建方式(0-自动/1-手动)")
private Integer createType;
@ApiModelProperty("创建人")
private Long createdUser;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
@ApiModelProperty("最后修改人")
private Long lastModifiedUser;
@ApiModelProperty("最后更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lastModifiedDate;
@ApiModelProperty("是否是现代纸书")
private Integer isPaperBook;
@ApiModelProperty("是否是社群书")
private Integer isGroupBook;
private String url;
private String qrcodeUrl;
}
\ No newline at end of file
...@@ -3,16 +3,21 @@ package com.pcloud.book.copyright.facade.impl; ...@@ -3,16 +3,21 @@ package com.pcloud.book.copyright.facade.impl;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.copyright.biz.BookAuthCodeBiz; import com.pcloud.book.copyright.biz.BookAuthCodeBiz;
import com.pcloud.book.copyright.biz.BookExportRecordBiz; import com.pcloud.book.copyright.biz.BookExportRecordBiz;
import com.pcloud.book.copyright.biz.BookSceneAuthBiz;
import com.pcloud.book.copyright.dto.BookAuthCodeDTO; import com.pcloud.book.copyright.dto.BookAuthCodeDTO;
import com.pcloud.book.copyright.dto.BookExportRecordDTO; import com.pcloud.book.copyright.dto.BookExportRecordDTO;
import com.pcloud.book.copyright.dto.DeleteAuthCodeDTO; import com.pcloud.book.copyright.dto.DeleteAuthCodeDTO;
import com.pcloud.book.copyright.entity.BookExportRecord; import com.pcloud.book.copyright.entity.BookExportRecord;
import com.pcloud.book.copyright.facade.BookAuthCodeFacade; import com.pcloud.book.copyright.facade.BookAuthCodeFacade;
import com.pcloud.book.copyright.vo.AuthOpenVO;
import com.pcloud.book.copyright.vo.CheckAuthCodeVO;
import com.pcloud.book.copyright.vo.CheckCodeParam; import com.pcloud.book.copyright.vo.CheckCodeParam;
import com.pcloud.book.copyright.vo.CheckIsAuthServeParam; import com.pcloud.book.copyright.vo.CheckIsAuthServeParam;
import com.pcloud.book.copyright.vo.CodeUseStatusVO; import com.pcloud.book.copyright.vo.CodeUseStatusVO;
import com.pcloud.book.copyright.vo.FileVO; import com.pcloud.book.copyright.vo.FileVO;
import com.pcloud.book.copyright.vo.GenerateCodeVO;
import com.pcloud.book.copyright.vo.ImportRecordVO; import com.pcloud.book.copyright.vo.ImportRecordVO;
import com.pcloud.book.copyright.vo.UseAuthCodeVO;
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.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -35,9 +40,12 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -35,9 +40,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/** /**
* @author lily * @author lily
* @date 2018/11/29 16:59 * @date 2018/11/29 16:59
...@@ -52,6 +60,9 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade { ...@@ -52,6 +60,9 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade {
@Autowired @Autowired
private BookExportRecordBiz bookExportRecordBiz; private BookExportRecordBiz bookExportRecordBiz;
@Autowired
private BookSceneAuthBiz bookSceneAuthBiz;
@Override @Override
@RequestMapping(value = "checkCode", method = RequestMethod.POST) @RequestMapping(value = "checkCode", method = RequestMethod.POST)
public ResponseDto<CodeUseStatusVO> checkCode(@CookieValue("userInfo") String userInfo, @RequestBody CheckCodeParam checkCodeParam) throws PermissionException, BizException { public ResponseDto<CodeUseStatusVO> checkCode(@CookieValue("userInfo") String userInfo, @RequestBody CheckCodeParam checkCodeParam) throws PermissionException, BizException {
...@@ -175,11 +186,112 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade { ...@@ -175,11 +186,112 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade {
public ResponseDto<?> getGenerateCodeHistory(@RequestHeader("token")String token, public ResponseDto<?> getGenerateCodeHistory(@RequestHeader("token")String token,
@RequestParam(required = false, value ="bookId") Long bookId, @RequestParam(required = false, value ="bookId") Long bookId,
@RequestParam(required = false, value ="channelId") Long channelId, @RequestParam(required = false, value ="channelId") Long channelId,
@RequestParam(required = false, value ="sceneId") Long sceneId,
@RequestParam(required = false,value = "currentPage")Integer currentPage, @RequestParam(required = false,value = "currentPage")Integer currentPage,
@RequestParam(required = false,value = "numPerPage")Integer numPerPage) throws PermissionException, BizException { @RequestParam(required = false,value = "numPerPage")Integer numPerPage) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID); Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
PageParam pageParam = new PageParam(currentPage,numPerPage); PageParam pageParam = new PageParam(currentPage,numPerPage);
PageBeanNew<BookExportRecordDTO> result=bookExportRecordBiz.getGenerateCodeHistory(bookId,adviserId,channelId,pageParam); PageBeanNew<BookExportRecordDTO> result=bookExportRecordBiz.getGenerateCodeHistory(bookId,adviserId,channelId,sceneId,pageParam);
return new ResponseDto<>(result); return new ResponseDto<>(result);
} }
/**
* 新版二维码自动生成版权保护二维码
*/
@PostMapping("autoGenerateAuthCode")
public ResponseDto<?> autoGenerateAuthCode(@RequestHeader("token") String token, @RequestBody GenerateCodeVO generateCodeVO) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookSceneAuthBiz.autoGenerateAuthCode(generateCodeVO, adviserId);
return new ResponseDto<>();
}
/**
* 二维码下授权码列表
*/
@GetMapping("listSceneAuthCode")
public ResponseDto<?> listSceneAuthCode(@RequestHeader("token") String token,
@RequestParam(required = false, value ="bookId") Long bookId,
@RequestParam(required = false, value ="channelId") Long channelId,
@RequestParam(required = false, value ="sceneId") Long sceneId,
@RequestParam(required = false,value = "keyword")String keyword,
@RequestParam(required = false,value = "state")Integer state,
@RequestParam(required = false,value = "authBookType")Integer authBookType,
@RequestParam(required = false,value = "currentPage")Integer currentPage,
@RequestParam(required = false,value = "numPerPage")Integer numPerPage
) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
PageBeanNew<BookAuthCodeDTO> result=bookSceneAuthBiz.listSceneAuthCode(bookId,channelId,sceneId,keyword,state,authBookType,currentPage,numPerPage, adviserId);
return new ResponseDto<>(result);
}
/**
* 批量删除正版授权码
* @param token
* @param ids
* @return
* @throws PermissionException
* @throws BizException
*/
@PostMapping("deleteSceneAuthCode")
public ResponseDto<?> deleteSceneAuthCode(@RequestHeader String token,
@RequestBody List<Long> ids) throws PermissionException, BizException {
if(ListUtils.isEmpty(ids)){
return new ResponseDto<>();
}
bookSceneAuthBiz.deleteSceneAuthCode(ids);
return new ResponseDto<>();
}
/**
*一键删除未使用的授权码
*/
@PostMapping("clearNoUsedAuthCode")
public ResponseDto<?> clearNoUsedAuthCode(@RequestHeader("token")String token,
@RequestBody DeleteAuthCodeDTO deleteAuthCodeDTO) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if(null==deleteAuthCodeDTO || null == deleteAuthCodeDTO.getBookId() || null == deleteAuthCodeDTO.getChannelId() || null==deleteAuthCodeDTO.getSceneId()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
}
bookSceneAuthBiz.clearNoUsedAuthCode(deleteAuthCodeDTO,adviserId);
return new ResponseDto<>();
}
/**
* 升级用户扫描授权码之后
*/
@PostMapping("checkSceneAuthCode")
public ResponseDto<?> checkSceneAuthCode(@CookieValue("userInfo") String userInfo, @RequestBody UseAuthCodeVO useAuthCodeVO) throws PermissionException, BizException {
if(null==userInfo || null==useAuthCodeVO.getAuthCode()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
}
Long channelId = useAuthCodeVO.getChannelId();
if(channelId == null){
channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID);
}
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
CheckAuthCodeVO codeUseStatus = bookSceneAuthBiz.checkSceneAuthCode(useAuthCodeVO, channelId, wechatUserId);
return new ResponseDto<>(codeUseStatus);
}
/**
* 导出选中授权码
*/
@RequestMapping(value = "/exportSceneAuthCode", method = RequestMethod.GET)
public ResponseDto<?> exportSceneAuthCode(@RequestHeader("token") String token,
@RequestParam(required = false, value ="bookId") Long bookId,
@RequestParam(required = false, value ="codeIds") String codeIds,
@RequestParam(required = false, value ="channelId") Long channelId,
@RequestParam(required = false, value ="sceneId") Long sceneId,
@RequestParam(required = false, value ="status") Long status,
@RequestParam(required = false,value = "authBookType")Integer authBookType)
throws PermissionException, JsonParseException, BizException {
String systemCode = (String) SessionUtil.getVlaue(token, SessionUtil.SYSTEM_CODE);
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
//校验参数
if (null == status || null == bookId || null == channelId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
}
Map<String, Object> map = bookSceneAuthBiz.exportSceneAuthCode(bookId,codeIds, channelId,sceneId, status, systemCode, partyId, authBookType);
return new ResponseDto<>(map);
}
} }
package com.pcloud.book.copyright.facade.impl; package com.pcloud.book.copyright.facade.impl;
import com.pcloud.book.copyright.biz.BookAuthInfoBiz; import com.pcloud.book.copyright.biz.BookAuthInfoBiz;
import com.pcloud.book.copyright.biz.BookSceneAuthBiz;
import com.pcloud.book.copyright.entity.BookSceneAuth;
import com.pcloud.book.copyright.facade.BookAuthInfoFacade; import com.pcloud.book.copyright.facade.BookAuthInfoFacade;
import com.pcloud.book.copyright.vo.AuthOpenVO;
import com.pcloud.book.copyright.vo.BookAuthInfoAndServesVO; import com.pcloud.book.copyright.vo.BookAuthInfoAndServesVO;
import com.pcloud.book.copyright.vo.BookAuthInfoVO; import com.pcloud.book.copyright.vo.BookAuthInfoVO;
import com.pcloud.book.copyright.vo.BookAuthInfoWechatVO; import com.pcloud.book.copyright.vo.BookAuthInfoWechatVO;
...@@ -29,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -29,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @author lily * @author lily
* @date 2018/12/3 10:58 * @date 2018/12/3 10:58
...@@ -39,6 +44,8 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade { ...@@ -39,6 +44,8 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade {
@Autowired @Autowired
private BookAuthInfoBiz bookAuthInfoBiz; private BookAuthInfoBiz bookAuthInfoBiz;
@Autowired
private BookSceneAuthBiz bookSceneAuthBiz;
@Override @Override
@PostMapping("setBookAuthOpen") @PostMapping("setBookAuthOpen")
...@@ -132,4 +139,28 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade { ...@@ -132,4 +139,28 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade {
Boolean isCanExport = bookAuthInfoBiz.isHaveExport(bookId, channelId, adviserId); Boolean isCanExport = bookAuthInfoBiz.isHaveExport(bookId, channelId, adviserId);
return new ResponseDto<>(isCanExport == null ? false : isCanExport); return new ResponseDto<>(isCanExport == null ? false : isCanExport);
} }
@ApiOperation("升级版权保护")
@PostMapping("setBookCodeAuth")
public ResponseDto<?> setBookCodeAuth(@RequestHeader("token") String token, @RequestBody AuthOpenVO authOpenVO) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAuthInfoBiz.setBookCodeAuth(authOpenVO, adviserId);
return new ResponseDto<>();
}
@ApiOperation("修改二维码授权信息")
@PostMapping("updateSceneAuthInfo")
public ResponseDto<?> updateSceneAuthInfo(@RequestHeader("token") String token, @RequestBody BookSceneAuth bookSceneAuth) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookSceneAuthBiz.setBookCodeAuth(bookSceneAuth, adviserId);
return new ResponseDto<>();
}
@ApiOperation("保存二维码授权信息")
@PostMapping("saveSceneAuthInfo")
public ResponseDto<?> saveSceneAuthInfo(@RequestHeader("token") String token, @RequestBody List<BookSceneAuth> list) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookSceneAuthBiz.saveSceneAuthInfo(list, adviserId);
return new ResponseDto<>();
}
} }
...@@ -95,7 +95,7 @@ public class BookAuthUserFacadeImpl implements BookAuthUserFacade { ...@@ -95,7 +95,7 @@ public class BookAuthUserFacadeImpl implements BookAuthUserFacade {
channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID); channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID);
} }
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
Boolean result = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId, 1); Boolean result = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId, 1,null,null);
return new ResponseDto<>(result); return new ResponseDto<>(result);
} }
......
...@@ -2,9 +2,12 @@ package com.pcloud.book.copyright.service.impl; ...@@ -2,9 +2,12 @@ package com.pcloud.book.copyright.service.impl;
import com.pcloud.book.copyright.biz.BookAuthInfoBiz; import com.pcloud.book.copyright.biz.BookAuthInfoBiz;
import com.pcloud.book.copyright.biz.BookAuthUserBiz; import com.pcloud.book.copyright.biz.BookAuthUserBiz;
import com.pcloud.book.copyright.biz.BookSceneAuthBiz;
import com.pcloud.book.copyright.dto.BookAuthInfoCountDTO; import com.pcloud.book.copyright.dto.BookAuthInfoCountDTO;
import com.pcloud.book.copyright.dto.BookAuthTotalCountDTO; import com.pcloud.book.copyright.dto.BookAuthTotalCountDTO;
import com.pcloud.book.copyright.dto.CheckUserAuthDTO; import com.pcloud.book.copyright.dto.CheckUserAuthDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeResponseDTO;
import com.pcloud.book.copyright.dto.SceneAuthCodeSearchDTO;
import com.pcloud.book.copyright.service.BookAuthInfoService; import com.pcloud.book.copyright.service.BookAuthInfoService;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -31,6 +34,8 @@ public class BookAuthInfoServiceImpl implements BookAuthInfoService { ...@@ -31,6 +34,8 @@ public class BookAuthInfoServiceImpl implements BookAuthInfoService {
private BookAuthInfoBiz bookAuthInfoBiz; private BookAuthInfoBiz bookAuthInfoBiz;
@Autowired @Autowired
private BookAuthUserBiz bookAuthUserBiz; private BookAuthUserBiz bookAuthUserBiz;
@Autowired
private BookSceneAuthBiz bookSceneAuthBiz;
@Override @Override
@RequestMapping(value = "/getBookAuthPrice", method = RequestMethod.GET) @RequestMapping(value = "/getBookAuthPrice", method = RequestMethod.GET)
...@@ -73,4 +78,9 @@ public class BookAuthInfoServiceImpl implements BookAuthInfoService { ...@@ -73,4 +78,9 @@ public class BookAuthInfoServiceImpl implements BookAuthInfoService {
@RequestParam("channelId")Long channelId, @RequestParam("adviserId")Long adviserId) throws BizException { @RequestParam("channelId")Long channelId, @RequestParam("adviserId")Long adviserId) throws BizException {
return ResponseHandleUtil.toResponse(bookAuthInfoBiz.getBookAuthPrice(bookId, channelId, adviserId, 1)); return ResponseHandleUtil.toResponse(bookAuthInfoBiz.getBookAuthPrice(bookId, channelId, adviserId, 1));
} }
@Override
public ResponseEntity<ResponseDto<List<SceneAuthCodeResponseDTO>>> getSceneAuthInfo(SceneAuthCodeSearchDTO sceneAuthCodeSearchDTO) throws BizException {
return ResponseHandleUtil.toResponse(bookSceneAuthBiz.getSceneAuthInfo(sceneAuthCodeSearchDTO));
}
} }
...@@ -10,6 +10,7 @@ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; ...@@ -10,6 +10,7 @@ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.pcloud.book.book.constant.BookConstant; import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.copyright.dto.DateDTO; import com.pcloud.book.copyright.dto.DateDTO;
import com.pcloud.book.copyright.entity.BookAuthCode; import com.pcloud.book.copyright.entity.BookAuthCode;
import com.pcloud.book.copyright.entity.BookSceneAuthCode;
import com.pcloud.common.constant.OSConstant; import com.pcloud.common.constant.OSConstant;
import com.pcloud.common.entity.UploadResultInfo; import com.pcloud.common.entity.UploadResultInfo;
import com.pcloud.common.enums.ImageTypeEnum; import com.pcloud.common.enums.ImageTypeEnum;
...@@ -18,6 +19,7 @@ import com.pcloud.common.exceptions.FileException; ...@@ -18,6 +19,7 @@ import com.pcloud.common.exceptions.FileException;
import com.pcloud.common.utils.DateUtils; import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.FileUtils; import com.pcloud.common.utils.FileUtils;
import com.pcloud.common.utils.LocalDateUtils; import com.pcloud.common.utils.LocalDateUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.UUIDUitl; import com.pcloud.common.utils.UUIDUitl;
import com.pcloud.common.utils.aliyun.OssUtils; import com.pcloud.common.utils.aliyun.OssUtils;
import com.pcloud.common.utils.zip.CompressUtils; import com.pcloud.common.utils.zip.CompressUtils;
...@@ -223,6 +225,68 @@ public class CopyrightTools { ...@@ -223,6 +225,68 @@ public class CopyrightTools {
return uploadResultInfo == null ? null : uploadResultInfo.getUrl(); return uploadResultInfo == null ? null : uploadResultInfo.getUrl();
} }
/**
* 生成二维码
* @param bookAuthCodes
* @param fileName
* @param sceneUrl
* @return
*/
public static String generateQrcode4ZipNew(List<BookSceneAuthCode> bookAuthCodes, String fileName, String sceneUrl,Integer authBookType) {
fileName = FileUtils.formatName(fileName);
String tempZipName = fileName + "_" + LocalDateUtils.getYmdhmss();
String zipFilePath = ZIP_FILE_PATH + tempZipName + ".zip";
String fileFolderPath = FILE_LOCAL_PATH + tempZipName;
FileUtils.isDir(fileFolderPath);
UploadResultInfo uploadResultInfo;
try {
for (BookSceneAuthCode bookAuthCode : bookAuthCodes) {
LOGGER.info("【二维码】generateQrcode4Zip,<START>.[url]=" + bookAuthCode);
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.MARGIN, 0); // 设置白边
try {
String content=sceneUrl+"?authCode="+bookAuthCode.getFullCode()+"&authBookType="+authBookType;
// 生成矩阵
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, 430,
430, hints);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for(int x=0;x<width;x++){
for(int y=0;y<height;y++){
bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
}
}
// paintQrcodeText(bufferedImage, bookAuthCode.getFullCode());
File file = new File(fileFolderPath + "/" + bookAuthCode.getFullCode() + ".png");
ImageIO.write(bufferedImage, ImageTypeEnum.PNG.value, file);
String qrcodeUrl = QrcodeUtils.uploadImage(bufferedImage);
bookAuthCode.setUrl(content);
bookAuthCode.setQrcodeUrl(qrcodeUrl);
} catch (Exception e) {
LOGGER.error("【二维码】创建二维码失败,<ERROR>:" + e.getMessage(), e);
throw new FileException(FileException.FILE_UPLOAD_FAILURE, "创建二维码失败");
}
}
// 检查压缩包临时文件夹是否存在,不存在就创建
FileUtils.isDir(ZIP_FILE_PATH);
CompressUtils.zip(fileFolderPath, zipFilePath);
// 上传文件到服务器中
uploadResultInfo = OssUtils.uploadLocalFile4CustomName(zipFilePath, fileName);
} catch (Exception e) {
LOGGER.error("【压缩】压缩失败,<ERROR>:" + e.getMessage(), e);
throw new FileException(FileException.ZIP_ERROR, "压缩失败!");
} finally {
// 删除产生的文件
FileUtils.deleteDirectory(fileFolderPath);
FileUtils.deleteFile(zipFilePath);
}
return uploadResultInfo == null ? null : uploadResultInfo.getUrl();
}
public static String uploadImage(BufferedImage image) throws BizException { public static String uploadImage(BufferedImage image) throws BizException {
UploadResultInfo uploadResultInfo = null; UploadResultInfo uploadResultInfo = null;
......
package com.pcloud.book.copyright.vo;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 升级书刊二维保护
*/
@Data
@ApiModel
public class AuthOpenVO implements Serializable {
@ApiModelProperty("图书标识")
private Long bookId;
@ApiModelProperty("运营标识")
private Long channelId;
@ApiModelProperty("书刊类型:0-现代纸书 1-社群书")
private Integer authBookType;
}
package com.pcloud.book.copyright.vo;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 升级书刊二维保护,扫码之后
*/
@Data
@ApiModel
public class CheckAuthCodeVO implements Serializable {
@ApiModelProperty("码使用后状态")
private Integer codeUseStatus;
@ApiModelProperty("提示")
private String tips;
}
package com.pcloud.book.copyright.vo;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 升级书刊二维码自动生成保护二维码
*/
@Data
@ApiModel
public class GenerateCodeVO implements Serializable {
@ApiModelProperty("图书标识")
private Long bookId;
@ApiModelProperty("二维码id")
private Long sceneId;
@ApiModelProperty("运营标识")
private Long channelId;
@ApiModelProperty("书刊类型:0-现代纸书 1-社群书")
private Integer authBookType;
@ApiModelProperty("生成授权码个数")
private Integer codeCount;
}
...@@ -50,6 +50,17 @@ public class HaveSetAuthBook implements Serializable { ...@@ -50,6 +50,17 @@ public class HaveSetAuthBook implements Serializable {
@ApiModelProperty("是否有使用过的授权码") @ApiModelProperty("是否有使用过的授权码")
private Boolean haveUsedAuthCode; private Boolean haveUsedAuthCode;
@ApiModelProperty("授权类型(1-旧版-二维码+授权码,2-升级,二维码)")
private Integer authType;
public Integer getAuthType() {
return authType;
}
public void setAuthType(Integer authType) {
this.authType = authType;
}
public Long getBookId() { public Long getBookId() {
return bookId; return bookId;
} }
......
package com.pcloud.book.copyright.vo;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 升级书刊二维保护
*/
@Data
@ApiModel
public class UseAuthCodeVO implements Serializable {
private String authCode;
@ApiModelProperty("运营标识")
private Long channelId;
private Integer authBookType;
}
...@@ -731,7 +731,7 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz { ...@@ -731,7 +731,7 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
if (new BigDecimal(0).compareTo(classify.getPrice()) < 0) { if (new BigDecimal(0).compareTo(classify.getPrice()) < 0) {
//校验用户是否正版授权 //校验用户是否正版授权
Boolean isAuth = bookAuthUserBiz.checkIsHaveAuth(classify.getBookId(), classify.getChannelId(), classify.getCreateUser(), wechatUserId, 1); Boolean isAuth = bookAuthUserBiz.checkIsHaveAuth(classify.getBookId(), classify.getChannelId(), classify.getCreateUser(), wechatUserId, 1,null,null);
if(!isAuth) { if(!isAuth) {
//校验用户是否购买 //校验用户是否购买
Boolean isBuy = bookClassifyBuyRecordDao.checkUserBuy(wechatUserId, classifyId); Boolean isBuy = bookClassifyBuyRecordDao.checkUserBuy(wechatUserId, classifyId);
......
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
<insert id="insert" useGeneratedKeys="true" parameterType="bookAuthInfo"> <insert id="insert" useGeneratedKeys="true" parameterType="bookAuthInfo">
INSERT INTO BOOK_AUTH_INFO( INSERT INTO BOOK_AUTH_INFO(
BOOK_ID, CHANNEL_ID,ADVISER_ID,PRICE,CODE_USE_COUNT,BUY_URL,CHECK_TYPE, CREATED_USER, CREATED_DATE,LAST_MODIFIED_DATE,OPEN_TIME, BOOK_ID, CHANNEL_ID,ADVISER_ID,PRICE,CODE_USE_COUNT,BUY_URL,CHECK_TYPE, CREATED_USER, CREATED_DATE,LAST_MODIFIED_DATE,OPEN_TIME,
is_paper_book, is_group_book, is_authorized_pay, open_pay is_paper_book, is_group_book, is_authorized_pay, open_pay,auth_type
) )
VALUES VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT}, (#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
#{price}, #{codeUseCount,jdbcType=BIGINT}, #{buyUrl}, #{checkType}, #{price}, #{codeUseCount,jdbcType=BIGINT}, #{buyUrl}, #{checkType},
#{adviserId,jdbcType=BIGINT}, NOW(), NOW(), NOW(), #{adviserId,jdbcType=BIGINT}, NOW(), NOW(), NOW(),
#{isPaperBook}, #{isGroupBook}, IFNULL(#{isAuthorizedPay},0), IFNULL(#{openPay},1)) #{isPaperBook}, #{isGroupBook}, IFNULL(#{isAuthorizedPay},0), IFNULL(#{openPay},1),IFNULL(#{authType},1))
</insert> </insert>
<select id="getInfoByBook" resultMap="BookAuthInfoMap" parameterType="map"> <select id="getInfoByBook" resultMap="BookAuthInfoMap" parameterType="map">
...@@ -73,7 +73,8 @@ ...@@ -73,7 +73,8 @@
B.COVER_IMG coverImg, B.COVER_IMG coverImg,
B.SERIAL_NUMBER serialNumber, B.SERIAL_NUMBER serialNumber,
A.IS_MAIN_EDITOR isMainEditor, A.IS_MAIN_EDITOR isMainEditor,
I.book_status bookStatus I.book_status bookStatus,
I.auth_type authType
FROM FROM
BOOK_AUTH_INFO I BOOK_AUTH_INFO I
INNER JOIN BOOK_ADVISER A ON A.BOOK_ID = I.BOOK_ID AND A.CHANNEL_ID = I.CHANNEL_ID AND A.CREATED_USER = I.ADVISER_ID AND A.IS_DELETE = 0 INNER JOIN BOOK_ADVISER A ON A.BOOK_ID = I.BOOK_ID AND A.CHANNEL_ID = I.CHANNEL_ID AND A.CREATED_USER = I.ADVISER_ID AND A.IS_DELETE = 0
...@@ -271,6 +272,9 @@ ...@@ -271,6 +272,9 @@
<if test="openPay != null"> <if test="openPay != null">
open_pay = #{openPay}, open_pay = #{openPay},
</if> </if>
<if test="authType != null">
auth_type = #{authType},
</if>
LAST_MODIFIED_DATE = NOW() LAST_MODIFIED_DATE = NOW()
WHERE WHERE
ID = #{id} ID = #{id}
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
<insert id="insert" useGeneratedKeys="true" parameterType="bookAuthUser"> <insert id="insert" useGeneratedKeys="true" parameterType="bookAuthUser">
INSERT INTO BOOK_AUTH_USER( INSERT INTO BOOK_AUTH_USER(
BOOK_ID, CHANNEL_ID,ADVISER_ID,WECHAT_USER_ID,MONTHS,province,city,IS_AUTH_CODE, CREATED_DATE,CREATED_USER, CREATED_TIME, is_paper_book, is_group_book, book_auth_code_id) BOOK_ID, CHANNEL_ID,ADVISER_ID,WECHAT_USER_ID,MONTHS,province,city,IS_AUTH_CODE, CREATED_DATE,CREATED_USER, CREATED_TIME,
is_paper_book, is_group_book, book_auth_code_id,scene_id,book_auth_type)
VALUES VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT}, (#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
#{wechatUserId}, #{months}, #{province}, #{city}, #{isAuthCode},NOW(), #{adviserId}, NOW(), #{isPaperBook}, #{isGroupBook}, #{bookAuthCodeId}) #{wechatUserId}, #{months}, #{province}, #{city}, #{isAuthCode},NOW(), #{adviserId}, NOW(), #{isPaperBook}, #{isGroupBook}, #{bookAuthCodeId}
,#{sceneId},ifnull(#{bookAuthType},1))
</insert> </insert>
<select id="getAuthUserCount" resultType="bookAuthCodeUserVO" parameterType="map"> <select id="getAuthUserCount" resultType="bookAuthCodeUserVO" parameterType="map">
...@@ -32,6 +34,33 @@ ...@@ -32,6 +34,33 @@
</if> </if>
</select> </select>
<select id="getSceneAuthUserCount" resultType="Integer" parameterType="map">
SELECT
ifnull(COUNT(1),0)
FROM
BOOK_AUTH_USER
WHERE
BOOK_ID = #{bookId, jdbcType=BIGINT}
AND
CHANNEL_ID = #{channelId, jdbcType=BIGINT}
AND
ADVISER_ID = #{adviserId, jdbcType=BIGINT}
<if test="sceneId !=null">
and scene_id=#{sceneId}
</if>
<if test="bookAuthCodeId!=null">
and book_auth_code_id=#{bookAuthCodeId}
</if>
<if test="isPaperBook != null">
AND
is_paper_book = #{isPaperBook}
</if>
<if test="isGroupBook!=null">
AND
is_group_book = #{isGroupBook}
</if>
</select>
<select id="getAuthUserCountByMonth" resultType="bookAuthCodeUserVO" parameterType="map"> <select id="getAuthUserCountByMonth" resultType="bookAuthCodeUserVO" parameterType="map">
SELECT SELECT
COUNT(1) totalCount, COUNT(1) totalCount,
...@@ -66,6 +95,12 @@ ...@@ -66,6 +95,12 @@
<foreach collection="wechatUserIdList" open="(" close=")" item="item" separator="," index="index"> <foreach collection="wechatUserIdList" open="(" close=")" item="item" separator="," index="index">
#{item} #{item}
</foreach> </foreach>
<if test="sceneId!=null">
and scene_id=#{sceneId}
</if>
<if test="bookAuthCodeId!=null">
and book_auth_code_id=#{bookAuthCodeId}
</if>
<if test="isPaperBook != null"> <if test="isPaperBook != null">
AND AND
is_paper_book = #{isPaperBook} is_paper_book = #{isPaperBook}
...@@ -232,16 +267,22 @@ ...@@ -232,16 +267,22 @@
LIMIT 1 LIMIT 1
</select> </select>
<select id="getByAuthCodeIds" resultType="com.pcloud.book.copyright.dto.BookAuthUserDTO"> <select id="getByAuthCodeIds" parameterType="map" resultType="com.pcloud.book.copyright.dto.BookAuthUserDTO">
SELECT SELECT
id, is_auth_code isAuthCode, created_time createdTime, wechat_user_id wechatUserId, book_auth_code_id bookAuthCodeId id, is_auth_code isAuthCode, created_time createdTime, wechat_user_id wechatUserId, book_auth_code_id bookAuthCodeId
FROM FROM
BOOK_AUTH_USER BOOK_AUTH_USER
WHERE is_auth_code = 0 WHERE is_auth_code = 0
AND book_auth_code_id IN AND book_auth_code_id IN
<foreach collection="list" item="item" open="(" close=")" separator=","> <foreach collection="authCodeIds" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
<if test="sceneId !=null">
and scene_id=#{sceneId}
</if>
<!-- <if test="sceneId ==null">
and (book_auth_type=1 or book_auth_type is null)
</if>-->
</select> </select>
</mapper> </mapper>
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
<insert id="insert" useGeneratedKeys="true" parameterType="bookExportRecord"> <insert id="insert" useGeneratedKeys="true" parameterType="bookExportRecord">
INSERT INTO BOOK_EXPORT_RECORD( INSERT INTO BOOK_EXPORT_RECORD(
BOOK_ID, CHANNEL_ID,ADVISER_ID, BATCH_NUM, CREATED_USER, CREATED_DATE,code_count,is_have_bar_code) BOOK_ID, CHANNEL_ID,ADVISER_ID, BATCH_NUM, CREATED_USER, CREATED_DATE,code_count,is_have_bar_code,scene_id)
VALUES VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},#{batchNum}, (#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},#{batchNum},
#{adviserId}, NOW(),#{codeCount},#{isHaveBarCode}) #{adviserId}, NOW(),#{codeCount},#{isHaveBarCode},#{sceneId})
</insert> </insert>
<update id="updateRecordStatus" parameterType="bookAuthInfo" flushCache="true"> <update id="updateRecordStatus" parameterType="bookAuthInfo" flushCache="true">
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
LAST_MODIFIED_USER = #{lastModifiedUser} LAST_MODIFIED_USER = #{lastModifiedUser}
WHERE WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum} BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum}
<if test="sceneId !=null">
and scene_id=#{sceneId}
</if>
</update> </update>
<update id="updateRecord" parameterType="bookAuthInfo" flushCache="true"> <update id="updateRecord" parameterType="bookAuthInfo" flushCache="true">
...@@ -29,8 +32,22 @@ ...@@ -29,8 +32,22 @@
LAST_MODIFIED_USER = #{lastModifiedUser} LAST_MODIFIED_USER = #{lastModifiedUser}
WHERE WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum} BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum}
<if test="sceneId !=null">
and scene_id=#{sceneId}
</if>
</update> </update>
<select id="getExportUrl" parameterType="map" resultType="String">
select download_url
from BOOK_EXPORT_RECORD
WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId}
<if test="sceneId !=null">
and scene_id=#{sceneId}
</if>
order by id desc limit 1
</select>
<select id="isHaveExport" resultType="Boolean" parameterType="map"> <select id="isHaveExport" resultType="Boolean" parameterType="map">
SELECT SELECT
COUNT(1) COUNT(1)
...@@ -63,6 +80,9 @@ ...@@ -63,6 +80,9 @@
book_id = #{bookId} book_id = #{bookId}
AND channel_id = #{channelId} AND channel_id = #{channelId}
AND adviser_id = #{adviserId} AND adviser_id = #{adviserId}
<if test="sceneId !=null">
and scene_id=#{sceneId}
</if>
order by created_date desc order by created_date desc
</select> </select>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.copyright.dao.impl.BookSceneAuthDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.copyright.entity.BookSceneAuth">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="book_id" property="bookId" jdbcType="INTEGER"/>
<result column="scene_id" property="sceneId" jdbcType="INTEGER"/>
<result column="channel_id" property="channelId" jdbcType="INTEGER"/>
<result column="adviser_id" property="adviserId" jdbcType="INTEGER"/>
<result column="max_user_count" property="maxUserCount" jdbcType="INTEGER"/>
<result column="full_use_tips" property="fullUseTips" jdbcType="VARCHAR"/>
<result column="created_user" property="createdUser" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_id, scene_id, channel_id, adviser_id, max_user_count, full_use_tips, created_user, create_time, update_time
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM book_scene_auth
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM book_scene_auth
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO book_scene_auth(
book_id,
scene_id,
channel_id,
adviser_id,
max_user_count,
full_use_tips,
created_user,
create_time,
update_time
) VALUES (
#{bookId, jdbcType=INTEGER},
#{sceneId, jdbcType=INTEGER},
#{channelId, jdbcType=INTEGER},
#{adviserId, jdbcType=INTEGER},
#{maxUserCount, jdbcType=INTEGER},
#{fullUseTips, jdbcType=VARCHAR},
#{createdUser, jdbcType=INTEGER},
#{createTime, jdbcType=TIMESTAMP},
#{updateTime, jdbcType=TIMESTAMP}
)
</insert>
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO book_scene_auth (
book_id,
scene_id,
channel_id,
adviser_id,
max_user_count,
full_use_tips,
created_user,
create_time,
update_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.bookId, jdbcType=INTEGER},
#{item.sceneId, jdbcType=INTEGER},
#{item.channelId, jdbcType=INTEGER},
#{item.adviserId, jdbcType=INTEGER},
#{item.maxUserCount, jdbcType=INTEGER},
#{item.fullUseTips, jdbcType=VARCHAR},
#{item.createdUser, jdbcType=INTEGER},
#{item.createTime, jdbcType=TIMESTAMP},
#{item.updateTime, jdbcType=TIMESTAMP}
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE book_scene_auth
<set>
<if test="bookId != null">
book_id = #{bookId},
</if>
<if test="sceneId != null">
scene_id = #{sceneId},
</if>
<if test="channelId != null">
channel_id = #{channelId},
</if>
<if test="adviserId != null">
adviser_id = #{adviserId},
</if>
<if test="maxUserCount != null">
max_user_count = #{maxUserCount},
</if>
<if test="fullUseTips != null and fullUseTips != ''">
full_use_tips = #{fullUseTips},
</if>
<if test="createdUser != null">
created_user = #{createdUser},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE id = #{id}
</update>
<update id="batchUpdate" parameterType="list">
<foreach collection="list" index="index" item="item" separator=";">
UPDATE book_scene_auth
<set>
<if test="item.maxUserCount != null">
max_user_count = #{item.maxUserCount},
</if>
<if test="item.fullUseTips != null and item.fullUseTips != ''">
full_use_tips = #{item.fullUseTips},
</if>
update_time = now(),
</set>
WHERE id = #{item.id}
</foreach>
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM book_scene_auth WHERE id = #{id}
</delete>
<select id="getAuthSceneInfo" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from book_scene_auth
where book_id=#{bookId}
and scene_id=#{sceneId}
limit 1
</select>
<select id="getAuthSceneIds" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_scene_auth
where book_id=#{bookId}
<if test="sceneIds!=null and sceneIds.size()>0">
and scene_id in
<foreach collection="sceneIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment