Commit 91cb9893 authored by liwenbin's avatar liwenbin

fix

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