Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
feature-api-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
feature-api-test
Commits
0f44444a
Commit
0f44444a
authored
Mar 02, 2020
by
路朝阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同业特征新增 以及新增入参参数channel_no
parent
53e55a4a
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
137 additions
and
24 deletions
+137
-24
v7模型_延伸特征vcc.ipynb
J_feature/v7模型_延伸特征vcc.ipynb
+0
-0
feature_mapping.xlsx
data/feature_mapping.xlsx
+0
-0
Base_Features.py
features/Base_Features.py
+3
-0
Credit_process.py
features/calc_features/Credit_process.py
+4
-4
same_trade.py
features/calc_features/same_trade.py
+61
-0
Base_Handler.py
handler/Base_Handler.py
+1
-0
Calc_Features_Handler.py
handler/Calc_Features_Handler.py
+4
-1
测试报告-特征测试0227同业与非同业更新授信流程优化受影响特征迁移.xlsx
report/测试报告-特征测试0227同业与非同业更新授信流程优化受影响特征迁移.xlsx
+0
-0
Sql_cheat.py
service/Sql_cheat.py
+63
-18
addresss_book_sql.py
service/addresss_book_sql.py
+1
-1
No files found.
J_feature/v7模型_延伸特征vcc.ipynb
View file @
0f44444a
This diff is collapsed.
Click to expand it.
data/feature_mapping.xlsx
View file @
0f44444a
No preview for this file type
features/Base_Features.py
View file @
0f44444a
...
...
@@ -174,6 +174,9 @@ class BaseFeatures():
def
set_codes
(
self
,
_codes
):
self
.
codes
=
_codes
def
set_channel_no
(
self
,
_channel_no
):
self
.
channel_no
=
_channel_no
def
set_mapping
(
self
,
mapping
):
self
.
mapping
=
mapping
...
...
features/calc_features/Credit_process.py
View file @
0f44444a
...
...
@@ -20,10 +20,10 @@ class __INIT__(BF):
class
存在未结清订单数量():
"""
uncompleted_loan_nums
存在未结清订单数量(还款中,在贷)
"""
"""
uncompleted_
own_product_
loan_nums
存在未结清订单数量(还款中,在贷)
"""
def feature(self):
_存在未结清订单数量 = -9999999
get_quantity = quantity_ofopen_orders(self.
user_id,self._apply_at
)
get_quantity = quantity_ofopen_orders(self.
_apply_at,self.user_id
)
if get_quantity.empty == False:
get_quantity_count = get_quantity['count'].values[0]
_存在未结清订单数量 = get_quantity_count
...
...
@@ -32,7 +32,7 @@ class 存在未结清订单数量():
class 填写中申请单数量():
"""
user_fill_order_nums
enable
=
1
填写中申请单数量
"""
"""
user_fill_o
wn_product_o
rder_nums
enable
=
1
填写中申请单数量
"""
def feature(self):
_填写中申请单数量 = -9999999
get_quantity = application_forms_nums(self.uuid,self._apply_at)
...
...
@@ -76,7 +76,7 @@ class 用户申请订单在审核中的数量():
class 在途申请单数量():
"""
apply_in_verify_num_v2
enable
=
1
在途申请单数量(提交申请
->
完成放款)
"""
"""
own_product_apply_in_verify_nums
enable
=
1
在途申请单数量(提交申请
->
完成放款)
"""
def feature(self):
_在途申请单数量 = -9999999
get_requisition_quantity_xyqb = requisition_quantity_xyqb_new(self.user_id,self._apply_at)
...
...
features/calc_features/same_trade.py
0 → 100644
View file @
0f44444a
# -*- 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
在贷
_
同业
():
"""在贷_同业"""
def
feature
(
self
):
_
在贷
_
同业
=
-
9999999
#tongye_in_loan(apply_time,bussiness_type,_apply_from,userid)
if
self
.
business_type
!=
0
:
get_tongye_in_loan
=
tongye_in_loan
(
self
.
_apply_at
,
self
.
business_type
,
self
.
channel_no
,
self
.
user_id
)
if
get_tongye_in_loan
.
empty
==
False
:
get_loan_count
=
get_tongye_in_loan
[
'count'
]
.
values
[
0
]
_
在贷
_
同业
=
get_loan_count
self
.
_result
[
'在贷_同业'
][
'value'
]
=
_
在贷
_
同业
return
self
.
_result
class
填写中申请单数量
_
同业
():
"""填写中申请单数量_同业"""
def
feature
(
self
):
_
填写中申请单数量
_
同业
=
-
9999999
if
self
.
business_type
!=
0
:
get_quantity
=
tongye_application_nums
(
self
.
business_type
,
self
.
channel_no
,
self
.
uuid
,
self
.
_apply_at
)
get_quantity_count
=
get_quantity
[
'count'
]
.
values
[
0
]
_
填写中申请单数量
_
同业
=
get_quantity_count
self
.
_result
[
'填写中申请单数量_同业'
][
'value'
]
=
_
填写中申请单数量
_
同业
return
self
.
_result
class
在途申请单数量
_
同业
():
""""""
def
feature
(
self
):
_
在途申请单数量
_
同业
=
-
9999999
if
self
.
business_type
!=
0
:
get_requisition_quantity_xyqb
=
tongye_requisition_quantity_xyqb
(
self
.
business_type
,
self
.
channel_no
,
self
.
user_id
,
self
.
_apply_at
)
get_requisition_quantity_business_flow
=
tongye_quantity_business_flow
(
self
.
business_type
,
self
.
channel_no
,
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
handler/Base_Handler.py
View file @
0f44444a
...
...
@@ -17,6 +17,7 @@ class BaseHandler(tornado.web.RequestHandler):
self
.
_loanId
=
self
.
get_argument
(
'loan_id'
,
default
=
None
)
self
.
_termNo
=
self
.
get_argument
(
'term_no'
,
default
=
None
)
self
.
_apply_time
=
self
.
get_argument
(
'apply_time'
,
default
=
None
)
self
.
_channel_no
=
self
.
get_argument
(
'channel_no'
,
default
=
None
)
self
.
_codes
=
self
.
get_arguments
(
'codes'
)
if
self
.
_business_type
:
self
.
_business_type
=
int
(
self
.
_business_type
)
...
...
handler/Calc_Features_Handler.py
View file @
0f44444a
...
...
@@ -16,12 +16,15 @@ class CalcFeatures(BaseHandler): #feature_基础特征
loanId
=
self
.
_loanId
,
orderId
=
self
.
_orderId
,
apply_time
=
self
.
_apply_time
,
termNo
=
self
.
_termNo
termNo
=
self
.
_termNo
,
channel_no
=
self
.
_channel_no
)
BF
.
get_subclasses
(
'features.calc_features'
,
self
.
mapping
.
mapping_all
)
self
.
write
(
JsonUtil
.
build_json_feature
(
businessType
=
self
.
_business_type
,
orderId
=
self
.
_orderId
,
loanId
=
self
.
_loanId
,
userUuid
=
self
.
_uuid
,
user_id
=
self
.
_user_id
,
term_no
=
self
.
_termNo
,
channel_no
=
self
.
_channel_no
,
features
=
BF
.
_result
,
flag
=
True
,
code
=
JsonUtil
.
Constants
.
Code_Success
))
self
.
flush
()
self
.
finish
()
...
...
report/测试报告-特征测试0227同业与非同业更新授信流程优化受影响特征迁移.xlsx
0 → 100644
View file @
0f44444a
File added
service/Sql_cheat.py
View file @
0f44444a
...
...
@@ -71,26 +71,57 @@ 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
def
quantity_ofopen_orders
(
apply_time
,
userid
):
"""存在未结清订单数量(还款中,在贷)
2020-02-20
"""
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
left join loan_application_history c on a.loan_application_history_id=c.id
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
,)
and c.business_type=0
and a.user_id='{1}' ;"""
.
format
(
apply_time
,
userid
)
_df
=
pd
.
read_sql
(
Sql
,
con
=
con_tuomin_xyqb
)
return
_df
def
tongye_in_loan
(
apply_time
,
bussiness_type
,
_apply_from
,
userid
):
"""同业在贷"""
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
left join loan_application_history c on a.loan_application_history_id=c.id
left join loan_account_ext d on c.id=d.loan_id
left join apply_quota_record e on d.order_no=e.order_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 c.business_type={1} and e.apply_from='{2}'
and a.user_id='{3}';"""
.
format
(
apply_time
,
bussiness_type
,
_apply_from
,
userid
)
_df
=
pd
.
read_sql
(
Sql
,
con
=
con_tuomin_xyqb
)
return
_df
def
application_forms_nums
(
uuid
,
apply_time
):
"""填写中申请单数量"""
"""填写中申请单数量 2020-02-20"""
# Sql = """select count(*) from apply_list
# where apply_status=1 and enable=1 and product_type=0 and uuid='a64e3393-191e-4ba1-8e1d-95a40d967820';"""
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
)
where apply_status=1 and uuid='{0}' and enable=1 and product_type=0 and created_at< '{1}';"""
.
format
(
uuid
,
apply_time
)
_df
=
pd
.
read_sql
(
Sql
,
con
=
con_business_flow
)
return
_df
def
tongye_application_nums
(
bussiness_type
,
_apply_from
,
uuid
,
apply_time
):
"""填写中申请单数量(同业)"""
Sql
=
"""select count(*) as count from apply_list
where apply_status=1 and enable=1
and product_type={0}
and channel_id='{1}'
and uuid='{2}' and created_at< '{3}';"""
.
format
(
bussiness_type
,
_apply_from
,
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
...
...
@@ -116,32 +147,46 @@ def user_order_approval(uuid,apply_time):
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)
Sql
=
"""SELECT count(*) count_xyqb FROM assign_funding_record a
"""xyqb 在在途申请单数量 2020-02-20"""
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 ((b.status=0 and c.id is null) or (b.status=1 and c.funding_corp_progress not in (5,6)))
left join apply_quota_record d on b.out_trade_no=d.id
WHERE a.assign_status=3 and d.product_type=0 and ((b.status in(0,1) and c.id is null) or (b.status=1 and 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_new_xyqb
)
print
(
Sql
)
return
_df
def
requisition_quantity_business_flow_new
(
uuid
,
apply_time
):
"""business_flow 在在途申请单数量"""
"""business_flow 在在途申请单数量 2020-02-20"""
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
)
and uuid ='{0}' and enable=1 and
product_type=0 and
created_at< '{1}';"""
.
format
(
uuid
,
apply_time
)
_df
=
pd
.
read_sql
(
Sql
,
con
=
con_business_flow
)
return
_df
def
tongye_requisition_quantity_xyqb
(
bussiness_type
,
_apply_from
,
userid
,
apply_time
):
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
left join apply_quota_record d on b.out_trade_no=d.id
WHERE a.assign_status=3 and d.product_type={0} and d.apply_from='{1}'
and ((b.status=0 and c.id is null) or (b.status in(0,1) and c.funding_corp_progress not in (5,6)))
and a.user_id='{2}' and a.created_at<'{3}';"""
.
format
(
bussiness_type
,
_apply_from
,
userid
,
apply_time
)
_df
=
pd
.
read_sql
(
Sql
,
con
=
con_new_xyqb
)
return
_df
def
tongye_quantity_business_flow
(
bussiness_type
,
_apply_from
,
uuid
,
apply_time
):
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 enable=1
and product_type={0} and channel_id='{1}'
and uuid ='{2}' and created_at< '{3}';"""
.
format
(
bussiness_type
,
_apply_from
,
uuid
,
apply_time
)
_df
=
pd
.
read_sql
(
Sql
,
con
=
con_business_flow
)
return
_df
def
get_phone_info
(
phone_num
):
...
...
service/addresss_book_sql.py
View file @
0f44444a
...
...
@@ -142,7 +142,7 @@ def getSql_Apply_quota_record(user_id,order_no):
"""获取申请额度记录表"""
if
order_no
:
_sql
=
"""
select apply_time,order_no from apply_quota_record where user_id = {0} and order_no = '{1}'
select apply_time,order_no
,apply_from
from apply_quota_record where user_id = {0} and order_no = '{1}'
"""
.
format
(
user_id
,
order_no
)
_df
=
pd
.
read_sql
(
_sql
,
con_tuomin_xyqb
)
return
_df
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment