Commit 8cccfcc1 authored by 黎博's avatar 黎博

新增造数据接口

parent 0413397c
...@@ -101,6 +101,13 @@ ...@@ -101,6 +101,13 @@
<version>1.1.10</version> <version>1.1.10</version>
</dependency> </dependency>
<!--集成redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<!--lombok--> <!--lombok-->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
...@@ -133,6 +140,7 @@ ...@@ -133,6 +140,7 @@
<artifactId>commons-dbutils</artifactId> <artifactId>commons-dbutils</artifactId>
<version>1.6</version> <version>1.6</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -3,6 +3,7 @@ package cn.qg.qaplatform; ...@@ -3,6 +3,7 @@ package cn.qg.qaplatform;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication @SpringBootApplication
@MapperScan(value = "cn.qg.qaplatform.dao") @MapperScan(value = "cn.qg.qaplatform.dao")
......
...@@ -9,7 +9,8 @@ public enum Namespace { ...@@ -9,7 +9,8 @@ public enum Namespace {
TEST1("test1", "test1","jdbc:mysql://172.17.5.14:31548/", "qa", "qatest"), TEST1("test1", "test1","jdbc:mysql://172.17.5.14:31548/", "qa", "qatest"),
XJFQ("xjfq", "xjfq", "jdbc:mysql://172.17.5.2:32188/", "qa", "qatest"), XJFQ("xjfq", "xjfq", "jdbc:mysql://172.17.5.2:32188/", "qa", "qatest"),
XYQB("xyqb", "xyqb","jdbc:mysql://172.17.5.5:32556/", "qa", "qatest"), XYQB("xyqb", "xyqb","jdbc:mysql://172.17.5.5:32556/", "qa", "qatest"),
FE("fe", "fe", "jdbc:mysql://172.17.5.9:31024/", "qa", "qatest"); FE("fe", "fe", "jdbc:mysql://172.17.5.9:31024/", "qa", "qatest"),
VCC("vcc", "vcc", "jdbc:mysql://172.17.5.8:31110/", "qa", "qatest");
private String key; private String key;
private String desc; private String desc;
......
package cn.qg.qaplatform.controller;
import cn.qg.qaplatform.common.JsonResult;
import cn.qg.qaplatform.domain.ApplyLoanInfo;
import cn.qg.qaplatform.service.GenUserDataService;
import cn.qg.qaplatform.service.QueryBasicLoanStatusDataService;
import cn.qg.qaplatform.utils.RandomDataUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/gen")
public class GenLoanUserDataController {
@Autowired
GenUserDataService genUserDataService;
@Autowired
QueryBasicLoanStatusDataService queryBasicLoanStatusDataService;
@PostMapping("/loanUser")
public JsonResult genLoanUserData(@RequestBody ApplyLoanInfo applyLoanInfo) throws Exception {
if (applyLoanInfo.getNamespace() == null) {
return JsonResult.clientFailed("namespace不能为空!");
}
if (applyLoanInfo.getChannel() == null) {
return JsonResult.clientFailed("渠道不能为空!");
}
if (applyLoanInfo.getStatus() == null) {
return JsonResult.clientFailed("借款状态不能为空!");
}
// 如果手机号为空,则生成一个user库里没有的手机号
if (applyLoanInfo.getPhoneNo() == null) {
while (true) {
String phoneNo = RandomDataUtils.createMobile();
if (!queryBasicLoanStatusDataService.queryIfPhoneExist(applyLoanInfo.getNamespace(), phoneNo)) {
applyLoanInfo.setPhoneNo(phoneNo);
break;
}
}
}
if (applyLoanInfo.getAmount() == null) {
applyLoanInfo.setAmount(10000);
}
if (applyLoanInfo.getTerm() == null) {
applyLoanInfo.setTerm(6);
}
boolean result = genUserDataService.genLoanUser(applyLoanInfo);
return JsonResult.success(result);
}
@GetMapping("/supportChannelAndFund")
public JsonResult getSupportedLoanUserData() {
Map<String, List> map = new HashMap();
List<Integer> supportChannel = new ArrayList<>();
List<Integer> supportFund = new ArrayList<>();
supportChannel.add(1);
supportChannel.add(214);
supportChannel.add(217);
supportFund.add(480);
map.put("channelList", supportChannel);
map.put("fundList", supportFund);
return JsonResult.success(map);
}
}
...@@ -5,16 +5,14 @@ import cn.qg.qaplatform.common.JsonResult; ...@@ -5,16 +5,14 @@ import cn.qg.qaplatform.common.JsonResult;
import cn.qg.qaplatform.service.QueryBasicLoanStatusDataService; import cn.qg.qaplatform.service.QueryBasicLoanStatusDataService;
import cn.qg.qaplatform.utils.page.PageResult; import cn.qg.qaplatform.utils.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping("query")
public class QueryLoanUserDataController { public class QueryLoanUserDataController {
@Autowired @Autowired
...@@ -26,7 +24,7 @@ public class QueryLoanUserDataController { ...@@ -26,7 +24,7 @@ public class QueryLoanUserDataController {
/** /**
* @return 获取所有借款用户状态 * @return 获取所有借款用户状态
*/ */
@GetMapping("/allUserLoanStatus") @GetMapping("/getAllStatus")
public JsonResult getLoanUserDataStatus() { public JsonResult getLoanUserDataStatus() {
List<Map<String, Object>> statusList = basicLoanStatusDataService.getAllUserLoanStatus(); List<Map<String, Object>> statusList = basicLoanStatusDataService.getAllUserLoanStatus();
return JsonResult.success(statusList); return JsonResult.success(statusList);
...@@ -35,7 +33,7 @@ public class QueryLoanUserDataController { ...@@ -35,7 +33,7 @@ public class QueryLoanUserDataController {
/** /**
* @return 获取所有环境namespace * @return 获取所有环境namespace
*/ */
@GetMapping("/allEnvInfo") @GetMapping("/getAllEnv")
public JsonResult getAllEnvInfo() { public JsonResult getAllEnvInfo() {
List<Map<String, Object>> envList = basicLoanStatusDataService.getAllEnvInfo(); List<Map<String, Object>> envList = basicLoanStatusDataService.getAllEnvInfo();
return JsonResult.success(envList); return JsonResult.success(envList);
...@@ -47,7 +45,7 @@ public class QueryLoanUserDataController { ...@@ -47,7 +45,7 @@ public class QueryLoanUserDataController {
* @param pageSize * @param pageSize
* @return 所有借款用户数据 * @return 所有借款用户数据
*/ */
@GetMapping("/getLoanUserData") @GetMapping("/loanUser")
public JsonResult getLoanUserData(@RequestParam(value = "namespace") String namespace, public JsonResult getLoanUserData(@RequestParam(value = "namespace") String namespace,
@RequestParam(value = "status") Integer status, @RequestParam(value = "status") Integer status,
@RequestParam(value = "channel" ) Integer channel, @RequestParam(value = "channel" ) Integer channel,
...@@ -63,9 +61,14 @@ public class QueryLoanUserDataController { ...@@ -63,9 +61,14 @@ public class QueryLoanUserDataController {
* @param phone * @param phone
* @return * @return
*/ */
@GetMapping("/checkPhoneExistence") @GetMapping("/phoneExistence")
public JsonResult checkPhoneExistence(@RequestParam(value = "namespace") String namespace, public JsonResult checkPhoneExistence(@RequestParam(value = "namespace") String namespace,
@RequestParam(value = "phone") String phone) { @RequestParam(value = "phone") String phone) {
return JsonResult.success(basicLoanStatusDataService.queryIfPhoneExist(namespace, phone)); return JsonResult.success(basicLoanStatusDataService.queryIfPhoneExist(namespace, phone));
} }
@GetMapping("/getUserInfoByPhoneNo")
public JsonResult getUserInfoByPhoneNo(@RequestParam(value = "phoneNo") String phoneNo) {
return null;
}
} }
package cn.qg.qaplatform.domain;
import lombok.Data;
/**
* 造数据传递的参数实体类
*/
@Data
public class ApplyLoanInfo {
/**
* 状态
*/
private Integer status;
/**
* 环境
*/
private String namespace;
/**
* 手机号
*/
private String phoneNo;
/**
* 渠道
*/
private Integer channel;
/**
* 资方
*/
private Integer fundId;
/**
* 借款金额
*/
private Integer amount;
/**
* 借款期数
*/
private Integer term;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package cn.qg.qaplatform.service;
import cn.qg.qaplatform.domain.ApplyLoanInfo;
import java.sql.SQLException;
public interface GenUserDataService {
/**
* 授信
* @param applyLoanInfo 造数据的相关信息
* @return 成功或失败
*/
boolean quotaAuth(ApplyLoanInfo applyLoanInfo, boolean auditResult) throws Exception;
/**
* 提现
* @param applyLoanInfo 造数据相关信息
* @return 成功或失败
*/
boolean withDraw(ApplyLoanInfo applyLoanInfo) throws Exception;
/**
* 放款
* @param applyLoanInfo
* @return
*/
boolean makeLoan(ApplyLoanInfo applyLoanInfo, boolean payStatus) throws Exception;
boolean genLoanUser(ApplyLoanInfo applyLoanInfo) throws Exception;
}
package cn.qg.qaplatform.service.impl;
import cn.qg.qaplatform.domain.ApplyLoanInfo;
import cn.qg.qaplatform.process.xyqb.MainProcess;
import cn.qg.qaplatform.service.GenUserDataService;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class GenUserDataServiceImpl implements GenUserDataService {
/**
* 授信
* @param applyLoanInfo 造数据的相关信息
* @return
* @throws Exception
*/
@Override
public boolean quotaAuth(ApplyLoanInfo applyLoanInfo, boolean auditResult) throws Exception {
String namespace = applyLoanInfo.getNamespace();
String phoneNo = applyLoanInfo.getPhoneNo();
Integer channelId = applyLoanInfo.getChannel();
Integer fundId = applyLoanInfo.getFundId();
Integer amount = applyLoanInfo.getAmount();
Integer term = applyLoanInfo.getTerm();
// 登录
String token = MainProcess.login(namespace, channelId, phoneNo);
// 查询用户中心id
Map map = MainProcess.checkUserId(namespace, phoneNo);
String uuid = map.get("uuid").toString();
String userId = map.get("id").toString();
// 同步session到xyqb
MainProcess.syncSessionToXyqb(namespace, token);
// 授信session同步
MainProcess.creditSessionSync(namespace, "1", token);
// 实名认证
MainProcess.realNameAuth(namespace, token);
// 基本信息认证
MainProcess.authBasicInfo(namespace, token);
// 进入上传身份证页
String ocrToken = MainProcess.enterAuthOcr(namespace, token);
// 上传身份证正面
MainProcess.uploadFrontOfIdCard(ocrToken);
// 上传身份证反面
MainProcess.uploadBackOfIdCard(ocrToken);
// 提交拍照认证
MainProcess.submitPhotoAuth(ocrToken);
// 授信
MainProcess.credit(namespace, phoneNo, userId, uuid);
// 提交审核
MainProcess.submitAudit(namespace, token);
// 查询用户审核记录
Map authResult = MainProcess.queryUserAuditRecord(namespace, userId);
String orderNo = authResult.get("order_no").toString().trim();
String productId = authResult.get("product_id").toString();
// 风控授信回调
boolean result = MainProcess.creditAuthNotify(namespace, token, uuid, channelId, fundId, orderNo, 0, auditResult, amount, term);
return result;
}
/**
* 提现
* @param applyLoanInfo 造数据相关信息
* @return
* @throws Exception
*/
@Override
public boolean withDraw(ApplyLoanInfo applyLoanInfo) throws Exception {
String namespace = applyLoanInfo.getNamespace();
String phoneNo = applyLoanInfo.getPhoneNo();
Integer channelId = applyLoanInfo.getChannel();
Integer fundId = applyLoanInfo.getFundId();
Integer amount = applyLoanInfo.getAmount();
Integer term = applyLoanInfo.getTerm();
// 登录
String token = MainProcess.login(namespace, channelId, phoneNo);
// 查询用户中心id
Map map = MainProcess.checkUserId(namespace, phoneNo);
String uuid = map.get("uuid").toString();
String userId = map.get("id").toString();
// 同步session到xyqb
MainProcess.syncSessionToXyqb(namespace, token);
// 查询用户审核记录
Map authResult = MainProcess.queryUserAuditRecord(namespace, userId);
String orderNo = authResult.get("order_no").toString().trim();
String productId = authResult.get("product_id").toString();
// 查询accountId
Map accountMap = MainProcess.getUserAccountId(namespace, userId, productId);
Long accountId = (Long) accountMap.get("id");
// 绑卡
String payToken = MainProcess.bindCard(namespace, token, accountId);
// 绑卡发送短信
MainProcess.cardAuthSms(namespace, payToken, phoneNo);
// 绑卡确认
MainProcess.cardAuthSmsConfirm(namespace, payToken);
// 获取绑卡列表
Map firstCard = MainProcess.getBindCardList(namespace, token, accountId);
Integer cardId = (Integer) firstCard.get("id");
Integer cardBindInfoId = (Integer) firstCard.get("cardBindInfoId");
// 绑卡后提现
Integer loanId = MainProcess.createLoan(namespace, token, amount, term, accountId, productId, cardId, cardBindInfoId);
// 二次风控
boolean result = MainProcess.externalQuotaOrderAuditNotify(namespace, token, uuid, loanId, 0);
// 修改合同状态
MainProcess.modifyContactStatus(namespace, userId);
return result;
}
/**
* 放款
* @param applyLoanInfo
* @return
*/
@Override
public boolean makeLoan(ApplyLoanInfo applyLoanInfo, boolean payStatus) throws Exception {
String namespace = applyLoanInfo.getNamespace();
String phoneNo = applyLoanInfo.getPhoneNo();
Integer channelId = applyLoanInfo.getChannel();
Integer fundId = applyLoanInfo.getFundId();
Integer amount = applyLoanInfo.getAmount();
Integer term = applyLoanInfo.getTerm();
// 登录
String token = MainProcess.login(namespace, channelId, phoneNo);
// 查询用户中心id
Map map = MainProcess.checkUserId(namespace, phoneNo);
String uuid = map.get("uuid").toString();
String userId = map.get("id").toString();
// 登录OP,获取token
String opToken = MainProcess.loginOP(namespace);
// 查询待打款数量
Map<String, Integer> peopleMap = MainProcess.checkWaitingFundingCorpOperatePeople(namespace, fundId);
Integer money = peopleMap.get("money");
Integer people = peopleMap.get("people");
// 修改待放款用户创建时间
Integer loanId = MainProcess.getLoanId(namespace, userId);
MainProcess.modifyWaitingFundingCreatedAt(namespace, loanId);
Thread.sleep(5000);
// 直接打款
MainProcess.fundsPlanLoanApply(namespace,opToken, fundId, money, people);
Thread.sleep(30000);
// 放款结果通知
boolean result = MainProcess.payNotify(namespace, loanId, payStatus);
return result;
}
@Override
public boolean genLoanUser(ApplyLoanInfo applyLoanInfo) throws Exception {
Integer status = applyLoanInfo.getStatus();
/**
* 0 - 审核通过
*/
if (status == 0) {
return quotaAuth(applyLoanInfo, true);
}
/**
* 1 - 审核拒绝
*/
if (status == 1) {
return quotaAuth(applyLoanInfo, false);
}
/**
* 2 - 放款中
*/
if (status == 2) {
boolean result = quotaAuth(applyLoanInfo, true);
if (!result) {
return false;
}
Thread.sleep(300000);
return withDraw(applyLoanInfo);
}
/**
* 3 - 放款成功
*/
if (status == 3) {
boolean quotaAuthResult = quotaAuth(applyLoanInfo, true);
if (!quotaAuthResult) {
return false;
}
Thread.sleep(300000);
boolean withDrawResult = withDraw(applyLoanInfo);
if (!withDrawResult) {
return false;
}
Thread.sleep(10000);
return makeLoan(applyLoanInfo, true);
}
/**
* 4 - 放款失败
*/
if (status == 4) {
boolean quotaAuthResult = quotaAuth(applyLoanInfo, true);
if (!quotaAuthResult) {
return false;
}
Thread.sleep(300000);
boolean withDrawResult = withDraw(applyLoanInfo);
if (!withDrawResult) {
return false;
}
Thread.sleep(10000);
return makeLoan(applyLoanInfo, false);
}
return false;
}
}
...@@ -187,7 +187,12 @@ public class HttpClientUtils { ...@@ -187,7 +187,12 @@ public class HttpClientUtils {
CloseableHttpResponse response = client.execute(post); CloseableHttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
String respEntity = EntityUtils.toString(entity, "utf-8"); String respEntity = EntityUtils.toString(entity, "utf-8");
jsonResult = JSONObject.parseObject(respEntity); try {
jsonResult = JSONObject.parseObject(respEntity);
} catch (JSONException e) {
// e.printStackTrace();
jsonResult.put("content", respEntity.toString());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
package cn.qg.qaplatform.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
/**
* redis 工具类
*/
@Component
@Slf4j
public class RedisUtils {
@Resource
private RedisTemplate<String, Object> redisTemplate;
/**
* 指定缓存失效时间
* @param key 键
* @param time 失效时间
* @return
*/
public boolean expire(String key, long time) {
try {
if (time > 0) {
redisTemplate.expire(key, time, TimeUnit.SECONDS);
}
return true;
} catch (Exception e) {
log.error(key, e);
return false;
}
}
/**
* 获取过期时间
* @param key 键
* @return
*/
public long getExpire(String key) {
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
}
/**
* 判断key是否存在
* @param key
* @return
*/
public boolean hasKey(String key) {
try {
return redisTemplate.hasKey(key);
} catch (Exception e) {
log.error(key, e);
return false;
}
}
/**
* 删除缓存
* @param key
*/
@SuppressWarnings("unchecked")
public void del(String... key) {
if (key != null && key.length > 0) {
if (key.length == 1) {
redisTemplate.delete(key[0]);
} else {
redisTemplate.delete(CollectionUtils.arrayToList(key));
}
}
}
/**
* 普通缓存获取
* @param key 键
* @return
*/
public Object get(String key) {
return key == null ? null : redisTemplate.opsForValue().get(key);
}
/**
* 普通缓存放入
* @param key 键
* @param value 值
* @return
*/
public boolean set(String key, Object value) {
try {
redisTemplate.opsForValue().set(key, value);
return true;
} catch (Exception e) {
log.error(key, e);
return false;
}
}
/**
* 普通缓存放入并设置时间
* @param key 键
* @param value 值
* @param time 过期时间
* @return
*/
public boolean set(String key, Object value, long time) {
try {
if (time > 0) {
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
} else {
set(key, value);
}
return true;
} catch (Exception e) {
log.error(key, e);
return false;
}
}
}
...@@ -9,6 +9,16 @@ spring: ...@@ -9,6 +9,16 @@ spring:
jackson: jackson:
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8 time-zone: GMT+8
redis:
host: localhost
port: 6379
database: 0
password:
jedis:
pool:
max-active: 8
max-wait: -1
max-idle: 8
server: server:
port: 8082 port: 8082
...@@ -34,6 +44,3 @@ logging: ...@@ -34,6 +44,3 @@ logging:
cn.qg.qaplatform: debug cn.qg.qaplatform: debug
file: file:
name: /home/quant_group/logs/qa-platform.log name: /home/quant_group/logs/qa-platform.log
management:
health
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
package cn.quantgroup.qaplatform.test;
import cn.quantgroup.qaplatform.utils.DBUtils;
import cn.quantgroup.qaplatform.utils.EncryptUtils;
import cn.quantgroup.qaplatform.utils.HttpClientUtils;
import cn.quantgroup.qaplatform.utils.JsonTransUtils;
import com.alibaba.fastjson.JSONObject;
import java.net.URISyntaxException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class ProcessTest {
public static String namespace = "test1";
public static String phone = "13712345678";
public static String token = "";
public static String uuid = "";
public static Long userId;
public static int productId = 1;
public static String name = "刘志国";
public static String idNo = "455129197108031107";
public static Long createdFrom = 1L;
/**
* 标准登录
*
* @throws Exception
*/
public static void login() throws Exception {
String url = "http://passportapi-" + namespace + ".liangkebang.net" + "/user/login/fastV1";
Map<String, Object> params = new HashMap<>();
params.put("channelId", "1");
params.put("createdFrom", "1");
params.put("key", "xyqb");
params.put("btRegisterChannelId", "");
params.put("dimension", "");
params.put("click_id", "");
Map<String, Object> header = new HashMap<String, Object>();
header.put("Content-Type", "application/x-www-form-urlencoded");
String verification = EncryptUtils.base64Encrypt(phone);
header.put("Authorization", verification);
JSONObject result = HttpClientUtils.doPost(url, params, header);
Map map = (Map) result.get("data");
token = (String) map.get("token");
System.out.println("登录: " + result);
}
/**
* 查询用户中心id
*
* @throws SQLException
*/
public static void checkUserId() throws SQLException {
String sql = "select id, uuid from user where phone_no=" + phone;
DBUtils dbUtils = new DBUtils(namespace, "xyqb_user", "qa", "qatest");
dbUtils.connect();
Map result = dbUtils.queryForMap(sql);
uuid = (String) result.get("uuid");
userId = (Long) result.get("id");
System.out.println("查询用户中心id: " + result);
dbUtils.closeConnection();
}
/**
* 同步session到xyqb
*
* @throws URISyntaxException
*/
public static void syncSessionToXyqb() throws URISyntaxException {
String url = "http://api-" + namespace + ".liangkebang.net" + "/ex/login/receive_token?token=" + token;
HttpClientUtils.doGetWithoutResponse(url);
}
/**
* 授信session同步
*
* @throws URISyntaxException
*/
public static void creditSessionSync() throws URISyntaxException {
String url = "http://api-" + namespace + ".liangkebang.net" + "/v3/credit/apply?productId=" + productId;
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("x-auth-token", token);
JSONObject result = HttpClientUtils.doGet(url, null, headers);
System.out.println("授信session同步");
System.out.println(result);
if (!result.get("code").equals("0000")) {
System.out.println("授信session同步失败");
}
}
/**
* 实名认证
*/
public static void realNameVerified() {
String url = "http://api-" + namespace + ".liangkebang.net" + "/loan/auth/id_no";
Map<String, Object> params = new HashMap<>();
params.put("name", name);
params.put("idNo", idNo);
params.put("idType", 0);
Map<String, Object> headers = new HashMap<>();
headers.put("x-auth-token", token);
JSONObject result = HttpClientUtils.doPost(url, params, headers);
System.out.println("实名认证:" + result);
}
/**
* 基本信息认证
*/
public static void authBasicInfo() {
String url = "http://scapi-" + namespace + ".liangkebang.net" + "/auth/basic2/infos";
Map<String, Object> headers = new HashMap<>();
headers.put("x-auth-token", token);
Map<String, Object> params = new HashMap<>();
params.put("firstName", "任明星");
params.put("firstMobile", "13500000002");
params.put("firstRelation", 2);
params.put("secondName", "陈玉秋");
params.put("secondMobile", "13500000001");
params.put("secondRelation", 2);
params.put("address", "中国电子大厦");
params.put("city", "市辖区");
params.put("cityCode", 110100);
params.put("province", "北京市");
params.put("provinceCode", 110000);
params.put("districtCode", 110116);
params.put("vocation", 3);
params.put("salary", 3);
params.put("education", 3);
params.put("email", "12345678@qq.com");
JSONObject result = HttpClientUtils.doPost(url, params, headers);
System.out.println("基本信息认证:" + result);
}
/**
* 进入上传身份证页
*/
public static void enterAuthOcr() {
String url = "http://mapi-" + namespace + ".liangkebang.net" + "/sc/auth/ocr/url";
Map<String, Object> headers = new HashMap<>();
headers.put("x-auth-token", token);
Map<String, Object> params = new HashMap<>();
String returnUrl = "http://scapi-" + namespace + ".liangkebang.net/auth-page";
params.put("returnUrl", returnUrl);
params.put("registerFrom", createdFrom);
JSONObject result = HttpClientUtils.doPost(url, params, headers);
Map respData = (Map) result.get("data");
String respUrl = (String) respData.get("url");
String[] split1 = respUrl.split("\\?");
String[] split2 = split1[1].split("\\&");
String[] split3 = split2[0].split("\\=");
String ockToken = split3[1];
System.out.println("进入上传身份证页:" + result);
System.out.println("OCR_token为:" + ockToken);
}
public static void main(String[] args) throws Exception {
login();
checkUserId();
creditSessionSync();
syncSessionToXyqb();
realNameVerified();
authBasicInfo();
enterAuthOcr();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment