_sql="""select target_used_amount as transAmountNow, target_activated_amount as nowRealAmount
from user_quota_log where uuid = '{0}' and created_at < '{1}' order by created_at desc limit 1""".format(uuid,applyTime)
_df=pd.read_sql(_sql,con_vcc_quota)
return_df
defhistorical_overdue(user_id,applyTime):
"""vcc历史最大逾期"""
_sql="""select paid_off_date as paidOffDate, plan_date as planDate from acs_plan
where user_id = '{0}' and plan_status!='Refund' and plan_status!='Renew' and plan_date < '{1}'""".format(user_id,applyTime)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
deftime_credit(uuid,applyTime):
"""授信时间"""
_sql="""select created_at as creditAt from biz_audit_log where uuid = '{0}' and created_at < '{1}' order by created_at desc limit 1""".format(uuid,applyTime)
_df=pd.read_sql(_sql,con_vcc_workflow)
return_df
deftime_credit_quta(uuid):
"""重新获取授信时间"""
_sql="""select apply_time from risk_record where apply_status =2 and uuid ='{0}' order by apply_time desc limit 1""".format(uuid)
_df=pd.read_sql(_sql,con=con_vcc_talos)
return_df
deftime_credit_info(user_id,start_time,end_time):
_sql="""select * from acs_trans where user_id = '{0}' and trans_type IN ('Shop','Loan') and trans_status = 'Complete' and trans_time >= '{1}' and trans_time <= '{2}'""".format(user_id,start_time,end_time)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
defview_activation(uuid,created_at):
"""查看激活额度"""
_sql="""select * from user_quota_log where uuid = '{0}' and created_at >= '{1}' order by created_at asc limit 1""".format(uuid,created_at)
_df=pd.read_sql(_sql,con_vcc_quota)
return_df
deffirst_transaction(user_id,applyTime):
"""首次交易时间"""
_sql="""select min(business_date) as fristBusinessDate from acs_trans
where user_id = '{0}' and trans_type IN ('Shop','Loan') AND trans_status = 'Complete' and trans_time < '{1}';""".format(user_id,applyTime)
where user_id = '{0}' and trans_type IN ('Shop','Loan') and trans_status = 'Complete' and trans_time >= '{1}' and trans_time <= '{2}' """.format(user_id,start_time,end_time)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
defone_month_amount(user_id,start_time,end_time):
"""近一个月提前还款的金额"""
_sql="""select trans_amount from acs_trans where user_id = '{0}'
and trans_type = 'Repay' AND trans_status = 'Complete' and business_date<date(bill_no) and business_date >= '{1}' and business_date <= '{2}'""".format(user_id,start_time,end_time)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
defone_month_term(user_id,start_time,end_time):
""""""
_sql="""select * from acs_trans where user_id = '{0}' and trans_type IN ( 'Shop', 'Loan' )
AND trans_status = 'Complete' and business_date >= '{1}' and business_date <= '{2}'""".format(user_id,start_time,end_time)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
defall_month_term(user_id):
"""获取所有的交易笔数"""
_sql="""select * from acs_trans where user_id = '{0}' and trans_type IN ( 'Shop', 'Loan' )
AND trans_status = 'Complete' """.format(user_id)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
defhistorical_trans_amount(user_id,applyTime):
"""历史交易金额"""
_sql="""SELECT * FROM acs_trans WHERE user_id = '{0}' and trans_type IN ( 'Shop', 'Loan' )
AND trans_status = 'Complete' and business_date <= '{1}';""".format(user_id,applyTime)
_df=pd.read_sql(_sql,con_vcc_device_info)
return_df
defhistory_fail_count(user_id,applyTime):
_sql="""SELECT count(*) as count FROM acs_trans WHERE user_id = '{0}'
and trans_type not in ('Shop','Loan') and trans_type='Deduct' AND trans_status != 'Complete' and business_date <= '{1}';""".format(user_id,applyTime)