Commit f22080e2 authored by 黎博's avatar 黎博

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

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