ソースを参照

update
身份证校验方式

lifang 3 ヶ月 前
コミット
7fe589315c

+ 1 - 1
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/impl/BizClinicRoomServiceImpl.java

@@ -452,7 +452,7 @@ public class BizClinicRoomServiceImpl implements IBizClinicRoomService {
             return Boolean.TRUE;
         }
         IdCardInfoVO cardInfoVO = Id2Utils.getInfo(source.getName(), source.getCardNo());
-        if (!"0000".equals(cardInfoVO.getRespCode())) {
+        if (!"0".equals(cardInfoVO.getRespCode())) {
             return Boolean.FALSE;
         }
         idCard = new BizIdCardPO();

+ 17 - 3
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/wx/utils/Id2Utils.java

@@ -6,6 +6,8 @@ import java.util.Map;
 
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSON;
+import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import cn.tr.core.utils.JsonUtils;
 import cn.tr.module.smart.wx.controller.vo.IdCardInfoVO;
@@ -18,7 +20,7 @@ import okhttp3.Response;
 
 public class Id2Utils {
 	private static String url = "https://kzidcardv1.market.alicloudapi.com/api-mall/api/id_card/check";
-	private static String appCode = "83359fd73fe94948385f570e3c139105";
+	private static String appCode = "0b50e932833a476b96d6aafae04d95b0";
 
 	public static IdCardInfoVO getInfo(String name, String idNo) throws IOException {
 		return postData(appCode, url, name, idNo);
@@ -61,10 +63,22 @@ public class Id2Utils {
 			System.out.println("request failed----" + "返回状态码" + response.code()  + ",message:" + response.message());
 		}
 		String result = response.body().string();    //此处不可以使用toString()方法,该方法已过期
-		return JsonUtils.parseObject(result, IdCardInfoVO.class);
+		JSON parse = JSONUtil.parse(result);
+		IdCardInfoVO r = new IdCardInfoVO();
+		if("成功".equals(parse.getByPath("msg"))){
+			r.setRespCode("0");
+			r = JSONUtil.toBean((JSONObject) JSONUtil.getByPath(JSONUtil.parse(result), "data"), IdCardInfoVO.class);
+			r.setIdNo(idNo);
+			r.setName(name);
+		}else {
+			r.setRespMessage(parse.getByPath("msg",String.class));
+			r.setRespCode(parse.getByPath("code",String.class));
+		}
+
+		return r;
 	}
 
 	public static void main(String[] args) throws IOException {
-		System.out.println(getInfo("李放", "410728199802040031"));
+		System.out.println(getInfo("李放", "410728199802040030"));
 	}
 }