Merge branch 'gyj' into test
This commit is contained in:
@@ -3,19 +3,35 @@ package cn.ysk.cashier.service.impl.shopimpl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import cn.ysk.cashier.domain.QiniuContent;
|
||||
import cn.ysk.cashier.dto.shop.ShopInfoUpdateDTO;
|
||||
import cn.ysk.cashier.dto.shop.ShopMsgRemoveDTO;
|
||||
import cn.ysk.cashier.dto.shop.ShopMsgStateDTO;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopInfoMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopMsgState;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopOpenIdMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopMsgStateService;
|
||||
import cn.ysk.cashier.pojo.shop.TbFullShopId;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.QiNiuService;
|
||||
import cn.ysk.cashier.service.shop.MsgService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.dianguang.cloud.ossservice.service.OSSFactory;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -25,10 +41,16 @@ import java.util.Optional;
|
||||
public class MsgServiceImpl implements MsgService {
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
private final TbShopMsgStateService shopMsgStateService;
|
||||
private final TbShopInfoRepository tbShopInfoRepository;
|
||||
private final ResourceLoader resourceLoader;
|
||||
private final QiNiuService qiNiuService;
|
||||
|
||||
public MsgServiceImpl(TbShopOpenIdMapper shopOpenIdMapper, TbShopMsgStateService shopMsgStateService) {
|
||||
public MsgServiceImpl(TbShopOpenIdMapper shopOpenIdMapper, TbShopMsgStateService shopMsgStateService, TbShopInfoRepository tbShopInfoRepository, ResourceLoader resourceLoader, QiNiuService qiNiuService) {
|
||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||
this.shopMsgStateService = shopMsgStateService;
|
||||
this.tbShopInfoRepository = tbShopInfoRepository;
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.qiNiuService = qiNiuService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,4 +156,25 @@ public class MsgServiceImpl implements MsgService {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> getSubQrCodeUrl(String shopId) {
|
||||
TbShopInfo shopInfo = tbShopInfoRepository.getById(Integer.valueOf(shopId));
|
||||
if (shopInfo == null || shopInfo.getId() == 0) {
|
||||
return ResponseEntity.badRequest().body("店铺信息错误");
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg");
|
||||
try {
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
String url = StrUtil.format("https://invoice.sxczgkj.cn/index/wechat/weuserk?shopId={}", shopId);
|
||||
QrCodeUtil.generate(url, new QrConfig(500, 500).
|
||||
setImg(ImageIO.read(inputStream)).setErrorCorrection(ErrorCorrectionLevel.H).setRatio(4), "png", outputStream);
|
||||
|
||||
QiniuContent content = qiNiuService.uploadByte(outputStream.toByteArray(), qiNiuService.findCloud());
|
||||
return ResponseEntity.ok(content.getUrl());
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.badRequest().body("生成二维码失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.ysk.cashier.dto.shop.ShopMsgStateDTO;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||
import cn.ysk.cashier.pojo.shop.TbFullShopId;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
@@ -20,4 +21,6 @@ public interface MsgService {
|
||||
Optional<Boolean> updateInfo(ShopInfoUpdateDTO shopInfoUpdateDTO);
|
||||
|
||||
HashMap<String, Object> getInfo(Integer shopId, Integer type);
|
||||
|
||||
ResponseEntity<String> getSubQrCodeUrl(String shopId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user