Commit 16daa14f by 郑勇

feat: [1008097] 编辑运营优化(视频课、版权保护码、素材管理、做书数据、题库、图书配置、公众号资源配置)

parent b8420491
......@@ -252,11 +252,16 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
bookAuthCode.setAdviserId(adviserId);
String fullCode = data[i][1];
bookAuthCode.setFullCode(fullCode);
if (fullCode == null || fullCode.length() < 15) {
//feat:1008097 因为加入了可以导入10位纯数字。所以限制放改成10
if (fullCode == null || fullCode.length() < 10) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "授权码错误");
}
bookAuthCode.setBatchNum(fullCode.substring(0, 4));
bookAuthCode.setAuthCode(fullCode.substring(4, data[i][1].length()));
if(fullCode.length()==10){
bookAuthCode.setBatchNum(fullCode.substring(0, 2));
bookAuthCode.setAuthCode(fullCode.substring(2, data[i][1].length()));
}
bookAuthCode.setUseCount(0);
bookAuthCode.setCreateType(1);
bookAuthCode.setCreatedUser(adviserId);
......
......@@ -140,7 +140,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
bookAuthServeBiz.setBookAuthServes(setAuthOpenParam.getServes(), setAuthOpenParam.getBookId(), setAuthOpenParam.getChannelId(), adviserId);
}
//异步生成条形码并导出
asynExport(setAuthOpenParam.getBookId(), setAuthOpenParam.getChannelId(), adviserId, setAuthOpenParam.getCodeCount(), setAuthOpenParam.getIsHaveBarCode(),setAuthOpenParam.getAuthBookType());
asynExport(setAuthOpenParam.getBookId(), setAuthOpenParam.getChannelId(), adviserId, setAuthOpenParam.getCodeCount(), setAuthOpenParam.getIsHaveBarCode(),setAuthOpenParam.getAuthBookType(),setAuthOpenParam.getCodeComposeType());
Integer authBookType = setAuthOpenParam.getAuthBookType() == null ? 0 : setAuthOpenParam.getAuthBookType();
String key = CopyrightConstants.BOOK_AUTH_INFO + bookAuthInfo.getBookId() + "-" + bookAuthInfo.getChannelId() + "-" + adviserId + "-" + authBookType;
BookAuthInfoVO bookAuth = bookAuthInfoDao.getInfoByBook(setAuthOpenParam.getBookId(), setAuthOpenParam.getChannelId(), adviserId, setAuthOpenParam.getAuthBookType());
......@@ -162,7 +162,18 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
@ParamLog("异步导出")
private void asynExport(Long bookId, Long channelId, Long adviserId, Integer codeCount, Integer isHaveBarCode, Integer authBookType) {
private void asynExport(Long bookId, Long channelId, Long adviserId, Integer codeCount, Integer isHaveBarCode, Integer authBookType, Integer codeComposeType) {
//获取批次号
Integer batchNum = bookAuthCodeBiz.getMaxBatchNum(bookId, channelId, adviserId, authBookType);
if(null!=codeComposeType && codeComposeType==2){
if(batchNum>99){
throw new BookBizException(BookBizException.ERROR, "生成授权码已经超过最大次数了!");
}
}else{
if(batchNum>9999){
throw new BookBizException(BookBizException.ERROR, "生成授权码已经超过最大次数了!");
}
}
ThreadPoolUtils.EXPORT_THREAD_POOL.execute(() -> {
String commitTime = DateUtils.formatDate(new Date());
String num = "";
......@@ -170,9 +181,11 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
if(codeCount == null || codeCount == 0) {
return;
}
//获取批次号
Integer batchNum = bookAuthCodeBiz.getMaxBatchNum(bookId, channelId, adviserId, authBookType);// TODO
// TODO
num = String.format("%04d", batchNum);
if(null!=codeComposeType && codeComposeType==2){
num = String.format("%02d", batchNum);
}
//新增导出记录
insertExportRecord(bookId, channelId, adviserId, num,codeCount,isHaveBarCode);
//获取图书名称
......@@ -181,7 +194,12 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
return;
}
//获取随机数
List<String> uuids = CopyrightTools.createShortUuidByCount(codeCount);
List<String> uuids = new ArrayList<>();
if(null!=codeComposeType && codeComposeType==2){
uuids =CopyrightTools.createShortNumberByCount(codeCount);
}else {
uuids= CopyrightTools.createShortUuidByCount(codeCount);
}
List<BookAuthCode> bookAuthCodes = new ArrayList<>();
for (String uuid : uuids) {
BookAuthCode bookAuthCode = new BookAuthCode();
......
......@@ -77,4 +77,7 @@ public class BookAuthInfo extends BaseEntity {
@ApiModelProperty("授权类型(1-旧版-二维码+授权码,2-升级,二维码)")
private Integer authType;
@ApiModelProperty("授权码组成;1-15位字母+数字,2-10位纯数字")
private Integer codeComposeType;
}
......@@ -98,6 +98,14 @@ public class CopyrightTools {
return new ArrayList<>(numbers);
}
public static List<String> createShortNumberByCount(Integer count) {
Set<String> numbers = new HashSet<>(count);
while (numbers.size() < count) {
numbers.add(RandomUtil.randomString("0123456789", 8));
}
return new ArrayList<>(numbers);
}
public static String generateBarCode128Local(String strBarCode, String dimension, String barheight) {
try {
......
......@@ -56,4 +56,7 @@ public class BookAuthInfoVO implements Serializable {
@ApiModelProperty("授权类型(1-旧版-二维码+授权码,2-升级,二维码)")
private Integer authType;
@ApiModelProperty("授权码组成;1-15位字母+数字,2-10位纯数字")
private Integer codeComposeType;
}
......@@ -57,4 +57,7 @@ public class SetAuthOpenParam implements Serializable {
@ApiModelProperty("打开支付功能;0:关闭;1:开启;")
private Integer openPay;
@ApiModelProperty("授权码组成;1-15位字母+数字,2-10位纯数字")
private Integer codeComposeType;
}
......@@ -16,23 +16,24 @@
<result column="is_authorized_pay" property="isAuthorizedPay" jdbcType="TINYINT" />
<result column="open_pay" property="openPay" jdbcType="TINYINT" />
<result column="auth_type" property="authType" jdbcType="TINYINT" />
<result column="code_compose_type" property="codeComposeType" jdbcType="TINYINT" />
</resultMap>
<insert id="insert" useGeneratedKeys="true" parameterType="bookAuthInfo">
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,
is_paper_book, is_group_book, is_authorized_pay, open_pay,auth_type
is_paper_book, is_group_book, is_authorized_pay, open_pay,auth_type,code_compose_type
)
VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
#{price}, #{codeUseCount,jdbcType=BIGINT}, #{buyUrl}, #{checkType},
#{adviserId,jdbcType=BIGINT}, NOW(), NOW(), NOW(),
#{isPaperBook}, #{isGroupBook}, IFNULL(#{isAuthorizedPay},0), IFNULL(#{openPay},1),IFNULL(#{authType},1))
#{isPaperBook}, #{isGroupBook}, IFNULL(#{isAuthorizedPay},0), IFNULL(#{openPay},1),IFNULL(#{authType},1),#{codeComposeType})
</insert>
<select id="getInfoByBook" resultMap="BookAuthInfoMap" parameterType="map">
SELECT
ID, BOOK_ID, CHANNEL_ID,ADVISER_ID,PRICE,CODE_USE_COUNT,BUY_URL,CHECK_TYPE,BOOK_STATUS,LOCATION_DESC, is_authorized_pay, open_pay,auth_type
ID, BOOK_ID, CHANNEL_ID,ADVISER_ID,PRICE,CODE_USE_COUNT,BUY_URL,CHECK_TYPE,BOOK_STATUS,LOCATION_DESC, is_authorized_pay, open_pay,auth_type,code_compose_type
FROM
BOOK_AUTH_INFO
WHERE
......@@ -276,6 +277,9 @@
<if test="authType != null">
auth_type = #{authType},
</if>
<if test="codeComposeType != null">
code_compose_type = #{codeComposeType},
</if>
LAST_MODIFIED_DATE = NOW()
WHERE
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