فهرست منبع

迭代店铺扫码进店功能

fushengqian 1 سال پیش
والد
کامیت
02a62f54f2
15فایلهای تغییر یافته به همراه170 افزوده شده و 88 حذف شده
  1. 6 0
      fuint-application/src/main/java/com/fuint/common/dto/StoreDto.java
  2. 7 5
      fuint-application/src/main/java/com/fuint/common/http/HttpRESTDataClient.java
  3. 1 1
      fuint-application/src/main/java/com/fuint/common/service/StoreService.java
  4. 2 0
      fuint-application/src/main/java/com/fuint/common/service/WeixinService.java
  5. 4 1
      fuint-application/src/main/java/com/fuint/common/service/impl/SendSmsServiceImpl.java
  6. 17 2
      fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java
  7. 61 2
      fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java
  8. 18 0
      fuint-application/src/main/java/com/fuint/common/util/CommonUtil.java
  9. 3 0
      fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java
  10. 1 0
      fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStoreController.java
  11. 8 2
      fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendSubMessageController.java
  12. 1 1
      fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientGoodsController.java
  13. 17 6
      fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSystemController.java
  14. 3 0
      fuint-repository/src/main/java/com/fuint/repository/model/MtStore.java
  15. 21 68
      fuint-utils/src/main/java/com/fuint/utils/QRCodeUtil.java

+ 6 - 0
fuint-application/src/main/java/com/fuint/common/dto/StoreDto.java

