Commit a52cdcfa authored by 王向伟's avatar 王向伟

进件客户基本信息查询

parent 33b710a7
package cn.quantgroup.cashloanflowboss.api.customer.controller;
import cn.quantgroup.cashloanflowboss.api.customer.entity.CustomerInfo;
import cn.quantgroup.cashloanflowboss.api.customer.service.ICustomerService;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/**
* @author Wang Xiangwei
* @version 2020/7/9
*/
@RestController
@RequestMapping("/customer")
public class CustomerController {
@Autowired
private ICustomerService customerService;
@GetMapping("/info")
public Result<CustomerInfo> getCustomerInfo(String phoneNo,String channelOrderNo){
CustomerInfo customerInfo = customerService.getCustomerInfo(phoneNo, channelOrderNo);
if(Objects.isNull(customerInfo)){
return Result.buildFail("查询出错");
}
return Result.buildSuccess(customerInfo);
}
}
package cn.quantgroup.cashloanflowboss.api.customer.entity;
import lombok.Data;
/**
* 客户进件信息
* @author Wang Xiangwei
* @version 2020/7/8
*/
@Data
public class CustomerInfo {
private Long userId;
private String phoneNo;
private String uuid;
/**
* 是否启用
*/
private Boolean enable;
private String name;
/**
* 身份证号
*/
private String idNo;
private String email;
/**
* 收入方式
*/
private String income;
/**
* 收入范围
*/
private String incomeRange;
/**
* 职业
*/
private String occupation;
/**
* 学历
*/
private String education;
private Boolean hasCar;
private Boolean hasSocialSecurity;
private Boolean hasHouse;
private Boolean hasCreditCard;
private String marryStatus;
private String address;
private String contactNameA;
private String contactPhoneA;
private String contactRelationA;
private String contactNameB;
private String contactPhoneB;
private String contactRelationB;
}
package cn.quantgroup.cashloanflowboss.api.customer.service;
import cn.quantgroup.cashloanflowboss.api.customer.entity.CustomerInfo;
/**
* 进件客户
* @author Wang Xiangwei
* @version 2020/7/8
*/
public interface ICustomerService {
CustomerInfo getCustomerInfo(String phoneNo,String channelOrderNo);
}
package cn.quantgroup.cashloanflowboss.api.customer.service.impl;
import cn.quantgroup.cashloanflowboss.api.customer.entity.CustomerInfo;
import cn.quantgroup.cashloanflowboss.api.customer.service.ICustomerService;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping;
import cn.quantgroup.cashloanflowboss.spi.clf.repository.ClfOrderMappingRepository;
import cn.quantgroup.cashloanflowboss.spi.user.service.UserSysService;
import cn.quantgroup.user.retbean.*;
import cn.quantgroup.user.vo.UserSysResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* @author Wang Xiangwei
* @version 2020/7/8
*/
@Service
@Slf4j
public class CustomerService implements ICustomerService {
@Autowired
private UserSysService userSysService;
@Autowired
private ClfOrderMappingRepository clfOrderMappingRepository;
@Override
public CustomerInfo getCustomerInfo(String phoneNo, String channelOrderNo) {
String logPre = "CustomerService.getCustomerInfo";
log.info("{} 查询客户信息 phoneNo={},channelOrderNo={}",logPre,phoneNo,channelOrderNo);
if(StringUtils.isAllBlank(phoneNo,channelOrderNo)){
log.error("{} 查询客户信息失败 参数为空phoneNo={},channelOrderNo={}",logPre,phoneNo,channelOrderNo);
return null;
}
Long userId = getUserId(phoneNo, channelOrderNo);
if(userId == null){
return null;
}
UserSysResult<XUser> xUserResult = userSysService.getService().findUserByUserId(userId);
if(!xUserResult.isSuccess()){
log.error("{} 查询用户信息失败 userId={} userResult={}",logPre,userId,xUserResult);
return null;
}
CustomerInfo info = new CustomerInfo();
populateUser(info,xUserResult.getData());
UserSysResult<XUserDetail> userDetailResult = userSysService.getService().findUserDetailByUserId(userId);
if(!userDetailResult.isSuccess()){
log.error("{} 查询用户详细信息失败 userId={} userDetailResult={}",logPre,userId,userDetailResult);
return null;
}
populateDetail(info,userDetailResult.getData());
UserSysResult<XUserExtInfo> userExtInfoResult = userSysService.getService().findUserExtInfoByUserId(userId);
if(!userExtInfoResult.isSuccess()){
log.error("{} 查询用户扩展信息失败 userId={} userExtInfoResult={}",logPre,userId,userExtInfoResult);
return null;
}
populateExtInfo(info,userExtInfoResult.getData());
UserSysResult<List<XContact>> contactsResult = userSysService.getService().findContactsByUserId(userId);
if(!contactsResult.isSuccess()){
log.error("{} 查询用户紧急联系人失败 userId={} contactsResult={}",logPre,userId,contactsResult);
return null;
}
populateContact(info,contactsResult.getData());
UserSysResult<XAddress> addressResult = userSysService.getService().findAddressByUserId(userId);
if(!addressResult.isSuccess()){
log.error("{}查询用户地址失败 userId={} addressResult={}",logPre,userId,addressResult);
return null;
}
populateAddress(info,addressResult.getData());
return info;
}
private void populateAddress(CustomerInfo info, XAddress xAddress) {
String logStr = "CustomerService.populateAddress";
log.info("{} xAddress 填充客户信息 xAddress={}",logStr,xAddress);
if(Objects.isNull(xAddress)){
log.error("{} xAddress填充客户地址失败 xAddress为空",logStr);
return;
}
info.setAddress(xAddress.getAddress());
}
private void populateContact(CustomerInfo info, List<XContact> contacts) {
String logStr = "CustomerService.populateContact";
log.info("{} contacts填充客户信息 contacts={}",logStr,contacts);
if(CollectionUtils.isEmpty(contacts)){
log.error("{} contacts填充客户紧急联系人失败 contacts为空",logStr);
return;
}
if(contacts.size() != 2){
log.error("{} 紧急联系人个数错误 contacts={}",logStr,contacts);
return;
}
info.setContactNameA(contacts.get(0).getName());
info.setContactPhoneA(contacts.get(0).getPhoneNo());
info.setContactRelationA(contacts.get(0).getRelation().name());
info.setContactNameB(contacts.get(1).getName());
info.setContactPhoneB(contacts.get(1).getPhoneNo());
info.setContactRelationB(contacts.get(1).getRelation().name());
}
private void populateExtInfo(CustomerInfo info, XUserExtInfo xUserExtInfo) {
String logStr = "CustomerService.populateExtInfo";
log.info("{} xUserExtInfo填充客户信息 xUserExtInfo={}",logStr,xUserExtInfo);
if(Objects.isNull(xUserExtInfo)){
log.error("{} xUserExtInfo填充客户扩展信息失败 xUserExtInfo为空",logStr);
return;
}
info.setIncome(xUserExtInfo.getIncomeEnum().name());
info.setIncomeRange(xUserExtInfo.getIncomeRangeEnum().name());
info.setOccupation(xUserExtInfo.getOccupationEnum().name());
info.setEducation(xUserExtInfo.getEducationEnum().name());
info.setHasCar(xUserExtInfo.getHasCar());
info.setHasSocialSecurity(xUserExtInfo.getHasSocialSecurity());
info.setHasHouse(xUserExtInfo.getHasHouse());
info.setHasCreditCard(xUserExtInfo.getHasCar());
info.setMarryStatus(xUserExtInfo.getMarryStatus().name());
}
private void populateDetail(CustomerInfo info, XUserDetail xUserDetail) {
String logStr = "CustomerService.populateDetail";
log.info("{} xUser填充客户信息 xUser={}",logStr,xUserDetail);
if(Objects.isNull(xUserDetail)){
log.error("{} xUserDetail填充客户信息失败 xUserDetail为空",logStr);
return;
}
info.setName(xUserDetail.getName());
info.setIdNo(xUserDetail.getIdNo());
info.setEmail(xUserDetail.getEmail());
}
private void populateUser(CustomerInfo info, XUser xUser) {
String logStr = "CustomerService.populateUser";
log.info("{} xUser填充客户信息 xUser={}",logStr,xUser);
if(Objects.isNull(xUser)){
log.error("{} xUser填充客户信息失败 xUser为空",logStr);
return;
}
info.setUserId(xUser.getId());
info.setPhoneNo(xUser.getPhoneNo());
info.setUuid(xUser.getUuid());
info.setEnable(xUser.getEnable());
}
private Long getUserId(String phoneNo, String channelOrderNo) {
String logPre = "CustomerService.getUserId";
//优先使用渠道订单号查询userId
if(StringUtils.isNotBlank(channelOrderNo)){
ClfOrderMapping orderMapping = clfOrderMappingRepository.findByChannelOrderNoLastOne(channelOrderNo);
if(orderMapping == null){
log.error("{} 查询客户信息失败 未查到对应的order_mapping channelOrderNo={}",logPre,channelOrderNo);
return null;
}
return orderMapping.getQgUserId();
} else {
UserSysResult<XUser> user =
userSysService.getService().findUserByPhoneNo(phoneNo);
if(!user.isSuccess()){
log.error("{} 查询客户信息失败 phoneNo={},result={}",logPre,phoneNo,user);
return null;
}
return user.getData().getId();
}
}
}
......@@ -7,6 +7,8 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import cn.quantgroup.user.enums.Relation;
import lombok.Data;
@Data
......@@ -25,7 +27,7 @@ public class UserContact {
private String name;
@Column(name = "relation")
private String relation;
private Relation relation;
@Column(name = "created_at")
private String created_at;
......
package cn.quantgroup.cashloanflowboss.spi.user.repository;
import cn.quantgroup.cashloanflowboss.spi.user.entity.UserContact;
import cn.quantgroup.cashloanflowboss.spi.user.entity.UserDetail;
import cn.quantgroup.cashloanflowboss.spi.user.source.XyqbUserDataSource;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@XyqbUserDataSource
@Repository
public interface UserContactRepository extends JpaRepository<UserContact,Long>{
}
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