Commit e4827c7d authored by 李宗熹's avatar 李宗熹

获取公募基金名称

parent 46e8a56c
...@@ -23,41 +23,38 @@ class DateEncoder(json.JSONEncoder): ...@@ -23,41 +23,38 @@ class DateEncoder(json.JSONEncoder):
return json.JSONEncoder.default(self, obj) return json.JSONEncoder.default(self, obj)
def get_fund_name(fund, fund_type=1): def get_fund_name(fund):
if fund_type == 0: with TAMP_SQL(tamp_fund_engine) as tamp_fund:
with TAMP_SQL(tamp_fund_engine) as tamp_fund: tamp_fund_session = tamp_fund.session
tamp_fund_session = tamp_fund.session sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund)
sql = "SELECT fund_short_name FROM tx_fund_info WHERE `id`='{}'".format(fund) # df = pd.read_sql(sql, con)
# df = pd.read_sql(sql, con) cur = tamp_fund_session.execute(sql)
cur = tamp_fund_session.execute(sql) data = cur.fetchall()
data = cur.fetchall() df = pd.DataFrame(list(data), columns=['fund_short_name'])
df = pd.DataFrame(list(data), columns=['fund_short_name']) if len(df) == 0:
with TAMP_SQL(tamp_product_engine) as tamp_product:
elif fund_type == 1 or fund_type == 2: tamp_product_session = tamp_product.session
with TAMP_SQL(tamp_fund_engine) as tamp_fund: sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund)
tamp_fund_session = tamp_fund.session # df = pd.read_sql(sql, con)
sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund) cur = tamp_product_session.execute(sql)
# df = pd.read_sql(sql, con) data = cur.fetchall()
cur = tamp_fund_session.execute(sql) df = pd.DataFrame(list(data), columns=['fund_short_name'])
data = cur.fetchall()
df = pd.DataFrame(list(data), columns=['fund_short_name'])
if len(df) == 0: if len(df) == 0:
with TAMP_SQL(tamp_product_engine) as tamp_product: with TAMP_SQL(tamp_fund_engine) as tamp_fund:
tamp_product_session = tamp_product.session tamp_fund_session = tamp_fund.session
sql = "SELECT fund_short_name FROM fund_info WHERE id='{}'".format(fund) sql = "SELECT fund_short_name FROM tx_fund_info WHERE `id`='{}'".format(fund)
# df = pd.read_sql(sql, con) # df = pd.read_sql(sql, con)
cur = tamp_product_session.execute(sql) cur = tamp_fund_session.execute(sql)
data = cur.fetchall() data = cur.fetchall()
df = pd.DataFrame(list(data), columns=['fund_short_name']) df = pd.DataFrame(list(data), columns=['fund_short_name'])
if len(df) == 0:
else: with TAMP_SQL(tamp_fund_engine) as tamp_fund:
with TAMP_SQL(tamp_fund_engine) as tamp_fund: tamp_fund_session = tamp_fund.session
tamp_fund_session = tamp_fund.session sql = "SELECT fund_name FROM ifa_imported_fund_info WHERE id='{}'".format(fund)
sql = "SELECT fund_name FROM ifa_imported_fund_info WHERE id='{}'".format(fund) # df = pd.read_sql(sql, con)
# df = pd.read_sql(sql, con) cur = tamp_fund_session.execute(sql)
cur = tamp_fund_session.execute(sql) data = cur.fetchall()
data = cur.fetchall() df = pd.DataFrame(list(data), columns=['fund_short_name'])
df = pd.DataFrame(list(data), columns=['fund_short_name'])
if df.fund_short_name.count() > 0: if df.fund_short_name.count() > 0:
return df.fund_short_name.values[0] return df.fund_short_name.values[0]
...@@ -188,7 +185,10 @@ class Statement(object): ...@@ -188,7 +185,10 @@ class Statement(object):
def order_history(self): def order_history(self):
ifa_order = get_order_info(self.user_id) ifa_order = get_order_info(self.user_id)
ifa_name = ifa_order['user_name'].values[0] try:
ifa_name = ifa_order['user_name'].values[0]
except:
ifa_name = '用户'
try: try:
ifa_gender = ifa_order['value_sex'].values[0] ifa_gender = ifa_order['value_sex'].values[0]
except: except:
...@@ -293,7 +293,7 @@ class Statement(object): ...@@ -293,7 +293,7 @@ class Statement(object):
end_date = get_end_date(year, max(month_list)) end_date = get_end_date(year, max(month_list))
order_quarterly = self.ifa_order[(self.ifa_order['pay_date'] >= start_date) & order_quarterly = self.ifa_order[(self.ifa_order['pay_date'] >= start_date) &
(self.ifa_order['pay_date'] < end_date) & (self.ifa_order['pay_date'] < end_date) &
(self.ifa_order['order_type'] != 4)] (self.ifa_order['order_type'] == 1)]
ifa_cus_order_monthly = list(order_quarterly.groupby(order_quarterly.customer_id)) ifa_cus_order_monthly = list(order_quarterly.groupby(order_quarterly.customer_id))
for customer in ifa_cus_order_monthly: for customer in ifa_cus_order_monthly:
...@@ -304,6 +304,8 @@ class Statement(object): ...@@ -304,6 +304,8 @@ class Statement(object):
detail = [] detail = []
for i in range(df_length): for i in range(df_length):
tax_rate = get_tax_rate() tax_rate = get_tax_rate()
if customer_df['subscription_fee'].values[i] is None:
continue
detail.append({'fund': get_fund_name(customer_df['fund_id'].values[i]), detail.append({'fund': get_fund_name(customer_df['fund_id'].values[i]),
'confirm_amount': customer_df['confirm_amount'].values[i], 'confirm_amount': customer_df['confirm_amount'].values[i],
...@@ -419,16 +421,16 @@ class Statement(object): ...@@ -419,16 +421,16 @@ class Statement(object):
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']
order_type = type2note(self.ifa_order[self.ifa_order['order_id'] == order_id]['order_type'].values[0]) order_type = type2note(self.ifa_order[self.ifa_order['order_id'] == order_id]['order_type'].values[0])
confirm_date = self.ifa_order[self.ifa_order['order_id'] == order_id]['confirm_date'].values[0] confirm_date = self.ifa_order[self.ifa_order['order_id'] == order_id]['confirm_share_date'].values[0]
nav = self.ifa_order[self.ifa_order['order_id'] == order_id]['nav'].values[0] nav = self.ifa_order[self.ifa_order['order_id'] == order_id]['nav'].values[0]
native_amount = nav native_amount = nav
provision_date = self.ifa_order[self.ifa_order['order_id'] == order_id]['confirm_date'].values[0] provision_date = self.ifa_order[self.ifa_order['order_id'] == order_id]['confirm_share_date'].values[0]
detail.append({'customer': customer_name, detail.append({'customer': customer_name,
'order_type': order_type, 'order_type': order_type,
'confirm_date': confirm_date, 'confirm_date': np.datetime_as_string(confirm_date, unit='D'),
'native_amount': native_amount, 'native_amount': native_amount,
'nav': nav, 'nav': nav,
'provision_date': provision_date, 'provision_date': np.datetime_as_string(provision_date, unit='D'),
'provision_carry': provision_carry} 'provision_carry': provision_carry}
) )
......
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