Commit 1bc533f5 authored by 黎博's avatar 黎博

优化vcc授信回调接口以及新增分配资方接口

parent 8c88e281
...@@ -207,6 +207,12 @@ ...@@ -207,6 +207,12 @@
<version>0.3.8</version> <version>0.3.8</version>
</dependency> </dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -87,6 +87,11 @@ public class XyqbGenController { ...@@ -87,6 +87,11 @@ public class XyqbGenController {
return JsonResult.success(resultFundList); return JsonResult.success(resultFundList);
} }
/**
* 资方渠道映射
* @param fundId 资方id
* @return
*/
@GetMapping("/fundMappedChannel") @GetMapping("/fundMappedChannel")
public JsonResult mapChannel(@RequestParam Integer fundId) { public JsonResult mapChannel(@RequestParam Integer fundId) {
List<Map<String, Object>> supportChannel = EnumUtils.enumToListMap(ChannelEnum.class); List<Map<String, Object>> supportChannel = EnumUtils.enumToListMap(ChannelEnum.class);
...@@ -109,4 +114,15 @@ public class XyqbGenController { ...@@ -109,4 +114,15 @@ public class XyqbGenController {
return JsonResult.success(resultChannelList); return JsonResult.success(resultChannelList);
} }
/**
* @param namespace 环境
* @param fundCorpId 资方id
* @return
* @throws Exception
*/
@GetMapping("/assign/fund")
public JsonResult assignFund(String namespace, Integer fundCorpId) throws Exception {
return JsonResult.success(xyqbGenDataService.assignFund(namespace, fundCorpId));
}
} }
...@@ -4,6 +4,7 @@ import cn.qg.qaplatform.entity.zdata.XyqbApplyDataVo; ...@@ -4,6 +4,7 @@ import cn.qg.qaplatform.entity.zdata.XyqbApplyDataVo;
import cn.qg.qaplatform.entity.zdata.XjfqGenProcessVo; import cn.qg.qaplatform.entity.zdata.XjfqGenProcessVo;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
public interface XyqbGenDataService { public interface XyqbGenDataService {
...@@ -49,4 +50,5 @@ public interface XyqbGenDataService { ...@@ -49,4 +50,5 @@ public interface XyqbGenDataService {
*/ */
XjfqGenProcessVo queryUserStatus(String namespace, String phoneNo); XjfqGenProcessVo queryUserStatus(String namespace, String phoneNo);
String assignFund(String namespace, Integer fundCorpId) throws Exception;
} }
...@@ -7,7 +7,10 @@ import cn.qg.qaplatform.process.Xyqb; ...@@ -7,7 +7,10 @@ import cn.qg.qaplatform.process.Xyqb;
import cn.qg.qaplatform.service.zdata.xyqb.QueryInProcessStatusService; import cn.qg.qaplatform.service.zdata.xyqb.QueryInProcessStatusService;
import cn.qg.qaplatform.service.zdata.xyqb.XyqbGenDataService; import cn.qg.qaplatform.service.zdata.xyqb.XyqbGenDataService;
import cn.qg.qaplatform.service.zdata.xyqb.XyqbBasicQueryService; import cn.qg.qaplatform.service.zdata.xyqb.XyqbBasicQueryService;
import cn.qg.qaplatform.utils.HttpClientUtils;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.jayway.jsonpath.JsonPath;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
...@@ -15,6 +18,7 @@ import org.springframework.stereotype.Service; ...@@ -15,6 +18,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -34,6 +38,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -34,6 +38,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
/** /**
* 分配资产计划 * 分配资产计划
*
* @param namespace * @param namespace
* @param fundId * @param fundId
* @return * @return
...@@ -72,6 +77,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -72,6 +77,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
/** /**
* 授信 * 授信
*
* @param xyqbApplyDataVo 造数据的相关信息 * @param xyqbApplyDataVo 造数据的相关信息
* @return * @return
* @throws Exception * @throws Exception
...@@ -131,8 +137,9 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -131,8 +137,9 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
/** /**
* 提现 * 提现
*
* @param xyqbApplyDataVo 造数据相关信息 * @param xyqbApplyDataVo 造数据相关信息
* @param auditResult 二次风控成功or失败 * @param auditResult 二次风控成功or失败
* @return * @return
* @throws Exception * @throws Exception
*/ */
...@@ -192,6 +199,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -192,6 +199,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
/** /**
* 放款 * 放款
*
* @param xyqbApplyDataVo * @param xyqbApplyDataVo
* @return * @return
*/ */
...@@ -222,7 +230,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -222,7 +230,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
Xyqb.modifyWaitingFundingCreatedAt(namespace, loanId); Xyqb.modifyWaitingFundingCreatedAt(namespace, loanId);
Thread.sleep(5000); Thread.sleep(5000);
// 直接打款 // 直接打款
Xyqb.fundsPlanLoanApply(namespace,opToken, fundId, money, people); Xyqb.fundsPlanLoanApply(namespace, opToken, fundId, money, people);
Thread.sleep(30000); Thread.sleep(30000);
// 放款结果通知 // 放款结果通知
boolean makeLoanResult = Xyqb.payNotify(namespace, loanId, payStatus); boolean makeLoanResult = Xyqb.payNotify(namespace, loanId, payStatus);
...@@ -236,14 +244,15 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -236,14 +244,15 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
/** /**
* 设置redis值,查询状态 * 设置redis值,查询状态
*
* @param namespace * @param namespace
* @param phoneNo * @param phoneNo
* @param status 0-授信成功,1-授信失败,2-提现成功,3-放款成功,4-放款失败 * @param status 0-授信成功,1-授信失败,2-提现成功,3-放款成功,4-放款失败
*/ */
public void setUserStatusRedisValue(String namespace, String phoneNo, Integer status) { public void setUserStatusRedisValue(String namespace, String phoneNo, Integer status) {
String redisKey = namespace + "_" + phoneNo; String redisKey = namespace + "_" + phoneNo;
redisTemplate.opsForValue().set(redisKey, status); redisTemplate.opsForValue().set(redisKey, status);
redisTemplate.expire(redisKey,1800, TimeUnit.SECONDS); redisTemplate.expire(redisKey, 1800, TimeUnit.SECONDS);
} }
...@@ -302,7 +311,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -302,7 +311,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
} }
// 查询资方审核进度,如未分配成功,则阻塞下一步 // 查询资方审核进度,如未分配成功,则阻塞下一步
queryInProcessStatusService.queryFundingAssignProgress(namespace, phoneNo, fundId, symbol); queryInProcessStatusService.queryFundingAssignProgress(namespace, phoneNo, fundId, symbol);
boolean withDrawResult = withDraw(xyqbApplyDataVo, true); boolean withDrawResult = withDraw(xyqbApplyDataVo, true);
if (!withDrawResult) { if (!withDrawResult) {
WebSocketServer.sendInfo("提现失败!", symbol); WebSocketServer.sendInfo("提现失败!", symbol);
return false; return false;
...@@ -349,7 +358,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -349,7 +358,7 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
setUserStatusRedisValue(namespace, phoneNo, 4); setUserStatusRedisValue(namespace, phoneNo, 4);
return true; return true;
} }
boolean withDrawResult = withDraw(xyqbApplyDataVo, true); boolean withDrawResult = withDraw(xyqbApplyDataVo, true);
if (!withDrawResult) { if (!withDrawResult) {
WebSocketServer.sendInfo("提现失败!", symbol); WebSocketServer.sendInfo("提现失败!", symbol);
return false; return false;
...@@ -407,5 +416,54 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService { ...@@ -407,5 +416,54 @@ public class XyqbGenDataServiceImpl implements XyqbGenDataService {
return xjfqGenProcessVo; return xjfqGenProcessVo;
} }
@Override
public String assignFund(String namespace, Integer fundCorpId) throws Exception {
String loginOpUrl = "http://opapi-" + namespace + ".liangkebang.net" + "/user/login";
String fundAssignUrl = "https://clotho-" + namespace + ".liangkebang.net/" + "/funds/plan/funding/plan/save";
String unLockSwitchUrl = "http://opapi-" + namespace + ".liangkebang.net" + "/clotho/funds/plan/funding/switch/" + fundCorpId.toString() + "/loan/auto_lock";
String fundPolicySetUrl = "http://opapi-" + namespace + ".liangkebang.net" + "/clotho/funds/plan/funding/policy/save";
// 登录OP
log.info("开始分配资产计划,环境:{}, 资方id:{}", namespace, fundCorpId);
Map<String, Object> loginOpParams = new HashMap<>();
loginOpParams.put("auth", "dXNlcj1xYSZwYXNzd29yZD1xYXRlc3Q=");
JSONObject loginOpResult = HttpClientUtils.doGetReturnJson(loginOpUrl, loginOpParams, null);
log.info("登录OP结果:{}", loginOpResult);
String opToken = JsonPath.read(loginOpResult, "$.data.token");
// 分配资产计划
Map<String, Object> headers = new HashMap<>();
Map<String, Object> assignFundParams = new HashMap<>();
headers.put("Content-Type", "application/x-www-form-urlencoded");
headers.put("x-auth-token", opToken);
assignFundParams.put("fundCorpId", fundCorpId);
assignFundParams.put("planDate", "");
assignFundParams.put("maxAssignAmount", 1000000);
assignFundParams.put("maxLoanAmount", 1000000);
assignFundParams.put("maxLoanPeople", 100);
assignFundParams.put("maxAssignPeople", 100);
assignFundParams.put("priorityLevel", 1);
JSONObject assignFundResult = HttpClientUtils.doPost(fundAssignUrl, assignFundParams, headers);
log.info("分配资产计划结果:{}", assignFundResult);
Map<String, Object> unLockSwitchParams = new HashMap<>();
unLockSwitchParams.put("to", true);
JSONObject unLockSwitchResult = HttpClientUtils.doPost(unLockSwitchUrl, unLockSwitchParams, headers);
log.info("推送放款的结果:{}", unLockSwitchResult);
Map<String, Object> fundPolicySetParams = new HashMap<>();
fundPolicySetParams.put("fundingCorpId", fundCorpId);
fundPolicySetParams.put("minQgScore", -1);
fundPolicySetParams.put("maxQgScore", -1);
fundPolicySetParams.put("productType", 1);
fundPolicySetParams.put("fetchConfig", "0:01");
fundPolicySetParams.put("autoLoanFetchConfig", "0:01");
fundPolicySetParams.put("loanTimes", "0:00-23:59");
// fundPolicySetParams.put("onlyChannel", 159439);
fundPolicySetParams.put("isAutoAssign", true);
fundPolicySetParams.put("isAutoLoan", true);
fundPolicySetParams.put("isAutoFetch", true);
fundPolicySetParams.put("autoLoanFetch", true);
JSONObject fundPolicySetResult = HttpClientUtils.doPost(fundPolicySetUrl, fundPolicySetParams, headers);
log.info("设置资方不受限制的结果:{}", fundPolicySetResult);
return "资方分配成功";
}
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</select> </select>
<select id="getVccRiskRecord" resultType="java.util.Map"> <select id="getVccRiskRecord" resultType="java.util.Map">
SELECT * FROM `risk_record` where `uuid` = #{uuid} SELECT * FROM `risk_record` where `uuid` = #{uuid} order by id desc limit 1
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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