Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
fund_report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
fund_report
Commits
73d379e2
Commit
73d379e2
authored
Feb 06, 2021
by
withot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复名称显示,用户买入万元以下数据
parent
d309074e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
32 deletions
+31
-32
statement_service.py
app/service/statement_service.py
+31
-32
No files found.
app/service/statement_service.py
View file @
73d379e2
...
@@ -12,7 +12,7 @@ from datetime import datetime, date
...
@@ -12,7 +12,7 @@ from datetime import datetime, date
from
decimal
import
Decimal
from
decimal
import
Decimal
from
app.api.engine
import
tamp_order_engine
,
tamp_user_engine
,
tamp_diagnose_app_engine
,
TAMP_SQL
from
app.api.engine
import
tamp_order_engine
,
tamp_user_engine
,
tamp_diagnose_app_engine
,
TAMP_SQL
# from app.service.data_service_v2_1 import *
# from app.service.data_service_v2_1 import *
from
app.service.customer
import
get_customer_list
#
from app.service.customer import get_customer_list
from
app.service.portfolio_diagnose
import
get_fund_name
from
app.service.portfolio_diagnose
import
get_fund_name
...
@@ -51,7 +51,7 @@ def get_provision_info(user_id):
...
@@ -51,7 +51,7 @@ def get_provision_info(user_id):
cur
=
tamp_order_session
.
execute
(
sql
)
cur
=
tamp_order_session
.
execute
(
sql
)
data
=
cur
.
fetchall
()
data
=
cur
.
fetchall
()
provision_df
=
pd
.
DataFrame
(
list
(
data
),
provision_df
=
pd
.
DataFrame
(
list
(
data
),
columns
=
[
'id'
,
'ifa_id'
,
'customer_id'
,
'
fund_id'
,
'order
_id'
,
'fund_nav'
,
'fund_nav_date'
,
columns
=
[
'id'
,
'ifa_id'
,
'customer_id'
,
'
order_id'
,
'fund
_id'
,
'fund_nav'
,
'fund_nav_date'
,
'predict_date'
,
'pro_date'
,
'pro_type'
,
'predict_date'
,
'pro_date'
,
'pro_type'
,
'manage_predict_fee'
,
'permc_exc_predict_fee'
,
'permc_rem_predict_fee'
,
'manage_predict_fee'
,
'permc_exc_predict_fee'
,
'permc_rem_predict_fee'
,
'manage_fee'
,
'permc_exc_fee'
,
'permc_rem_fee'
,
'recommend_ifa_id'
,
'manage_fee'
,
'permc_exc_fee'
,
'permc_rem_fee'
,
'recommend_ifa_id'
,
...
@@ -171,9 +171,7 @@ class Statement(object):
...
@@ -171,9 +171,7 @@ class Statement(object):
provision_quarterly
=
self
.
ifa_provision
[
provision_quarterly
=
self
.
ifa_provision
[
(
self
.
ifa_provision
[
'predict_date'
]
>=
start_date
)
&
(
self
.
ifa_provision
[
'predict_date'
]
>=
start_date
)
&
(
self
.
ifa_provision
[
'predict_date'
]
<
end_date
.
date
())]
(
self
.
ifa_provision
[
'predict_date'
]
<
end_date
.
date
())]
processed_provision
=
list
(
provision_quarterly
.
groupby
([
provision_quarterly
.
customer_id
,
return
provision_quarterly
provision_quarterly
.
fund_id
]))
return
processed_provision
def
trade_record
(
self
):
def
trade_record
(
self
):
ifa_cus_order_info
=
list
(
self
.
ifa_order
.
groupby
(
self
.
ifa_order
.
customer_id
))
ifa_cus_order_info
=
list
(
self
.
ifa_order
.
groupby
(
self
.
ifa_order
.
customer_id
))
...
@@ -181,11 +179,12 @@ class Statement(object):
...
@@ -181,11 +179,12 @@ class Statement(object):
trade_record_data
=
[]
trade_record_data
=
[]
for
customer
in
ifa_cus_order_info
:
for
customer
in
ifa_cus_order_info
:
customer_df
=
customer
[
1
]
customer_df
=
customer
[
1
]
customer_df
=
customer_df
[
customer_df
[
'order_type'
]
!=
4
]
df_length
=
customer_df
[
'fund_id'
]
.
count
()
df_length
=
customer_df
[
'fund_id'
]
.
count
()
detail
=
[]
detail
=
[]
for
i
in
range
(
df_length
):
for
i
in
range
(
df_length
):
detail
.
append
({
'fund'
:
customer_df
[
'fund_id'
]
.
values
[
i
],
detail
.
append
({
'fund'
:
get_fund_name
(
customer_df
[
'fund_id'
]
.
values
[
i
])
.
values
[
0
][
0
],
'pay_date'
:
np
.
datetime_as_string
(
customer_df
[
'pay_date'
]
.
values
[
i
],
unit
=
'D'
),
'pay_date'
:
np
.
datetime_as_string
(
customer_df
[
'pay_date'
]
.
values
[
i
],
unit
=
'D'
),
'confirm_share_date'
:
np
.
datetime_as_string
(
customer_df
[
'confirm_share_date'
]
.
values
[
i
],
'confirm_share_date'
:
np
.
datetime_as_string
(
customer_df
[
'confirm_share_date'
]
.
values
[
i
],
unit
=
'D'
),
unit
=
'D'
),
...
@@ -197,7 +196,7 @@ class Statement(object):
...
@@ -197,7 +196,7 @@ class Statement(object):
total_amount
=
cal_total_amount
(
customer_df
)
total_amount
=
cal_total_amount
(
customer_df
)
trade_record_data
.
append
({
'customer'
:
customer_df
[
'customer_name'
]
.
values
[
0
],
trade_record_data
.
append
({
'customer'
:
customer_df
[
'customer_name'
]
.
values
[
0
],
'total_amount'
:
Decimal
(
round
(
float
(
total_amount
)
/
10000.0
,
2
)),
'total_amount'
:
Decimal
(
round
(
float
(
total_amount
)
/
10000.0
,
6
)),
'detail'
:
detail
})
'detail'
:
detail
})
return
trade_record_data
return
trade_record_data
...
@@ -235,11 +234,11 @@ class Statement(object):
...
@@ -235,11 +234,11 @@ class Statement(object):
month_remain_data
[
'bonus_policy'
]
=
bonus_policy
month_remain_data
[
'bonus_policy'
]
=
bonus_policy
bonus_image
=
[]
bonus_image
=
[]
bonus_image
.
append
({
'goal_value'
:
float
(
quarter_amount
)
/
500000.0
,
'goal'
:
'5000万目标'
})
bonus_image
.
append
({
'goal_value'
:
round
(
float
(
quarter_amount
)
/
3.0
/
500000.0
,
2
)
,
'goal'
:
'5000万目标'
})
bonus_image
.
append
({
'goal_value'
:
float
(
quarter_amount
)
/
400000.0
,
'goal'
:
'4000万目标'
})
bonus_image
.
append
({
'goal_value'
:
round
(
float
(
quarter_amount
)
/
3.0
/
400000.0
,
2
)
,
'goal'
:
'4000万目标'
})
bonus_image
.
append
({
'goal_value'
:
float
(
quarter_amount
)
/
300000.0
,
'goal'
:
'3000万目标'
})
bonus_image
.
append
({
'goal_value'
:
round
(
float
(
quarter_amount
)
/
3.0
/
300000.0
,
2
)
,
'goal'
:
'3000万目标'
})
bonus_image
.
append
({
'goal_value'
:
float
(
quarter_amount
)
/
200000.0
,
'goal'
:
'2000万目标'
})
bonus_image
.
append
({
'goal_value'
:
round
(
float
(
quarter_amount
)
/
3.0
/
200000.0
,
2
)
,
'goal'
:
'2000万目标'
})
bonus_image
.
append
({
'goal_value'
:
float
(
quarter_amount
)
/
100000.0
,
'goal'
:
'1000万目标'
})
bonus_image
.
append
({
'goal_value'
:
round
(
float
(
quarter_amount
)
/
3.0
/
100000.0
,
2
)
,
'goal'
:
'1000万目标'
})
month_remain_data
[
'bonus_image'
]
=
bonus_image
month_remain_data
[
'bonus_image'
]
=
bonus_image
return
month_remain_data
return
month_remain_data
...
@@ -266,7 +265,7 @@ class Statement(object):
...
@@ -266,7 +265,7 @@ class Statement(object):
for
i
in
range
(
df_length
):
for
i
in
range
(
df_length
):
tax_rate
=
get_tax_rate
()
tax_rate
=
get_tax_rate
()
detail
.
append
({
'fund'
:
customer_df
[
'fund_id'
]
.
values
[
i
],
detail
.
append
({
'fund'
:
get_fund_name
(
customer_df
[
'fund_id'
]
.
values
[
i
])
.
values
[
0
][
0
],
'confirm_amount'
:
customer_df
[
'confirm_amount'
]
.
values
[
i
],
'confirm_amount'
:
customer_df
[
'confirm_amount'
]
.
values
[
i
],
'pay_date'
:
np
.
datetime_as_string
(
customer_df
[
'pay_date'
]
.
values
[
i
],
unit
=
'D'
),
'pay_date'
:
np
.
datetime_as_string
(
customer_df
[
'pay_date'
]
.
values
[
i
],
unit
=
'D'
),
'subscription_fee'
:
customer_df
[
'subscription_fee'
]
.
values
[
i
],
'subscription_fee'
:
customer_df
[
'subscription_fee'
]
.
values
[
i
],
...
@@ -296,16 +295,18 @@ class Statement(object):
...
@@ -296,16 +295,18 @@ class Statement(object):
total_after_tax
=
0
total_after_tax
=
0
customer_detail
=
[]
customer_detail
=
[]
processed_provision
=
self
.
process_provision
()
provision_quarterly
=
self
.
process_provision
()
processed_provision
=
list
(
provision_quarterly
.
groupby
([
provision_quarterly
.
customer_id
,
provision_quarterly
.
fund_id
]))
for
customer_fund
in
processed_provision
:
for
customer_fund
in
processed_provision
:
customer_id
=
customer_fund
[
0
][
0
]
customer_id
=
customer_fund
[
0
][
0
]
customer_name
=
self
.
ifa_order
[
self
.
ifa_order
[
'customer_id'
]
==
customer_id
][
'customer_name'
]
.
values
[
0
]
customer_name
=
self
.
ifa_order
[
self
.
ifa_order
[
'customer_id'
]
==
customer_id
][
'customer_name'
]
.
values
[
0
]
fund_id
=
customer_fund
[
0
][
1
]
try
:
fund_name
=
get_fund_name
(
fund_id
)
.
values
[
0
][
0
]
except
:
fund_name
=
fund_id
customer_fund_df
=
customer_fund
[
1
]
customer_fund_df
=
customer_fund
[
1
]
fund_id
=
customer_fund_df
[
'fund_id'
]
.
values
[
0
]
fund_name
=
get_fund_name
(
fund_id
)
.
values
[
0
][
0
]
df_length
=
customer_fund_df
[
'predict_date'
]
.
count
()
df_length
=
customer_fund_df
[
'predict_date'
]
.
count
()
before_tax
=
0
before_tax
=
0
after_tax
=
0
after_tax
=
0
...
@@ -371,10 +372,9 @@ class Statement(object):
...
@@ -371,10 +372,9 @@ class Statement(object):
provision_carry
=
row
[
'permc_exc_fee'
]
provision_carry
=
row
[
'permc_exc_fee'
]
if
provision_carry
==
0
:
if
provision_carry
==
0
:
continue
continue
try
:
tax_rate
=
get_tax_rate
()
tax_rate
=
get_tax_rate
()
except
:
tax_rate
=
0
customer_id
=
row
[
'customer_id'
]
customer_id
=
row
[
'customer_id'
]
customer_name
=
self
.
ifa_order
[
self
.
ifa_order
[
'customer_id'
]
==
customer_id
][
'customer_name'
]
.
values
[
0
]
customer_name
=
self
.
ifa_order
[
self
.
ifa_order
[
'customer_id'
]
==
customer_id
][
'customer_name'
]
.
values
[
0
]
order_id
=
row
[
'order_id'
]
order_id
=
row
[
'order_id'
]
...
@@ -415,15 +415,16 @@ class Statement(object):
...
@@ -415,15 +415,16 @@ class Statement(object):
total_after_tax
=
0
total_after_tax
=
0
customer_detail
=
[]
customer_detail
=
[]
processed_provision
=
self
.
process_provision
()
provision_quarterly
=
self
.
process_provision
()
processed_provision
=
list
(
provision_quarterly
.
groupby
([
provision_quarterly
.
customer_id
,
provision_quarterly
.
fund_id
]))
for
customer_fund
in
processed_provision
:
for
customer_fund
in
processed_provision
:
customer_id
=
customer_fund
[
0
][
0
]
customer_id
=
customer_fund
[
0
][
0
]
customer_name
=
self
.
ifa_order
[
self
.
ifa_order
[
'customer_id'
]
==
customer_id
][
'customer_name'
]
.
values
[
0
]
customer_name
=
self
.
ifa_order
[
self
.
ifa_order
[
'customer_id'
]
==
customer_id
][
'customer_name'
]
.
values
[
0
]
fund_id
=
customer_fund
[
0
][
1
]
fund_id
=
customer_fund
[
0
][
1
]
try
:
fund_name
=
get_fund_name
(
fund_id
)
.
values
[
0
][
0
]
fund_name
=
get_fund_name
(
fund_id
)
.
values
[
0
][
0
]
except
:
fund_name
=
fund_id
customer_fund_df
=
customer_fund
[
1
]
customer_fund_df
=
customer_fund
[
1
]
incentive_rate_sum
=
customer_fund_df
[
'incentive_fee_ratio'
]
.
sum
()
incentive_rate_sum
=
customer_fund_df
[
'incentive_fee_ratio'
]
.
sum
()
if
incentive_rate_sum
==
0
:
if
incentive_rate_sum
==
0
:
...
@@ -436,10 +437,8 @@ class Statement(object):
...
@@ -436,10 +437,8 @@ class Statement(object):
incentive_rate
=
customer_fund_df
[
'incentive_fee_ratio'
]
.
values
[
i
]
incentive_rate
=
customer_fund_df
[
'incentive_fee_ratio'
]
.
values
[
i
]
if
incentive_rate
==
0
:
if
incentive_rate
==
0
:
continue
continue
try
:
tax_rate
=
get_tax_rate
()
tax_rate
=
get_tax_rate
()
except
:
tax_rate
=
0
detail
.
append
({
'date'
:
customer_fund_df
[
'predict_date'
]
.
values
[
i
]
.
strftime
(
'
%
Y-
%
m-
%
d'
),
detail
.
append
({
'date'
:
customer_fund_df
[
'predict_date'
]
.
values
[
i
]
.
strftime
(
'
%
Y-
%
m-
%
d'
),
'hold_share'
:
customer_fund_df
[
'retention_shares'
]
.
values
[
i
],
'hold_share'
:
customer_fund_df
[
'retention_shares'
]
.
values
[
i
],
...
...
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