Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
duizhang_tools
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data—王林芳
duizhang_tools
Commits
d5c72ef2
Commit
d5c72ef2
authored
Nov 20, 2017
by
data—王林芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去哪儿done
parent
f21ad4ea
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
39 deletions
+62
-39
SQL校验.sql
去哪儿/常规对账-基础数据处理入库/SQL校验.sql
+6
-0
去哪儿流水导入.ipynb
去哪儿/常规对账-基础数据处理入库/去哪儿流水导入.ipynb
+0
-0
去哪儿罚息计算.py
去哪儿/常规对账-基础数据处理入库/去哪儿罚息计算.py
+5
-4
去哪儿账单文件导入库.py
去哪儿/常规对账-基础数据处理入库/去哪儿账单文件导入库.py
+18
-2
哈银债转表处理.py
去哪儿/常规对账-基础数据处理入库/哈银债转表处理.py
+31
-31
惠金所债转表处理.py
去哪儿/常规对账-基础数据处理入库/惠金所债转表处理.py
+1
-1
还款计划拆分-针对用户的角度.py
去哪儿/常规对账-基础数据处理入库/还款计划拆分-针对用户的角度.py
+1
-1
No files found.
去哪儿/常规对账-基础数据处理入库/SQL校验.sql
View file @
d5c72ef2
...
...
@@ -131,6 +131,12 @@ JOIN `repay_detail` t2 ON t1.`fund_code`=t2.`fund_code` AND t1.`product_no`=t2.`
WHERE
t1
.
status
=
1
#==========
step_5
================
#====
重点校验
===
逻辑
债转前的
退还款
+
债转金额
=
债转前的放款金额
债转后的金额
>=
债转后的退还款
#
判断是否有退款时间
>
债转时间,但资金方
ID
非保理
SELECT
t1
.
id
,
t1
.
`product_no`
,
t1
.
`trans_time`
,
t2
.
`refund_time`
FROM
`baoli_pay_detail`
t1
JOIN
`refund_detail`
t2
ON
t1
.
`product_no`
=
t2
.
product_no
...
...
去哪儿/常规对账-基础数据处理入库/去哪儿流水导入.ipynb
0 → 100644
View file @
d5c72ef2
This diff is collapsed.
Click to expand it.
去哪儿/常规对账-基础数据处理入库/去哪儿罚息计算.py
View file @
d5c72ef2
...
...
@@ -51,8 +51,8 @@ def cal_due_amount(deadline,repaid_at,require_fee,is_new=True):
if
__name__
==
'__main__'
:
deadline
=
datetime
.
date
(
201
7
,
6
,
1
)
repaid_at
=
datetime
.
date
(
201
7
,
10
,
5
)
require_fee
=
1012.34
punish
=
cal_due_amount
(
deadline
,
repaid_at
,
require_fee
)
deadline
=
datetime
.
date
(
201
6
,
1
,
26
)
repaid_at
=
datetime
.
date
(
201
6
,
1
,
27
)
require_fee
=
79.5
punish
=
cal_due_amount
(
deadline
,
repaid_at
,
require_fee
,
is_new
=
False
)
print
'----罚息----'
,
punish
\ No newline at end of file
去哪儿/常规对账-基础数据处理入库/去哪儿账单文件导入库.py
View file @
d5c72ef2
...
...
@@ -253,4 +253,20 @@ if __name__ == '__main__':
# print df['refund_amount'].sum()
# 导入还款数据
# df = load_repay(year,month, insert_db=True)
# print df['repay_amount'].sum()
\ No newline at end of file
# print df['repay_amount'].sum()
#===如果 退款时间在 债转时间之后,那么更新资金方ID ;如果还款时间在 在债转时间之后,那么更新 资金方ID
#===继续执行下面的SQL===
# update_refund='''
# update repay_detail set repay.fund_code=1
# from repay_detail repay
# JOIN baoli_pay_detail t2 on repay.product_no = t2.product_no and repay.repay_status=1 and repay.fund_code != 1
# where date(t2.trans_time) < DATE(repay.repay_time)
# '''
#
# update_refund = '''
# update refund_detail set repay.fund_code=1
# from refund_detail repay
# JOIN baoli_pay_detail t2 on repay.product_no = t2.product_no and repay.refund_status=1 and repay.fund_code != 1
# where date(t2.trans_time) < DATE(repay.refund_time)
# '''
\ No newline at end of file
去哪儿/常规对账-基础数据处理入库/哈银债转表处理.py
View file @
d5c72ef2
...
...
@@ -154,36 +154,35 @@ def step_5(year,month):
df_fund_repay_no
.
to_sql
(
'baoli_pay_detail'
,
engine_qunaer
,
if_exists
=
'append'
,
index
=
None
,
chunksize
=
10000
)
# # 债转后的保理放款表的还款计划入库
# def step_6(year,month):
# start_time = datetime.date(year, month, 1)
# end_time = start_time + relativedelta(months=+1)
# sql_1='''
# select t1.product_no,t1.new_stages,t1.stages from qunaer_new.baoli_pay_detail t1
# JOIN qunaer_new.pay_detail t2 on t1.product_no = t2.product_no and t2.fund_code = 3
# where t1.trans_time >= '%s' and t1.trans_time < '%s'
# ''' % (start_time,end_time)
# df_1=pd.read_sql(sql_1,engine_qunaer)
# #还款计划
# sql_2='''
# select product_no,current_stage_no user_current_stage_no,deadline,rate,principle,fee_amount,due_amount,status
# from qunaer_new.repayment_plan_2017 where product_no in %s
# ''' % str(tuple(df_1['product_no'].astype(str).tolist()))
# df_2=pd.read_sql(sql_2,engine_qunaer)
# df_2['fund_code']=1
# sql_3='''
# select product_no,current_stage_no user_current_stage_no,repay_no from qunaer_new.repay_detail
# where fund_code = 3 AND product_no in %s
# ''' % str(tuple(df_1['product_no'].astype(str).tolist()))
# df_3=pd.read_sql(sql_3,engine_qunaer)
# df_2=pd.merge(df_2,df_3,on=['product_no','user_current_stage_no'],how='left')
# df_2=df_2.ix[df_2.repay_no.isnull()]
# df_2=pd.merge(df_2,df_1,on='product_no',how='left')
# df_2['diff']=np.round(df_2['stages']-df_2['new_stages'],2)
# df_2['current_stage_no']=np.round(df_2['user_current_stage_no']-df_2['diff'],2)
# df_2=df_2[['product_no','current_stage_no','user_current_stage_no','deadline','rate','principle','fee_amount','due_amount','status']]
# # df_2.to_csv('E:/ddd.csv')
# df_2.to_sql('baoli_repayment_plan',engine_qunaer,if_exists='append',index=None,chunksize=10000)
# # 债转后的保理放款表的还款计划更新
def
step_6
(
year
,
month
):
start_time
=
datetime
.
date
(
year
,
month
,
1
)
end_time
=
start_time
+
relativedelta
(
months
=+
1
)
sql_1
=
'''
select t1.product_no,t1.new_stages,t1.stages from qunaer_new.baoli_pay_detail t1
JOIN qunaer_new.pay_detail t2 on t1.product_no = t2.product_no and t2.fund_code = 3
where t1.trans_time >= '
%
s' and t1.trans_time < '
%
s'
'''
%
(
start_time
,
end_time
)
df_1
=
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
#还款计划
sql_2
=
'''
select id plan_id,product_no,current_stage_no user_current_stage_no
from qunaer_new.repayment_plan_2017 where product_no in
%
s
'''
%
str
(
tuple
(
df_1
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
df_2
=
pd
.
read_sql
(
sql_2
,
engine_qunaer
)
df_2
[
'fund_code'
]
=
1
sql_3
=
'''
select product_no,current_stage_no user_current_stage_no,repay_no from qunaer_new.repay_detail
where fund_code = 3 AND product_no in
%
s
'''
%
str
(
tuple
(
df_1
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
df_3
=
pd
.
read_sql
(
sql_3
,
engine_qunaer
)
df_2
=
pd
.
merge
(
df_2
,
df_3
,
on
=
[
'product_no'
,
'user_current_stage_no'
],
how
=
'left'
)
df_2
=
df_2
.
ix
[
df_2
.
repay_no
.
isnull
()]
df_2
=
pd
.
merge
(
df_2
,
df_1
,
on
=
'product_no'
,
how
=
'left'
)
update_sql
=
'''
update repayment_plan_2017 set fund_code=1 where fund_code = 3 and plan_id =
%
s
'''
engine_qunaer
.
execute
(
update_sql
,
df_2
[[
'plan_id'
]]
.
values
.
tolist
())
# 债转校验--
...
...
@@ -226,7 +225,8 @@ if __name__ == '__main__':
#===到期日
# step_4(year,month)
# step_5(year,month)
#TODO ==== 更新,客户的还款计划中的资金方 ID
#更新,客户的还款计划中的资金方 ID
# step_6(year,month)
#--根据客户的还款计划更新保理的还款计划
...
...
去哪儿/常规对账-基础数据处理入库/惠金所债转表处理.py
View file @
d5c72ef2
...
...
@@ -222,7 +222,7 @@ if __name__ == '__main__':
# step_6(year,month)
#--根据客户的还款计划更新保理的还款计划
# step_7(year,month)
step_8
(
year
,
month
)
#
step_8(year,month)
...
...
去哪儿/常规对账-基础数据处理入库/还款计划拆分-针对用户的角度.py
View file @
d5c72ef2
...
...
@@ -154,7 +154,7 @@ def step_1_1(year,month,product_no='',insert_db = False):
return
df
# 单单只有退款服务费的时候,也需要更新下。
# 有退款的订单,更新还款计划-- 更新应还本金,利息
# 还款计划表 repayment_plan_2017
def
step_2
(
year
,
month
,
product_no
=
''
,
insert_db
=
False
):
...
...
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