H5调用数据平台验证授信项
。 (1) mobile : 默认手机号。传入该值合法,页面手机号文本框赋值并不可修改
(2)
applyNo: 进件号(必填)
(3) cardId:身份证号
(4) userName: 用户姓名
(5)
successDirectUrl: 成功跳转地址(必填)
String requestIdRes = restTemplate.postForObject(url, null, String.class);
LOGGER.info("getRequestIdUrl res {}", requestIdRes);
String requestId = JSONObject.parseObject(requestIdRes).getString("data");
HashMap<String, Object> map = new HashMap<>();
map.put("applyNo", requestId);
map.put("cardId", CommonUtils.decrypt(userIdnoInfo.getIdNo()));
map.put("mobile", CommonUtils.decrypt(user.getMobile()));
map.put("userName", userIdnoInfo.getName());
map.put("token", System.currentTimeMillis());
map.put("accessToken", MD5Utils.getMD5String(UrlConfig.JWT_SECRET + map.get("token")));
JSONObject jsonObject = new JSONObject();
jsonObject.put("custId", user.getToken());
map.put("relationalParam", jsonObject.toJSONString());
map.put("color", "blue");
StringBuilder sb = new StringBuilder();
sb.append(mobileSuccessdirectUrl).append("/").append(requestId).append("/").append(user.getToken());
map.put("successDirectUrl", sb.toString());
LOGGER.info("mobileValid map:{} ", map.toString());
String token = JwtUtils.sign(map);
StringBuilder resUrl = new StringBuilder();
resUrl.append(UrlConfig.MobileCrawler.MOBILE_H5_URL).append("?color=blue&corpId=")
.append(requestId.substring(0, 3)).append("&token=").append(token);
* 进件号从风控获取,requestid
*token是当前时间戳,最后给数据平台的token是jwt加密后的string串
*accessToken 是密钥和当前时间戳进行md5加密
*JwtUtils是封装的工具栏,具体代码下面有,主要把通用参数放入map
所有参数放入map后,利用jwt把map生产token,发送给数据平台,其实数据平台需要的只是下面几个:
String token = JwtUtils.sign(map); StringBuilder resUrl = new StringBuilder(); resUrl.append(UrlConfig.MobileCrawler.MOBILE_H5_URL).append("?color=blue&corpId=") .append(requestId.substring(0, 3)).append("&token=").append(token);
回头看看数据平台文档:
加密方式
我们会分配一个渠道号(corpId,比如301),每个渠道就相当于一个商户,有自己corpSecret,即密钥,调用的所有步骤都需要加上corpId、token以及accessToken这个参数,accessToken是md5(corpSecret + token)
corpId | string |