Commit 997e9809 authored by 张鹏程's avatar 张鹏程

提交dev 分支

parents 23f589b1 a77ebab6
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -836,7 +836,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.0"
}
},
"nbformat": 4,
......
This diff is collapsed.
This diff is collapsed.
......@@ -212,7 +212,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
"version": "3.6.6"
}
},
"nbformat": 4,
......
......@@ -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)
"""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 enable = 1填写中申请单数量"""
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 用户申请订单在审核中的数量():
"""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
# 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 在途申请单数量():
"""apply_in_verify_num_v2 enable=1 在途申请单数量(提交申请->完成放款)"""
def feature(self):
_在途申请单数量 = -9999999
get_requisition_quantity_xyqb = requisition_quantity_xyqb_new(self.user_id,self._apply_at)
get_requisition_quantity_business_flow = requisition_quantity_business_flow_new(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
\ No newline at end of file
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
from service.Sql_cheat import *
from service.Sql_contactsOperator 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 根据手机号查找归属地编号():
""" 根据手机号查找归属地编号 lkb_user_phone_province_code"""
def feature(self):
_根据手机号查找归属地编号 = 125
user_phone = getSql_userPhone(str(tuple([str(self.user_id)])).replace(',)',')'))['phone_no'].tolist()
"""紧急联系人"""
phone_info_city =get_phone_info(user_phone[0])[1]
if phone_info_city:
get_city_dict_df = city_dict_df()
"""根据对应的列找到对应的值"""
if phone_info_city == '内蒙古':
phone_info_city = '内蒙'
get_city_dict_value = get_city_dict_df[phone_info_city].values[0]
_根据手机号查找归属地编号 = get_city_dict_value
self._result['根据手机号查找归属地编号']['value'] = _根据手机号查找归属地编号
return self._result
class 根据身份证号查找归属地编号():
""" 根据身份证号查找归属地编号 user_province_code"""
def feature(self):
_根据身份证号查找归属地编号 = -9999999
id_no_ = getSql_id_no(str(self.user_id))["id_no"].values[0]
if id_no_:
id_no_split_2 = str(id_no_)[0:2]
_根据身份证号查找归属地编号 = int(id_no_split_2)
self._result['根据身份证号查找归属地编号']['value'] = _根据身份证号查找归属地编号
return self._result
\ No newline at end of file
......@@ -31,16 +31,32 @@ class __INIT__(BF):
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):
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()
_本人手机号命中的黑名单 = 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.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内的次数
self._result[featureName]["value"] = _本人手机号命中的黑名单
return self._result
return self._result
\ No newline at end of file
......@@ -32,8 +32,8 @@ def get_if_apply_type_sql(uuid=None, order_no=None):
params = {'user_uuid': str(uuid), 'codes': 'user_loan_type_v4',
"order_id": str(order_no), "business_type": 0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......@@ -70,7 +70,169 @@ where user_id ='{0}' and apply_time < '{1}' ORDER BY apply_time desc limit 1'''
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 enable=1 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
def requisition_quantity_xyqb_new(userid,apply_time):
"""xyqb 在在途申请单数量"""
Sql = """SELECT count(*) 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_new(uuid,apply_time):
"""business_flow 在在途申请单数量"""
Sql = """SELECT count(*) count_business FROM apply_list
WHERE (apply_status in (2,3) or (apply_status =4 and audit_result<>0)) and (assets_result<>2 or assets_result is null)
and uuid ='{0}' and enable=1 and created_at< '{1}';""".format(uuid,apply_time)
_df = pd.read_sql(Sql, con=con_business_flow)
return _df
from phone import Phone
def get_phone_info(phone_num):
"""根据手机号查询省份"""
phone_info = Phone().find(phone_num)
try:
phone = phone_info['phone']
province = phone_info['province'] # 省
city = phone_info['city'] # 城市
zip_code = phone_info['zip_code'] # 邮编
area_code = phone_info['area_code'] # 区号
phone_type = phone_info['phone_type'] # 运营商
except:
print('----- the phone number is empty, please check your phone number! -----')
return phone, province, city, zip_code, area_code, phone_type
def city_dict_df():
"""标准的归属地码表"""
city_dict = {'北京': 11,
'天津': 12,
'河北': 13,
'山西': 14,
'内蒙': 15,
'辽宁': 21,
'吉林': 22,
'黑龙江': 23,
'上海': 31,
'江苏': 32,
'浙江': 33,
'安徽': 34,
'福建': 35,
'江西': 36,
'山东': 37,
'河南': 41,
'湖北': 42,
'湖南': 43,
'广东': 44,
'广西': 45,
'海南': 46,
'重庆': 50,
'四川': 51,
'贵州': 52,
'云南': 53,
'西藏': 54,
'陕西': 61,
'甘肃': 62,
'青海': 63,
'宁夏': 64,
'新疆': 65,
'台湾': 71,
'香港': 81,
'澳门': 82,
'海外': 91}
df = pd.DataFrame(city_dict, pd.Index(range(1)))
return df
def idcard_dict_df():
"""标准的身份证归属地码表"""
idcard_dict = {'北京': 11,
'天津': 12,
'河北': 13,
'山西': 14,
'内蒙': 15,
'辽宁': 21,
'吉林': 22,
'黑龙江': 23,
'上海': 31,
'江苏': 32,
'浙江': 33,
'安徽': 34,
'福建': 35,
'江西': 36,
'山东': 37,
'河南': 41,
'湖北': 42,
'湖南': 43,
'广东': 44,
'广西': 45,
'海南': 46,
'重庆': 50,
'四川': 51,
'贵州': 52,
'云南': 53,
'西藏': 54,
'陕西': 61,
'甘肃': 62,
'青海': 63,
'宁夏': 64,
'新疆': 65,
'台湾': 71,
'香港': 81,
'澳门': 82,
'海外': 91}
df = pd.DataFrame(idcard_dict, pd.Index(range(1)))
return df
......@@ -713,8 +713,8 @@ def get_user_bill_info_rows(uuid,_created_at=None,time_from=0):
"""获取手机话费账单"""
params = {'user_uuid':str(uuid),'codes':'user_bill_info_rows'}
headers = {
'rc_auth_key':'rc_developer',
'rc_auth_secret':'rc_secret'
'rc_auth_key':'rc_offline',
'rc_auth_secret':"9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......@@ -742,8 +742,8 @@ def get_lkb_user_phone_location(uuid):
params = {'user_uuid':str(uuid),'codes':'lkb_user_phone_location'}
headers = {
'rc_auth_key':'rc_developer',
'rc_auth_secret':'rc_secret'
'rc_auth_key':'rc_offline',
'rc_auth_secret':"9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......
......@@ -17,8 +17,8 @@ def get_td_qu_rules(uuid):
params = {'user_uuid':str(uuid),'codes':'td_qu_rules'}
headers = {
'rc_auth_key':'rc_developer',
'rc_auth_secret':'rc_secret'
'rc_auth_key':'rc_offline',
'rc_auth_secret':"9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......
......@@ -151,8 +151,8 @@ def get_lxr_list_hmd(uuid=None,order_no=None):
params = {'user_uuid':str(uuid) , 'codes': 'user_contact_book_info#d30_contact_nums',
"order_id":str(order_no),"business_type":0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
_df = pd.DataFrame()
......@@ -238,8 +238,8 @@ def get30day_addressbook(uuid=None,order_no=None):
params = {'user_uuid':str(uuid) , 'codes': 'user_contact_book_info#d30_contact_nums',
"order_id":str(order_no),"business_type":0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
_df = pd.DataFrame()
......@@ -343,8 +343,8 @@ def Nation(uuid=None,order_no=None):
params = {'user_uuid': str(uuid), 'codes': 'user_ocr_info#nation',
"order_id": str(order_no), "business_type": 0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......@@ -456,8 +456,8 @@ def city_sign(uuid=None,order_no=None):
params = {'user_uuid':str(uuid) , 'codes': 'user_ocr_info#address',
"order_id":str(order_no),"business_type":0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......@@ -518,8 +518,8 @@ def card_expires(uuid=None,order_no=None):
params = {'user_uuid': str(uuid), 'codes': 'user_ocr_info#validDateEnd',
"order_id": str(order_no), "business_type": 0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......
......@@ -179,8 +179,8 @@ def get_lxr_list(uuid=None,order_no=None):
params = {'user_uuid':str(uuid) , 'codes': 'user_contact_book_info#d7_contact_nums',
"order_id":str(order_no),"business_type":0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
......@@ -209,8 +209,8 @@ def get_lxr_list_hmd(uuid=None,order_no=None):
params = {'user_uuid':str(uuid) , 'codes': 'user_contact_book_info#d7_contact_nums',
"order_id":str(order_no),"business_type":0}
headers = {
'rc_auth_key': 'rc_developer',
'rc_auth_secret': 'rc_secret'
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
_df = pd.DataFrame()
......
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