puzhibing
2023-11-25 53e7558400dcacecdce70e39ebfe1727740f9296
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.dsh.account.util;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dsh.account.util.httpClinet.HttpClientUtil;
import com.dsh.account.util.httpClinet.HttpResult;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * @author zhibing.pu
 * @date 2023/7/11 12:05
 */
public class JuHeUtil {
 
 
    /**
     * 校验实名认证
     *
     * @param idcard
     * @param name
     * @return
     * @throws Exception
     */
    public static Boolean idcardAuthentication(String idcard, String name) throws Exception {
        Map<String, Object> params = new HashMap<>();
        params.put("idcard", idcard);
        params.put("realname", name);
        params.put("key", "29fec4bbe3108e4fbf52704e5a906fe0");
        HttpResult httpResult = HttpClientUtil.pushHttpRequset("POST", "http://op.juhe.cn/idcard/query", params, null, "form");
        if (httpResult.getCode() != 200) {
            return false;
        }
        JSONObject jsonObject = JSON.parseObject(httpResult.getData());
        Integer error_code = jsonObject.getInteger("error_code");
        if (0 == error_code) {
            JSONObject result = jsonObject.getJSONObject("result");
            Integer res = result.getInteger("res");
            return res == 1 ? true : false;
        }
        return false;
    }
 
}