Commit 396a5094 authored by xianyang's avatar xianyang

新增需求

parent 1d522f3f
......@@ -45,7 +45,7 @@ class HDUd():
if i['unique_tag']:
start, end = get_yesterday_timestamp()
if i['unique_tag'] == 'guild_account':
sql = f"select sum(initial_money) as number from v3_guild_account_statistics where create_time>={start} and create_time<{end}"
sql = f"select initial_money as number from v3_guild_account_statistics_copy where create_time>={start} and create_time<{end} ORDER BY create_time DESC"
money_res = LinkMysql(env.DB_3YV2).query_mysql(sql)
i['consumable'] = money_res[0]['number'] if money_res and money_res[0]['number'] else 0
elif i['unique_tag'] == 'anchor_account':
......@@ -81,13 +81,13 @@ class HDUd():
def get_account_list(self, name, page, size):
"""账户列表,查询"""
if name:
count_sql = f"select count(id) as num from fi_account where name like '%{name}%' and unique_tag!='anchor_account'"
count_sql = f"select count(id) as num from fi_account where name like '%{name}%' and unique_tag!='anchor_account' order by create_time"
number = LinkMysql(env.DB_3YV2).query_mysql(count_sql)
if number:
count = number[0].get("num")
else:
count = 0
data_sql = f"select id,name,unique_tag,uuid,config_key,beneficiary,description,create_time, income, output from fi_account where name like '%{name}%' and unique_tag!='anchor_account' ORDER BY id LIMIT {(int(page) - 1) * size},{size}"
data_sql = f"select id,name,unique_tag,uuid,config_key,beneficiary,description,create_time, income, output from fi_account where name like '%{name}%' and unique_tag!='anchor_account' ORDER BY create_time LIMIT {(int(page) - 1) * size},{size}"
query_res = LinkMysql(env.DB_3YV2).query_mysql(data_sql)
else:
count_sql = f"select count(id) as num from fi_account where unique_tag!='anchor_account'"
......@@ -96,7 +96,7 @@ class HDUd():
count = number[0].get("num")
else:
count = 0
data_sql = f"select id,name,unique_tag,uuid,config_key,beneficiary,description,create_time, income, output from fi_account where unique_tag!='anchor_account' ORDER BY id LIMIT {(int(page) - 1) * size},{size}"
data_sql = f"select id,name,unique_tag,uuid,config_key,beneficiary,description,create_time, income, output from fi_account where unique_tag!='anchor_account' ORDER BY create_time LIMIT {(int(page) - 1) * size},{size}"
query_res = LinkMysql(env.DB_3YV2).query_mysql(data_sql)
if not query_res:
return [], 0
......@@ -359,7 +359,7 @@ class AccountStatistics(object):
self.type = type
self.gift_type = gift_type
self.unique = unique
self.guild_uuid = []
self.guild_dict = {}
self.user_list = []
def business_query(self, date, condition):
......@@ -436,12 +436,16 @@ class AccountStatistics(object):
else:
month, last_month, before_last_month = get_last_month()
if self.unique == 'guild_account':
guild_sql = f"select id,guild_name from guild"
guild_info = LinkMysql(env.DB_3YV2).query_mysql(guild_sql)
for i in guild_info:
self.guild_dict[i['id']] = i['guild_name']
data, total = self.guild_calculation()
return data, total, 0
if self.unique == "pledgeDeduction":
data, total, money = self. guild_calculation_pledge()
return data, total, money
if self.unique == "user_account":
if self.unique == "user_account" or self.unique == "knapsack_account":
if self.user_id:
user_sql = f"select uuid from v2_user where user_id={self.user_id}"
self.user_list = LinkMysql(env.DB_3YV2).query_mysql(user_sql)
......@@ -497,6 +501,8 @@ class AccountStatistics(object):
guild_cond_list.append(f" guild_id={self.user_id}")
sql = f"select guild_id,initial_money,income,outcome,create_time from v3_guild_account_detail_copy where {' and '.join(guild_cond_list)} order by create_time DESC"
mysql_data = LinkMysql(env.DB_3YV2).query_mysql(sql)
for info in mysql_data:
info['guild_name'] = self.guild_dict.get(info['guild_id'])
return mysql_data[int(self.page - 1) * self.size: self.page * self.size], len(mysql_data)
def guild_calculation_pledge(self):
......@@ -699,3 +705,19 @@ class HomePageDisplay(object):
income.append(op)
res_list = outcome + income
return res_list, self.outcome/1000, self.income/1000
class AccountAnchor(object):
def __init__(self, anchor_id):
self.anchor_id = anchor_id
def anchor_balance(self):
if self.anchor_id:
sql = f"SELECT sum(pearl) as num FROM v2_user_account where user_id in(SELECT user_id from v2_user where is_achor=1) and user_id = {self.anchor_id} "
else:
sql = "SELECT sum(pearl) as num FROM v2_user_account where user_id in(SELECT user_id from v2_user where is_achor=1)"
res = LinkMysql(env.DB_3YV2).query_mysql(sql)
money = res[0]['num']
if not money:
return 0
return money/100
......@@ -233,3 +233,10 @@ def outon_account(token=Depends(login_required)):
"""系统账户列表"""
account_list = crud.query_account_data()
return HttpResultResponse(data=account_list)
@router.get("/anchor")
def anchor_account(anchor_id: Optional[int] = None, ):
"""主播账户余额"""
anchor_money = crud.AccountAnchor(anchor_id).anchor_balance()
return HttpResultResponse(data=anchor_money)
......@@ -323,7 +323,7 @@ class ReferenceTypeClassification():
def classification_summary(self):
data_sql = f"select uuid,type,sum(amount) as amount,reference_type from {self.date} where reference_type='{self.reference_type}' GROUP BY uuid,type"
data_sql = f"select uuid,type,sum(amount) as amount,reference_type,amount_type from {self.date} where reference_type='{self.reference_type}' GROUP BY uuid,type"
guild_sql = f"select uuid from guild"
account_sql = f"select uuid,name from fi_account"
anchor_sql = f"select uuid from v2_user where is_achor in(1,2)"
......
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