Commit 73d379e2 authored by withot's avatar withot

修复名称显示,用户买入万元以下数据

parent d309074e
......@@ -12,7 +12,7 @@ from datetime import datetime, date
from decimal import Decimal
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.customer import get_customer_list
# from app.service.customer import get_customer_list
from app.service.portfolio_diagnose import get_fund_name
......@@ -51,7 +51,7 @@ def get_provision_info(user_id):
cur = tamp_order_session.execute(sql)
data = cur.fetchall()
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',
'manage_predict_fee', 'permc_exc_predict_fee', 'permc_rem_predict_fee',
'manage_fee', 'permc_exc_fee','permc_rem_fee', 'recommend_ifa_id',
......@@ -171,9 +171,7 @@ class Statement(object):
provision_quarterly = self.ifa_provision[
(self.ifa_provision['predict_date'] >= start_date) &
(self.ifa_provision['predict_date'] < end_date.date())]
processed_provision = list(provision_quarterly.groupby([provision_quarterly.customer_id,
provision_quarterly.fund_id]))
return processed_provision
return provision_quarterly
def trade_record(self):
ifa_cus_order_info = list(self.ifa_order.groupby(self.ifa_order.customer_id))
......@@ -181,11 +179,12 @@ class Statement(object):
trade_record_data = []
for customer in ifa_cus_order_info:
customer_df = customer[1]
customer_df = customer_df[customer_df['order_type']!=4]
df_length = customer_df['fund_id'].count()
detail = []
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'),
'confirm_share_date': np.datetime_as_string(customer_df['confirm_share_date'].values[i],
unit='D'),
......@@ -197,7 +196,7 @@ class Statement(object):
total_amount = cal_total_amount(customer_df)
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})
return trade_record_data
......@@ -235,11 +234,11 @@ class Statement(object):
month_remain_data['bonus_policy'] = bonus_policy
bonus_image = []
bonus_image.append({'goal_value': float(quarter_amount)/500000.0, 'goal': '5000万目标'})
bonus_image.append({'goal_value': float(quarter_amount)/400000.0, 'goal': '4000万目标'})
bonus_image.append({'goal_value': float(quarter_amount)/300000.0, 'goal': '3000万目标'})
bonus_image.append({'goal_value': float(quarter_amount)/200000.0, '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/500000.0,2), 'goal': '5000万目标'})
bonus_image.append({'goal_value': round(float(quarter_amount)/3.0/400000.0,2), 'goal': '4000万目标'})
bonus_image.append({'goal_value': round(float(quarter_amount)/3.0/300000.0,2), 'goal': '3000万目标'})
bonus_image.append({'goal_value': round(float(quarter_amount)/3.0/200000.0,2), 'goal': '2000万目标'})
bonus_image.append({'goal_value': round(float(quarter_amount)/3.0/100000.0,2), 'goal': '1000万目标'})
month_remain_data['bonus_image'] = bonus_image
return month_remain_data
......@@ -266,7 +265,7 @@ class Statement(object):
for i in range(df_length):
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],
'pay_date': np.datetime_as_string(customer_df['pay_date'].values[i], unit='D'),
'subscription_fee': customer_df['subscription_fee'].values[i],
......@@ -296,16 +295,18 @@ class Statement(object):
total_after_tax = 0
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:
customer_id = customer_fund[0][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]
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()
before_tax = 0
after_tax = 0
......@@ -371,10 +372,9 @@ class Statement(object):
provision_carry = row['permc_exc_fee']
if provision_carry == 0:
continue
try:
tax_rate = get_tax_rate()
except:
tax_rate = 0
customer_id = row['customer_id']
customer_name = self.ifa_order[self.ifa_order['customer_id'] == customer_id]['customer_name'].values[0]
order_id = row['order_id']
......@@ -415,15 +415,16 @@ class Statement(object):
total_after_tax = 0
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:
customer_id = customer_fund[0][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]
incentive_rate_sum = customer_fund_df['incentive_fee_ratio'].sum()
if incentive_rate_sum == 0:
......@@ -436,10 +437,8 @@ class Statement(object):
incentive_rate = customer_fund_df['incentive_fee_ratio'].values[i]
if incentive_rate == 0:
continue
try:
tax_rate = get_tax_rate()
except:
tax_rate = 0
detail.append({'date': customer_fund_df['predict_date'].values[i].strftime('%Y-%m-%d'),
'hold_share': customer_fund_df['retention_shares'].values[i],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment