Commit 7343bd8b authored by 路朝阳's avatar 路朝阳

vcc商户预警特征新接口

vcc特征迁移特征
parent 0f44444a
......@@ -836,7 +836,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
"version": "3.6.6"
}
},
"nbformat": 4,
......
This diff is collapsed.
......@@ -85,3 +85,25 @@ con_business_flow =create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!
,echo=False)
con_new_xyqb = create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33306/xyqb?charset=utf8',echo=False)
"""vcc商户"""
con_vcc_talos = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/vcc_talos?charset=utf8',echo=False)
"""vcc线上库talos"""
# con_vcc_talos = create_engine('mysql+pymysql://rc_slave_user_r:fiQFWvFIQV5vn1Ai@vcc-db.quantgroups.com:3306/vcc_talos?charset=utf8',echo=False)
con_vcc_quota = create_engine('mysql+pymysql://bigdata_test:ieneue7ldondk03d@172.30.5.27:8066/vcc_quota?charset=utf8',echo=False)
"""vcc线上库quota"""
# con_vcc_quota = create_engine('mysql+pymysql://rc_feature_user:G5QcBud5eR7foGIU@172.18.4.12:3306/vcc_quota?charset=utf8',echo=False)
con_vcc_transfer = create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33315/vcc_feature?charset=utf8',echo=False)
con_vcc_transfer_pay = create_engine('mysql+pymysql://real_data_test:qpRBSarm$Tv*YO!n@172.30.220.16:33316/payment_center?charset=utf8',echo=False)
# vcc_talos信息:
# url: vcc-db.quantgroups.com:3306
# user: rc_slave_user_r
# password: fiQFWvFIQV5vn1Ai
#
# vcc_quota信息:
# url: 172.18.4.12:3306
# user: rc_feature_user
# password: G5QcBud5eR7foGIU
\ No newline at end of file
......@@ -14,5 +14,6 @@ url_complex_order = '/features/complex_order' # 多订单
# url_collection = '/calc/loanPostFeatures' # 催收模型
url_loanPostFeatures = '/calc/loanPostFeatures' # 催收模型
url_test = '/calc/test' # 测试
url_calc_features4store = '/calc/features4store' #vcc用户商城
......@@ -177,6 +177,15 @@ class BaseFeatures():
def set_channel_no(self,_channel_no):
self.channel_no = _channel_no
def set_store_id(self,_store_id):
self.store_id = _store_id
def set_snapshot_time(self,_snapshot_time):
self.snapshot_time = _snapshot_time
def set_trade_no(self,_trade_no):
self.trade_no = _trade_no
def set_mapping(self,mapping):
self.mapping = mapping
......
......@@ -58,21 +58,6 @@ class 用户申请订单在审核中的数量():
# 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 在途申请单数量():
......
This diff is collapsed.
This diff is collapsed.
......@@ -7,8 +7,6 @@ import json
import time
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._created_at = time_now
......
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.addresss_book_sql import *
import datetime
from service.Sql_vcc import *
import json
import time
from pandas import DataFrame
import numpy as np
import datetime
from datetime import timedelta
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 惠金所9当日放款额():
""""""
def feature(self):
_惠金所9当日放款额 = 0
get_gratia_payment_amount = gratia_payment_amount()
if get_gratia_payment_amount['amount'].values[0] != None:
# get_amount_of_merchant["now_time"] = self._apply_at
# id_resufe_from['apply_time'] = id_resufe_from['apply_time'].dt.date
# get_amount_merchant_result =
_惠金所9当日放款额 = get_gratia_payment_amount['amount'].values[0]
self._result['惠金所9当日放款额']['value'] = _惠金所9当日放款额
return self._result
# class 商户当日累计交易金额():
# """last_apply_time#lastApplyRefusedRecords 同一身份证用户上次申请拒绝距今天数"""
# def feature(self):
# _商户当日累计交易金额 = -9999999
# get_amount_of_merchant = amount_of_merchant(self.store_id,self.today,self.tomorrow)
# if get_amount_of_merchant.empty == False:
# # get_amount_of_merchant["now_time"] = self._apply_at
# # id_resufe_from['apply_time'] = id_resufe_from['apply_time'].dt.date
# get_amount_merchant_result =get_amount_of_merchant['amount'].sum()
# _商户当日累计交易金额 = get_amount_merchant_result
# 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_vcc import *
import json
import time
from pandas import DataFrame
import numpy as np
import datetime
from datetime import timedelta
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 用户身份证是否过期():
"""user_ocr_info#isValid 身份证是否过期 需求待修改"""
def feature(self):
_用户身份证是否过期 = -9999999
id_time= int(str(self._apply_at).split()[0].replace("-", ""))
card_expires_time = card_expires(self.uuid, self.orderId)
if isinstance(card_expires_time,int):
if id_time >= card_expires_time:
_用户身份证是否过期 = 0
elif id_time < card_expires_time:
_用户身份证是否过期 = 1
self._result['用户身份证是否过期']['value'] = _用户身份证是否过期
return self._result
# class 用户手机号前三位():
# def feature(self):
# _用户手机号前三位 = -9999999
# id_time= int(str(self._apply_at).split()[0].replace("-", ""))
# card_expires_time = card_expires(self.uuid, self.orderId)
#
# self._result['用户手机号前三位']['value'] = _用户手机号前三位
# return self._result
......@@ -18,7 +18,7 @@ class __INIT__(BF):
class 在贷_同业():
"""在贷_同业"""
"""same_trade_channel_uncompleted_loan_nums 在贷_同业"""
def feature(self):
_在贷_同业 = -9999999 #tongye_in_loan(apply_time,bussiness_type,_apply_from,userid)
if self.business_type != 0:
......@@ -31,7 +31,7 @@ class 在贷_同业():
class 填写中申请单数量_同业():
"""填写中申请单数量_同业"""
"""user_fill_same_trade_channel_order_nums 填写中申请单数量_同业"""
def feature(self):
_填写中申请单数量_同业 = -9999999
if self.business_type != 0:
......@@ -41,9 +41,8 @@ class 填写中申请单数量_同业():
self._result['填写中申请单数量_同业']['value'] = _填写中申请单数量_同业
return self._result
class 在途申请单数量_同业():
""""""
"""same_trade_channel_apply_in_verify_nums 在途申请单数量_同业 """
def feature(self):
_在途申请单数量_同业 = -9999999
if self.business_type != 0:
......
# -*- coding:utf-8 -*-
from features.Base_Features import BaseFeatures as BF
from service.Sql_contactsOperator import *
from service.Sql_vcc import *
import datetime
import json
import time
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.user_phone = str(getSql_userPhone(self.uuid)['phone_no'].values[0])[0:7]
BF.user_all_phone = str(getSql_userPhone(self.uuid)['phone_no'].values[0])
BF._apply_at = time_now
class VCC手机运营商():
""""""
def feature(self):
_VCC手机运营商 = -9999999
get_vcc_phone_user = vcc_phone_user(self.user_phone)
if get_vcc_phone_user.empty == False:
get_vcc_phone_value =get_vcc_phone_user['isp'].values[0]
if get_vcc_phone_value =='移动':
_VCC手机运营商 = 1
elif get_vcc_phone_value =='联通':
_VCC手机运营商 = 2
elif get_vcc_phone_value =='电信':
_VCC手机运营商 = 3
else:
_VCC手机运营商 = -9999999
self._result['VCC手机运营商']['value'] = _VCC手机运营商
return self._result
class VCC手机归属地():
""""""
def feature(self):
_VCC手机归属地 = -9999999
get_vcc_phone_city = vcc_phone_user(self.user_phone)
if get_vcc_phone_city.empty == False:
get_vcc_phone_city_value =get_vcc_phone_city['city'].values[0]
if get_vcc_phone_city_value =='null':
_VCC手机归属地 = -9999999
else:
_VCC手机归属地 = get_vcc_phone_city_value
self._result['VCC手机归属地']['value'] = _VCC手机归属地
return self._result
class VCC信用卡是否认证():
""""""
def feature(self):
_VCC信用卡是否认证 = 0
get_vcc_user_info = vcc_user_info(self.uuid)
if get_vcc_user_info.empty == False:
get_vcc_user_info_value = get_vcc_user_info['cardType'].values[0]
if get_vcc_user_info_value == 2:
_VCC信用卡是否认证 = 1
else:
_VCC信用卡是否认证 = 0
self._result['VCC信用卡是否认证']['value'] = _VCC信用卡是否认证
return self._result
class VCC职业():
""""""
def feature(self):
_VCC职业 = -9999999
# info_dict = {10600:'企事业单位负责人',20600:'经济和金融人员',20700:'法律、社会和宗教人员',
# 20800:'教学人员',20900:'文学艺术、体育人员',21000:'新闻出版、文化人员',
# 40300:'住宿和餐饮服务人员',49900:'社会生产和生活服务人员',59900:'农林牧渔水利人员',
# 70000:'军人',99999:'学生、无业、退休',-9999999:'其他'}
get_vcc_user_info = vcc_user_info(self.uuid)
if get_vcc_user_info.empty == False:
get_vcc_user_info_value = get_vcc_user_info['jobCode'].values[0]
if (get_vcc_user_info_value =='null') or (get_vcc_user_info_value ==None):
_VCC职业 = -9999999
else:
job_type = get_vcc_user_info_value
_VCC职业 = job_type
self._result['VCC职业']['value'] = _VCC职业
return self._result
class VCC收入():
""""""
def feature(self):
_VCC收入 = -9999999
get_vcc_user_info = vcc_user_info(self.uuid)
if get_vcc_user_info.empty == False:
get_vcc_user_info_value = get_vcc_user_info['incomeCode'].values[0]
if get_vcc_user_info_value ==None:
_VCC收入 = -9999999
else:
_VCC收入 = int(get_vcc_user_info_value)
self._result['VCC收入']['value'] = _VCC收入
return self._result
class VCC手机号与绑卡手机号一致性校验():
""""""
def feature(self):
_VCC手机号与绑卡手机号一致性校验 = -9999999
get_vcc_credit_phone = vcc_credit_phone(self.user_id,self.user_all_phone)
if get_vcc_credit_phone.empty == False:
get_vcc_user_info_value = get_vcc_credit_phone['as_type'].values[0]
if get_vcc_user_info_value ==0:
_VCC手机号与绑卡手机号一致性校验 = -9999999
else:
_VCC手机号与绑卡手机号一致性校验 = int(get_vcc_user_info_value)
self._result['VCC手机号与绑卡手机号一致性校验']['value'] = _VCC手机号与绑卡手机号一致性校验
return self._result
class VCC系统风控审批时间():
""""""
def feature(self):
_VCC系统风控审批时间 = -9999999
get_vcc_user_time = self._apply_at.hour + 1
_VCC系统风控审批时间 = get_vcc_user_time
self._result['VCC系统风控审批时间']['value'] = _VCC系统风控审批时间
return self._result
......@@ -18,6 +18,9 @@ class BaseHandler(tornado.web.RequestHandler):
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._store_id = self.get_argument('store_id', default=None)
self._snapshot_time = self.get_argument('snapshot_time', default=None)
self._trade_no = self.get_argument('trade_no',default=None)
self._codes = self.get_arguments('codes')
if self._business_type:
self._business_type = int(self._business_type)
......
# -*- coding:utf-8 -*-
from handler.Base_Handler import BaseHandler
from utils import JsonUtil
import importlib
from features.Base_Features import BaseFeatures as BF
import datetime
class CalcFeatures(BaseHandler): #feature_基础特征
def post(self):
try:
BF.set_private_var(
codes = self._codes,
business_type = self._business_type,
uuid=self._uuid,
user_id = self._user_id,
orderId = self._orderId,
apply_time = self._apply_time,
store_id = self._store_id,
snapshot_time = self._snapshot_time,
trade_no = self._trade_no
)
BF.get_subclasses('features.calc_features',self.mapping.mapping_all)
self.write(JsonUtil.build_json_feature(businessType=self._business_type, orderId=self._orderId,
userUuid = self._uuid,user_id=self._user_id,
store_id = self._store_id,
snapshot_time=self._snapshot_time,
trade_no =self._trade_no,
features=BF._result, flag=True,code=JsonUtil.Constants.Code_Success))
self.flush()
self.finish()
except ValueError as e:
# == 数据类型或者字段缺少导致
self.write(JsonUtil.build_json(JsonUtil.Constants.Code_Param_Error, JsonUtil.Constants.Msg_Param_Error))
self.flush()
except Exception as e:
# == 报异常,查询失败
self.write(JsonUtil.build_json(JsonUtil.Constants.Code_Error, JsonUtil.Constants.Msg_Error))
self.flush()
pass
......@@ -147,42 +147,64 @@ def user_order_approval(uuid,apply_time):
return _df
def requisition_quantity_xyqb_new(userid,apply_time):
"""xyqb 在在途申请单数量 2020-02-20"""
Sql ="""SELECT count(*) count_xyqb FROM assign_funding_record a
"""xyqb 在在途申请单数量 2020-03-05"""
# 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 ((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)
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 loan_application_manifest_history 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 ((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)
WHERE a.assign_status=3 and d.product_type=0
and ((b.status =0 and c.id is null) or (b.status=1 and c.transaction_status not in (2,4,5)))
and a.user_id='{0}'and a.created_at<'{1}';""".format(userid,apply_time)
_df = pd.read_sql(Sql, con=con_new_xyqb)
return _df
def requisition_quantity_business_flow_new(uuid,apply_time):
"""business_flow 在在途申请单数量 2020-02-20"""
"""business_flow 在在途申请单数量 2020-03-05"""
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 product_type=0 and created_at< '{1}';""".format(uuid,apply_time)
WHERE (apply_status in (2,3,4) or (apply_status =5 and assets_result=3))
and assets_result<>2 and enable=1
and product_type=0
and uuid ='{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)
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 loan_application_manifest_history 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 ((b.status =0 and c.id is null) or (b.status=1 and c.transaction_status not in (2,4,5)))
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)
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
WHERE (apply_status in (2,3,4) or (apply_status =5 and assets_result=3) )
and assets_result<>2 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)
......
......@@ -9,6 +9,7 @@ from functools import reduce
from dateutil.relativedelta import relativedelta
import time
import numpy as np
from datetime import timedelta
# 用户申请表
def get_sql_apply_quota_record(user_id,apply_time):
......@@ -516,14 +517,14 @@ def city_sign(uuid=None,order_no=None):
#身份证是否过期
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}
"order_id": str(order_no), "business_type": 0,'ignore_cache':True}
headers = {
'rc_auth_key': 'rc_offline',
'rc_auth_secret': "9d9}bc24!e1z1x3`(x~4r29d$+45n3)'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^"
}
_response = None
try:
_url = "http://172.20.1.131:23010/calc/features"
_url = "http://172.20.1.184:23010/calc/features"
_request = requests.get(_url, params=params, headers=headers)
if _request.status_code == 200:
_response = _request.json()
......@@ -532,12 +533,12 @@ def card_expires(uuid=None,order_no=None):
if _response:
if _response['data']['features']['user_ocr_info#validDateEnd']['value'] == -9999999:
return list([])
if _response['data']['features']['user_ocr_info#validDateEnd']['value'] == "?":
return list([])
# if _response['data']['features']['user_ocr_info#validDateEnd']['value'] == "?":
# return list([])
ll_idcard = _response['data']['features']['user_ocr_info#validDateEnd']['value']
if ll_idcard:
if ll_idcard =='长期':
if (ll_idcard =='长期') or (ll_idcard =='长期有效'):
return 20301230
elif isinstance(ll_idcard.replace(".",""),str):
return int(ll_idcard.replace(".",""))
......@@ -568,7 +569,6 @@ def id_is_whitelist(phone_num_pre_seven,created_at):
"""查身份证是否在白名单"""
_sql = """select count(DISTINCT cert_number) count from
white_list where cert_number = "{0}" and is_enable = 1 and created_at < "{1}" """.format(phone_num_pre_seven,created_at)
_df = pd.read_sql(_sql, con_realtime_hmd)
return _df
......@@ -608,3 +608,115 @@ def sale_phone_white(phone_no):
_sql = """ select * from white_list_phone_no where phone_no = {0} and is_enable = 1 """.format(phone_no)
_df = pd.read_sql(_sql, con_realtime_hmd)
return _df
def gratia_payment_amount():
"""惠金所当日放款额"""
_sql = """select sum(contract_loan_amount) amount from loan_application_manifest_history
where loan_paid_at>=CURDATE() and transaction_status in (2,5)
and funding_corp_id=950 and user_id = 430"""
_df = pd.read_sql(_sql,con_tuomin_xyqb)
return _df
def amount_of_merchant(store_id,start_time,end_time):
_sql = """select amount as amount, trade_type as tradeType,trade_time as tradeTime from trade_record
where inner_merchant_no = '{0}' and status = 1 and trade_time >= '{1}' and trade_time < '{2}'; """.format(store_id,start_time,end_time)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def userid_of_merchant(store_id,start_time,end_time):
_sql = """ select user_id as userId, trade_time as tradeTime from trade_record
where inner_merchant_no = '{0}' and trade_type = 3 and status = 1 and trade_time >= '{1}' and trade_time < '{2}'; """.format(store_id,start_time,end_time)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def store_amount(uuid):
"""商户额度"""
_sql = """ select activated_amount,user_id from user_quota_record where uuid = '{0}';""".format(uuid)
_df = pd.read_sql(_sql, con_vcc_quota)
return _df
def uuid_store_amount(store_id,uuid,start_time,end_time):
_sql = """select amount as amount, trade_type as tradeType from trade_record
where inner_merchant_no = '{0}' and uuid = '{1}'and status = 1 and trade_time >= '{2}' and trade_time < '{3}'; """.format(store_id,uuid,start_time,end_time)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def on_uuid_store(uuid,store_id,order_id):
_sql = """select amount from trade_record
where uuid = '{0}' and inner_merchant_no = '{1}' and order_id = '{2}' and trade_type = 3 and status = 1""".format(uuid,store_id,order_id)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def store_type(store_id):
_sql = """select risk_flag as type from inner_merchant_info where inner_merchant_no = '{0}';""".format(store_id)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def get_orderid_trade(orderid):
_sql= """select trade_time from trade_record where order_id = '{0}'""".format(orderid)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def time_restart_zero(data_time):
time_zero = datetime.datetime.strptime(datetime.datetime.strftime(data_time, '%Y-%m-%d 00:00:00'), '%Y-%m-%d 00:00:00')
return time_zero
def iftime_order_snapshot(apply_time):
today = time_restart_zero(apply_time)
tomorrow = apply_time
yesterday = today - timedelta(days=1)
this_week_start = time_restart_zero(apply_time - timedelta(days=apply_time.weekday()))
this_week_end = apply_time
last_week_start = this_week_start - timedelta(days=7)
last_week_end = this_week_start
this_month_start = datetime.datetime(apply_time.year, apply_time.month, 1)
this_month_end = apply_time
last_month_up = this_month_start - timedelta(days=1)
last_month_start = datetime.datetime(last_month_up.year, last_month_up.month, 1)
last_month_end = this_month_start
return today,tomorrow,yesterday,this_week_start,this_week_end,last_week_start,last_week_end\
,this_month_start,this_month_end,last_month_start,last_month_end
def getSql_userPhone(uuid):
"""获取用户手机号"""
_sql = """
select phone_no
from xyqb_i_user
where uuid = '{0}'
""".format(uuid) # type: str
_df = pd.read_sql(_sql,con_realtime)
return _df
def vcc_phone_user(phone):
_sql = """select isp, city from dict_phone where phone= '{0}';""".format(phone)
_df = pd.read_sql(_sql, con_vcc_transfer)
return _df
def vcc_user_info(uuid):
_sql = """ select card_type as cardType, job_code as jobCode, income_code as incomeCode from
account a left join account_other_info b on a.user_id=b.user_id where a.uuid= '{0}';""".format(uuid)
_df = pd.read_sql(_sql, con_vcc_talos)
return _df
def vcc_credit_phone(userid,phone):
_sql = """select
case when count(1)>0
then 1 when count(1)=0
then 0
else '-9999999'
end as as_type from payment_center.bank_card where uid='{0}' and preserve_phone_no='{1}';""".format(userid,phone)
_df = pd.read_sql(_sql, con_vcc_transfer_pay)
return _df
\ No newline at end of file
......@@ -20,7 +20,7 @@ from handler import NewAudit_Handler
from handler import Calc_Features_Handler # 基础特征
from handler import ComplexOrder_Handler # 多订单特征
from handler import LoanPostFeatures_Handler # 催收模型特征
from handler import Calc_Features_4store #vcc商户特征
# settings = {'debug' : False}
class LogFormatter(tornado.log.LogFormatter):
......@@ -37,7 +37,8 @@ def apps():
(URL.url_new_audit, NewAudit_Handler.New_Audit),
(URL.url_calc_features, Calc_Features_Handler.CalcFeatures),
(URL.url_complex_order, ComplexOrder_Handler.ComplexOrder),
(URL.url_loanPostFeatures, LoanPostFeatures_Handler.loanPostFeatures)
(URL.url_loanPostFeatures, LoanPostFeatures_Handler.loanPostFeatures),
(URL.url_calc_features4store,Calc_Features_4store.CalcFeatures)
])
......
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