Commit 91cb9893 authored by liwenbin's avatar liwenbin

fix

parent 94da5a28
......@@ -89,7 +89,7 @@ public class AssetServiceImpl implements IAssetService{
// 资方配置空跑
doTestExecute(JSON.parseObject(JSON.toJSONString(assetForm), AssetForm.class), data);
// 如果使用资方模块则去命中资方,创建金融产品集
String hitFinanceProduct = hitFundIfUseFundModule(assetForm, data);
String hitFinanceProduct = hitFundIfUseFundModule(assetForm, data, ExecuteType.ONLINE);
// 资方模块结果处理
checkFundResult(assetForm, hitFinanceProduct);
// 资产分发
......@@ -220,13 +220,17 @@ public class AssetServiceImpl implements IAssetService{
* 如果使用资方模块,需要去命中资方
* @param assetForm
*/
public String hitFundIfUseFundModule(AssetForm assetForm, Map<String, Object> data) {
public String hitFundIfUseFundModule(AssetForm assetForm, Map<String, Object> data, ExecuteType executeType) {
// 如果auditResult为true, amount或term有一个为空, 那就不管是否是测试,都不能使用资方模块了
// 同时兼容量子魔方白名单,白名单的没有期数直接返回
if ("true".equals(assetForm.getAuditResult()) && (StringUtils.isEmpty(assetForm.getAmount()) || StringUtils.isEmpty(assetForm.getTerm()))) {
return null;
}
FundModuleChannelFundConfig config = fundModuleCHannelFundConfigService.findByBizChannel(assetForm.getBizChannel());
if (config == null && executeType == ExecuteType.TEST) {
return null;
}
QGPreconditions.checkArgument(config != null, QGExceptionType.NOT_FOUNT_CHANNEL_FUNDS_INFO, assetForm.getBizChannel());
JSONArray fundArray = new JSONArray();
List<ChannelFundConfig> fundConfigList = JSONArray.parseArray(config.getFunds(), ChannelFundConfig.class);
......@@ -240,24 +244,16 @@ public class AssetServiceImpl implements IAssetService{
if (expression.contains("audit_result")) {
hasAuditResultLimit = true;
}
if (!ruleService.valid(expression, data)) {
continue A;
}
}
// 必须前置,不然如果没有判断的参数就会报错
if (!hasAuditResultLimit) {
// 如果没配,自动过一层auditResult@true的条件
if (!ruleService.valid("audit_result==true", data)) {
continue A;
}
}
for (ChannelFundConfig.Limit limit : limits) {
String expression = limit.getLimit();
// 如果是拒绝原因判断并且没有配置拒绝原因,不满足
if (expression.contains("refuseReason") && data.get("refuseReason") == null) {
continue A;
}
if (!ruleService.valid(expression, data)) {
continue A;
}
}
}
// 创建并增加资方配置
JSONObject fundInfoJSON = new JSONObject();
......@@ -291,7 +287,7 @@ public class AssetServiceImpl implements IAssetService{
bucket[priority] = true;
}
String hitFinanceProduct = createFinancePro(assetForm, fundArray);
log.info("资方模块组成金融产品集完成, uuid : {}, assetNo : {}, bizNo : {}, bizChannel : {}, financeProduct : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizNo(), assetForm.getBizChannel(), hitFinanceProduct);
log.info("资方模块组成金融产品集完成, uuid : {}, assetNo : {}, bizNo : {}, bizChannel : {}, financeProduct : {}, executeType : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizNo(), assetForm.getBizChannel(), hitFinanceProduct, executeType.name());
return hitFinanceProduct;
}
......@@ -303,6 +299,11 @@ public class AssetServiceImpl implements IAssetService{
*/
private AssetForm checkFundResult(AssetForm assetForm, String hitFinanceProduct) {
if (hitFinanceProduct == null) {
if ("false".equals(assetForm.getAuditResult())) {
// 把传过来的额度和期数处理为null
assetForm.setAmount(null);
assetForm.setTerm(null);
}
return assetForm;
}
......@@ -318,6 +319,7 @@ public class AssetServiceImpl implements IAssetService{
// 保存日志
financeProductHitLogService.saveLog(assetForm, oldFinanceProduct, hitFinanceProduct, oldAuditResult, assetForm.getAuditResult(), ExecuteType.ONLINE);
log.info("资方命中后,审核最终结果, assetForm : {}", JSON.toJSONString(assetForm));
return assetForm;
}
......@@ -360,16 +362,23 @@ public class AssetServiceImpl implements IAssetService{
executorPool.execute(() -> {
try {
assetForm.setBizChannel("88888_" + assetForm.getBizChannel());
String hitFundPro = hitFundIfUseFundModule(assetForm, data);
String hitFundPro = hitFundIfUseFundModule(assetForm, data, ExecuteType.TEST);
if (hitFundPro != null) {
// 如果命中了记录一下,并且如果审核状态为false改为true
String oldFundPro = assetForm.getFinanceProducts();
String oldAuditResult = assetForm.getAuditResult();
if (hitFundPro != null) {
assetForm.setFinanceProducts(hitFundPro);
if ("false".equals(assetForm.getAuditResult())) {
assetForm.setAuditResult("true");
financeProductHitLogService.saveLog(assetForm, oldFundPro, hitFundPro, oldAuditResult, assetForm.getAuditResult(), ExecuteType.TEST);
} else {
// 如果没命中,且审核结果未false
if ("false".equals(assetForm.getAuditResult())) {
// 把传过来的额度和期数处理为null
assetForm.setAmount(null);
assetForm.setTerm(null);
}
}
financeProductHitLogService.saveLog(assetForm, oldFundPro, hitFundPro, oldAuditResult, assetForm.getAuditResult(), ExecuteType.TEST);
log.info("空跑审核最终结果, assetForm : {}", JSON.toJSONString(assetForm));
} catch (QGException qe) {
log.error("资方配置执行空跑出现错误 : {}, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} ",
qe.qgExceptionType.code + "->" + qe.detail, assetForm.getUuid(),
......
......@@ -461,7 +461,7 @@ public class Expression {
pos--;
}
token.type = ch == '(' ? TokenType.FUNCTION
: variables.containsKey(token.surface) ? TokenType.VARIABLE : TokenType.LITERAL;
: TokenType.VARIABLE;
} else if (ch == '(' || ch == ')' || ch == ',') {
if (ch == '(') {
token.type = TokenType.OPEN_PAREN;
......@@ -672,7 +672,7 @@ public class Expression {
if (v1 == null || v2 == null) {
return BigDecimal.ZERO;
}
if (v1.equals(v2)) {
if (v1.equalsIgnoreCase(v2)) {
return BigDecimal.ONE;
} else {
return BigDecimal.ZERO;
......@@ -1130,6 +1130,10 @@ public class Expression {
variables.put("e", CreateLazyNumber(e.toPlainString()));
variables.put("PI", CreateLazyNumber(PI.toPlainString()));
variables.put("NULL", null);
variables.put("true", CreateLazyNumber("true"));
variables.put("TRUE", CreateLazyNumber("TRUE"));
variables.put("false", CreateLazyNumber("false"));
variables.put("FALSE", CreateLazyNumber("FALSE"));
}
private void assertNotNull(String v1) {
......@@ -1398,7 +1402,7 @@ public class Expression {
break;
case VARIABLE:
if (!variables.containsKey(token.surface)) {
throw new ExpressionException("Unknown operator or function: " + token);
return BigDecimal.ZERO;
}
stack.push(() -> {
......
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