Commit 10c56564 authored by xianyang's avatar xianyang

优化特定账户明细

parent a2b3e008
...@@ -277,7 +277,7 @@ class AccountStatistics(object): ...@@ -277,7 +277,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,SUM(cast(amount as decimal(20,6)))/1000 as amount,FROM_UNIXTIME(create_time, '%y%m%d') as create_time,amount_type from {date} WHERE {' and '.join(condition)} GROUP BY uuid,type ORDER BY FROM_UNIXTIME(create_time, '%y%m%d') DESC" 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"
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"
...@@ -293,10 +293,11 @@ class AccountStatistics(object): ...@@ -293,10 +293,11 @@ class AccountStatistics(object):
with ThreadPoolExecutor(max_workers=2) as pool: with ThreadPoolExecutor(max_workers=2) as pool:
guild = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, guild_sql) guild = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, guild_sql)
system = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, system_sql) system = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, system_sql)
guild_uuid_list = guild.result() guild_list = guild.result()
system_uuid_list = system.result() system_list = system.result()
res_list = [] res_list = []
if self.unique == 'guild_account': if self.unique == 'guild_account':
guild_uuid_list = [i.get('uuid') for i in guild_list]
for info in data: for info in data:
if info.get('uuid') in guild_uuid_list: if info.get('uuid') in guild_uuid_list:
res_list.append(info) res_list.append(info)
...@@ -305,6 +306,8 @@ class AccountStatistics(object): ...@@ -305,6 +306,8 @@ class AccountStatistics(object):
if info.get('amount_type') == 'backpack': if info.get('amount_type') == 'backpack':
res_list.append(info) res_list.append(info)
if self.unique == 'user_account': if self.unique == 'user_account':
guild_uuid_list = [i.get('uuid') for i in guild_list]
system_uuid_list = [i.get('uuid') for i in system_list]
for info in data: for info in data:
if info.get('uuid') not in guild_uuid_list and info.get('uuid') not in system_uuid_list: if info.get('uuid') not in guild_uuid_list and info.get('uuid') not in system_uuid_list:
res_list.append(info) res_list.append(info)
...@@ -359,12 +362,12 @@ class AccountStatistics(object): ...@@ -359,12 +362,12 @@ class AccountStatistics(object):
class SpecificAccountQuery(object): class SpecificAccountQuery(object):
"""账户用户,背包,公会第四层查询""" """账户用户,背包,公会第四层查询"""
def __init__(self, page, size, uuid, start_time, end_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
self.uuid = uuid self.uuid = uuid
self.start_time = start_time self.start_time = time
self.end_time = end_time self.end_time = time
self.type = type self.type = type
self.reference_type = reference_type self.reference_type = reference_type
self.total_list = [] self.total_list = []
......
...@@ -102,16 +102,15 @@ def finance_info_excel(data: schemas.FinanceDetails, request: Request, ...@@ -102,16 +102,15 @@ def finance_info_excel(data: schemas.FinanceDetails, request: Request,
@router.get("/finance/fourth/details") @router.get("/finance/fourth/details")
def finance_fourth_info(page: int, def finance_fourth_info(page: int,
size: int, size: int,
uuid: str, uuid: Optional[str] = "",
start_time: Optional[str] = "", time: Optional[str] = "",
end_time: Optional[str] = "",
type: Optional[int] = None, type: Optional[int] = None,
reference_type: Optional[str] = "", reference_type: Optional[str] = "",
token=Depends(login_required)): token=Depends(login_required)):
"""账户财务明细 第四层""" """账户财务明细 第四层"""
if not all([uuid, start_time, end_time]): if not all([uuid, time]):
return HttpResultResponse(code=500, msg="缺少必传参数") return HttpResultResponse(code=500, msg="缺少必传参数")
res, total, count = SpecificAccountQuery(page, size, uuid, start_time, end_time, type, res, total, count = SpecificAccountQuery(page, size, uuid, time, type,
reference_type).business_logic() reference_type).business_logic()
return HttpResultResponse(total=total, data=res, count=count) return HttpResultResponse(total=total, data=res, count=count)
......
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