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
a0054bba
Commit
a0054bba
authored
Nov 18, 2017
by
Perry_Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
白条坏账
parent
c26fefc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
白条坏账.py
白条/出表/白条坏账.py
+23
-13
No files found.
白条/出表/白条坏账.py
View file @
a0054bba
...
...
@@ -9,12 +9,9 @@ import pandas as pd
import
numpy
as
np
from
sqlalchemy
import
create_engine
import
multiprocessing
as
mtp
import
pyexcelerate
as
pe
from
dateutil.relativedelta
import
relativedelta
import
datetime
columns
=
[
'plan_id'
,
'白条商家'
,
'产品编号'
,
'放款日期'
,
'总期数'
,
'放款金额'
,
'本金债权'
,
'当期应还期数'
,
'当期应还款日'
,
'当期本金'
,
'还款时间'
,
'坏账统计时间'
]
# years = (2017,)
# months = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
path
=
u'E:/审计出表/11月份开始使用表数据/11月份白条出表/坏账'
engine_audit
=
create_engine
(
'mysql+mysqldb://internal_r:ArbNgtvlJzZHXsEu@172.16.3.201:3306/audit?charset=utf8'
,
echo
=
True
)
...
...
@@ -22,49 +19,57 @@ engine_audit = create_engine('mysql+mysqldb://internal_r:ArbNgtvlJzZHXsEu@172.16
sql_plan
=
"""select plan.id plan_id, loan.order_no 产品编号,
loan.real_loan_amount 放款金额, plan.term_no 当期应还期数,date(plan.deadline) deadline, plan.principle
from new_transaction.user_bt_repayment_plan plan
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id
AND loan.funding_corp_id=1
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id
where plan.deadline < date_sub('
%
s', interval 90 day)
AND loan.funding_corp_id=1
and loan.is_active in(1,-2)"""
#之前(2017-10)给财务的坏账数据实还本金用的是ref表的principle,没有减去减免本金
sql_online
=
'''
select t1.plan_id,
t1.principle
real_principle
select t1.plan_id,
(t1.principle-IFNULL(t1.mitigate_principle,0))
real_principle
from new_transaction.baitiao_repay_plan_repay_record_ref t1
join new_transaction.repay_record_online t2 on t1.record_id = t2.id and t1.repay_channel < 13
JOIN (
select plan.id plan_id
from new_transaction.user_bt_repayment_plan plan
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id
AND loan.funding_corp_id=1
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id AND loan.funding_corp_id=1
where plan.deadline < date_sub('
%
s', interval 90 day)
and loan.is_active in(1,-2)
)t3 ON t1.plan_id =t3.plan_id
WHERE t2.bill_time < '
%
s'
'''
sql_alipay
=
'''
select t1.plan_id,
t1.principle
real_principle
select t1.plan_id,
(t1.principle-IFNULL(t1.mitigate_principle,0))
real_principle
from new_transaction.baitiao_repay_plan_repay_record_ref t1
join new_transaction.offline_alipay_record t2 on t1.record_id = t2.id and t1.repay_channel = 13
JOIN (
select plan.id plan_id
from new_transaction.user_bt_repayment_plan plan
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id
AND loan.funding_corp_id=1
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id AND loan.funding_corp_id=1
where plan.deadline < date_sub('
%
s', interval 90 day)
and loan.is_active in(1,-2)
AND loan.funding_corp_id=1
)t3 ON t1.plan_id =t3.plan_id
WHERE t2.transfer_time < '
%
s'
'''
sql_bank
=
'''
select t1.plan_id,
t1.principle
real_principle
select t1.plan_id,
(t1.principle-IFNULL(t1.mitigate_principle,0))
real_principle
from new_transaction.baitiao_repay_plan_repay_record_ref t1
join new_transaction.offline_bank_repay_record t2 on t1.record_id = t2.id and t1.repay_channel > 13
JOIN (
select plan.id plan_id
from new_transaction.user_bt_repayment_plan plan
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id
AND loan.funding_corp_id=1
join baitiao_audit.baitiao_order loan on loan.ref_id = plan.ref_id AND loan.funding_corp_id=1
where plan.deadline < date_sub('
%
s', interval 90 day)
and loan.is_active in(1,-2)
)t3 ON t1.plan_id =t3.plan_id
WHERE t2.transfer_time < '
%
s'
'''
columns
=
[
'plan_id'
,
'白条商家'
,
'产品编号'
,
'放款日期'
,
'总期数'
,
'放款金额'
,
'本金债权'
,
'当期应还期数'
,
'当期应还款日'
,
'当期本金'
,
'还款时间'
,
'坏账统计时间'
]
years
=
(
2017
,)
months
=
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
)
path
=
u'E:/数据汇总/白条/坏账/'
def
bad_debt
(
year
,
month
):
end_time
=
datetime
.
date
(
year
,
month
,
1
)
+
relativedelta
(
months
=+
1
)
...
...
@@ -87,7 +92,12 @@ def bad_debt(year, month):
df_plan
[
u'坏账统计时间'
]
=
end_time
df_plan
.
rename
(
columns
=
{
'principle'
:
u'应还本金'
,
'real_principle'
:
u'实还本金'
,
'diff'
:
u'坏账金额'
},
inplace
=
True
)
df_plan
.
to_excel
(
path
+
u'
%
s-
%
s_白条坏账.xlsx'
%
(
year
,
month
),
index
=
None
)
data_list
=
df_plan
.
values
.
tolist
()
data_list
.
insert
(
0
,
df_plan
.
columns
.
tolist
())
wb
=
pe
.
Workbook
()
wb
.
new_sheet
(
u'明细'
,
data
=
data_list
)
wb
.
save
(
path
+
u'
%
s-
%
s_白条坏账.xlsx'
%
(
year
,
month
))
# df_plan.to_excel(path + u'%s-%s_白条坏账.xlsx' % (year, month), index=None)
bad_debt
(
2017
,
10
)
...
...
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