Commit 2b6f44e9 authored by liwenbin's avatar liwenbin

新诚导流联系人缺失判断条件前置

parent 630a4027
package com.quantgroup.asset.distribution.service.funding.impl;
import cn.quantgroup.motan.bean.UserInfo;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Stopwatch;
import com.quantgroup.asset.distribution.constant.AidFundStatus;
......@@ -7,6 +8,7 @@ import com.quantgroup.asset.distribution.constant.aid.AidRiskInfoConstants;
import com.quantgroup.asset.distribution.enums.UserLoanType;
import com.quantgroup.asset.distribution.exception.QGExceptionType;
import com.quantgroup.asset.distribution.exception.QGPreconditions;
import com.quantgroup.asset.distribution.model.entity.user.SDKUserInfo;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.feature.IFeatureService;
......@@ -19,6 +21,7 @@ import com.quantgroup.asset.distribution.service.jpa.repository.ICustomerTypeRul
import com.quantgroup.asset.distribution.service.niwodai.INiwodaiAssetService;
import com.quantgroup.asset.distribution.service.redis.IRedisService;
import com.quantgroup.asset.distribution.service.rule.IRuleService;
import com.quantgroup.asset.distribution.service.user.IUserCenterService;
import com.quantgroup.asset.distribution.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
......@@ -48,17 +51,16 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
@Autowired
private IRedisService<String> redisService;
@Autowired
private IRedisService<AidLoanFundRouteRecord> redisRouteRecord;
@Autowired
private IRuleService ruleService;
@Autowired
private ICustomerTypeRuleConfigRepository iCustomerTypeRuleConfigRepository;
@Autowired
private IAidFundAssetService aidFundAssetService;
@Autowired
private IAidFundAuditOrderService aidFundAuditOrderService;
@Autowired
private IFeatureService featureService;
@Autowired
private IUserCenterService userCenterService;
/**
* 助贷资金路由
......@@ -270,6 +272,22 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
asset.getUuid(), aidLoanFundConfig.getFundId(), aidLoanFundConfig.getFundProductId(), age, province, qgScore3);
}
}
return valid;
if (!valid) { return false; }
// 通用, 用户联系人缺失的不导, md,这是用户中心的bug, 要在这里做兼容
UserInfo userInfo = userCenterService.getUserInfoByUuid(assetForm.getUuid());
if (userInfo == null || StringUtils.isEmpty(userInfo.getPhoneNo())) {
log.info("助贷资方导流, 用户手机号缺失, 不进行导流, uuid : {}, fundId : {}, fundProductId : {}", asset.getUuid(), aidLoanFundConfig.getFundId(), aidLoanFundConfig.getFundProductId());
return false;
}
SDKUserInfo sdkUserInfo = userCenterService.getSDKUserExtInfo(userInfo.getPhoneNo(), assetForm.getUuid());
if (sdkUserInfo == null || sdkUserInfo.getContactList() == null || sdkUserInfo.getContactList().size() == 0) {
log.info("助贷资方导流, 用户联系人缺失, 不进行导流, uuid : {}, fundId : {}, fundProductId : {}, contactList : {}",
assetForm.getUuid(), aidLoanFundConfig.getFundId(), aidLoanFundConfig.getFundProductId(), 0);
return false;
}
return true;
}
}
......@@ -9,55 +9,55 @@ import java.sql.Timestamp;
/**
* Created by renfeng on 2020/3/24.
*/
@Entity
@Table(name="customer_type_rule_config")
//@Entity
//@Table(name="customer_type_rule_config")
@Data
public class CustomerTypeRuleConfig implements Serializable{
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name="customer_type_rule_no")
private String customerTypeRuleNo;
@Column(name="customer_type_rule_desc")
private String customerTypeRuleDesc;
@Column(name="customer_type")
private Integer customerType;
@Column(name="customer_type_rule_el")
private String customerTypeRuleEl;
@Column(name = "enable")
private Boolean enable;
@Column(name="created_by")
private String createdBy;
@Column(name="updated_by")
private String updatedBy;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
@PrePersist
public void prePersist() {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
createdAt = timestamp;
updatedAt = timestamp;
}
@PreUpdate
public void preUpdate() {
updatedAt = new Timestamp(System.currentTimeMillis());
}
//
// @Id
// @Column(name = "id")
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Long id;
//
// @Column(name="customer_type_rule_no")
// private String customerTypeRuleNo;
//
// @Column(name="customer_type_rule_desc")
// private String customerTypeRuleDesc;
//
// @Column(name="customer_type")
// private Integer customerType;
//
// @Column(name="customer_type_rule_el")
// private String customerTypeRuleEl;
//
// @Column(name = "enable")
// private Boolean enable;
//
// @Column(name="created_by")
// private String createdBy;
//
// @Column(name="updated_by")
// private String updatedBy;
//
// @Column(name = "created_at")
// private Timestamp createdAt;
//
// @Column(name = "updated_at")
// private Timestamp updatedAt;
//
//
// @PrePersist
// public void prePersist() {
// Timestamp timestamp = new Timestamp(System.currentTimeMillis());
// createdAt = timestamp;
// updatedAt = timestamp;
// }
//
// @PreUpdate
// public void preUpdate() {
// updatedAt = new Timestamp(System.currentTimeMillis());
// }
}
......@@ -8,7 +8,8 @@ import java.util.List;
/**
* Created by renfeng on 2019/7/17.
*/
public interface ICustomerTypeRuleConfigRepository extends JpaRepository<CustomerTypeRuleConfig, Long>{
public interface ICustomerTypeRuleConfigRepository {
//public interface ICustomerTypeRuleConfigRepository extends JpaRepository<CustomerTypeRuleConfig, Long>{
......
......@@ -43,6 +43,8 @@ public class UserCenterServiceImpl implements IUserCenterService {
@Autowired
private IRedisService<UserInfo> redisService;
@Autowired
private IRedisService<SDKUserInfo> sdkUserInfoRedisService;
@Autowired
private IHttpService httpService;
......@@ -51,6 +53,11 @@ public class UserCenterServiceImpl implements IUserCenterService {
*/
private static final String USER_INFO_PRE_FIX = "ASSET_DISTRIBUTION:GET_USER_INFO_BY_UUID:MMNACH99:";
/**
* SDKUserInfo redisKey前缀
*/
private static final String SDK_USER_INFO_PREFIX = "ASSET_DISTRIBUTION:GET_SDK_USER_INFO_BY_PHONE_NO:AMMVYY16:";
@PostConstruct
private void init() {
userSdkService = UserSdkServiceFactory.generateSDKService(userSysUrl, httpClient);
......@@ -75,17 +82,34 @@ public class UserCenterServiceImpl implements IUserCenterService {
@Override
public SDKUserInfo getSDKUserExtInfo(String phoneNo, String uuid) {
// 这个暂时就先不做缓存了,如果后续有需求用到,再加上缓存,目前是一次性使用
final String cacheKey = getSdkUserInfoCacheKey(phoneNo);
SDKUserInfo sdkUserInfo = sdkUserInfoRedisService.getEntity(cacheKey);
if (sdkUserInfo == null) {
sdkUserInfo = getSDKUserInfoFromUserCenter(phoneNo, uuid);
if (sdkUserInfo != null) {
sdkUserInfoRedisService.setEntityEx(cacheKey, sdkUserInfo, 5, TimeUnit.MINUTES);
}
}
return sdkUserInfo;
}
/**
* 从用户中心获取SDKUserInfo
* @param uuid
* @param phoneNo
* @return
*/
private SDKUserInfo getSDKUserInfoFromUserCenter(String phoneNo, String uuid) {
String url = userSysUrl + "/innerapi/user-association/search/userId";
Map<String, String> params = new HashMap<>();
params.put("phoneNo", phoneNo);
String result = httpService.post(url, params);
JSONObject data = JSON.parseObject(result);
Boolean success = data.getBoolean("success");
if (!(success != null && success.booleanValue() && "0000".equals(data.getString("code"))
&& "0000".equals(data.getString("businessCode")))) {
log.info("用户中心根据phoneNo查询用户全量信息失败, phone : {}, result : {}", phoneNo, result);
log.info("用户中心根据phoneNo查询用户全量信息失败, uuid : {}, phone : {}, result : {}", uuid, phoneNo, result);
return null;
}
......@@ -102,4 +126,13 @@ public class UserCenterServiceImpl implements IUserCenterService {
return USER_INFO_PRE_FIX + uuid;
}
/**
* 获取SDKUserInfo缓存key前缀
* @param phoneNo
* @return
*/
private static final String getSdkUserInfoCacheKey(String phoneNo) {
return SDK_USER_INFO_PREFIX + phoneNo;
}
}
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