Commit 95b174b4 authored by shiyu's avatar shiyu

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

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