Commit 638ad886 authored by 黎博's avatar 黎博

更新造数据接口

parent 1a6b9fba
......@@ -4,6 +4,7 @@ import cn.qg.qaplatform.common.JsonResult;
import cn.qg.qaplatform.common.enums.ChannelEnum;
import cn.qg.qaplatform.common.enums.FundEnum;
import cn.qg.qaplatform.domain.ApplyLoanInfo;
import cn.qg.qaplatform.domain.GenLoanUser;
import cn.qg.qaplatform.service.GenUserDataService;
import cn.qg.qaplatform.service.QueryBasicLoanStatusDataService;
import cn.qg.qaplatform.utils.EnumUtils;
......@@ -81,10 +82,8 @@ public class GenLoanUserDataController {
@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);
GenLoanUser genLoanUser = genUserDataService.queryUserStatus(namespace, phoneNo);
return JsonResult.success(genLoanUser);
}
}
package cn.qg.qaplatform.dao;
import cn.qg.qaplatform.domain.GenLoanUser;
import cn.qg.qaplatform.domain.LoanUser;
import org.apache.ibatis.annotations.Param;
......@@ -61,5 +62,12 @@ public interface QueryBasicLoanStatusDataMapper {
*/
List<String> getMultiOrderuuidList();
/**
* 根据userId获取资方id
* @param userId
* @return
*/
Integer getAssignFundIdByUserId(String userId);
GenLoanUser getUserInfoByPhoneNo(String phoneNo);
}
package cn.qg.qaplatform.domain;
import lombok.Data;
import java.util.Date;
@Data
public class GenLoanUser {
/**
* 手机号
*/
private String phoneNo;
/**
* 用户id
*/
private String userId;
/**
* uuid
*/
private String uuid;
/**
* 创建渠道
*/
private Long registeredFrom;
/**
* 分配的资方
*/
private Integer fundId;
/**
* 创建日期
*/
private Date createdAt;
/**
* 当前状态
*/
private String status;
}
package cn.qg.qaplatform.service;
import cn.qg.qaplatform.domain.ApplyLoanInfo;
import cn.qg.qaplatform.domain.GenLoanUser;
import java.sql.SQLException;
......@@ -41,5 +42,5 @@ public interface GenUserDataService {
* @param phoneNo
* @return
*/
Integer queryUserStatus(String namespace, String phoneNo);
GenLoanUser queryUserStatus(String namespace, String phoneNo);
}
package cn.qg.qaplatform.service;
import cn.qg.qaplatform.domain.GenLoanUser;
import cn.qg.qaplatform.domain.LoanUser;
import java.util.List;
......@@ -68,5 +69,5 @@ public interface QueryBasicLoanStatusDataService {
/**
* 根据手机号查询用户信息
*/
LoanUser getUserInfoByPhoneNo(String namespace, String phoneNo);
GenLoanUser getUserInfoByPhoneNo(String namespace, String phoneNo);
}
package cn.qg.qaplatform.service.impl;
import cn.qg.qaplatform.domain.ApplyLoanInfo;
import cn.qg.qaplatform.domain.GenLoanUser;
import cn.qg.qaplatform.process.xyqb.MainProcess;
import cn.qg.qaplatform.service.GenUserDataService;
import cn.qg.qaplatform.service.QueryBasicLoanStatusDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -20,6 +22,8 @@ public class GenUserDataServiceImpl implements GenUserDataService {
@Resource
RedisTemplate redisTemplate;
@Autowired
QueryBasicLoanStatusDataService queryBasicLoanStatusDataService;
/**
* 授信
......@@ -68,10 +72,13 @@ public class GenUserDataServiceImpl implements GenUserDataService {
String productId = authResult.get("product_id").toString();
// 风控授信回调
boolean result = MainProcess.creditAuthNotify(namespace, token, uuid, channelId, fundId, orderNo, 0, auditResult, amount, term);
String redisKey = namespace + "_" + phoneNo;
if (result) {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 0);
log.info("风控授信回调接口返回成功,设置redis缓存:" + namespace + "-" + phoneNo + ": 0");
redisTemplate.expire(phoneNo, 86400, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(redisKey, 0);
log.info("风控授信回调接口返回成功,设置redis缓存:" + redisKey + ": 0");
} else {
redisTemplate.opsForValue().set(redisKey, 1);
log.info("风控授信回调接口返回失败,设置redis缓存:" + redisKey + ": 1");
}
return result;
}
......@@ -122,9 +129,13 @@ public class GenUserDataServiceImpl implements GenUserDataService {
boolean result = MainProcess.externalQuotaOrderAuditNotify(namespace, token, uuid, loanId, 0);
// 修改合同状态
MainProcess.modifyContactStatus(namespace, userId);
String redisKey = namespace + "_" + phoneNo;
if (result) {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 1);
log.info("提现接口返回正常,设置redis缓存:" + namespace + "_" + phoneNo + ": 1");
redisTemplate.opsForValue().set(redisKey, 2);
log.info("提现成功,设置redis缓存:" + redisKey + ": 2");
} else {
redisTemplate.opsForValue().set(redisKey, 3);
log.info("提现失败,设置redis缓存:" + redisKey + ": 3");
}
return result;
}
......@@ -166,8 +177,11 @@ public class GenUserDataServiceImpl implements GenUserDataService {
// 放款结果通知
boolean result = MainProcess.payNotify(namespace, loanId, payStatus);
if (result) {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 2);
log.info("提现成功,设置redis缓存:" + namespace + "-" + phoneNo + ": 2");
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 4);
log.info("放款成功,设置redis缓存:" + namespace + "-" + phoneNo + ": 4");
} else {
redisTemplate.opsForValue().set(namespace + "_" + phoneNo, 5);
log.info("放款失败,设置redis缓存:" + namespace + "-" + phoneNo + ": 5");
}
return result;
}
......@@ -239,22 +253,36 @@ public class GenUserDataServiceImpl implements GenUserDataService {
}
@Override
public Integer queryUserStatus(String namespace, String phoneNo) {
public GenLoanUser queryUserStatus(String namespace, String phoneNo) {
String redisResult = redisTemplate.opsForValue().get(namespace + "_" + phoneNo).toString();
log.info("获取redis key结果为:" + redisResult);
// 授信成功未提现
GenLoanUser genLoanUser = new GenLoanUser();
genLoanUser = queryBasicLoanStatusDataService.getUserInfoByPhoneNo(namespace, phoneNo);
// 资方审核中
if (redisResult.equals("0")) {
return 0;
genLoanUser.setStatus("资方审核中...");
}
// 提现成功未放款
// 资方审核失败
if (redisResult.equals("1")) {
return 1;
genLoanUser.setStatus("资方审核失败");
}
// 放款成功
// 提现成功
if (redisResult.equals("2")) {
return 2;
genLoanUser.setStatus("提现成功");
}
// 提现失败
if (redisResult.equals("3")) {
genLoanUser.setStatus("提现失败");
}
// 放款成功
if (redisResult.equals("4")) {
genLoanUser.setStatus("放款成功");
}
// 放款失败
if (redisResult.equals("5")) {
genLoanUser.setStatus("放款失败");
}
return null;
return genLoanUser;
}
......
......@@ -3,6 +3,7 @@ package cn.qg.qaplatform.service.impl;
import cn.qg.qaplatform.common.enums.LoanStatus;
import cn.qg.qaplatform.common.enums.Namespace;
import cn.qg.qaplatform.dao.QueryBasicLoanStatusDataMapper;
import cn.qg.qaplatform.domain.GenLoanUser;
import cn.qg.qaplatform.domain.LoanUser;
import cn.qg.qaplatform.common.SwitchDataSource;
import cn.qg.qaplatform.service.QueryBasicLoanStatusDataService;
......@@ -171,8 +172,8 @@ public class QueryBasicLoanStatusDataServiceImpl implements QueryBasicLoanStatus
}
@Override
public LoanUser getUserInfoByPhoneNo(String namespace, String phoneNo) {
SwitchDataSource.dataSourceSwitch(namespace, "xyqb");
return null;
public GenLoanUser getUserInfoByPhoneNo(String namespace, String phoneNo) {
SwitchDataSource.dataSourceSwitch(namespace, "xyqb_user");
return basicLoanStatusDataMapper.getUserInfoByPhoneNo(phoneNo);
}
}
......@@ -93,4 +93,10 @@
WHERE `user_id` = #{userId} order by id desc limit 0,1
</select>
<!-- 根据手机号获取用户信息-->
<select id="getUserInfoByPhoneNo" resultType="cn.qg.qaplatform.domain.GenLoanUser">
SELECT `id` as userId, `phone_no` as phoneNo, `uuid`, `registered_from` as registeredFrom, `created_at` as createdAt FROM `user`
WHERE `phone_no` = #{phoneNo}
</select>
</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