Commit 13d3d23f authored by xianyang's avatar xianyang

优化公会质押金,新增首页查询

parent 48c493eb
...@@ -10,7 +10,7 @@ from core.config.env import env ...@@ -10,7 +10,7 @@ from core.config.env import env
from libs.business import TYPE_NAME, query_fi_account_type from libs.business import TYPE_NAME, query_fi_account_type
from libs.db_link import LinkMysql from libs.db_link import LinkMysql
from libs.functions import wrapper_out, get_now_timestamp, uuid, get_before_timestamp, time_str_to_timestamp, \ from libs.functions import wrapper_out, get_now_timestamp, uuid, get_before_timestamp, time_str_to_timestamp, \
get_yesterday_timestamp, search, get_last_month get_yesterday_timestamp, search, get_last_month, get_date_list
from libs.orm import QueryAllData from libs.orm import QueryAllData
from models import account as models from models import account as models
from models.account import AccountFinance, AccountFinanceDetails, AccountType from models.account import AccountFinance, AccountFinanceDetails, AccountType
...@@ -420,6 +420,9 @@ class AccountStatistics(object): ...@@ -420,6 +420,9 @@ class AccountStatistics(object):
if self.unique == 'guild_account': if self.unique == 'guild_account':
data, total = self.guild_calculation() data, total = self.guild_calculation()
return data, total, 0 return data, total, 0
if self.unique == "pledgeDeduction":
data, total = self. guild_calculation_pledge()
return data, total, 0
if self.unique == "user_account": if self.unique == "user_account":
if self.user_id: if self.user_id:
user_sql = f"select uuid from v2_user where user_id={self.user_id}" user_sql = f"select uuid from v2_user where user_id={self.user_id}"
...@@ -477,6 +480,33 @@ class AccountStatistics(object): ...@@ -477,6 +480,33 @@ class AccountStatistics(object):
mysql_data = LinkMysql(env.DB_3YV2).query_mysql(sql) mysql_data = LinkMysql(env.DB_3YV2).query_mysql(sql)
return mysql_data[int(self.page - 1) * self.size: self.page * self.size], len(mysql_data) return mysql_data[int(self.page - 1) * self.size: self.page * self.size], len(mysql_data)
def guild_calculation_pledge(self):
"""公会质押金处理"""
cp_cond = []
start_time = time_str_to_timestamp(self.start_time + ' 00:00:00')
end_time = time_str_to_timestamp(self.end_time + ' 23:59:59')
month_tuple = get_date_list(self.start_time, self.end_time)
cp_cond.append(f" create_time >={start_time} and create_time<= {end_time}")
cp_cond.append(" (income != 0 or outcome !=0 or initial_money !=0) ")
if self.user_id:
guild_sql = f"select ice_uuid from guild where id={self.user_id}"
res_data = LinkMysql(env.DB_3YV2).query_mysql(guild_sql)
if not res_data:
return [], 0
cp_cond.append(f" uuid='{res_data[0]['ice_uuid']}'")
result_list = []
for i in month_tuple:
year, month = str(i)[:4], str(i)[4:]
table = 'finance_data_calculation_pledge' + year + '_' + month
try:
cp_sql = f"SELECT FROM_UNIXTIME(create_time, '%Y-%c-%d') as create_time,uuid,income,outcome,initial_money from {table} WHERE {' and '.join(cp_cond)} GROUP BY create_time, uuid ORDER BY create_time DESC"
mysql_data = LinkMysql(env.DB_3YV2).query_mysql(cp_sql)
result_list = result_list + mysql_data
except Exception as e:
print(f"没有此表{table},或者检查:{cp_sql},是否正确!")
continue
return result_list[int(self.page - 1) * self.size: self.page * self.size], len(result_list)
def delete_specify_field(data): def delete_specify_field(data):
res_list = [] 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