Commit f22080e2 authored by 黎博's avatar 黎博

新增用户已有额度判断及状态和渠道判断

parent 1416a0ea
......@@ -3,6 +3,8 @@ package cn.qg.qaplatform.controller;
import cn.qg.qaplatform.common.JsonResult;
import cn.qg.qaplatform.domain.GenVccUser;
import cn.qg.qaplatform.service.VccDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -10,13 +12,21 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("vcc")
@Api(tags = "vcc造数据")
public class GenVccController {
@Autowired
VccDataService vccDataService;
@PostMapping("/gen")
@ApiOperation(value = "vcc造数据")
public JsonResult genVccUser(String namespace, String phoneNo, String channel, Integer status) throws Exception {
if (status != 0 && status != 1) {
return JsonResult.clientFailed("状态必须为0或者1");
}
if (!channel.equals("214") && !channel.equals("217")) {
return JsonResult.clientFailed("渠道必须为214或217");
}
GenVccUser result = vccDataService.makeVccUser(namespace, phoneNo, channel, status);
return JsonResult.success(result);
}
......
......@@ -14,12 +14,6 @@ public class GenVccUser {
* 开通的渠道
*/
private String openedChannel;
/**
* 开通状态
* 0-授信通过,
*/
private Integer status;
/**
* 额度
*/
......@@ -29,4 +23,6 @@ public class GenVccUser {
* 卡号
*/
private String eacctNo;
private String msg;
}
......@@ -290,4 +290,17 @@ public class Vcc {
log.info("开户结果:" + result);
return result;
}
/**
* 查询用户是否已有额度
*/
public static boolean checkIfAlreadyHaveQuota(String namespace, String uuid) throws SQLException {
DBUtils dbUtils = new DBUtils(namespace, "vcc_quota", "qa", "qatest");
String sql = "select * from user_quota_record where uuid='" + uuid + "'";
Map result = dbUtils.queryForMap(sql);
if (result.isEmpty()) {
return false;
}
return true;
}
}
......@@ -28,7 +28,8 @@ public class VccDataServiceImpl implements VccDataService {
String vccChannel = null;
if (openedChannel.equals("214")) {
vccChannel = "159904";
} else if (openedChannel.equals("217")) {
}
if (openedChannel.equals("217")) {
vccChannel = "159905";
}
if (vccChannel == null) {
......@@ -38,6 +39,12 @@ public class VccDataServiceImpl implements VccDataService {
Map loginResult = Vcc.login(namespace, phoneNo, openedChannel, openedChannel);
String token = loginResult.get("token").toString();
String uuid = loginResult.get("uuid").toString();
// 检查用户是否已有额度
boolean haveQuota = Vcc.checkIfAlreadyHaveQuota(namespace, uuid);
if (haveQuota) {
genVccUser.setMsg("用户已有额度!");
return genVccUser;
}
// credit url
String vccToken = Vcc.creditUrl(namespace, token, vccChannel);
// 身份证正面
......@@ -55,6 +62,7 @@ public class VccDataServiceImpl implements VccDataService {
// 授信结果查询
Vcc.searchCreditResult(namespace, token, vccChannel);
if (status == 0) {
genVccUser.setMsg("提交授信成功!");
return genVccUser;
}
if (status == 1) {
......@@ -73,6 +81,7 @@ public class VccDataServiceImpl implements VccDataService {
String eacctNo = data.get("eacctNo").toString();
genVccUser.setAmount(amount);
genVccUser.setEacctNo(eacctNo);
genVccUser.setMsg("开户成功");
}
return genVccUser;
}
......
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