Commit 0aec42a8 authored by xupeng's avatar xupeng

Merge remote-tracking branch 'origin/development' into development

parents 843e2b79 33108689
......@@ -268,13 +268,16 @@ def get_account_type(**data):
condition.append(f" type={data.get('type')}")
if condition:
total_sql = f"select count(id) as num from fi_account_type where {' and '.join(condition)}"
gift_sql = f"select id,keyName,keyValue,type from fi_account_type where {' and '.join(condition)} limit {(int(data.get('page')) - 1) * data.get('size')},{data.get('size')}"
gift_sql = f"select id,keyName,keyValue,type,createTime as create_time from fi_account_type where {' and '.join(condition)} limit {(int(data.get('page')) - 1) * data.get('size')},{data.get('size')}"
else:
total_sql = f"select count(id) as num from fi_account_type"
gift_sql = f"select id,keyName,keyValue,type from fi_account_type limit {(int(data.get('page')) - 1) * data.get('size')},{data.get('size')}"
gift_sql = f"select id,keyName,keyValue,type,createTime as create_time from fi_account_type limit {(int(data.get('page')) - 1) * data.get('size')},{data.get('size')}"
total = LinkMysql(env.DB_3YV2).query_mysql(total_sql)
output = LinkMysql(env.DB_3YV2).query_mysql(gift_sql)
if output:
for i in output:
time_array = time.localtime(i['create_time'])
i['create_time'] = time.strftime("%Y-%m-%d %H:%M:%S", time_array)
return output, total[0]['num']
return [], 0
......
......@@ -8,6 +8,7 @@ from libs.functions import get_now_datetime
from libs.orm import QueryAllData
from models.export import ExportFile
import pandas as pd
from xpinyin import Pinyin
from starlette.responses import StreamingResponse
......@@ -85,6 +86,9 @@ class CalculationMonthlyBill(object):
assert_list.append(f" reference_type in{tuple(k_list)}")
if len(k_list) == 1:
assert_list.append(f" reference_type='{k_list[0]}'")
if not k_list:
py = Pinyin().get_pinyin(name)
assert_list.append(f" reference_type='{py.replace('-', '')}'")
if key_type:
assert_list.append(f" reference_type like '%{key_type}%'")
if assert_list:
......@@ -231,7 +235,7 @@ class ReferenceTypeClassification():
def classification_summary(self):
data_sql = f"select uuid,type,amount/1000 as amount,create_time from {self.date} where reference_type='{self.reference_type}' GROUP BY uuid,type"
data_sql = f"select uuid,type,sum(amount)/1000 as amount,create_time 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)"
......@@ -257,9 +261,9 @@ class ReferenceTypeClassification():
op['money'] = round(float(op['amount']), 2)
if op.get('uuid') in guild_data:
op['nickname'] = '公会'
if op.get('uuid') in anchor_data:
elif op.get('uuid') in anchor_data:
op['nickname'] = '主播'
if account_dict.get(op['uuid']):
elif account_dict.get(op['uuid']):
op['nickname'] = account_dict.get(op['uuid'])
else:
op['nickname'] = '用户'
......@@ -277,6 +281,6 @@ class ReferenceTypeClassification():
if self.income:
income = pd.DataFrame(self.income)
igs = income.groupby("nickname").sum()
for k,v in igs.to_dict().get('money').items():
for k, v in igs.to_dict().get('money').items():
res_list.append({"type": "入账", "name": k, "money": v})
return res_list
......@@ -150,6 +150,8 @@ def account_thead_task(data):
account = LinkMysql(env.DB_3YV2).query_mysql(account_sql)
if account:
data['transfer_name'] = account[0]['name']
else:
data['transfer_name'] = data.get('transfer_uuid')
def accout_list_data(**params):
......
This diff is collapsed.
......@@ -44,3 +44,4 @@ uvicorn==0.20.0
xmltodict==0.13.0
openpyxl==3.1.2
redis==4.3.4
xpinyin==0.7.6
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