Commit eefc649a authored by xianyang's avatar xianyang

优化公会提现列表字段

parent bb72b823
...@@ -4,12 +4,8 @@ import time ...@@ -4,12 +4,8 @@ import time
from concurrent.futures.thread import ThreadPoolExecutor from concurrent.futures.thread import ThreadPoolExecutor
from datetime import datetime from datetime import datetime
import xlsxwriter import xlsxwriter
import openpyxl
import pandas as pd import pandas as pd
from fastapi import Depends
from sqlalchemy import func, and_ from sqlalchemy import func, and_
from app import get_db
from app.api.statement import schemas from app.api.statement import schemas
from app.api.statement.guild import query_token from app.api.statement.guild import query_token
from starlette.responses import StreamingResponse from starlette.responses import StreamingResponse
...@@ -17,13 +13,12 @@ from sqlalchemy.orm import Session ...@@ -17,13 +13,12 @@ from sqlalchemy.orm import Session
from app.api.export import crud from app.api.export import crud
from core.config.env import env from core.config.env import env
from libs.db_link import LinkMysql from libs.db_link import LinkMysql
from core.config.env import env
from libs.db_link import LinkMysql
from libs.functions import time_str_to_timestamp, timestamp_to_time_str, get_month_last_month, get_date_list from libs.functions import time_str_to_timestamp, timestamp_to_time_str, get_month_last_month, get_date_list
from libs.log_utils import Logger
from libs.orm import QueryAllData from libs.orm import QueryAllData
from models.recharge import Recharge, UserWC, GuildWC, FinanceFixLog from models.recharge import Recharge, UserWC, GuildWC, FinanceFixLog
from models.menuconfig import Menuconfig from models.menuconfig import Menuconfig
from models.users import User from decimal import Decimal
locka = threading.Lock() locka = threading.Lock()
...@@ -349,6 +344,33 @@ class WithdrawStatement(object): ...@@ -349,6 +344,33 @@ class WithdrawStatement(object):
reality_moeny=moeny_data-abs(moeny_income) reality_moeny=moeny_data-abs(moeny_income)
return count, once_res, moeny_data,reality_moeny return count, once_res, moeny_data,reality_moeny
def structure_data(self, guild_data, s_time, e_time):
guild_query = []
Logger().logger.info("拼接数据!!!")
if s_time:
guild_query.append(f" t.update_time>={time_str_to_timestamp(s_time + ' 00:00:00')} ")
if e_time:
guild_query.append(f" t.update_time<{time_str_to_timestamp(e_time + ' 23:59:59')} ")
if guild_query:
gui_sql = f"SELECT g.id,g.guild_name,g.uuid,t.withdrawal_time,t.update_time,t.money,t.dec_money,t.finalMoney from guild_ti_xian as t LEFT JOIN guild as g on t.guild_id=g.id where {(' and '.join(guild_query))}"
else:
gui_sql = "SELECT g.id,g.guild_name,g.uuid,t.withdrawal_time,t.update_time,t.money,t.dec_money,t.finalMoney from guild_ti_xian as t LEFT JOIN guild as g on t.guild_id=g.id"
guild_info = LinkMysql(env.DB_3YV2).query_mysql(gui_sql)
for guild in guild_data:
for i in guild_info:
amount = Decimal(guild['amount']).quantize(Decimal("0.00"))
if guild['uuid'] == i['uuid'] and str(amount) == i['finalMoney']:
guild['withdrawal_time'] = i['withdrawal_time']
guild['update_time'] = i['update_time']
guild['guild_id'] = i['id']
guild['guild_name'] = i['guild_name']
guild['money'] = i['money']
guild['dec_money'] = i['dec_money']
guild['finalMoney'] = Decimal(i['finalMoney']).quantize(Decimal("0.00"))
Logger().logger.info("完成!!!")
return guild_data
def get_guild_withdraw_cash(self, db, page, size, name, status, start_time, end_time, month_type, menu_id): def get_guild_withdraw_cash(self, db, page, size, name, status, start_time, end_time, month_type, menu_id):
"""公会提现""" """公会提现"""
query =[] query =[]
...@@ -390,7 +412,9 @@ class WithdrawStatement(object): ...@@ -390,7 +412,9 @@ class WithdrawStatement(object):
query_data = self.query_add_time(query,start_time, end_time) query_data = self.query_add_time(query,start_time, end_time)
now_month = get_month_last_month(month_type,start_time,end_time) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data,reality_moeny = self.dispose_user(month_type, query_data, page, size, now_month) count, once_res, moeny_data,reality_moeny = self.dispose_user(month_type, query_data, page, size, now_month)
return count, once_res, moeny_data/1000,reality_moeny/1000 # 数据构造
res_list = self.structure_data(once_res, start_time, end_time)
return count, res_list, moeny_data/1000, reality_moeny/1000
class FinanceFix(object): class FinanceFix(object):
......
...@@ -238,7 +238,6 @@ class TableToFile(object): ...@@ -238,7 +238,6 @@ class TableToFile(object):
# params["status"] = 2 # params["status"] = 2
# crud.create_export_data(self.db, params, user) # crud.create_export_data(self.db, params, user)
from fastapi.responses import RedirectResponse
def main_method(self): def main_method(self):
"""主函数""" """主函数"""
Logger().logger.info('开始导出') Logger().logger.info('开始导出')
......
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