@@ -22,12 +22,18 @@ public class StoreDto implements Serializable {
     @ApiModelProperty("商户ID")
     private Integer merchantId;
 
+    @ApiModelProperty("商户号")
+    private String merchantNo;
+
     @ApiModelProperty("商户名称")
     private String merchantName;
 
     @ApiModelProperty("店铺名称")
     private String name;
 
+    @ApiModelProperty("店铺二维码")
+    private String qrCode;
+
     @ApiModelProperty("店铺LOGO")
     private String logo;
 

+ 7 - 5
fuint-application/src/main/java/com/fuint/common/http/HttpRESTDataClient.java

@@ -1,9 +1,13 @@
 package com.fuint.common.http;
 
+import org.apache.http.HttpResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
 import okhttp3.*;
 
 /**
@@ -29,19 +33,17 @@ public class HttpRESTDataClient {
         return response.body().string();
     }
 
-    public static String requestPost(String url, String postData) throws IOException {
+    public static byte[] requestPost(String url, String postData) throws IOException {
         String postBody = postData;
-        MediaType MEDIA_TYPE_MARKDOWN
-                = MediaType.parse("text/xml; charset=utf-8");
+        MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("text/x-markdown;charset=utf-8");
         Request request = new Request.Builder()
                 .url(url)
                 .post(RequestBody.create(MEDIA_TYPE_MARKDOWN, postBody))
                 .build();
-
         Response response = client.newCall(request).execute();
         if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
 
-        return response.body().string();
+        return response.body().bytes();
     }
 
     public static String requestPost(String url, String contentType, String postData) throws IOException {

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/StoreService.java

@@ -67,7 +67,7 @@ public interface StoreService extends IService<MtStore> {
     /**
      * 根据店铺ID查询店铺信息
      *
-     * @param id 店铺ID
+     * @param  id 店铺ID
      * @return
      * @throws BusinessCheckException
      */

+ 2 - 0
fuint-application/src/main/java/com/fuint/common/service/WeixinService.java

@@ -41,4 +41,6 @@ public interface WeixinService {
 
     Boolean doRefund(Integer storeId, String orderSn, BigDecimal totalAmount, BigDecimal refundAmount, String platform) throws BusinessCheckException;
 
+    String createStoreQrCode(Integer merchantId, Integer storeId, Integer width);
+
 }

+ 4 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/SendSmsServiceImpl.java

@@ -6,6 +6,7 @@ import com.fuint.common.dto.MessageResDto;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.service.SendSmsService;
 import com.fuint.common.service.SmsTemplateService;
+import com.fuint.common.util.CommonUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
@@ -129,7 +130,9 @@ public class SendSmsServiceImpl implements SendSmsService {
         boolean flag = false;
         try {
             // idea下中文乱码
-            signName = new String(signName.getBytes("ISO8859-1"), "UTF-8");
+            if (!CommonUtil.isUtf8(signName)) {
+                signName = new String(signName.getBytes("ISO8859-1"), "UTF-8");
+            }
 
             // 阿里云短信
             DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, secret);

+ 17 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java

@@ -8,6 +8,7 @@ import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.enums.YesOrNoEnum;
 import com.fuint.common.service.MerchantService;
 import com.fuint.common.service.StoreService;
+import com.fuint.common.service.WeixinService;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
@@ -52,6 +53,12 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
     @Autowired
     private MerchantService merchantService;
 
+    /**
+     * 微信服务接口
+     * */
+    @Autowired
+    private WeixinService weixinService;
+
     /**
      * 分页查询店铺列表
      *
@@ -169,6 +176,9 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
             mtStore.setMerchantId(storeDto.getMerchantId());
         }
 
+        String qr = weixinService.createStoreQrCode(mtStore.getMerchantId(), mtStore.getId(), 320);
+        mtStore.setQrCode(qr);
+
         if (mtStore.getStatus() == null) {
             mtStore.setStatus(StatusEnum.ENABLED.getKey());
         }
@@ -183,7 +193,7 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
     /**
      * 根据店铺ID获取店铺信息
      *
-     * @param id 店铺ID
+     * @param  id 店铺ID
      * @throws BusinessCheckException
      */
     @Override
@@ -201,7 +211,7 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
      * @throws BusinessCheckException
      */
     @Override
-    public MtStore getDefaultStore(String merchantNo) throws BusinessCheckException {
+    public MtStore getDefaultStore(String merchantNo) {
         Map<String, Object> params = new HashMap<>();
         params.put("status", StatusEnum.ENABLED.getKey());
         params.put("is_default", YesOrNoEnum.YES.getKey());
@@ -273,6 +283,11 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
         StoreDto mtStoreDto = new StoreDto();
         BeanUtils.copyProperties(mtStore, mtStoreDto);
 
+        if (StringUtil.isEmpty(mtStore.getQrCode())) {
+            String qr = weixinService.createStoreQrCode(mtStore.getMerchantId(), mtStore.getId(), 320);
+            mtStoreDto.setQrCode(qr);
+        }
+
         return mtStoreDto;
     }
 

+ 61 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java

@@ -3,16 +3,19 @@ package com.fuint.common.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONArray;
+import com.aliyun.oss.OSS;
 import com.fuint.common.bean.WxPayBean;
 import com.fuint.common.dto.OrderDto;
 import com.fuint.common.dto.UserOrderDto;
 import com.fuint.common.enums.*;
 import com.fuint.common.http.HttpRESTDataClient;
 import com.fuint.common.service.*;
+import com.fuint.common.util.AliyunOssUtil;
 import com.fuint.common.util.RedisUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.web.ResponseObject;
 import com.fuint.repository.model.*;
+import com.fuint.utils.QRCodeUtil;
 import com.fuint.utils.StringUtil;
 import com.ijpay.core.enums.SignType;
 import com.ijpay.core.kit.HttpKit;
@@ -24,6 +27,13 @@ import com.ijpay.wxpay.model.MicroPayModel;
 import com.ijpay.wxpay.model.OrderQueryModel;
 import com.ijpay.wxpay.model.RefundModel;
 import com.ijpay.wxpay.model.UnifiedOrderModel;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.protocol.HTTP;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.core.env.Environment;
+import org.springframework.util.ResourceUtils;
 import weixin.popular.util.JsonUtil;
 
 import javax.crypto.Cipher;
@@ -38,8 +49,7 @@ import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.*;
 import java.math.BigDecimal;
 import java.security.AlgorithmParameters;
 import java.security.Security;
@@ -724,6 +734,55 @@ public class WeixinServiceImpl implements WeixinService {
         }
     }
 
+    /***
+     * 生成店铺二维码
+     *
+     * @param merchantId
+     * @param storeId
+     * @param width
+     * @return
+     * */
+    public String createStoreQrCode(Integer merchantId, Integer storeId, Integer width) {
+        try {
+            String accessToken = getAccessToken(merchantId, true);
+            String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken;
+            String reqDataJsonStr = "";
+
+            Map<String, Object> reqData = new HashMap<>();
+            reqData.put("access_token", accessToken);
+            reqData.put("path", "pages/index/index?storeId=" + storeId);
+            reqData.put("width", width);
+            reqDataJsonStr = JsonUtil.toJSONString(reqData);
+
+            byte[] bytes = HttpRESTDataClient.requestPost(url, reqDataJsonStr);
+            logger.info("WechatService createStoreQrCode response success");
+
+            String pathRoot = env.getProperty("images.root");
+            String baseImage = env.getProperty("images.path");
+            String filePath = "/storeQr" + storeId + ".png";
+            String path = pathRoot + baseImage + filePath;
+            QRCodeUtil.saveQrCodeToLocal(bytes, path);
+
+            // 上传阿里云oss
+            String mode = env.getProperty("aliyun.oss.mode");
+            if (mode.equals("1")) { // 检查是否开启上传
+                String endpoint = env.getProperty("aliyun.oss.endpoint");
+                String accessKeyId = env.getProperty("aliyun.oss.accessKeyId");
+                String accessKeySecret = env.getProperty("aliyun.oss.accessKeySecret");
+                String bucketName = env.getProperty("aliyun.oss.bucketName");
+                String folder = env.getProperty("aliyun.oss.folder");
+                OSS ossClient = AliyunOssUtil.getOSSClient(accessKeyId, accessKeySecret, endpoint);
+                File ossFile = new File(path);
+                return AliyunOssUtil.upload(ossClient, ossFile, bucketName, folder);
+            } else {
+                return baseImage + filePath;
+            }
+        } catch (Exception e) {
+            logger.error("生成店铺二维码出错:" + e.getMessage());
+        }
+        return "";
+    }
+
     /**
      * 获取支付配置
      *

+ 18 - 0
fuint-application/src/main/java/com/fuint/common/util/CommonUtil.java

@@ -35,6 +35,24 @@ public class CommonUtil {
         return new String(ch);
     }
 
+    /**
+     * 判断是否UTF-8编码
+     *
+     * @param str
+     * @return
+     * */
+    public static boolean isUtf8(String str) {
+        try {
+            byte[] bytes = str.getBytes("UTF-8");
+            String newStr = new String(bytes, "UTF-8");
+            return str.equals(newStr);
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+
     /**
      * 判断是否数字
      * */

+ 3 - 0
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java

@@ -308,6 +308,9 @@ public class BackendGoodsController extends BaseController {
 
         Map<String, Object> param = new HashMap<>();
         param.put("status", StatusEnum.ENABLED.getKey());
+        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
+            param.put("merchantId", accountInfo.getMerchantId());
+        }
         List<MtGoodsCate> cateList = cateService.queryCateListByParams(param);
         result.put("cateList", cateList);
 

+ 1 - 0
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStoreController.java

@@ -8,6 +8,7 @@ import com.fuint.common.enums.YesOrNoEnum;
 import com.fuint.common.service.MerchantService;
 import com.fuint.common.service.SettingService;
 import com.fuint.common.service.StoreService;
+import com.fuint.common.service.WeixinService;
 import com.fuint.common.util.CommonUtil;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;

+ 8 - 2
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendSubMessageController.java

@@ -9,6 +9,7 @@ import com.fuint.common.enums.SettingTypeEnum;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.enums.WxMessageEnum;
 import com.fuint.common.service.SettingService;
+import com.fuint.common.util.CommonUtil;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.web.BaseController;
@@ -155,7 +156,10 @@ public class BackendSubMessageController extends BaseController {
                         ParamDto dto = new ParamDto();
                         dto.setKey(obj.get("key").toString());
                         // 解决中文乱码
-                        String pName = new String(obj.get("name").toString().getBytes("ISO8859-1"), "UTF-8");
+                        String pName = obj.get("name").toString();
+                        if (!CommonUtil.isUtf8(pName)) {
+                            pName = new String(obj.get("name").toString().getBytes("ISO8859-1"), "UTF-8");
+                        }
                         dto.setName(pName);
                         if (paramArray != null) {
                             dto.setValue("");
@@ -231,7 +235,9 @@ public class BackendSubMessageController extends BaseController {
 
                 ParamDto para = new ParamDto();
                 String name = obj.get("name").toString();
-                name = new String(name.getBytes("ISO8859-1"), "UTF-8");
+                if (!CommonUtil.isUtf8(name)) {
+                    name = new String(name.getBytes("ISO8859-1"), "UTF-8");
+                }
                 para.setName(name);
                 para.setKey(obj.get("key").toString());
                 para.setValue(value);

+ 1 - 1
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientGoodsController.java

@@ -86,7 +86,7 @@ public class ClientGoodsController extends BaseController {
             param.put("storeId", storeId);
         }
         List<MtGoodsCate> cateList = cateService.queryCateListByParams(param);
-        Map<String, Object> goodsData = goodsService.getStoreGoodsList(storeId, "", 0, 1, 200);
+        Map<String, Object> goodsData = goodsService.getStoreGoodsList(storeId, "", 0, 1, 500);
         List<MtGoods> goodsList = (ArrayList)goodsData.get("goodsList");
         String baseImage = settingService.getUploadBasePath();
         if (goodsList.size() > 0) {

+ 17 - 6
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSystemController.java

@@ -1,6 +1,7 @@
 package com.fuint.module.clientApi.controller;
 
 import com.fuint.common.dto.ParamDto;
+import com.fuint.common.dto.StoreDto;
 import com.fuint.common.dto.UserInfo;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.service.MemberService;
@@ -11,11 +12,13 @@ import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
+import com.fuint.repository.model.MtMerchant;
 import com.fuint.repository.model.MtStore;
 import com.fuint.repository.model.MtUser;
 import com.fuint.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
@@ -88,7 +91,7 @@ public class ClientSystemController extends BaseController {
                 if (!mtUser.getStatus().equals(StatusEnum.ENABLED.getKey())) {
                     return getFailureResult(1001);
                 }
-                // 商户不同
+                // 商户不同
                 if (!mtUser.getMerchantId().equals(merchantId)) {
                     return getFailureResult(1001);
                 }
@@ -103,9 +106,6 @@ public class ClientSystemController extends BaseController {
                 if (!storeInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) {
                     storeInfo = null;
                 }
-                if (storeInfo != null && !merchantId.equals(storeInfo.getMerchantId())) {
-                    storeInfo = null;
-                }
             }
         }
 
@@ -122,18 +122,29 @@ public class ClientSystemController extends BaseController {
             storeInfo = storeService.getDefaultStore(merchantNo);
         }
 
-        // 完善店铺信息
+        // 完善会员的店铺信息
         if (mtUser != null && (mtUser.getStoreId() == null || mtUser.getStoreId() < 1)) {
             mtUser.setStoreId(storeInfo.getId());
             mtUser.setUpdateTime(new Date());
             memberService.updateMember(mtUser);
         }
 
+        StoreDto storeDto = new StoreDto();
+        if (storeInfo != null) {
+            BeanUtils.copyProperties(storeInfo, storeDto);
+            MtMerchant mtMerchant = merchantService.queryMerchantById(storeInfo.getMerchantId());
+            if (mtMerchant != null) {
+                storeDto.setMerchantNo(mtMerchant.getNo());
+            }
+        } else {
+            storeDto = null;
+        }
+
         // 支付方式列表
         List<ParamDto> payTypeList = settingService.getPayTypeList(platform);
 
         Map<String, Object> result = new HashMap<>();
-        result.put("storeInfo", storeInfo);
+        result.put("storeInfo", storeDto);
         result.put("payTypeList", payTypeList);
 
         return getSuccessResult(result);

+ 3 - 0
fuint-repository/src/main/java/com/fuint/repository/model/MtStore.java

@@ -38,6 +38,9 @@ public class MtStore implements Serializable {
     @ApiModelProperty("商户logo")
     private String logo;
 
+    @ApiModelProperty("店铺二维码")
+    private String qrCode;
+
     @ApiModelProperty("是否默认")
     private String isDefault;
 

+ 21 - 68
fuint-utils/src/main/java/com/fuint/utils/QRCodeUtil.java

@@ -1,19 +1,11 @@
 package com.fuint.utils;
 
-import com.google.zxing.*;
-import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.common.HybridBinarizer;
-import com.google.zxing.qrcode.QRCodeReader;
-import com.google.zxing.qrcode.QRCodeWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
 import java.io.*;
-import java.util.HashMap;
 
 /**
  * 二维码生成工具类
@@ -24,69 +16,30 @@ import java.util.HashMap;
 public class QRCodeUtil {
     public static final Logger logger = LoggerFactory.getLogger(QRCodeUtil.class);
 
+    @Autowired
+    private Environment env;
+
     /**
-     * 生成包含字符串信息的二维码图片
+     * 保存二维码
      *
-     * @param outputStream 文件输出流路径
-     * @param content      二维码携带信息
-     * @param width        宽度
-     * @param height       高度
-     * @param imageFormat  二维码的格式
-     */
-    public static boolean createQrCode(OutputStream outputStream, String content, int width, int height, String imageFormat) {
-        //设置二维码纠错级别
-        HashMap<EncodeHintType, String> hints = new HashMap<EncodeHintType, String>();
-        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
-        width = width + 200;
-        height = height + 200;
+     * @param bytes
+     * @return
+     * */
+    public static void saveQrCodeToLocal(byte[] bytes, String path) {
         try {
-            //创建比特矩阵(位矩阵)的QR码编码的字符串
-            QRCodeWriter qrCodeWriter = new QRCodeWriter();
-            BitMatrix byteMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
-
-            // 使BufferedImage勾画QRCode  (matrixWidth 是行二维码像素点)
-            int matrixWidth = byteMatrix.getWidth();
-            BufferedImage image = new BufferedImage(matrixWidth - 200, matrixWidth - 200, BufferedImage.TYPE_INT_RGB);
+            InputStream inputStream = new ByteArrayInputStream(bytes);
+            FileOutputStream out = new FileOutputStream(path);
 
-            // 使用比特矩阵画并保存图像
-            image.createGraphics();
-            Graphics2D graphics = (Graphics2D) image.getGraphics();
-            graphics.setColor(Color.WHITE);
-            graphics.fillRect(0, 0, matrixWidth, matrixWidth);
-            graphics.setColor(Color.BLACK);
-            for (int i = 0; i < matrixWidth; i++) {
-                for (int j = 0; j < matrixWidth; j++) {
-                    if (byteMatrix.get(i, j)) {
-                        graphics.fillRect(i - 100, j - 100, 1, 1);
-                    }
-                }
+            byte[] buffer = new byte[8192];
+            int bytesRead;
+            while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
+                out.write(buffer, 0, bytesRead);
             }
-            return ImageIO.write(image, imageFormat, outputStream);
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-        }
-        return false;
-    }
-
-    /**
-     * 读二维码并输出携带的信息
-     */
-    public static void readQrCode(InputStream inputStream) throws IOException {
-        //设置二维码纠错级别
-        HashMap<DecodeHintType, String> hints = new HashMap<DecodeHintType, String>();
-        hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
-        //从输入流中获取字符串信息
-        BufferedImage image = ImageIO.read(inputStream);
-        //将图像转换为二进制位图源
-        LuminanceSource source = new BufferedImageLuminanceSource(image);
-        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
-        QRCodeReader reader = new QRCodeReader();
-        Result result = null;
-        try {
-            result = reader.decode(bitmap, hints);
-        } catch (ReaderException e) {
-            logger.error(e.getMessage(), e);
+            out.flush();
+            inputStream.close();
+            out.close();
+        } catch (IOException e) {
+            e.printStackTrace();
         }
-        logger.info(result.getText());
     }
 }