Commit d5eb2b53 by 田超

Merge branch 'fixbug/perfCheckCode' into 'master'

bug: [none] 优化授权码接口

See merge request rays/pcloud-book!1047
parents 0a639509 d9c65ae1
...@@ -155,16 +155,15 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz { ...@@ -155,16 +155,15 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
if (isHaveAuth) { if (isHaveAuth) {
return BookStatusEnum.CodeUseTypeEnum.RIGHT.value; return BookStatusEnum.CodeUseTypeEnum.RIGHT.value;
} }
Boolean isHaveCode = bookAuthCodeDao.getIsHaveCode(bookId, channelId, adviserId, code, authBookType); Long authCodeId = bookAuthCodeDao.getBookAuthCodeId(bookId, channelId, adviserId, code, authBookType);
Integer count = bookAuthCodeDao.updateUseCount(bookId, channelId, adviserId, code, authBookInfo.getCodeUseCount(), authBookType); Integer count = bookAuthCodeDao.updateUseCount(bookId, channelId, adviserId, code, authBookInfo.getCodeUseCount(), authBookType);
if (count < 1 && isHaveCode) { if (count < 1 && authCodeId != null && authCodeId > 0) {
return BookStatusEnum.CodeUseTypeEnum.HAVE_USE.value; return BookStatusEnum.CodeUseTypeEnum.HAVE_USE.value;
} else if (count < 1 && !isHaveCode) { } else if (count < 1 && (authCodeId == null || authCodeId == 0)) {
return BookStatusEnum.CodeUseTypeEnum.NOT_RIGHT.value; return BookStatusEnum.CodeUseTypeEnum.NOT_RIGHT.value;
} else { } else {
BookAuthCode bookAuthCode = bookAuthCodeDao.getByFullCode(code);
//新增一条校验成功记录 //新增一条校验成功记录
addUserRecord(bookId, channelId, adviserId, wechatUserId, authBookType, bookAuthCode.getId()); addUserRecord(bookId, channelId, adviserId, wechatUserId, authBookType, authCodeId);
return BookStatusEnum.CodeUseTypeEnum.RIGHT.value; return BookStatusEnum.CodeUseTypeEnum.RIGHT.value;
} }
} }
......
...@@ -29,6 +29,11 @@ public interface BookAuthCodeDao extends BaseDao<BookAuthCode> { ...@@ -29,6 +29,11 @@ public interface BookAuthCodeDao extends BaseDao<BookAuthCode> {
Boolean getIsHaveCode(Long bookId, Long channelId, Long adviserId, String code, Integer authBookType); Boolean getIsHaveCode(Long bookId, Long channelId, Long adviserId, String code, Integer authBookType);
/** /**
* 获取码数量
*/
Long getBookAuthCodeId(Long bookId, Long channelId, Long adviserId, String code, Integer authBookType);
/**
* 批量删除正版授权码 * 批量删除正版授权码
* @param ids * @param ids
*/ */
......
...@@ -65,6 +65,21 @@ public class BookAuthCodeDaoImpl extends BaseDaoImpl<BookAuthCode> implements Bo ...@@ -65,6 +65,21 @@ public class BookAuthCodeDaoImpl extends BaseDaoImpl<BookAuthCode> implements Bo
} }
@Override @Override
public Long getBookAuthCodeId(Long bookId, Long channelId, Long adviserId, String code, Integer authBookType) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId);
paramMap.put("code",code);
if(authBookType == null || authBookType.equals(0)) {
paramMap.put("isPaperBook", 1);
} else {
paramMap.put("isGroupBook", 1);
}
return this.getSqlSession().selectOne(this.getStatement("getBookAuthCodeId"), paramMap);
}
@Override
public void batchDeleteCode(List<Long> ids) { public void batchDeleteCode(List<Long> ids) {
this.getSqlSession().delete(this.getStatement("batchDeleteCode"), ids); this.getSqlSession().delete(this.getStatement("batchDeleteCode"), ids);
} }
......
...@@ -86,6 +86,30 @@ ...@@ -86,6 +86,30 @@
</if> </if>
</select> </select>
<select id="getBookAuthCodeId" resultType="Long" parameterType="map">
SELECT
id
FROM
BOOK_AUTH_CODE
WHERE
BOOK_ID = #{bookId, jdbcType=BIGINT}
AND
CHANNEL_ID = #{channelId, jdbcType=BIGINT}
AND
ADVISER_ID = #{adviserId, jdbcType=BIGINT}
AND
FULL_CODE = #{code}
<if test="isPaperBook != null">
AND
is_paper_book = #{isPaperBook}
</if>
<if test="isGroupBook!=null">
AND
is_group_book = #{isGroupBook}
</if>
LIMIT 1
</select>
<select id="getCodeList" parameterType="map" resultType="com.pcloud.book.copyright.dto.BookAuthCodeDTO"> <select id="getCodeList" parameterType="map" resultType="com.pcloud.book.copyright.dto.BookAuthCodeDTO">
SELECT SELECT
id id, id 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