Commit 87b9e3a9 authored by xianyang's avatar xianyang

优化账户列表排序

parent 5ef4ee00
......@@ -239,33 +239,33 @@ def get_finance_info(unique_tag, id, page, size, start_time, end_time, is_list=N
if unique_tag == 'guild_account':
finance_condition.append('amount_type=1')
count_sql = f"select create_time from v3_guild_account_statistics_copy where {' and '.join(finance_condition)} GROUP BY create_time"
data_sql = f"select id,initial_money as balance,income,outcome,create_time from v3_guild_account_statistics_copy where {' and '.join(finance_condition)} GROUP BY create_time order by create_time DESC limit {(int(page) - 1) * size},{size}"
data_sql = f"select id,initial_money as balance,income,outcome,create_time from v3_guild_account_statistics_copy where {' and '.join(finance_condition)} GROUP BY create_time order by create_time limit {(int(page) - 1) * size},{size}"
other_sql = f"select initial_money as balance,income,outcome,create_time,amount_type from v3_guild_account_statistics_copy where amount_type != 1"
if unique_tag == 'anchor_account':
if finance_condition:
conditions = [i.replace('create_time', 'date') for i in finance_condition]
count_sql = f"select date as create_time from v3_user_account_statistics where {' and '.join(conditions)} GROUP BY date"
data_sql = f"select id,initial_money as balance,income,pay as outcome,date as create_time from v3_user_account_statistics where {' and '.join(conditions)} GROUP BY date order by date DESC limit {(int(page) - 1) * size},{size}"
data_sql = f"select id,initial_money as balance,income,pay as outcome,date as create_time from v3_user_account_statistics where {' and '.join(conditions)} GROUP BY date order by date limit {(int(page) - 1) * size},{size}"
else:
count_sql = f"select date as create_time from v3_user_account_statistics GROUP BY date"
data_sql = f"select id,initial_money as balance,income,pay as outcome,date as create_time from v3_user_account_statistics GROUP BY date order by date DESC limit {(int(page) - 1) * size},{size}"
data_sql = f"select id,initial_money as balance,income,pay as outcome,date as create_time from v3_user_account_statistics GROUP BY date order by date limit {(int(page) - 1) * size},{size}"
if unique_tag == 'user_account':
finance_condition.append('type=1')
condition = [i.replace('create_time', 'calculation_time') for i in finance_condition]
other_sql = f"select initial_money as balance,income,outcome,calculation_time as create_time,amount_type from finance_data_calculation_sum_copy where {' and '.join(condition)} and amount_type != 1"
condition.append('amount_type=1')
count_sql = f"select calculation_time from finance_data_calculation_sum_copy where {' and '.join(condition)} GROUP BY calculation_time"
data_sql = f"select id,initial_money as balance,income,outcome,calculation_time as create_time from finance_data_calculation_sum_copy where {' and '.join(condition)} GROUP BY calculation_time order by calculation_time DESC limit {(int(page) - 1) * size},{size}"
data_sql = f"select id,initial_money as balance,income,outcome,calculation_time as create_time from finance_data_calculation_sum_copy where {' and '.join(condition)} GROUP BY calculation_time order by calculation_time limit {(int(page) - 1) * size},{size}"
if unique_tag == 'knapsack_account':
finance_condition.append('amount_type=1')
condition = [i.replace('create_time', 'calculation_time') for i in finance_condition]
count_sql = f"select calculation_time from finance_data_calculation_sum_copy where type=4 and {' and '.join(condition)} GROUP BY calculation_time"
data_sql = f"select id,initial_money as balance,income,outcome,calculation_time as create_time from finance_data_calculation_sum_copy where type=4 and {' and '.join(condition)} GROUP BY calculation_time order by calculation_time DESC limit {(int(page) - 1) * size},{size}"
data_sql = f"select id,initial_money as balance,income,outcome,calculation_time as create_time from finance_data_calculation_sum_copy where type=4 and {' and '.join(condition)} GROUP BY calculation_time order by calculation_time limit {(int(page) - 1) * size},{size}"
if unique_tag == 'pledgeDeduction':
finance_condition.append('amount_type=1')
condition = [i.replace('create_time', 'calculation_time') for i in finance_condition]
count_sql = f"select calculation_time from finance_data_calculation_sum_copy where type=5 and {' and '.join(condition)} GROUP BY calculation_time"
data_sql = f"select id,initial_money as balance,income,outcome,calculation_time as create_time from finance_data_calculation_sum_copy where type=5 and {' and '.join(condition)} GROUP BY calculation_time order by calculation_time DESC limit {(int(page) - 1) * size},{size}"
data_sql = f"select id,initial_money as balance,income,outcome,calculation_time as create_time from finance_data_calculation_sum_copy where type=5 and {' and '.join(condition)} GROUP BY calculation_time order by calculation_time limit {(int(page) - 1) * size},{size}"
with ThreadPoolExecutor(max_workers=2) as pool:
future1 = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, count_sql)
......@@ -275,7 +275,7 @@ def get_finance_info(unique_tag, id, page, size, start_time, end_time, is_list=N
res = future2.result()
else:
finance_condition.append('amount_type=1')
sys_sql = f"select initial_money as balance,income,outcome,create_time from v2_system_account_statistics_copy where fi_account_id={id} and {' and '.join(finance_condition)} ORDER BY create_time DESC"
sys_sql = f"select initial_money as balance,income,outcome,create_time from v2_system_account_statistics_copy where fi_account_id={id} and {' and '.join(finance_condition)} ORDER BY create_time "
result = LinkMysql(env.DB_3YV2).query_mysql(sys_sql)
res = result[int(page - 1) * size: page * size]
count = result
......
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