Commit fd455d63 authored by xianyang's avatar xianyang

优化充值列表

parent 9084b13a
......@@ -19,7 +19,7 @@ from core.config.env import env
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
from libs.functions import time_str_to_timestamp, timestamp_to_time_str, get_month_last_month, get_date_list
from libs.orm import QueryAllData
from models.recharge import Recharge, UserWC, GuildWC, FinanceFixLog
from models.menuconfig import Menuconfig
......@@ -93,8 +93,8 @@ class RechargeStatement(object):
if end_time:
query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
query = ' and '.join(query)
now_month = get_month_last_month(month_type)
count, once_res, moeny_data = self.statistics_data(month_type, query, page, size, now_month[1])
now_month = get_date_list(start_time, end_time)
count, once_res, moeny_data = self.statistics_data(month_type, query, page, size, now_month[0])
else:
query_data = self.query_add_time(start_time, end_time, query)
count, once_res, moeny_data = self.thread_data(month_type, query_data, page, size)
......
......@@ -36,7 +36,7 @@ def statement_derive_excel(request:Request,data: schemas.StatementList,db: Sessi
total,statement_list,money= RechargeStatement().query_data(db, data.page, data.size, data.order_number, data.uuid,
data.sid, data.start_time, data.end_time, data.types,
data.menu_id, data.month_type)
field_list = ["uuid", "充值金额(元)", "支付时间", "类型", "订单号"]
field_list = ["id", "uuid", "充值金额(元)", "支付时间", "类型", "订单号"]
return crud.data_to_file(db, statement_list, "充值报表", header_list, field_list)
......
......@@ -149,3 +149,30 @@ def query_guild_info(guild_uuid):
url = "http://106.55.103.148:8787/api/userInfo/getGuildInfo"
result = requests.post(url=url, json={"uuid": guild_uuid})
return result
def gen_dates(b_date, days):
"""
日期生成器
:param b_date: 开始时间
:param days: 天数
:return:
"""
day = timedelta(days=1)
for i in range(days):
yield b_date + day * i
def get_date_list(start, end):
"""
获取n天前日期列表
:param n: 几天前
:return:
"""
data = []
start_time = datetime.strptime(start, "%Y-%m-%d")
end_time = datetime.strptime(end, "%Y-%m-%d")
for ym in gen_dates(start_time, (end_time - start_time).days):
year_month = ym.strftime('%Y%m')
data.append(year_month)
return tuple(set(data))
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