hst_rule_set.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import json
  2. def null2Zero(value):
  3. if value == None:
  4. return 0
  5. else:
  6. return float(value)
  7. def callLocal(businessInfo):
  8. jsonData = json.loads(businessInfo['result'])
  9. loanInfo = jsonData['贷款信息']
  10. badDebtsInfo = jsonData['呆账信息汇总']
  11. parsePayRcdStatus = jsonData['24期还款状态']
  12. creditInfo = jsonData['贷记卡账户']
  13. creditandloanSum=jsonData['信贷交易授信及负债信息概要']
  14. querySum=jsonData['查询记录汇总']
  15. newcreditInfo=jsonData['开户数']
  16. queryDetail=jsonData['信贷审批查询记录明细']
  17. useRate=jsonData['使用率']
  18. publicInfo=jsonData['公共信息概要']
  19. specialInfo=jsonData['特殊交易']
  20. creditoverdueInfo=jsonData['信贷交易违约信息概要']
  21. creditTradeInfo=jsonData['信贷交易信息提示']
  22. data1=jsonData['逾期(透支)信息汇总']
  23. hsz_data=jsonData['慧算账新增']
  24. #信息过少
  25. if null2Zero(creditTradeInfo['个人住房贷款账户数'])+null2Zero(creditTradeInfo['个人商用房贷款(包括商住两用)账户数'])+\
  26. null2Zero(creditTradeInfo['其他类贷款账户数'])+null2Zero(creditTradeInfo['贷记卡账户数'])==0:
  27. return {"approveResult":'0',"rule":'F1'}
  28. # 贷记卡逾期
  29. elif null2Zero(creditInfo['当前贷记卡最大逾期金额'])>=500:
  30. return {"approveResult":'0',"rule":'A1'}
  31. elif null2Zero(parsePayRcdStatus['贷记卡账户近3月逾期期数大于或等于“1”的次数'])>0:
  32. return {"approveResult":'0',"rule":'A2'}
  33. elif null2Zero(parsePayRcdStatus['贷记卡账户近6月逾期期数大于或等于“1”的次数'])>1:
  34. return {"approveResult":'0',"rule":'A3'}
  35. elif null2Zero(parsePayRcdStatus['贷记卡账户近12月逾期期数大于或等于“1”的次数'])>3:
  36. return {"approveResult": '0', "rule": 'A4'}
  37. elif null2Zero(creditInfo['最近12个月贷记卡最大连续逾期月份数'])>1:
  38. return {"approveResult": '0', "rule": 'A5'}
  39. elif null2Zero(creditInfo['近24月贷记卡最大逾期期数'])>1 and (null2Zero(parsePayRcdStatus['贷记卡账户近12月逾期期数大于或等于“1”的次数'])>0 \
  40. or null2Zero(creditInfo['贷记卡24期还款记录次数'])<20):
  41. return {"approveResult": '0', "rule": 'A6'}
  42. elif null2Zero(parsePayRcdStatus['贷记卡账户近24月逾期期数大于或等于“3”的次数'])>0:
  43. return {"approveResult": '0', "rule": 'A7'}
  44. elif null2Zero(parsePayRcdStatus['贷记卡账户近6月逾期期数大于或等于“1”的次数'])>0 and null2Zero(creditInfo['贷记卡24期还款记录次数'])<=6:
  45. return {"approveResult": '0', "rule": 'A8'}
  46. elif null2Zero(parsePayRcdStatus['贷记卡账户近24个月是否出现\"G\"'])>0 or null2Zero(creditInfo['名下贷记卡数量-状态异常'])>0 \
  47. or null2Zero(badDebtsInfo['账户数'])>0 or null2Zero(data1['贷记卡账户最长逾期月数'])>=3:
  48. return {"approveResult": '0', "rule": 'A9'}
  49. #贷款逾期
  50. elif null2Zero(loanInfo['当前贷款最大逾期金额'])>0:
  51. return {"approveResult": '0', "rule": 'B1'}
  52. elif null2Zero(parsePayRcdStatus['贷款账户近3月逾期期数大于或等于“1”的次数'])>0:
  53. return {"approveResult": '0', "rule": 'B2'}
  54. elif null2Zero(parsePayRcdStatus['贷款账户近6月逾期期数大于或等于“1”的次数'])>1:
  55. return {"approveResult": '0', "rule": 'B3'}
  56. elif null2Zero(parsePayRcdStatus['贷款账户近12月逾期期数大于或等于“1”的次数'])>3:
  57. return {"approveResult": '0', "rule": 'B4'}
  58. elif null2Zero(parsePayRcdStatus['贷款账户近24月逾期期数大于或等于“2”的次数'])>0 and (null2Zero(parsePayRcdStatus['贷款账户近12月逾期期数大于或等于“1”的次数'])>0 \
  59. or null2Zero(loanInfo['贷款24期还款记录次数'])<22):
  60. return {"approveResult": '0', "rule": 'B5'}
  61. elif null2Zero(parsePayRcdStatus['贷款账户近24月逾期期数大于或等于“3”的次数'])>0:
  62. return {"approveResult": '0', "rule": 'B6'}
  63. elif null2Zero(parsePayRcdStatus['贷款账户近6月逾期期数大于或等于“1”的次数'])>0 and null2Zero(loanInfo['贷款24期还款记录次数'])<=6:
  64. return {"approveResult": '0', "rule": 'B7'}
  65. elif null2Zero(parsePayRcdStatus['贷款账户近24个月是否出现\"G\"'])>0 or null2Zero(parsePayRcdStatus['贷款账户近24个月是否出现\"Z\"'])>0 or\
  66. null2Zero(data1['非循环贷帐户最长逾期月数'])>=3 or null2Zero(data1['循环额度下分账户最长逾期月数'])>=3:
  67. return {"approveResult": '0', "rule": 'B8'}
  68. #高负债
  69. elif null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.95 and null2Zero(creditInfo['贷记卡24期还款记录次数'])<=3 and \
  70. null2Zero(creditInfo['当前正常贷记卡已用额度'])>28500:
  71. return {"approveResult": '0', "rule": 'C1'}
  72. elif (null2Zero(loanInfo['当前房贷LTV'])==0 and null2Zero(loanInfo['当前车贷LTV'])==0 and null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>=0.95 and \
  73. null2Zero(creditInfo['当前正常贷记卡已用额度'])>=50000) or (null2Zero(loanInfo['当前房贷LTV'])+null2Zero(loanInfo['当前车贷LTV'])>0 and \
  74. null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>=0.95 and null2Zero(creditInfo['当前正常贷记卡已用额度'])>=80000):
  75. return {"approveResult": '0', "rule": 'C2'}
  76. elif null2Zero(loanInfo['当前未结清贷款余额总和'])-null2Zero(loanInfo['当前未结清住房贷款余额总和'])-null2Zero(loanInfo['当前未结清汽车贷款余额总和'])-\
  77. null2Zero(loanInfo['当前未结清个人经营性贷款余额总和'])>=100000:
  78. return {"approveResult": '0', "rule": 'C3'}
  79. elif null2Zero(creditInfo['当前正常贷记卡已用额度'])>=200000:
  80. return {"approveResult": '0', "rule": 'C4'}
  81. elif (null2Zero(loanInfo['当前贷款本月应还金额总和'])+null2Zero(creditInfo['当前贷记卡本月应还金额总和'])>50000 and \
  82. null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.9) or \
  83. null2Zero(loanInfo['当前贷款本月应还金额总和'])+null2Zero(creditInfo['当前贷记卡本月应还金额总和'])>80000:
  84. return {"approveResult": '0', "rule": 'C5'}
  85. elif (null2Zero(creditInfo['当前贷记卡本月应还金额总和'])!=0 and \
  86. null2Zero(creditInfo['当前贷记卡本月实还金额总和'])/null2Zero(creditInfo['当前贷记卡本月应还金额总和'])<0.3) or \
  87. (null2Zero(loanInfo['当前贷款本月应还金额总和'])!=0 and \
  88. null2Zero(loanInfo['当前贷款本月实还金额总额'])/null2Zero(loanInfo['当前贷款本月应还金额总和'])<0.3) or \
  89. (null2Zero(creditInfo['当前贷记卡本月应还金额总和'])!=0 and \
  90. null2Zero(creditInfo['当前贷记卡本月实还金额总和'])/null2Zero(creditInfo['当前贷记卡本月应还金额总和'])<0.4 and \
  91. null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.95):
  92. return {"approveResult": '0', "rule": 'C6'}
  93. elif null2Zero(creditandloanSum['贷记卡授信总额'])>100000 and null2Zero(creditInfo['贷记卡账户近6月平均额度总的使用率'])>0.9:
  94. return {"approveResult": '0', "rule": 'C7'}
  95. elif null2Zero(creditandloanSum['贷记卡发卡机构数'])>=10 and null2Zero(creditInfo['贷记卡账户近6月平均额度总的使用率'])>0.95:
  96. return {"approveResult": '0', "rule": 'C8'}
  97. #查询次数
  98. elif null2Zero(querySum['近1月内的查询次数-信用卡审批'])>=10:
  99. return {"approveResult": '0', "rule": 'D1'}
  100. elif null2Zero(querySum['近1月内的查询次数-信用卡审批'])>=6 and null2Zero(newcreditInfo['近3个月贷记卡账户开户数'])==0:
  101. return {"approveResult": '0', "rule": 'D2'}
  102. elif null2Zero(queryDetail['近3月查询次数信用卡审批'])>=12 and null2Zero(newcreditInfo['近3个月贷记卡账户开户数'])==0:
  103. return {"approveResult": '0', "rule": 'D3'}
  104. elif null2Zero(queryDetail['近3月查询次数信用卡审批'])>=15:
  105. return {"approveResult": '0', "rule": 'D4'}
  106. elif null2Zero(querySum['近1月内的查询次数-贷款审批'])>=15:
  107. return {"approveResult": '0', "rule": 'D5'}
  108. elif null2Zero(querySum['近1月内的查询次数-贷款审批'])>=10 and \
  109. null2Zero(newcreditInfo['近3个月贷款账户开户数'])+null2Zero(newcreditInfo['近3个月消费金融类账户开户数'])==0:
  110. return {"approveResult": '0', "rule": 'D6'}
  111. elif (null2Zero(queryDetail['近3月查询次数贷款审批'])>=18 and null2Zero(useRate['全账户使用率(已用额度/授信总额)'])>=0.8) or \
  112. null2Zero(queryDetail['近3月查询次数贷款审批'])>=20:
  113. return {"approveResult": '0', "rule": 'D7'}
  114. elif null2Zero(queryDetail['近3月查询次数贷款审批'])+null2Zero(queryDetail['近3月查询次数信用卡审批'])>=25:
  115. return {"approveResult": '0', "rule": 'D8'}
  116. elif null2Zero(querySum['近1月内的查询次数-本人查询'])>=2:
  117. return {"approveResult": '0', "rule": 'D9'}
  118. #公共信息
  119. elif null2Zero(publicInfo['欠税信息-记录数'])>0 and null2Zero(parsePayRcdStatus['全账户近12月逾期期数大于或等于“1”的次数'])>0:
  120. return {"approveResult": '0', "rule": 'G1'}
  121. elif null2Zero(publicInfo['民事判决信息-记录数'])>0 and null2Zero(parsePayRcdStatus['全账户近12月逾期期数大于或等于“1”的次数'])>0:
  122. return {"approveResult": '0', "rule": 'G2'}
  123. elif null2Zero(publicInfo['行政处罚信息-记录数'])>0 and null2Zero(parsePayRcdStatus['全账户近12月逾期期数大于或等于“1”的次数'])>0:
  124. return {"approveResult": '0', "rule": 'G3'}
  125. elif null2Zero(publicInfo['强制执行信息-记录数'])>0:
  126. return {"approveResult": '0', "rule": 'G4'}
  127. #其它
  128. elif null2Zero(specialInfo['当前用户发生特殊交易的严重程度'])==1:
  129. return {"approveResult": '0', "rule": 'E1'}
  130. elif (null2Zero(creditoverdueInfo['资产处置业务账户数'])>0 and null2Zero(creditoverdueInfo['资产处置业务余额'])>0) or \
  131. (null2Zero(creditoverdueInfo['垫款业务账户数'])>0 and null2Zero(creditoverdueInfo['垫款业务余额'])>0) or \
  132. null2Zero(creditoverdueInfo['债权转移时属于催收状态的账户数'])>0 or \
  133. null2Zero(creditoverdueInfo['债权转移时属于催收状态的账户数/被追偿信息总数']) > 0:
  134. return {"approveResult": '0', "rule": 'E2'}
  135. elif null2Zero(creditInfo['最近新发放的3张贷记卡平均额度'])<=5000 and null2Zero(creditInfo['贷记卡账户当前总额度使用率'])>0.95 and \
  136. null2Zero(creditInfo['近6月贷记卡最大逾期期数'])>0:
  137. return {"approveResult": '0', "rule": 'E3'}
  138. elif null2Zero(creditandloanSum['相关还款责任账户总担保余额-担保责任'])>=500000:
  139. return {"approveResult": '0', "rule": 'E4'}
  140. elif null2Zero(hsz_data['最近6个月有贷款还款记录的月份数'])<3:
  141. return {"approveResult": '0', "rule": 'E5'}
  142. elif null2Zero(hsz_data['贷款历史最大逾期期数'])>0 and null2Zero(hsz_data['最近12个月有贷款还款记录的月份数'])==0:
  143. return {"approveResult": '0', "rule": 'E6'}
  144. elif null2Zero(hsz_data['贷款发放笔数'])==0:
  145. return {"approveResult": '0', "rule": 'E7'}
  146. else:
  147. return {"approveResult": '1', "rule": 'P'}