xyHttp.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. # -*- coding: utf-8 -*-
  2. import requests
  3. import json
  4. import os
  5. from ini_op import Config;
  6. base_dir = os.path.dirname(os.path.abspath(__file__))
  7. import log
  8. import utils
  9. # import jzutil
  10. logger = log.logger
  11. config = Config(base_dir+"/config.ini");
  12. CREATE_API = config.get("baseconf","create_api")
  13. qk_url= config.get("baseconf", "qk_url");
  14. hsz_url= config.get("baseconf", "hsz_url");
  15. hc_url= config.get("baseconf", "hc_url");
  16. jz_url= config.get("baseconf", "jz_url");
  17. rd_url= config.get("baseconf", "rd_url");
  18. isAutoApprove = config.get("baseconf", "isAutoApprove");
  19. #小赢服务
  20. def call_credit(businessInfo):
  21. credit_xml = businessInfo["creditXml"]
  22. extendData = businessInfo["extend"]
  23. extendData = json.loads(extendData)
  24. # credit_xml = '<征信原始Json串>'
  25. rule_params = {"riskVar": {"xdStatus": 1, "isApp": 1, "pyEdu": 1},
  26. "version": "0.0.3",
  27. "product_name": "kd",
  28. "ruleSet": {"ruleZx113": {},
  29. "ruleZx120": {},
  30. "ruleZx121": {},
  31. "ruleZx101": {},
  32. "ruleZxNohigh": {},
  33. "ruleZx119": {},
  34. "ruleZx118": {},
  35. "ruleZx108": {},
  36. "ruleZx104": {"tdCardOpenMonth": "3"},
  37. "ruleZx110": {},
  38. "ruleZx116": {"tdLoanOver1p5M": "1500000"},
  39. "ruleZx115": {"tdDebitCardTotal1": "0", "tdDebitCardTotal2": "2",
  40. "tdSingleDebitCardMax": "2"}},
  41. "specialSet": {"ruleZx111": {"tdMaxOpenMonth": "6"}},
  42. "scoreSet": {"ruleZx129": {"tdCreditScore": "850"}},
  43. "method": "rule_kd_one"}
  44. model_params = {"version": "kyd_pboc_lr_v1"}
  45. params = {
  46. 'ruleParams' : rule_params,
  47. 'modelParams': model_params
  48. }
  49. request_data = {
  50. 'requestId': businessInfo["coopBusinessNum"],
  51. 'extendData': json.dumps(extendData["zxmb"]),
  52. 'zxData': credit_xml
  53. }
  54. request_data1 = {
  55. 'requestId': businessInfo["coopBusinessNum"],
  56. 'extendData': extendData,
  57. }
  58. # logger.info(request_data1)
  59. resp = requests.post(CREATE_API, data=json.dumps(request_data))
  60. return resp.text
  61. #调用洽客http
  62. def callQk(businessInfo):
  63. credit_xml = businessInfo["result"]
  64. request_data = {
  65. 'queryReq': credit_xml
  66. }
  67. # logger.info(json.dumps(request_data))
  68. headers = {"Content-Type":"application/json"}
  69. resp = requests.post(qk_url, data=json.dumps(request_data),headers=headers)
  70. return resp.text
  71. #恒昌
  72. def callHc(businessInfo):
  73. credit_json = businessInfo["result"]
  74. request_data = {
  75. 'queryReq': credit_json
  76. }
  77. # logger.info(json.dumps(request_data))
  78. headers = {"Content-Type":"application/json"}
  79. resp = requests.post(hc_url, data=json.dumps(request_data),headers=headers)
  80. return resp.text
  81. #调用慧算账
  82. def callHsz(businessInfo):
  83. creditJson = businessInfo["result"]
  84. extend = businessInfo["extend"]
  85. request_data = {
  86. 'queryReq': creditJson,
  87. 'extend':extend
  88. }
  89. # logger.info(json.dumps(request_data))
  90. headers = {"Content-Type":"application/json"}
  91. resp = requests.post(hsz_url, data=json.dumps(request_data),headers=headers)
  92. return resp.text
  93. #新版桔子
  94. def callJz(businessInfo):
  95. creditJson = businessInfo["result"]
  96. extend = businessInfo["extend"]
  97. request_data = {
  98. 'queryReq': creditJson,
  99. 'extend':extend
  100. }
  101. # logger.info(json.dumps(request_data))
  102. headers = {"Content-Type":"application/json"}
  103. resp = requests.post(jz_url, data=json.dumps(request_data),headers=headers)
  104. result = resp.text
  105. dataResult = json.loads(result)
  106. dataResult["data"]["orderNo"]=businessInfo["coopBusinessNum"]
  107. # 桔子新版加密合并data字段
  108. # newResult = jzutil.encode(businessInfo)
  109. # dataResult["data"] = dataResult["data"].update(newResult)
  110. return json.dumps(dataResult)
  111. #仁东
  112. def callRd(businessInfo):
  113. credit_json = businessInfo["result"]
  114. request_data = {
  115. 'queryReq': credit_json
  116. }
  117. # logger.info(json.dumps(request_data))
  118. headers = {"Content-Type":"application/json"}
  119. resp = requests.post(rd_url, data=json.dumps(request_data),headers=headers)
  120. return resp.text
  121. def convert(N,key):
  122. N = null2Zero(N)
  123. result = ""
  124. if N == 0:
  125. result = "sun"
  126. elif N>=1 and N<3 and (key=="A2" or key=="A3" or key=="A8" or key=="A9" or key=="A10"):
  127. result = "aries"
  128. elif N>=3 and (key=="A2"):
  129. result = "taurus"
  130. elif N>=3 and N<6 and (key=="A3" or key=="A8" or key=="A9" or key=="A10"):
  131. result = "gemini"
  132. elif N>=6 and (key=="A3" or key=="A8" or key=="A9" or key=="A10"):
  133. result = "cancer"
  134. elif N>0 and N<=5000 and (key=="A4"):
  135. result = "leo"
  136. elif N > 5000 and N <= 10000 and (key == "A4"):
  137. result = "virgo"
  138. elif N > 0 and N <= 10000 and (key == "A1" or key == "A7"):
  139. result = "libra"
  140. elif N > 10000 and N <= 30000 and (key == "A1" or key == "A7"):
  141. result = "scorpio"
  142. elif N >30000 and (key == "A1" or key == "A7"):
  143. result = "sagittarius"
  144. elif N > 0 and N <= 50000 and (key == "A5" or key == "A6"):
  145. result = "capricorn"
  146. elif N > 50000 and N <= 100000 and (key == "A5" or key == "A6"):
  147. result = "aquarius"
  148. elif N > 100000 and N <= 500000 and (key == "A5" or key == "A6"):
  149. result = "pisces"
  150. elif N >500000 and (key == "A5" or key == "A6"):
  151. result = "moon"
  152. return result;
  153. def buildJyData(businessInfo,jsonPath):
  154. try:
  155. data = {}
  156. jsonData = json.loads(businessInfo["result"]);
  157. #强制执行信息-涉及金额
  158. publicInfoBrief = jsonData["公共信息概要"];
  159. data["A1"] = convert(publicInfoBrief["强制执行信息-涉及金额"],"A1")
  160. queryRecordSum = jsonData["查询记录汇总"];
  161. data["A2"] = convert(queryRecordSum["近1月内的查询次数-贷款审批"],"A2")
  162. loanInfo = jsonData["贷款信息"];
  163. data["A3"] = convert(loanInfo["当前贷款最大逾期期数"],"A3")
  164. data["A4"] = convert(loanInfo["当前贷款最大逾期金额"],"A4")
  165. data["A5"] = convert(loanInfo["当前未结清贷款余额总和"],"A5")
  166. data["A6"] = convert(loanInfo["当前正常贷款账户余额"],"A6")
  167. creditInfo = jsonData["贷记卡账户"];
  168. data["A7"] = convert(creditInfo["当前贷记卡最大逾期金额"],"A7")
  169. data["A8"] = convert(creditInfo["近12月贷记卡最大逾期期数"],"A8")
  170. queryRecordDetailDf = jsonData["信贷审批查询记录明细"]
  171. data["A9"] = convert(publicInfoBrief["强制执行信息-记录数"], "A9")
  172. data["A10"] = convert(queryRecordDetailDf["近3月查询次数"],"A10")
  173. except:
  174. pass
  175. with open(jsonPath, 'w', encoding='utf-8') as fp:
  176. fp.write(json.dumps(data))
  177. def null2Zero(value):
  178. if value==None:
  179. return 0
  180. else:
  181. return utils.toInt(value);
  182. #本地jar
  183. def callLocal(businessInfo):
  184. # 测试修改 这个地方改为读文件
  185. # with open('D:/jin_rong/test_data/朱传光_371425199305027971_256979050910728199.txt','r',encoding='utf8') as fp:
  186. # jsonData=json.load(fp);
  187. test_str=businessInfo["result"];
  188. jsonData = json.loads(test_str);
  189. approveResult = "1";
  190. #默认为通过,如果不满足条件为3
  191. loanInfo = jsonData["贷款信息"];
  192. badDebtsInfo = jsonData["呆账信息汇总"];
  193. parsePayRcdStatus = jsonData["24期还款状态"];
  194. creditInfo = jsonData["贷记卡账户"];
  195. creditInfoZ = jsonData["准贷记卡账户"];
  196. loanTradeInfoDf = jsonData["信贷交易信息提示"]
  197. # useRate = jsonData["使用率"]
  198. # queryRecordDetailDf = jsonData["信贷审批查询记录明细"]
  199. recoveryInfoSum = jsonData["信贷交易违约信息概要"]
  200. allAccountNum = null2Zero(loanTradeInfoDf["个人住房贷款账户数"])+null2Zero(loanTradeInfoDf["个人商用房贷款(包括商住两用)账户数"])\
  201. +null2Zero(loanTradeInfoDf["其他类贷款账户数"])+null2Zero(loanTradeInfoDf["贷记卡账户数"])\
  202. +null2Zero(loanTradeInfoDf["准贷记卡账户数"])
  203. #公积金
  204. housingFundRcd = jsonData["住房公积金参缴记录"]
  205. rule = ""
  206. if null2Zero(parsePayRcdStatus["全账户近24月逾期期数大于或等于“3”的次数"])>=1 or null2Zero(parsePayRcdStatus["全账户近24月逾期期数大于或等于“1”的次数"])>=6:
  207. approveResult = "0"
  208. rule="#1"
  209. rule += "#全账户近24月逾期期数大于或等于“3”的次数=" + str(parsePayRcdStatus["全账户近24月逾期期数大于或等于“3”的次数"])
  210. rule += "#全账户近24月逾期期数大于或等于“1”的次数=" + str(parsePayRcdStatus["全账户近24月逾期期数大于或等于“1”的次数"])
  211. elif (utils.toInt(null2Zero(badDebtsInfo["账户数"]))>0) or null2Zero(badDebtsInfo["余额"])>0:
  212. approveResult = "0"
  213. rule="#2"
  214. rule += "#呆账账户数=" + str(badDebtsInfo["账户数"])
  215. elif parsePayRcdStatus["贷款账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷记卡账户近24个月是否出现\"G\""]=="1" \
  216. or parsePayRcdStatus["准贷记卡账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷款账户近24个月是否出现\"Z\""]=="1":
  217. approveResult = "0"
  218. rule="#3"
  219. rule += "#明细出现\"G\或者还款记录出现以资抵债\"Z\"=" + str(parsePayRcdStatus["贷款账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷记卡账户近24个月是否出现\"G\""]=="1" \
  220. or parsePayRcdStatus["准贷记卡账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷款账户近24个月是否出现\"Z\""]=="1")
  221. elif loanInfo.__contains__("当前贷款最大逾期期数") and null2Zero(loanInfo["当前贷款最大逾期期数"])>0:
  222. approveResult = "0"
  223. rule="#4"
  224. rule += "#当前贷款最大逾期期数=" + str(loanInfo["当前贷款最大逾期期数"])
  225. elif creditInfo.__contains__("当前贷记卡最大逾期期数") and null2Zero(creditInfo["当前贷记卡最大逾期期数"]) > 0:
  226. approveResult = "0"
  227. rule = "#4"
  228. rule += "#当前贷记卡最大逾期期数=" + str(creditInfo["当前贷记卡最大逾期期数"])
  229. elif null2Zero(creditInfo["名下贷记卡数量-状态异常"])>0:
  230. approveResult = "0"
  231. rule="#5"
  232. rule += "#名下贷记卡数量-状态异常=" + str(creditInfo["名下贷记卡数量-状态异常"])
  233. elif creditInfoZ.__contains__("名下准贷记卡数量-状态异常") and null2Zero(creditInfoZ["名下准贷记卡数量-状态异常"])>0:
  234. approveResult = "0"
  235. rule="#6"
  236. rule += "#名下准贷记卡数量-状态异常=" + str(creditInfoZ["名下准贷记卡数量-状态异常"])
  237. elif null2Zero(recoveryInfoSum["垫款业务账户数"])>=3:#原来为>0
  238. approveResult = "0"
  239. rule="#16"
  240. rule += "#垫款业务账户数=" + str(recoveryInfoSum["垫款业务账户数"])
  241. elif null2Zero(recoveryInfoSum["垫款业务余额"]) > 0:
  242. approveResult = "0"
  243. rule="#17"
  244. rule += "#垫款业务余额=" + str(recoveryInfoSum["垫款业务余额"])
  245. #白户
  246. elif allAccountNum==0 and housingFundRcd["参缴日期"]==None:
  247. approveResult = "0"
  248. rule = "#18"
  249. rule += "#白户#无信贷交易明细"
  250. if isAutoApprove =="1":
  251. approveResult = "1"
  252. data = {"approveResult":approveResult,"rule":rule}
  253. return data;
  254. #新版本地模型
  255. def callNewModel(businessInfo):
  256. jsonData = json.loads(businessInfo["result"]);
  257. approveResult = "1";
  258. # 默认为通过,如果不满足条件为3
  259. loanInfo = jsonData["贷款信息"];
  260. badDebtsInfo = jsonData["呆账信息汇总"];
  261. parsePayRcdStatus = jsonData["24期还款状态"];
  262. creditInfo = jsonData["贷记卡账户"];
  263. creditInfoZ = jsonData["准贷记卡账户"];
  264. loanTradeInfoDf = jsonData["信贷交易信息提示"]
  265. # useRate = jsonData["使用率"]
  266. # queryRecordDetailDf = jsonData["信贷审批查询记录明细"]
  267. recoveryInfoSum = jsonData["信贷交易违约信息概要"]
  268. allAccountNum = null2Zero(loanTradeInfoDf["个人住房贷款账户数"]) + null2Zero(loanTradeInfoDf["个人商用房贷款(包括商住两用)账户数"]) \
  269. + null2Zero(loanTradeInfoDf["其他类贷款账户数"]) + null2Zero(loanTradeInfoDf["贷记卡账户数"]) \
  270. + null2Zero(loanTradeInfoDf["准贷记卡账户数"])
  271. # 公积金
  272. housingFundRcd = jsonData["住房公积金参缴记录"]
  273. rule = ""
  274. if null2Zero(parsePayRcdStatus["全账户近24月逾期期数大于或等于“3”的次数"]) >= 1 or null2Zero(
  275. parsePayRcdStatus["全账户近24月逾期期数大于或等于“1”的次数"]) >= 6:
  276. approveResult = "0"
  277. rule = "#1"
  278. rule += "#全账户近24月逾期期数大于或等于“3”的次数=" + str(parsePayRcdStatus["全账户近24月逾期期数大于或等于“3”的次数"])
  279. rule += "#全账户近24月逾期期数大于或等于“1”的次数=" + str(parsePayRcdStatus["全账户近24月逾期期数大于或等于“1”的次数"])
  280. elif (utils.toInt(null2Zero(badDebtsInfo["账户数"])) > 0) or null2Zero(badDebtsInfo["余额"]) > 0:
  281. approveResult = "0"
  282. rule = "#2"
  283. rule += "#呆账账户数=" + str(badDebtsInfo["账户数"])
  284. elif parsePayRcdStatus["贷款账户近24个月是否出现\"G\""] == "1" or parsePayRcdStatus["贷记卡账户近24个月是否出现\"G\""] == "1" \
  285. or parsePayRcdStatus["准贷记卡账户近24个月是否出现\"G\""] == "1" or parsePayRcdStatus["贷款账户近24个月是否出现\"Z\""] == "1":
  286. approveResult = "0"
  287. rule = "#3"
  288. rule += "#明细出现\"G\或者还款记录出现以资抵债\"Z\"=" + str(
  289. parsePayRcdStatus["贷款账户近24个月是否出现\"G\""] == "1" or parsePayRcdStatus["贷记卡账户近24个月是否出现\"G\""] == "1" \
  290. or parsePayRcdStatus["准贷记卡账户近24个月是否出现\"G\""] == "1" or parsePayRcdStatus["贷款账户近24个月是否出现\"Z\""] == "1")
  291. elif loanInfo.__contains__("当前贷款最大逾期期数") and null2Zero(loanInfo["当前贷款最大逾期期数"]) > 0:
  292. approveResult = "0"
  293. rule = "#4"
  294. rule += "#当前贷款最大逾期期数=" + str(loanInfo["当前贷款最大逾期期数"])
  295. elif creditInfo.__contains__("当前贷记卡最大逾期期数") and null2Zero(creditInfo["当前贷记卡最大逾期期数"]) > 0:
  296. approveResult = "0"
  297. rule = "#4"
  298. rule += "#当前贷记卡最大逾期期数=" + str(creditInfo["当前贷记卡最大逾期期数"])
  299. elif null2Zero(creditInfo["名下贷记卡数量-状态异常"]) > 0:
  300. approveResult = "0"
  301. rule = "#5"
  302. rule += "#名下贷记卡数量-状态异常=" + str(creditInfo["名下贷记卡数量-状态异常"])
  303. elif creditInfoZ.__contains__("名下准贷记卡数量-状态异常") and null2Zero(creditInfoZ["名下准贷记卡数量-状态异常"]) > 0:
  304. approveResult = "0"
  305. rule = "#6"
  306. rule += "#名下准贷记卡数量-状态异常=" + str(creditInfoZ["名下准贷记卡数量-状态异常"])
  307. elif null2Zero(recoveryInfoSum["垫款业务账户数"]) >= 3: # 原来为>0
  308. approveResult = "0"
  309. rule = "#16"
  310. rule += "#垫款业务账户数=" + str(recoveryInfoSum["垫款业务账户数"])
  311. elif null2Zero(recoveryInfoSum["垫款业务余额"]) > 0:
  312. approveResult = "0"
  313. rule = "#17"
  314. rule += "#垫款业务余额=" + str(recoveryInfoSum["垫款业务余额"])
  315. # 白户
  316. elif allAccountNum == 0 and housingFundRcd["参缴日期"] == None:
  317. approveResult = "1"
  318. rule = "#18"
  319. rule += "#白户#无信贷交易明细"
  320. if isAutoApprove == "1":
  321. approveResult = "1"
  322. data = {"approveResult": approveResult, "rule": rule}
  323. return data;
  324. #未上线
  325. def callNewModelX(businessInfo):
  326. jsonData = json.loads(businessInfo["result"]);
  327. approveResult = "1";
  328. #默认为通过,如果不满足条件为3
  329. loanInfo = jsonData["贷款信息"];
  330. badDebtsInfo = jsonData["呆账信息汇总"];
  331. parsePayRcdStatus = jsonData["24期还款状态"];
  332. creditInfo = jsonData["贷记卡账户"];
  333. creditInfoZ = jsonData["准贷记卡账户"];
  334. loanTradeInfoDf = jsonData["信贷交易信息提示"]
  335. useRate = jsonData["使用率"]
  336. queryRecordDetailDf = jsonData["信贷审批查询记录明细"]
  337. recoveryInfoSum = jsonData["信贷交易违约信息概要"]
  338. allAccountNum = null2Zero(loanTradeInfoDf["个人住房贷款账户数"])+null2Zero(loanTradeInfoDf["个人商用房贷款(包括商住两用)账户数"])\
  339. +null2Zero(loanTradeInfoDf["其他类贷款账户数"])+null2Zero(loanTradeInfoDf["贷记卡账户数"])\
  340. +null2Zero(loanTradeInfoDf["准贷记卡账户数"])
  341. loanAccountNum = null2Zero(loanTradeInfoDf["个人住房贷款账户数"]) + null2Zero(
  342. loanTradeInfoDf["个人商用房贷款(包括商住两用)账户数"]) + null2Zero(loanTradeInfoDf["其他类贷款账户数"])
  343. #公积金
  344. housingFundRcd = jsonData["住房公积金参缴记录"]
  345. rule = ""
  346. if null2Zero(parsePayRcdStatus["全账户近24月逾期期数大于或等于“3”的次数"])>=1 or null2Zero(parsePayRcdStatus["全账户近24月逾期期数大于或等于“1”的次数"])>=6:
  347. approveResult = "0"
  348. rule="#1"
  349. rule += "#全账户近24月逾期期数大于或等于“3”的次数=" + str(parsePayRcdStatus["全账户近24月逾期期数大于或等于“3”的次数"])
  350. rule += "#全账户近24月逾期期数大于或等于“1”的次数=" + str(parsePayRcdStatus["全账户近24月逾期期数大于或等于“1”的次数"])
  351. elif (utils.toInt(null2Zero(badDebtsInfo["账户数"]))>0) or null2Zero(badDebtsInfo["余额"])>0:
  352. approveResult = "0"
  353. rule="#2"
  354. rule += "#呆账账户数=" + str(badDebtsInfo["账户数"])
  355. elif parsePayRcdStatus["贷款账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷记卡账户近24个月是否出现\"G\""]=="1" \
  356. or parsePayRcdStatus["准贷记卡账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷款账户近24个月是否出现\"Z\""]=="1":
  357. approveResult = "0"
  358. rule="#3"
  359. rule += "#明细出现\"G\或者还款记录出现以资抵债\"Z\"=" + str(parsePayRcdStatus["贷款账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷记卡账户近24个月是否出现\"G\""]=="1" \
  360. or parsePayRcdStatus["准贷记卡账户近24个月是否出现\"G\""]=="1" or parsePayRcdStatus["贷款账户近24个月是否出现\"Z\""]=="1")
  361. elif loanInfo.__contains__("当前贷款最大逾期期数") and null2Zero(loanInfo["当前贷款最大逾期期数"])>0:
  362. approveResult = "0"
  363. rule="#4"
  364. rule += "#当前贷款最大逾期期数=" + str(loanInfo["当前贷款最大逾期期数"])
  365. elif creditInfo.__contains__("当前贷记卡最大逾期期数") and null2Zero(creditInfo["当前贷记卡最大逾期期数"]) > 0:
  366. approveResult = "0"
  367. rule = "#4"
  368. rule += "#当前贷记卡最大逾期期数=" + str(creditInfo["当前贷记卡最大逾期期数"])
  369. elif null2Zero(creditInfo["名下贷记卡数量-状态异常"])>0:
  370. approveResult = "0"
  371. rule="#5"
  372. rule += "#名下贷记卡数量-状态异常=" + str(creditInfo["名下贷记卡数量-状态异常"])
  373. elif creditInfoZ.__contains__("名下准贷记卡数量-状态异常") and null2Zero(creditInfoZ["名下准贷记卡数量-状态异常"])>0:
  374. approveResult = "0"
  375. rule="#6"
  376. rule += "#名下准贷记卡数量-状态异常=" + str(creditInfoZ["名下准贷记卡数量-状态异常"])
  377. elif null2Zero(loanTradeInfoDf["贷记卡账户数"]) > 6 and null2Zero(useRate["贷记卡账户使用率(已用额度/授信总额)"]) > 0.9:
  378. approveResult = "3" # 当前信用卡超过6笔且信用卡透支严重(余额/授信>90%)
  379. rule = "#6"
  380. elif (null2Zero(loanTradeInfoDf["个人住房贷款账户数"]) + null2Zero(loanTradeInfoDf["个人商用房贷款(包括商住两用)账户数"]) + null2Zero(
  381. loanTradeInfoDf["其他类贷款账户数"])
  382. + null2Zero(loanTradeInfoDf["贷记卡账户数"]) + null2Zero(loanTradeInfoDf["准贷记卡账户数"])) > 8 and \
  383. null2Zero(useRate["全账户使用率(已用额度/授信总额)"]) > 0.9:
  384. approveResult = "3" # 全账户现在贷账户超过8且余额占比超90%
  385. rule = "#7"
  386. elif (loanAccountNum) > 6 and null2Zero(useRate["非循环贷账户使用率(已用额度/授信总额)"]) > 0.9:
  387. approveResult = "3" # 当前贷款超过6笔且余额较多(余额/授信>90%)
  388. rule = "#8"
  389. elif null2Zero(queryRecordDetailDf["近1月查询次数"]) > 3:
  390. rule = "#9" # 近1月总查询次数超过3次
  391. rule += "#近1月查询次数=" + str(null2Zero(queryRecordDetailDf["近1月查询次数"]))
  392. elif null2Zero(queryRecordDetailDf["最近1个月查询机构数"]) > 2:
  393. approveResult = "3" # 近1月查询机构数超过2个
  394. rule = "#18"
  395. rule += "#最近1个月查询机构数=" + str(queryRecordDetailDf["最近1个月查询机构数"])
  396. elif null2Zero(queryRecordDetailDf["近3月查询次数"]) > 6:
  397. approveResult = "3" # 近3月总查询超过6次
  398. rule = "#19"
  399. rule += "#近3月查询次数=" + str(queryRecordDetailDf["近3月查询次数"])
  400. elif null2Zero(queryRecordDetailDf["近6月查询次数贷款审批"]) > 6:
  401. approveResult = "3" # 近半年“贷款审批”、“信用卡审批”和“担保资格审查”超过6次
  402. rule = "#20"
  403. rule += "#近6月查询次数贷款审批=" + str(queryRecordDetailDf["近6月查询次数贷款审批"])
  404. elif null2Zero(queryRecordDetailDf["近6月查询次数信用卡审批"]) > 6:
  405. approveResult = "3" # 近半年“贷款审批”、“信用卡审批”和“担保资格审查”超过6次
  406. rule = "#21"
  407. rule += "#近6月查询次数信用卡审批=" + str(queryRecordDetailDf["近6月查询次数信用卡审批"])
  408. elif null2Zero(queryRecordDetailDf["最近6个月担保资格审查查询次数"]) > 6:
  409. approveResult = "3"
  410. rule = "#22"
  411. rule += "#最近6个月担保资格审查查询次数=" + str(queryRecordDetailDf["最近6个月担保资格审查查询次数"])
  412. elif null2Zero(queryRecordDetailDf["近3月查询次数贷款审批"]) > 4:
  413. approveResult = "3" # 近3月“贷款审批”、“信用卡审批”和“担保资格审查”超过4次
  414. rule = "#10"
  415. rule += "#近3月查询次数贷款审批=" + str(queryRecordDetailDf["近3月查询次数贷款审批"])
  416. elif null2Zero(queryRecordDetailDf["近3月查询次数信用卡审批"]) > 4:
  417. approveResult = "3" # 近3月“贷款审批”、“信用卡审批”和“担保资格审查”超过4次
  418. rule = "#11"
  419. rule += "#近3月查询次数信用卡审批=" + str(queryRecordDetailDf["近3月查询次数信用卡审批"])
  420. elif queryRecordDetailDf.__contains__("最近3个月担保资格审查查询次数") and null2Zero(queryRecordDetailDf["最近3个月担保资格审查查询次数"]) > 4:
  421. approveResult = "3" # 近3月“贷款审批”、“信用卡审批”和“担保资格审查”超过4次
  422. rule = "#12"
  423. rule += "#最近3个月担保资格审查查询次数=" + str(queryRecordDetailDf["最近3个月担保资格审查查询次数"])
  424. elif null2Zero(queryRecordDetailDf["最近3个月查询机构数"]) > 3:
  425. approveResult = "3" # 近3月查询机构数超过3个
  426. rule = "#14"
  427. rule += "#最近3个月查询机构数=" + str(queryRecordDetailDf["最近3个月查询机构数"])
  428. elif null2Zero(queryRecordDetailDf["近6月查询次数"]) > 10:
  429. approveResult = "3" # 近半年总查询超过10次
  430. rule = "#15"
  431. rule += "#近6月查询次数=" + str(queryRecordDetailDf["近6月查询次数"])
  432. elif null2Zero(recoveryInfoSum["垫款业务账户数"])>=3:#原来为>0
  433. approveResult = "0"
  434. rule="#16"
  435. rule += "#垫款业务账户数=" + str(recoveryInfoSum["垫款业务账户数"])
  436. elif null2Zero(recoveryInfoSum["垫款业务余额"]) > 0:
  437. approveResult = "0"
  438. rule="#17"
  439. rule += "#垫款业务余额=" + str(recoveryInfoSum["垫款业务余额"])
  440. #白户
  441. elif allAccountNum==0 and housingFundRcd["参缴日期"]==None:
  442. approveResult = "1"
  443. rule = "#18"
  444. rule += "#白户#无信贷交易明细#审批通过"
  445. if isAutoApprove =="1":
  446. approveResult = "1"
  447. data = {"approveResult":approveResult,"rule":rule}
  448. return data;
  449. if __name__ == '__main__':
  450. print(call_credit())