Commit 5757e0e4 authored by xianyang's avatar xianyang

优化特定账户返回数据

parent 10c56564
...@@ -70,7 +70,8 @@ class HDUd(): ...@@ -70,7 +70,8 @@ class HDUd():
platform_data = search({"uuid": i['uuid']}, 'Server.UserQuery.GetUserAsset') platform_data = search({"uuid": i['uuid']}, 'Server.UserQuery.GetUserAsset')
if platform_data['status']: if platform_data['status']:
try: try:
i['consumable'] = platform_data['data']['result']['data']['asset_balance']['consumable']['current_amount'] i['consumable'] = platform_data['data']['result']['data']['asset_balance']['consumable'][
'current_amount']
except Exception as e: except Exception as e:
print(e) print(e)
i['consumable'] = 0 i['consumable'] = 0
...@@ -262,6 +263,7 @@ def create_type(db: Session, data): ...@@ -262,6 +263,7 @@ def create_type(db: Session, data):
class AccountStatistics(object): class AccountStatistics(object):
"""账户列表,查询""" """账户列表,查询"""
def __init__(self, page, size, uuid, user_id, start_time, end_time, type, gift_type, unique): def __init__(self, page, size, uuid, user_id, start_time, end_time, type, gift_type, unique):
self.page = page self.page = page
self.size = size self.size = size
...@@ -277,7 +279,7 @@ class AccountStatistics(object): ...@@ -277,7 +279,7 @@ class AccountStatistics(object):
def business_query(self, date, condition): def business_query(self, date, condition):
"""业务数据查询""" """业务数据查询"""
if self.unique in ["user_account", "guild_account", "knapsack_account"]: if self.unique in ["user_account", "guild_account", "knapsack_account"]:
u_sql = f"select uuid,type,reference_type,SUM(cast(amount as decimal(20,6)))/1000 as amount,create_time,amount_type from {date} WHERE {' and '.join(condition)} GROUP BY uuid,type" u_sql = f"select uuid,type,reference_type,SUM(cast(amount as decimal(20,6)))/1000 as amount,create_time,amount_type from {date} WHERE {' and '.join(condition)} GROUP BY uuid,type ORDER BY create_time DESC"
else: else:
if condition: if condition:
u_sql = f"select id,uuid,order_number,type,reference_type,amount/1000 as amount,create_time from {date} WHERE {' and '.join(condition)} ORDER BY create_time DESC" u_sql = f"select id,uuid,order_number,type,reference_type,amount/1000 as amount,create_time from {date} WHERE {' and '.join(condition)} ORDER BY create_time DESC"
...@@ -344,6 +346,19 @@ class AccountStatistics(object): ...@@ -344,6 +346,19 @@ class AccountStatistics(object):
ultimately_data = total_list + before_last_data if before_last_data else total_list ultimately_data = total_list + before_last_data if before_last_data else total_list
if self.unique in ["user_account", "guild_account", "knapsack_account"]: if self.unique in ["user_account", "guild_account", "knapsack_account"]:
ultimately_data = self.user_guild_query(total_list) ultimately_data = self.user_guild_query(total_list)
record = []
record_dict = {}
for info in ultimately_data:
res_dict = {'uuid': info.get("uuid"), 'create_time': info.get("create_time"), 'income': 0, 'outcome': 0}
if info.get("uuid") not in record:
record.append(info.get("uuid"))
record_dict[info.get("uuid")] = res_dict
if info.get("type") == 1:
record_dict[info.get("uuid")]['income'] = float(info.get("amount"))
else:
record_dict[info.get("uuid")]['outcome'] = float(info.get("amount"))
res_data = [v for k, v in record_dict.items()]
return res_data[int(self.page - 1) * self.size: self.page * self.size], len(res_data), 0
total = len(ultimately_data) total = len(ultimately_data)
res = ultimately_data[int(self.page - 1) * self.size: self.page * self.size] res = ultimately_data[int(self.page - 1) * self.size: self.page * self.size]
# 判断是列表还是导出接口 # 判断是列表还是导出接口
...@@ -362,6 +377,7 @@ class AccountStatistics(object): ...@@ -362,6 +377,7 @@ class AccountStatistics(object):
class SpecificAccountQuery(object): class SpecificAccountQuery(object):
"""账户用户,背包,公会第四层查询""" """账户用户,背包,公会第四层查询"""
def __init__(self, page, size, uuid, time, type, reference_type): def __init__(self, page, size, uuid, time, type, reference_type):
self.page = page self.page = page
self.size = size self.size = size
......
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