Commit 0f44444a authored by 路朝阳's avatar 路朝阳

同业特征新增 以及新增入参参数channel_no

parent 53e55a4a
This diff is collapsed.
......@@ -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
......
......@@ -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_own_product_order_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)
......
# -*- 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
......@@ -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)
......
......@@ -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()
......
......@@ -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):
......
......@@ -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
......
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