Commit 153728e1 authored by xianyang's avatar xianyang

优化测试账户数据查询二版

parent e47d5623
......@@ -326,6 +326,10 @@ class AccountStatistics(object):
public_list.append(f" create_time >= {time_str_to_timestamp(self.start_time + ' 00:00:00')} ")
if self.end_time:
public_list.append(f" create_time <= {time_str_to_timestamp(self.end_time + ' 23:59:59')} ")
if self.unique == 'knapsack_account':
public_list.append(f" amount_type='backpack'")
if self.unique == 'user_account':
public_list.append(f" amount_type in('consumable','withdrawable')")
return public_list
def get_finance_details(self, is_list=None):
......@@ -378,7 +382,7 @@ class AccountStatistics(object):
class SpecificAccountQuery(object):
"""账户用户,背包,公会第四层查询"""
def __init__(self, page, size, uuid, time, type, reference_type):
def __init__(self, page, size, uuid, time, type, reference_type, unique_tag):
self.page = page
self.size = size
self.uuid = uuid
......@@ -386,6 +390,7 @@ class SpecificAccountQuery(object):
self.end_time = time
self._type = type
self.reference_type = reference_type
self.unique_tag = unique_tag
self.total_list = []
def condition_query(self, date, cond_list):
......@@ -404,6 +409,10 @@ class SpecificAccountQuery(object):
condition.append(f" type={self._type}")
if self.reference_type:
condition.append(f" reference_type='{self.reference_type}'")
if self.unique_tag == 'knapsack_account':
condition.append(f" amount_type='backpack'")
if self.unique_tag == 'user_account':
condition.append(f" amount_type in('consumable','withdrawable')")
month, last_month, before_last_month = get_last_month()
with ThreadPoolExecutor(max_workers=3) as pool:
future1 = pool.submit(self.condition_query, 'assets_log_' + month, condition)
......
......@@ -108,12 +108,13 @@ def finance_fourth_info(page: int,
time: Optional[str] = "",
type: Optional[int] = None,
reference_type: Optional[str] = "",
unique_tag: Optional[str] = "",
token=Depends(login_required)):
"""账户财务明细 第四层"""
if not all([uuid, time]):
if not all([uuid, time, unique_tag]):
return HttpResultResponse(code=500, msg="缺少必传参数")
res, total, count = SpecificAccountQuery(page, size, uuid, time, type,
reference_type).business_logic()
reference_type, unique_tag).business_logic()
return HttpResultResponse(total=total, data=res, count=count)
......
......@@ -272,4 +272,10 @@ class ReferenceTypeClassification():
income = pd.DataFrame(self.income)
ogs = outcome.groupby("nickname").sum()
igs = income.groupby("nickname").sum()
return {"outcome": ogs.to_dict().get('money'), "income": igs.to_dict().get('money')}
# 格式化
res_list = []
for k,v in ogs.to_dict().get('money').items():
res_list.append({"type": "出账", "name": k, "money": v})
for k,v in igs.to_dict().get('money').items():
res_list.append({"type": "入账", "name": k, "money": v})
return res_list
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