Commit 95b174b4 authored by shiyu's avatar shiyu

批量创建打印的二维码,改为无限制小程序码

parent debb1eb1
......@@ -111,6 +111,7 @@ public class WxAppletApi {
return urlLink + " ";
}
/**
* 获取小程序访问数据
* @param startTime
......
......@@ -36,7 +36,6 @@ public class CacheUtil {
@Autowired
CategoryDao categoryDao;
@Autowired
AiAssistantDao aiAssistantDao;
......
......@@ -8,14 +8,16 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
/**
* mvc配置
*/
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
@Bean
LoginInterceptor loginInterceptor() {
return new LoginInterceptor();
......
package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.api.WxAppletApi;
import com.wwdz.ch.core.api.WxLoginManager;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.consts.MediaTypeEnum;
import com.wwdz.ch.core.consts.SupplierItemEnum;
import com.wwdz.ch.core.entity.SupplierItemVo;
import com.wwdz.ch.core.storage.QiniuStorage;
......@@ -29,10 +31,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.IntStream;
import java.util.stream.Stream;
......@@ -62,6 +66,9 @@ public class ItemTagQrCodeServiceImpl implements ItemTagQrCodeService {
@Autowired
SupplierItemService supplierItemService;
@Autowired
WxLoginManager wxLoginManager;
@Override
public Result createQrCode(ItemTagQrCodeRequestDto dto) {
try {
......@@ -72,13 +79,17 @@ public class ItemTagQrCodeServiceImpl implements ItemTagQrCodeService {
ItemTagQrCode itemTagQrCode = new ItemTagQrCode();
itemTagQrCode.setCode(code);
itemTagQrCode.setCategoryId(dto.getCategoryId());
itemTagQrCode.setCategoryName(category.getName());
Category parentCategory = categoryDao.findById(category.getPid());
itemTagQrCode.setCategoryName(parentCategory.getName() + "-" +category.getName());
itemTagQrCode.setCreateTime(now);
//获取页面短链
String url = wxAppletApi.getUrlLink("/pages/blindBoxDetail/index", "code=" + code);
String qrCode = QRCodeUtil.createCodeToBase64(url);
String keyName = CommConsts.UPLOAD_PRE_DIRECTORY + code;
String qrCodeUrl = qiniuStorage.storeItemQrcodeBase64Str(qrCode, keyName);
String keyName = CommConsts.UPLOAD_PRE_WXACODE_DIRECTORY + code + "." + MediaTypeEnum.IMAGE_JPG.getExt();
InputStream inputStream = wxLoginManager.getWxacodeStream("pages/blindBoxDetail/index", code);
if (Objects.isNull(inputStream)) {
return Result.failed("获取微信小程序流失败");
}
// 新生成微信小程序码并上传到七牛云
qiniuStorage.store(inputStream, 1, MediaTypeEnum.IMAGE_JPG.getMime(), keyName);
String qrCodeUrl = qiniuStorage.generateUrl(keyName);
logger.info("上传的商品标签二维码url :{}", qrCodeUrl);
itemTagQrCode.setQrCode(qrCodeUrl);
itemTagQrCodeDao.insert(itemTagQrCode);
......
......@@ -114,7 +114,6 @@ public class SpecialPerformanceNoticeJob {
*/
@Scheduled(fixedDelay = 1000 * 60 * 10)
public void execute() {
RLock lock = redissonClient.getLock(SPECIAL_PERFORMANCE_SEND_MSG_KEY);
if (!lock.tryLock()) {
logger.warn("专场即将开始通知任务,当前服务实例获取锁成功: {} 获取锁失败,锁被占用不执行", Thread.currentThread().getId());
......
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