Commit f939b0ea authored by 黎博's avatar 黎博

新增查询状态接口

parent d4b72a43
...@@ -3,7 +3,6 @@ package cn.qg.qaplatform; ...@@ -3,7 +3,6 @@ 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")
......
...@@ -67,4 +67,13 @@ public class GenLoanUserDataController { ...@@ -67,4 +67,13 @@ public class GenLoanUserDataController {
return JsonResult.success(map); return JsonResult.success(map);
} }
@GetMapping("/userStatus")
public JsonResult queryUserStatus(@RequestParam String namespace,
@RequestParam String phoneNo) {
Integer status = genUserDataService.queryUserStatus(namespace, phoneNo);
Map map = new HashMap();
map.put("status", status);
return JsonResult.success(map);
}
} }
...@@ -3,7 +3,6 @@ package cn.qg.qaplatform.process.xyqb; ...@@ -3,7 +3,6 @@ package cn.qg.qaplatform.process.xyqb;
import cn.qg.qaplatform.utils.DBUtils; import cn.qg.qaplatform.utils.DBUtils;
import cn.qg.qaplatform.utils.EncryptUtils; import cn.qg.qaplatform.utils.EncryptUtils;
import cn.qg.qaplatform.utils.HttpClientUtils; import cn.qg.qaplatform.utils.HttpClientUtils;
import cn.qg.qaplatform.utils.RedisUtils;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
...@@ -27,5 +27,19 @@ public interface GenUserDataService { ...@@ -27,5 +27,19 @@ public interface GenUserDataService {
*/ */
boolean makeLoan(ApplyLoanInfo applyLoanInfo, boolean payStatus) throws Exception; boolean makeLoan(ApplyLoanInfo applyLoanInfo, boolean payStatus) throws Exception;
/**
* 造数据
* @param applyLoanInfo
* @return
* @throws Exception
*/
boolean genLoanUser(ApplyLoanInfo applyLoanInfo) throws Exception; boolean genLoanUser(ApplyLoanInfo applyLoanInfo) throws Exception;
/**
* 获取用户状态
* @param namespace
* @param phoneNo
* @return
*/
Integer queryUserStatus(String namespace, String phoneNo);
} }
...@@ -3,13 +3,24 @@ package cn.qg.qaplatform.service.impl; ...@@ -3,13 +3,24 @@ package cn.qg.qaplatform.service.impl;
import cn.qg.qaplatform.domain.ApplyLoanInfo; import cn.qg.qaplatform.domain.ApplyLoanInfo;
import cn.qg.qaplatform.process.xyqb.MainProcess; import cn.qg.qaplatform.process.xyqb.MainProcess;
import cn.qg.qaplatform.service.GenUserDataService; import cn.qg.qaplatform.service.GenUserDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service @Service
@Slf4j
public class GenUserDataServiceImpl implements GenUserDataService { public class GenUserDataServiceImpl implements GenUserDataService {
@Resource
RedisTemplate redisTemplate;
/** /**
* 授信 * 授信
* @param applyLoanInfo 造数据的相关信息 * @param applyLoanInfo 造数据的相关信息
...@@ -57,6 +68,11 @@ public class GenUserDataServiceImpl implements GenUserDataService { ...@@ -57,6 +68,11 @@ public class GenUserDataServiceImpl implements GenUserDataService {
String productId = authResult.get("product_id").toString(); String productId = authResult.get("product_id").toString();
// 风控授信回调 // 风控授信回调
boolean result = MainProcess.creditAuthNotify(namespace, token, uuid, channelId, fundId, orderNo, 0, auditResult, amount, term); boolean result = MainProcess.creditAuthNotify(namespace, token, uuid, channelId, fundId, orderNo, 0, auditResult, amount, term);
if (result) {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 0);
log.info("风控授信回调接口返回成功,设置redis缓存:" + namespace + "-" + phoneNo + ": 0");
redisTemplate.expire(phoneNo, 86400, TimeUnit.SECONDS);
}
return result; return result;
} }
...@@ -106,6 +122,10 @@ public class GenUserDataServiceImpl implements GenUserDataService { ...@@ -106,6 +122,10 @@ public class GenUserDataServiceImpl implements GenUserDataService {
boolean result = MainProcess.externalQuotaOrderAuditNotify(namespace, token, uuid, loanId, 0); boolean result = MainProcess.externalQuotaOrderAuditNotify(namespace, token, uuid, loanId, 0);
// 修改合同状态 // 修改合同状态
MainProcess.modifyContactStatus(namespace, userId); MainProcess.modifyContactStatus(namespace, userId);
if (result) {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 1);
log.info("提现接口返回正常,设置redis缓存:" + namespace + "_" + phoneNo + ": 1");
}
return result; return result;
} }
...@@ -145,6 +165,10 @@ public class GenUserDataServiceImpl implements GenUserDataService { ...@@ -145,6 +165,10 @@ public class GenUserDataServiceImpl implements GenUserDataService {
Thread.sleep(30000); Thread.sleep(30000);
// 放款结果通知 // 放款结果通知
boolean result = MainProcess.payNotify(namespace, loanId, payStatus); boolean result = MainProcess.payNotify(namespace, loanId, payStatus);
if (result) {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 2);
log.info("提现成功,设置redis缓存:" + namespace + "-" + phoneNo + ": 2");
}
return result; return result;
} }
...@@ -214,5 +238,24 @@ public class GenUserDataServiceImpl implements GenUserDataService { ...@@ -214,5 +238,24 @@ public class GenUserDataServiceImpl implements GenUserDataService {
return false; return false;
} }
@Override
public Integer queryUserStatus(String namespace, String phoneNo) {
String redisResult = redisTemplate.opsForValue().get(namespace + "_" + phoneNo).toString();
log.info("获取redis key结果为:" + redisResult);
// 授信成功未提现
if (redisResult.equals("0")) {
return 0;
}
// 提现成功未放款
if (redisResult.equals("1")) {
return 1;
}
// 放款成功
if (redisResult.equals("2")) {
return 2;
}
return null;
}
} }
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;
}
}
}
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