Browse Source

improve:健康码参数解析兼容问题

lileilei 2 years ago
parent
commit
520df3b002
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/main/java/com/yixin/ms/service/impl/HealthCodeServiceImpl.java

+ 13 - 0
src/main/java/com/yixin/ms/service/impl/HealthCodeServiceImpl.java

@@ -3,6 +3,7 @@ package com.yixin.ms.service.impl;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.UUID;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpUtil;
 import com.alibaba.excel.util.CollectionUtils;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -35,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Executor;
@@ -96,6 +98,17 @@ public class HealthCodeServiceImpl implements HealthCodeService {
             }
         }
 
+        if(StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && (HttpUtil.isHttp(shortTermDTO.getHealthCode()) || HttpUtil.isHttps(shortTermDTO.getHealthCode()))){
+            log.info("请求健康码参数信息: {}", shortTermDTO.getHealthCode());
+            //扫码推送参数为链接,提取杭州健康码barCode参数信息
+            String barCode = HttpUtil.decodeParamMap(shortTermDTO.getHealthCode().toLowerCase(), Charset.defaultCharset()).get("statecouncilbarcode");
+            if(StrUtil.isEmpty(barCode)){
+                throw new ServiceException("请打开支付宝选择杭州健康码重试");
+            }else {
+                shortTermDTO.setHealthCode(barCode);
+            }
+        }
+
         if (StringUtils.isBlank(shortTermDTO.getToken())) {
             throw new ServiceException(700, "token为空哦");
         }