import json def null2Zero(value): if value == None: return 0 else: return float(value) def callLocal(businessInfo): jsonData = json.loads(businessInfo['result']) loanInfo = jsonData['贷款信息'] badDebtsInfo = jsonData['呆账信息汇总'] parsePayRcdStatus = jsonData['24期还款状态'] creditInfo = jsonData['贷记卡账户'] creditandloanSum=jsonData['信贷交易授信及负债信息概要'] querySum=jsonData['查询记录汇总'] newcreditInfo=jsonData['开户数'] queryDetail=jsonData['信贷审批查询记录明细'] useRate=jsonData['使用率'] publicInfo=jsonData['公共信息概要'] specialInfo=jsonData['特殊交易'] creditoverdueInfo=jsonData['信贷交易违约信息概要'] creditTradeInfo=jsonData['信贷交易信息提示'] data1=jsonData['逾期(透支)信息汇总'] hsz_data=jsonData['慧算账新增'] #信息过少 if null2Zero(creditTradeInfo['个人住房贷款账户数'])+null2Zero(creditTradeInfo['个人商用房贷款(包括商住两用)账户数'])+\ null2Zero(creditTradeInfo['其他类贷款账户数'])+null2Zero(creditTradeInfo['贷记卡账户数'])==0: return {"approveResult":'0',"rule":'F1'} # 贷记卡逾期 elif null2Zero(creditInfo['当前贷记卡最大逾期金额'])>=500: return {"approveResult":'0',"rule":'A1'} elif null2Zero(parsePayRcdStatus['贷记卡账户近3月逾期期数大于或等于“1”的次数'])>0: return {"approveResult":'0',"rule":'A2'} elif null2Zero(parsePayRcdStatus['贷记卡账户近6月逾期期数大于或等于“1”的次数'])>1: return {"approveResult":'0',"rule":'A3'} elif null2Zero(parsePayRcdStatus['贷记卡账户近12月逾期期数大于或等于“1”的次数'])>3: return {"approveResult": '0', "rule": 'A4'} elif null2Zero(creditInfo['最近12个月贷记卡最大连续逾期月份数'])>1: return {"approveResult": '0', "rule": 'A5'} elif null2Zero(creditInfo['近24月贷记卡最大逾期期数'])>1 and (null2Zero(parsePayRcdStatus['贷记卡账户近12月逾期期数大于或等于“1”的次数'])>0 \ or null2Zero(creditInfo['贷记卡24期还款记录次数'])<20): return {"approveResult": '0', "rule": 'A6'} elif null2Zero(parsePayRcdStatus['贷记卡账户近24月逾期期数大于或等于“3”的次数'])>0: return {"approveResult": '0', "rule": 'A7'} elif null2Zero(parsePayRcdStatus['贷记卡账户近6月逾期期数大于或等于“1”的次数'])>0 and null2Zero(creditInfo['贷记卡24期还款记录次数'])<=6: return {"approveResult": '0', "rule": 'A8'} elif null2Zero(parsePayRcdStatus['贷记卡账户近24个月是否出现\"G\"'])>0 or null2Zero(creditInfo['名下贷记卡数量-状态异常'])>0 \ or null2Zero(badDebtsInfo['账户数'])>0 or null2Zero(data1['贷记卡账户最长逾期月数'])>=3: return {"approveResult": '0', "rule": 'A9'} #贷款逾期 elif null2Zero(loanInfo['当前贷款最大逾期金额'])>0: return {"approveResult": '0', "rule": 'B1'} elif null2Zero(parsePayRcdStatus['贷款账户近3月逾期期数大于或等于“1”的次数'])>0: return {"approveResult": '0', "rule": 'B2'} elif null2Zero(parsePayRcdStatus['贷款账户近6月逾期期数大于或等于“1”的次数'])>1: return {"approveResult": '0', "rule": 'B3'} elif null2Zero(parsePayRcdStatus['贷款账户近12月逾期期数大于或等于“1”的次数'])>3: return {"approveResult": '0', "rule": 'B4'} elif null2Zero(parsePayRcdStatus['贷款账户近24月逾期期数大于或等于“2”的次数'])>0 and (null2Zero(parsePayRcdStatus['贷款账户近12月逾期期数大于或等于“1”的次数'])>0 \ or null2Zero(loanInfo['贷款24期还款记录次数'])<22): return {"approveResult": '0', "rule": 'B5'} elif null2Zero(parsePayRcdStatus['贷款账户近24月逾期期数大于或等于“3”的次数'])>0: return {"approveResult": '0', "rule": 'B6'} elif null2Zero(parsePayRcdStatus['贷款账户近6月逾期期数大于或等于“1”的次数'])>0 and null2Zero(loanInfo['贷款24期还款记录次数'])<=6: return {"approveResult": '0', "rule": 'B7'} elif null2Zero(parsePayRcdStatus['贷款账户近24个月是否出现\"G\"'])>0 or null2Zero(parsePayRcdStatus['贷款账户近24个月是否出现\"Z\"'])>0 or\ null2Zero(data1['非循环贷帐户最长逾期月数'])>=3 or null2Zero(data1['循环额度下分账户最长逾期月数'])>=3: return {"approveResult": '0', "rule": 'B8'} #高负债 elif null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.95 and null2Zero(creditInfo['贷记卡24期还款记录次数'])<=3 and \ null2Zero(creditInfo['当前正常贷记卡已用额度'])>28500: return {"approveResult": '0', "rule": 'C1'} elif (null2Zero(loanInfo['当前房贷LTV'])==0 and null2Zero(loanInfo['当前车贷LTV'])==0 and null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>=0.95 and \ null2Zero(creditInfo['当前正常贷记卡已用额度'])>=50000) or (null2Zero(loanInfo['当前房贷LTV'])+null2Zero(loanInfo['当前车贷LTV'])>0 and \ null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>=0.95 and null2Zero(creditInfo['当前正常贷记卡已用额度'])>=80000): return {"approveResult": '0', "rule": 'C2'} elif null2Zero(loanInfo['当前未结清贷款余额总和'])-null2Zero(loanInfo['当前未结清住房贷款余额总和'])-null2Zero(loanInfo['当前未结清汽车贷款余额总和'])-\ null2Zero(loanInfo['当前未结清个人经营性贷款余额总和'])>=100000: return {"approveResult": '0', "rule": 'C3'} elif null2Zero(creditInfo['当前正常贷记卡已用额度'])>=200000: return {"approveResult": '0', "rule": 'C4'} elif (null2Zero(loanInfo['当前贷款本月应还金额总和'])+null2Zero(creditInfo['当前贷记卡本月应还金额总和'])>50000 and \ null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.9) or \ null2Zero(loanInfo['当前贷款本月应还金额总和'])+null2Zero(creditInfo['当前贷记卡本月应还金额总和'])>80000: return {"approveResult": '0', "rule": 'C5'} elif (null2Zero(creditInfo['当前贷记卡本月应还金额总和'])!=0 and \ null2Zero(creditInfo['当前贷记卡本月实还金额总和'])/null2Zero(creditInfo['当前贷记卡本月应还金额总和'])<0.3) or \ (null2Zero(loanInfo['当前贷款本月应还金额总和'])!=0 and \ null2Zero(loanInfo['当前贷款本月实还金额总额'])/null2Zero(loanInfo['当前贷款本月应还金额总和'])<0.3) or \ (null2Zero(creditInfo['当前贷记卡本月应还金额总和'])!=0 and \ null2Zero(creditInfo['当前贷记卡本月实还金额总和'])/null2Zero(creditInfo['当前贷记卡本月应还金额总和'])<0.4 and \ null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.95): return {"approveResult": '0', "rule": 'C6'} elif null2Zero(creditandloanSum['贷记卡授信总额'])>100000 and null2Zero(creditInfo['贷记卡账户近6月平均额度总的使用率'])>0.9: return {"approveResult": '0', "rule": 'C7'} elif null2Zero(creditandloanSum['贷记卡发卡机构数'])>=10 and null2Zero(creditInfo['贷记卡账户近6月平均额度总的使用率'])>0.95: return {"approveResult": '0', "rule": 'C8'} #查询次数 elif null2Zero(querySum['近1月内的查询次数-信用卡审批'])>=10: return {"approveResult": '0', "rule": 'D1'} elif null2Zero(querySum['近1月内的查询次数-信用卡审批'])>=6 and null2Zero(newcreditInfo['近3个月贷记卡账户开户数'])==0: return {"approveResult": '0', "rule": 'D2'} elif null2Zero(queryDetail['近3月查询次数信用卡审批'])>=12 and null2Zero(newcreditInfo['近3个月贷记卡账户开户数'])==0: return {"approveResult": '0', "rule": 'D3'} elif null2Zero(queryDetail['近3月查询次数信用卡审批'])>=15: return {"approveResult": '0', "rule": 'D4'} elif null2Zero(querySum['近1月内的查询次数-贷款审批'])>=15: return {"approveResult": '0', "rule": 'D5'} elif null2Zero(querySum['近1月内的查询次数-贷款审批'])>=10 and \ null2Zero(newcreditInfo['近3个月贷款账户开户数'])+null2Zero(newcreditInfo['近3个月消费金融类账户开户数'])==0: return {"approveResult": '0', "rule": 'D6'} elif (null2Zero(queryDetail['近3月查询次数贷款审批'])>=18 and null2Zero(useRate['全账户使用率(已用额度/授信总额)'])>=0.8) or \ null2Zero(queryDetail['近3月查询次数贷款审批'])>=20: return {"approveResult": '0', "rule": 'D7'} elif null2Zero(queryDetail['近3月查询次数贷款审批'])+null2Zero(queryDetail['近3月查询次数信用卡审批'])>=25: return {"approveResult": '0', "rule": 'D8'} elif null2Zero(querySum['近1月内的查询次数-本人查询'])>=2: return {"approveResult": '0', "rule": 'D9'} #公共信息 elif null2Zero(publicInfo['欠税信息-记录数'])>0 and null2Zero(parsePayRcdStatus['全账户近12月逾期期数大于或等于“1”的次数'])>0: return {"approveResult": '0', "rule": 'G1'} elif null2Zero(publicInfo['民事判决信息-记录数'])>0 and null2Zero(parsePayRcdStatus['全账户近12月逾期期数大于或等于“1”的次数'])>0: return {"approveResult": '0', "rule": 'G2'} elif null2Zero(publicInfo['行政处罚信息-记录数'])>0 and null2Zero(parsePayRcdStatus['全账户近12月逾期期数大于或等于“1”的次数'])>0: return {"approveResult": '0', "rule": 'G3'} elif null2Zero(publicInfo['强制执行信息-记录数'])>0: return {"approveResult": '0', "rule": 'G4'} #其它 elif null2Zero(specialInfo['当前用户发生特殊交易的严重程度'])==1: return {"approveResult": '0', "rule": 'E1'} elif (null2Zero(creditoverdueInfo['资产处置业务账户数'])>0 and null2Zero(creditoverdueInfo['资产处置业务余额'])>0) or \ (null2Zero(creditoverdueInfo['垫款业务账户数'])>0 and null2Zero(creditoverdueInfo['垫款业务余额'])>0) or \ null2Zero(creditoverdueInfo['债权转移时属于催收状态的账户数'])>0 or \ null2Zero(creditoverdueInfo['债权转移时属于催收状态的账户数/被追偿信息总数']) > 0: return {"approveResult": '0', "rule": 'E2'} elif null2Zero(creditInfo['最近新发放的3张贷记卡平均额度'])<=5000 and null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.95 and \ null2Zero(creditInfo['近6月贷记卡最大逾期期数'])>0: return {"approveResult": '0', "rule": 'E3'} elif null2Zero(creditandloanSum['相关还款责任账户总担保余额-担保责任'])>=500000: return {"approveResult": '0', "rule": 'E4'} elif null2Zero(hsz_data['最近6个月有贷款还款记录的月份数'])<3: return {"approveResult": '0', "rule": 'E5'} elif null2Zero(hsz_data['贷款历史最大逾期期数'])>0 and null2Zero(hsz_data['最近12个月有贷款还款记录的月份数'])==0: return {"approveResult": '0', "rule": 'E6'} elif null2Zero(hsz_data['贷款发放笔数'])==0: return {"approveResult": '0', "rule": 'E7'} else: return {"approveResult": '1', "rule": 'P'}