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
b01d6787
Commit
b01d6787
authored
Nov 03, 2017
by
data—王林芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去哪儿对账
parent
ee9dd9fc
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
36 deletions
+73
-36
去哪儿账单文件导入库.py
去哪儿/常规对账-基础数据处理入库/去哪儿账单文件导入库.py
+3
-3
哈银债转表处理.py
去哪儿/常规对账-基础数据处理入库/哈银债转表处理.py
+60
-23
惠金所债转表处理.py
去哪儿/常规对账-基础数据处理入库/惠金所债转表处理.py
+8
-8
还款计划拆分-针对用户的角度.py
去哪儿/常规对账-基础数据处理入库/还款计划拆分-针对用户的角度.py
+2
-2
还资金方表处理.py
去哪儿/常规对账-基础数据处理入库/还资金方表处理.py
+0
-0
No files found.
去哪儿/常规对账-基础数据处理入库/去哪儿账单文件导入库.py
View file @
b01d6787
...
@@ -252,5 +252,5 @@ if __name__ == '__main__':
...
@@ -252,5 +252,5 @@ if __name__ == '__main__':
# df = load_refund(year, month, insert_db=True)
# df = load_refund(year, month, insert_db=True)
# print df['refund_amount'].sum()
# print df['refund_amount'].sum()
# 导入还款数据
# 导入还款数据
df
=
load_repay
(
year
,
month
,
insert_db
=
True
)
# df = load_repay(year,month, insert_db=True)
print
df
[
'repay_amount'
]
.
sum
()
# print df['repay_amount'].sum()
\ No newline at end of file
\ No newline at end of file
去哪儿/常规对账-基础数据处理入库/哈银债转表处理.py
View file @
b01d6787
...
@@ -22,7 +22,7 @@ path = u'E:/量化派/去哪儿/去哪儿账单文件/201708'
...
@@ -22,7 +22,7 @@ path = u'E:/量化派/去哪儿/去哪儿账单文件/201708'
4、生成债转表中的放款表
4、生成债转表中的放款表
5、生成债转表中的还款计划
5、生成债转表中的还款计划
'''
'''
engine_qunaer
=
create_engine
(
'mysql+mysqldb://
yulong:ohVU1nPITynSZwR2
@172.16.3.201:3306/qunaer_new?charset=utf8'
,
echo
=
False
)
.
connect
()
engine_qunaer
=
create_engine
(
'mysql+mysqldb://
linfang.wang:#jkl3453YUGuo99
@172.16.3.201:3306/qunaer_new?charset=utf8'
,
echo
=
False
)
.
connect
()
# 提取退款数据
# 提取退款数据
...
@@ -30,13 +30,19 @@ def step_1(year,month):
...
@@ -30,13 +30,19 @@ def step_1(year,month):
start_time
=
datetime
.
date
(
year
,
month
,
1
)
start_time
=
datetime
.
date
(
year
,
month
,
1
)
end_time
=
start_time
+
relativedelta
(
months
=+
1
)
end_time
=
start_time
+
relativedelta
(
months
=+
1
)
sql_1
=
'''
sql_1
=
'''
select
fund_code,product_no,sum(repay_principle) repay_amount
,max(repay_time) fund_repay_time from qunaer_new.fund_repay_detail
select
product_no
,max(repay_time) fund_repay_time from qunaer_new.fund_repay_detail
where repay_time >= '
%
s' and repay_time < '
%
s' and fund_code = 3 and type=7
where repay_time >= '
%
s' and repay_time < '
%
s' and fund_code = 3 and type=7
GROUP by 1
,2
GROUP by 1
'''
%
(
start_time
,
end_time
)
'''
%
(
start_time
,
end_time
)
df
=
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
df
=
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
df
[
'fund_repay_time'
]
=
pd
.
to_datetime
(
df
[
'fund_repay_time'
])
.
dt
.
date
df
[
'fund_repay_time'
]
=
pd
.
to_datetime
(
df
[
'fund_repay_time'
])
.
dt
.
date
df
.
drop_duplicates
([
'product_no'
],
inplace
=
True
)
df
.
drop_duplicates
([
'product_no'
],
inplace
=
True
)
sql_pay
=
'''
select product_no ,loan_amount AS all_loan_amount from qunaer_new.pay_detail where status = 1
and fund_code = 3 and product_no in
%
s
'''
%
str
(
tuple
(
df
.
product_no
.
astype
(
str
)
.
tolist
()))
df_pay
=
pd
.
read_sql
(
sql_pay
,
engine_qunaer
)
df
=
pd
.
merge
(
df
,
df_pay
,
on
=
'product_no'
,
how
=
'left'
)
return
df
return
df
# 提取用户退款数据
# 提取用户退款数据
...
@@ -45,7 +51,7 @@ def step_2(product_nos):
...
@@ -45,7 +51,7 @@ def step_2(product_nos):
return
return
sql_1
=
'''
sql_1
=
'''
select id refund_id,fund_code src_fund_code,product_no,refund_principle,refund_time
select id refund_id,fund_code src_fund_code,product_no,refund_principle,refund_time
from qunaer_new.refund_detail where product_no in
%
s
from qunaer_new.refund_detail where product_no in
%
s
AND fund_code != 1
'''
%
str
(
tuple
(
product_nos
))
'''
%
str
(
tuple
(
product_nos
))
return
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
return
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
...
@@ -55,7 +61,7 @@ def step_3(product_nos):
...
@@ -55,7 +61,7 @@ def step_3(product_nos):
return
return
sql_1
=
'''
sql_1
=
'''
select id repay_id,fund_code src_fund_code,product_no,repay_principle,repay_time
select id repay_id,fund_code src_fund_code,product_no,repay_principle,repay_time
from qunaer_new.repay_detail where product_no in
%
s
from qunaer_new.repay_detail where product_no in
%
s
AND fund_code != 1
'''
%
str
(
tuple
(
product_nos
))
'''
%
str
(
tuple
(
product_nos
))
return
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
return
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
...
@@ -70,13 +76,13 @@ def step_4(year,month):
...
@@ -70,13 +76,13 @@ def step_4(year,month):
df_repay
=
pd
.
merge
(
df_repay
,
df_fund_repay
[[
'product_no'
,
'fund_repay_time'
]],
on
=
[
'product_no'
],
how
=
'left'
)
df_repay
=
pd
.
merge
(
df_repay
,
df_fund_repay
[[
'product_no'
,
'fund_repay_time'
]],
on
=
[
'product_no'
],
how
=
'left'
)
print
'====有还款有退款===='
,
df_fund_repay
.
ix
[(
df_fund_repay
.
product_no
.
isin
(
df_repay
.
product_no
))
&
(
df_fund_repay
.
product_no
.
isin
(
df_refund
.
product_no
))]
print
'====有还款有退款===='
,
df_fund_repay
.
ix
[(
df_fund_repay
.
product_no
.
isin
(
df_repay
.
product_no
))
&
(
df_fund_repay
.
product_no
.
isin
(
df_refund
.
product_no
))]
#提取债转后的退款数据
#提取债转后的退款数据
df_refund_after
=
df_refund
.
ix
[
df_refund
.
refund_time
>
=
df_refund
.
fund_repay_time
]
df_refund_after
=
df_refund
.
ix
[
df_refund
.
refund_time
>
df_refund
.
fund_repay_time
]
update_sql_1
=
'''
update_sql_1
=
'''
update refund_detail set fund_code = 1 where id =
%
s
update refund_detail set fund_code = 1 where id =
%
s
'''
'''
engine_qunaer
.
execute
(
update_sql_1
,
df_refund_after
[[
'refund_id'
]]
.
values
.
tolist
())
engine_qunaer
.
execute
(
update_sql_1
,
df_refund_after
[[
'refund_id'
]]
.
values
.
tolist
())
#提取债转后的还款数据
#提取债转后的还款数据
df_repay_after
=
df_repay
.
ix
[
df_repay
.
repay_time
>
=
df_repay
.
fund_repay_time
]
df_repay_after
=
df_repay
.
ix
[
df_repay
.
repay_time
>
df_repay
.
fund_repay_time
]
update_sql_2
=
'''
update_sql_2
=
'''
update repay_detail set fund_code = 1 where id =
%
s
update repay_detail set fund_code = 1 where id =
%
s
'''
'''
...
@@ -97,22 +103,23 @@ def step_4(year,month):
...
@@ -97,22 +103,23 @@ def step_4(year,month):
def
step_5
(
year
,
month
):
def
step_5
(
year
,
month
):
df_fund_repay
=
step_1
(
year
,
month
)
df_fund_repay
=
step_1
(
year
,
month
)
sql_repay
=
'''
sql_repay
=
'''
select
fund_code,
product_no,sum(repay_principle) repay_principle from
select product_no,sum(repay_principle) repay_principle from
qunaer_new.repay_detail where product_no in
%
s
qunaer_new.repay_detail where product_no in
%
s
and fund_code=3 and repay_status=1
group by 1
,2
group by 1
'''
%
str
(
tuple
(
df_fund_repay
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
.
replace
(
',)'
,
')'
)
'''
%
str
(
tuple
(
df_fund_repay
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
.
replace
(
',)'
,
')'
)
df_repay
=
pd
.
read_sql
(
sql_repay
,
engine_qunaer
)
df_repay
=
pd
.
read_sql
(
sql_repay
,
engine_qunaer
)
sql_refund
=
'''
sql_refund
=
'''
select
fund_code,
product_no,-sum(refund_principle) repay_principle from qunaer_new.refund_detail
select product_no,-sum(refund_principle) repay_principle from qunaer_new.refund_detail
WHERE product_no in
%
s
WHERE product_no in
%
s
AND fund_code = 3 and refund_status=1
GROUP by 1
,2
GROUP by 1
'''
%
str
(
tuple
(
df_fund_repay
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
.
replace
(
',)'
,
')'
)
'''
%
str
(
tuple
(
df_fund_repay
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
.
replace
(
',)'
,
')'
)
df_refund
=
pd
.
read_sql
(
sql_refund
,
engine_qunaer
)
df_refund
=
pd
.
read_sql
(
sql_refund
,
engine_qunaer
)
df_repay_all
=
pd
.
concat
([
df_repay
,
df_refund
],
ignore_index
=
True
)
df_repay_all
=
pd
.
concat
([
df_repay
,
df_refund
],
ignore_index
=
True
)
df_repay_all
=
df_repay_all
.
groupby
([
'fund_code'
,
'product_no'
])
.
agg
({
'repay_principle'
:
'sum'
})
.
reset_index
()
df_repay_all
=
df_repay_all
.
groupby
([
'product_no'
])
.
agg
({
'repay_principle'
:
'sum'
})
.
reset_index
()
df_fund_repay
=
pd
.
merge
(
df_fund_repay
,
df_repay_all
,
on
=
[
'fund_code'
,
'product_no'
],
how
=
'left'
)
df_fund_repay
=
pd
.
merge
(
df_fund_repay
,
df_repay_all
,
on
=
[
'product_no'
],
how
=
'left'
)
print
'====未找到的订单===='
,
df_repay_all
.
ix
[
~
df_repay_all
.
product_no
.
isin
(
df_fund_repay
.
product_no
)]
# diff---债转后的金额
# diff---债转后的金额
df_fund_repay
[
'diff'
]
=
np
.
round
(
df_fund_repay
[
'
repay
_amount'
]
-
df_fund_repay
[
'repay_principle'
],
2
)
df_fund_repay
[
'diff'
]
=
np
.
round
(
df_fund_repay
[
'
all_loan
_amount'
]
-
df_fund_repay
[
'repay_principle'
],
2
)
df_fund_repay
=
df_fund_repay
.
ix
[
df_fund_repay
[
'diff'
]
!=
0
]
df_fund_repay
=
df_fund_repay
.
ix
[
df_fund_repay
[
'diff'
]
!=
0
]
sql_pay
=
'''
sql_pay
=
'''
select product_no,user_no,loan_time,loan_amount,stages,is_ptf,status,rate
select product_no,user_no,loan_time,loan_amount,stages,is_ptf,status,rate
...
@@ -141,7 +148,7 @@ def step_5(year,month):
...
@@ -141,7 +148,7 @@ def step_5(year,month):
df_fund_repay_no
.
ix
[
df_fund_repay_no
.
stages
==
1
,
'left_stages'
]
=
0
df_fund_repay_no
.
ix
[
df_fund_repay_no
.
stages
==
1
,
'left_stages'
]
=
0
df_fund_repay_no
[
'new_stages'
]
=
df_fund_repay_no
[
'stages'
]
-
df_fund_repay_no
[
'left_stages'
]
df_fund_repay_no
[
'new_stages'
]
=
df_fund_repay_no
[
'stages'
]
-
df_fund_repay_no
[
'left_stages'
]
#TODO 做这儿一定要注意,剩余期数这个概念
#TODO 做这儿一定要注意,剩余期数这个概念
df_fund_repay_no
.
to_csv
(
'E:/cc.csv'
)
df_fund_repay_no
.
to_csv
(
'E:/cc
c
.csv'
)
df_fund_repay_no
=
df_fund_repay_no
[[
'fund_code'
,
'product_no'
,
'new_stages'
,
'stages'
,
'status'
,
'is_ptf'
,
'loan_time'
,
'diff'
,
'trans_time'
,
'user_no'
,
'rate'
]]
df_fund_repay_no
=
df_fund_repay_no
[[
'fund_code'
,
'product_no'
,
'new_stages'
,
'stages'
,
'status'
,
'is_ptf'
,
'loan_time'
,
'diff'
,
'trans_time'
,
'user_no'
,
'rate'
]]
df_fund_repay_no
.
rename
(
columns
=
{
'diff'
:
'loan_amount'
},
inplace
=
True
)
df_fund_repay_no
.
rename
(
columns
=
{
'diff'
:
'loan_amount'
},
inplace
=
True
)
df_fund_repay_no
.
to_sql
(
'baoli_pay_detail'
,
engine_qunaer
,
if_exists
=
'append'
,
index
=
None
,
chunksize
=
10000
)
df_fund_repay_no
.
to_sql
(
'baoli_pay_detail'
,
engine_qunaer
,
if_exists
=
'append'
,
index
=
None
,
chunksize
=
10000
)
...
@@ -159,7 +166,7 @@ def step_6(year,month):
...
@@ -159,7 +166,7 @@ def step_6(year,month):
df_1
=
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
df_1
=
pd
.
read_sql
(
sql_1
,
engine_qunaer
)
#还款计划
#还款计划
sql_2
=
'''
sql_2
=
'''
select product_no,current_stage_no user_current_stage_no,deadline,rate,
require_fee,
principle,fee_amount,due_amount,status
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
from qunaer_new.repayment_plan_2017 where product_no in
%
s
'''
%
str
(
tuple
(
df_1
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
'''
%
str
(
tuple
(
df_1
[
'product_no'
]
.
astype
(
str
)
.
tolist
()))
df_2
=
pd
.
read_sql
(
sql_2
,
engine_qunaer
)
df_2
=
pd
.
read_sql
(
sql_2
,
engine_qunaer
)
...
@@ -174,25 +181,55 @@ def step_6(year,month):
...
@@ -174,25 +181,55 @@ def step_6(year,month):
df_2
=
pd
.
merge
(
df_2
,
df_1
,
on
=
'product_no'
,
how
=
'left'
)
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
[
'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
[
'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'
,
'
require_fee'
,
'
principle'
,
'fee_amount'
,
'due_amount'
,
'status'
]]
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_csv('E:/ddd.csv')
df_2
.
to_sql
(
'baoli_repayment_plan'
,
engine_qunaer
,
if_exists
=
'append'
,
index
=
None
,
chunksize
=
10000
)
df_2
.
to_sql
(
'baoli_repayment_plan'
,
engine_qunaer
,
if_exists
=
'append'
,
index
=
None
,
chunksize
=
10000
)
# 债转校验--
def
check_baoli
(
year
,
month
):
sql_fund
=
'''
select product_no,sum(repay_principle) fund_repay_principle from qunaer_new.fund_repay_detail
where fund_code = 3 and type = 7
GROUP by 1
'''
sql_refund
=
'''
select product_no,-sum(refund_principle) repay_principle from qunaer_new.refund_detail
where fund_code = 3 and product_no in
%
s
group by 1
'''
sql_repay
=
'''
select product_no,sum(repay_principle) repay_principle from qunaer_new.repay_detail
WHERE fund_code = 3 and product_no in
%
s
GROUP BY 1
'''
sql_baoli
=
'''
select product_no,loan_amount ,trans_time from qunaer_new.baoli_pay_detail
'''
df_baoli
=
pd
.
read_sql
(
sql_baoli
,
engine_qunaer
)
df_fund
=
pd
.
read_sql
(
sql_fund
,
engine_qunaer
)
df_refund
=
pd
.
read_sql
(
sql_refund
%
str
(
tuple
(
df_fund
.
product_no
.
astype
(
str
)
.
tolist
())),
engine_qunaer
)
df_repay
=
pd
.
read_sql
(
sql_repay
%
str
(
tuple
(
df_fund
.
product_no
.
astype
(
str
)
.
tolist
())),
engine_qunaer
)
df_repay
=
pd
.
concat
([
df_refund
,
df_repay
])
df_repay
=
df_repay
.
groupby
(
'product_no'
)[
'repay_principle'
]
.
sum
()
.
reset_index
()
df_diff
=
pd
.
merge
(
df_fund
,
df_repay
,
on
=
'product_no'
,
how
=
'outer'
)
df_diff
=
pd
.
merge
(
df_diff
,
df_baoli
,
on
=
'product_no'
,
how
=
'outer'
)
df_diff
.
fillna
(
0
,
inplace
=
True
)
df_diff
[
'diff'
]
=
np
.
round
(
df_diff
[
'fund_repay_principle'
]
-
df_diff
[
'repay_principle'
],
2
)
df_diff
.
to_csv
(
'E:/cccc.csv'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
year
=
2017
year
=
2017
month
=
9
month
=
10
#====针对提前结算的处理========
#===针对退款的情况进行债转处理
#===只有提前结算有债转处理=====
#===到期日
#===到期日
# step_4(year,month)
# step_4(year,month)
# step_5(year,month)
# step_5(year,month)
# step_6(year,month)
# step_6(year,month)
#--根据客户的还款计划更新保理的还款计划
#--根据客户的还款计划更新保理的还款计划
# 更新还款计划---哈银在9月上线,所以就无需更新了,但是之后10月必须更新的。
# 更新还款计划---哈银在9月上线,所以就无需更新了,但是之后10月必须更新的。
# check_baoli(year,month)
...
...
去哪儿/常规对账-基础数据处理入库/惠金所债转表处理.py
View file @
b01d6787
...
@@ -23,7 +23,7 @@ path = u'E:/量化派/去哪儿/去哪儿账单文件/201708'
...
@@ -23,7 +23,7 @@ path = u'E:/量化派/去哪儿/去哪儿账单文件/201708'
4、生成债转表中的放款表
4、生成债转表中的放款表
5、生成债转表中的还款计划
5、生成债转表中的还款计划
'''
'''
engine_qunaer
=
create_engine
(
'mysql+mysqldb://
yulong:ohVU1nPITynSZwR2
@172.16.3.201:3306/qunaer_new?charset=utf8'
,
echo
=
False
)
.
connect
()
engine_qunaer
=
create_engine
(
'mysql+mysqldb://
linfang.wang:#jkl3453YUGuo99
@172.16.3.201:3306/qunaer_new?charset=utf8'
,
echo
=
False
)
.
connect
()
# 提取提前结算数据
# 提取提前结算数据
...
@@ -166,23 +166,23 @@ def step_7(year,month):
...
@@ -166,23 +166,23 @@ def step_7(year,month):
'''
%
(
start_time
,
end_time
)
'''
%
(
start_time
,
end_time
)
sql_user_plan
=
'''
sql_user_plan
=
'''
select product_no,current_stage_no,
require_fee,
principle,fee_amount,due_amount ,status from qunaer_new.repayment_plan_2017
select product_no,current_stage_no,principle,fee_amount,due_amount ,status from qunaer_new.repayment_plan_2017
WHERE product_no in
%
s
WHERE product_no in
%
s
'''
'''
sql_baoli_plan
=
'''
sql_baoli_plan
=
'''
select id,product_no,user_current_stage_no,
require_fee baoli_require_fee
from qunaer_new.baoli_repayment_plan
select id,product_no,user_current_stage_no,
principle src_principle,fee_amount src_fee_amount,due_amount src_due_amount
from qunaer_new.baoli_repayment_plan
where product_no in
%
s
where product_no in
%
s
'''
'''
update_sql
=
'''
update_sql
=
'''
update baoli_repayment_plan set
require_fee=
%
s,
principle=
%
s,fee_amount=
%
s,due_amount=
%
s,status=
%
s where id=
%
s
update baoli_repayment_plan set principle=
%
s,fee_amount=
%
s,due_amount=
%
s,status=
%
s where id=
%
s
'''
'''
df_refund
=
pd
.
read_sql
(
sql_refund
,
engine_qunaer
)
df_refund
=
pd
.
read_sql
(
sql_refund
,
engine_qunaer
)
df_user_plan
=
pd
.
read_sql
(
sql_user_plan
%
str
(
tuple
(
df_refund
[
'product_no'
]
.
astype
(
str
)
.
tolist
())),
engine_qunaer
)
df_user_plan
=
pd
.
read_sql
(
sql_user_plan
%
str
(
tuple
(
df_refund
[
'product_no'
]
.
astype
(
str
)
.
tolist
())),
engine_qunaer
)
df_baoli_plan
=
pd
.
read_sql
(
sql_baoli_plan
%
str
(
tuple
(
df_refund
[
'product_no'
]
.
astype
(
str
)
.
tolist
())),
engine_qunaer
)
df_baoli_plan
=
pd
.
read_sql
(
sql_baoli_plan
%
str
(
tuple
(
df_refund
[
'product_no'
]
.
astype
(
str
)
.
tolist
())),
engine_qunaer
)
df_plan
=
pd
.
merge
(
df_baoli_plan
,
df_user_plan
,
left_on
=
[
'product_no'
,
'user_current_stage_no'
],
right_on
=
[
'product_no'
,
'current_stage_no'
],
how
=
'left'
)
df_plan
=
pd
.
merge
(
df_baoli_plan
,
df_user_plan
,
left_on
=
[
'product_no'
,
'user_current_stage_no'
],
right_on
=
[
'product_no'
,
'current_stage_no'
],
how
=
'left'
)
df_plan
[
'diff'
]
=
np
.
round
(
df_plan
[
'baoli_require_fee'
]
-
df_plan
[
'require_fee'
],
2
)
#
df_plan['diff']=np.round(df_plan['baoli_require_fee']-df_plan['require_fee'],2)
df_plan
=
df_plan
.
ix
[
df_plan
[
'diff'
]
!=
0
]
#
df_plan=df_plan.ix[df_plan['diff'] != 0]
engine_qunaer
.
execute
(
update_sql
,
df_plan
[[
'
require_fee'
,
'
principle'
,
'fee_amount'
,
'due_amount'
,
'status'
,
'id'
]]
.
values
.
tolist
())
engine_qunaer
.
execute
(
update_sql
,
df_plan
[[
'principle'
,
'fee_amount'
,
'due_amount'
,
'status'
,
'id'
]]
.
values
.
tolist
())
#更新还款状态
#更新还款状态
def
step_8
(
year
,
month
):
def
step_8
(
year
,
month
):
...
@@ -213,7 +213,7 @@ def step_8(year,month):
...
@@ -213,7 +213,7 @@ def step_8(year,month):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
year
=
2017
year
=
2017
month
=
9
month
=
10
#====针对提前结算的处理========
#====针对提前结算的处理========
#===只有提前结算有债转处理=====
#===只有提前结算有债转处理=====
#===到期日
#===到期日
...
...
去哪儿/常规对账-基础数据处理入库/还款计划拆分-针对用户的角度.py
View file @
b01d6787
...
@@ -477,14 +477,14 @@ if __name__ == '__main__':
...
@@ -477,14 +477,14 @@ if __name__ == '__main__':
#=========step_1 BEGIN================
#=========step_1 BEGIN================
# 录入还款计划
# 录入还款计划
step_1
(
year
,
month
,
insert_db
=
True
)
#
step_1(year,month,insert_db=True)
# deadline 同步都江堰
# deadline 同步都江堰
# df=step_1_1(year,month,insert_db=True)
# df=step_1_1(year,month,insert_db=True)
# =========step_1 END================
# =========step_1 END================
# =========step_2 BEGIN================
# =========step_2 BEGIN================
#根据退款,进行更新还款计划
#根据退款,进行更新还款计划
step_2
(
year
,
month
,
insert_db
=
True
)
#
step_2(year,month,insert_db=True)
# 校验还款计划更新的对否
# 校验还款计划更新的对否
# df=check_plan_vs_djy(year,month)
# df=check_plan_vs_djy(year,month)
# df.to_csv('E:/diff_2017_plan.csv')
# df.to_csv('E:/diff_2017_plan.csv')
...
...
去哪儿/常规对账-基础数据处理入库/还资金方表处理.py
View file @
b01d6787
This diff is collapsed.
Click to expand it.
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