Commit 60132d2d authored by 路朝阳's avatar 路朝阳

新增:授信流程优化受影响特征迁移 0113

parent dfc4e43e
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.0" "version": "3.6.6"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -80,3 +80,6 @@ con_app_applied_type = create_engine('mysql+pymysql://b_events_w:q3ReZoL9x5asCxc ...@@ -80,3 +80,6 @@ con_app_applied_type = create_engine('mysql+pymysql://b_events_w:q3ReZoL9x5asCxc
"""催收二期""" """催收二期"""
con_collection = create_engine('mysql+pymysql://rc-meta-user-pre:YqnqVfIwZFMlkGya@10.17.115.6:4010/rc_meta_data_pre?charset=utf8',echo=False) con_collection = create_engine('mysql+pymysql://rc-meta-user-pre:YqnqVfIwZFMlkGya@10.17.115.6:4010/rc_meta_data_pre?charset=utf8',echo=False)
"""business flow 线上库"""
con_business_flow =create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33314/business_flow?charset=utf8'
,echo=False)
\ No newline at end of file
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
from service.Sql_cheat import *
import re
class __INIT__(BF):
def __init__(self):
time_now = datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
BF._apply_at = time_now
if self.orderId:
_df = getSql_Apply_quota_record(self.user_id,self.orderId)
if _df.empty == False:
BF._apply_at = datetime.datetime.strptime(_df['apply_time'].astype(str).values[0],'%Y-%m-%d %H:%M:%S')
class 存在未结清订单数量():
"""uncompleted_loan_nums 存在未结清订单数量(还款中,在贷)"""
def feature(self):
_存在未结清订单数量 = -9999999
get_quantity = quantity_ofopen_orders(self.user_id,self._apply_at)
if get_quantity.empty == False:
get_quantity_count = get_quantity['count'].values[0]
_存在未结清订单数量 = get_quantity_count
self._result['存在未结清订单数量']['value'] = _存在未结清订单数量
return self._result
class 填写中申请单数量():
"""user_fill_order_nums 填写中申请单数量"""
def feature(self):
_填写中申请单数量 = -9999999
get_quantity = application_forms_nums(self.uuid,self._apply_at)
if get_quantity.empty == False:
get_quantity_count = get_quantity['count'].values[0]
_填写中申请单数量 = get_quantity_count
self._result['填写中申请单数量']['value'] = _填写中申请单数量
return self._result
class 在途申请单数量():
"""apply_in_verify_num_v2 在途申请单数量(提交申请->完成放款)"""
def feature(self):
_在途申请单数量 = -9999999
get_requisition_quantity_xyqb = requisition_quantity_xyqb(self.user_id,self._apply_at)
get_requisition_quantity_business_flow = requisition_quantity_business_flow(self.uuid,self._apply_at)
if get_requisition_quantity_xyqb.empty == False:
get_quantity_count = get_requisition_quantity_xyqb['count_xyqb'].values[0]
if get_requisition_quantity_business_flow.empty == False:
get_business_flow_count = get_requisition_quantity_business_flow['count_business'].values[0]
_在途申请单数量 = get_quantity_count + get_business_flow_count
self._result['在途申请单数量']['value'] = _在途申请单数量
return self._result
class 用户申请订单在审核中的数量():
"""new_xyqb_apply_in_credit_v2 用户申请订单在审核中的数量"""
def feature(self):
_用户申请订单在审核中的数量 = -9999999
get_user_order_approval = user_order_approval(self.uuid,self._apply_at)
if get_user_order_approval.empty == False:
get_user_order_count = get_user_order_approval['count'].values[0]
_用户申请订单在审核中的数量 = get_user_order_count
self._result['用户申请订单在审核中的数量']['value'] = _用户申请订单在审核中的数量
return self._result
...@@ -31,16 +31,32 @@ class __INIT__(BF): ...@@ -31,16 +31,32 @@ class __INIT__(BF):
BF.phon_black_all['type'] = BF.phon_black_all['type'].astype(int) BF.phon_black_all['type'] = BF.phon_black_all['type'].astype(int)
class 本人手机号命中的黑名单类型在0_1内的次数(): # class 本人手机号命中的黑名单类型在0_1内的次数():
# def feature(self,*args):
# featureName = args[0]
# daysWindow = int(re.findall('\d+',args[1][0])[0])
# if daysWindow == 0:
# _本人手机号命中的黑名单类型在0_1内的次数 = self.phon_black_all.loc[(self.phon_black_all['type'].isin(self.a_tuple))]['id'].count()
# else:
# day_window_time = self.get_DayWindow(self._apply_at,daysWindow)
# _本人手机号命中的黑名单类型在0_1内的次数 = self.phon_black_all.loc[(self.phon_black_all['createdAt']>day_window_time)
# & (self.phon_black_all['type'].isin(self.a_tuple))]['id'].count()
# self._result[featureName]["value"] = _本人手机号命中的黑名单类型在0_1内的次数
#
# return self._result
class 本人手机号命中的黑名单():
def feature(self,*args): def feature(self,*args):
featureName = args[0] featureName = args[0]
daysWindow = int(re.findall('\d+',args[1][0])[0]) daysWindow = int(re.findall('\d+',args[1][0])[0])
if daysWindow == 0: if daysWindow == 0:
_本人手机号命中的黑名单类型在0_1内的次数 = self.phon_black_all.loc[(self.phon_black_all['type'].isin(self.a_tuple))]['id'].count() _本人手机号命中的黑名单 = self.phon_black_all.loc[(self.phon_black_all['type'].isin(self.a_tuple))]['id'].count()
else: else:
day_window_time = self.get_DayWindow(self._apply_at,daysWindow) day_window_time = self.get_DayWindow(self._apply_at,daysWindow)
_本人手机号命中的黑名单类型在0_1内的次数 = self.phon_black_all.loc[(self.phon_black_all['createdAt']>day_window_time) _本人手机号命中的黑名单 = self.phon_black_all.loc[(self.phon_black_all['createdAt']>day_window_time)
& (self.phon_black_all['type'].isin(self.a_tuple))]['id'].count() & (self.phon_black_all['type'].isin(self.a_tuple))]['id'].count()
self._result[featureName]["value"] = _本人手机号命中的黑名单类型在0_1内的次数 self._result[featureName]["value"] = _本人手机号命中的黑名单
return self._result return self._result
\ No newline at end of file
...@@ -70,7 +70,45 @@ where user_id ='{0}' and apply_time < '{1}' ORDER BY apply_time desc limit 1''' ...@@ -70,7 +70,45 @@ where user_id ='{0}' and apply_time < '{1}' ORDER BY apply_time desc limit 1'''
return _df return _df
def quantity_ofopen_orders(userid,apply_time):
"""存在未结清订单数量(还款中,在贷)"""
Sql = '''select count(*) as count from loan_application_manifest_history a
left join repayment_plan b on a.loan_application_history_id=b.loan_application_history_id
and a.contract_term=b.term_no
where (b.repayment_status not in (3,4) or (b.repayment_status=3 and b.repaid_at>'{0}'))
and a.transaction_status in (2,5) and a.loan_paid_at<'{0}'
and a.user_id='{1}' ;'''.format(apply_time,userid,)
_df = pd.read_sql(Sql, con=con_tuomin_xyqb)
return _df
def application_forms_nums(uuid,apply_time):
"""填写中申请单数量"""
Sql = """select count(*) as count from apply_list
where apply_status=1 and uuid='{0}' and created_at< '{1}';""".format(uuid,apply_time)
_df = pd.read_sql(Sql, con=con_business_flow)
return _df
def requisition_quantity_xyqb(userid,apply_time):
"""xyqb 在在途申请单数量"""
Sql = """SELECT count(*) as count_xyqb FROM assign_funding_record a
left join assets_order b on a.asset_order_id=b.id
left join waiting_funding_corp_operate_people c on b.loan_id=c.loan_application_history_id
WHERE a.assign_status=3 and (c.id is null or c.funding_corp_progress not in (5,6))
and a.user_id='{0}' and a.created_at<'{1}';""".format(userid,apply_time)
_df = pd.read_sql(Sql, con=con_tuomin_xyqb)
return _df
def requisition_quantity_business_flow(uuid,apply_time):
"""business_flow 在在途申请单数量"""
Sql = """SELECT count(*) as count_business FROM apply_list WHERE (apply_status in (2,3) or (apply_status =4 and audit_result<>0))
and uuid ='{0}' and created_at< '{1}';""".format(uuid,apply_time)
_df = pd.read_sql(Sql, con=con_business_flow)
return _df
def user_order_approval(uuid,apply_time):
Sql = """select count(id) count from apply_list where enable = 1
and apply_status =3 and uuid ='{0}' and created_at< '{1}'; """.format(uuid,apply_time)
_df = pd.read_sql(Sql, con=con_business_flow)
return _df
\ No newline at end of file
...@@ -50,16 +50,16 @@ if __name__ == "__main__": ...@@ -50,16 +50,16 @@ if __name__ == "__main__":
tornado.options.parse_command_line() tornado.options.parse_command_line()
# #== 本地调试 # #== 本地调试
app.listen(23010) # app.listen(23010)
IOLoop.instance().start() # IOLoop.instance().start()
# from tornado.options import define, options from tornado.options import define, options
# define("port", default=23010, help="run on the given port ", type=int) define("port", default=23010, help="run on the given port ", type=int)
# define("log_path", default='/tmp', help="log path ", type=str) define("log_path", default='/tmp', help="log path ", type=str)
# tornado.options.parse_command_line() tornado.options.parse_command_line()
# app = apps() app = apps()
# http_server = tornado.httpserver.HTTPServer(app) http_server = tornado.httpserver.HTTPServer(app)
# http_server.bind(options.port) http_server.bind(options.port)
# http_server.start() # num_processes=0 # tornado将按照cpu核数来fork进程 http_server.start(num_processes=0) # num_processes=0 # tornado将按照cpu核数来fork进程
# tornado.ioloop.IOLoop.instance().start() tornado.ioloop.IOLoop.instance().start()
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