Commit dbb1b0aa authored by xianyang's avatar xianyang

盲盒充值功能,账户可提现可消费功能,明细查询筛选条件

parent 1342106b
This diff is collapsed.
......@@ -45,6 +45,7 @@ class FinanceDetails(PublicModel):
uuid: str
user_id: Optional[int] = None
unique_tag: Optional[str] = ""
amount_type: Optional[str] = ""
class FixTable(BaseModel):
......
......@@ -85,12 +85,13 @@ def finance_details(page: int,
type: Optional[int] = None,
gift_type: Optional[str] = "",
unique_tag: Optional[str] = "",
amount_type: Optional[str] = "",
token=Depends(login_required)):
"""账户财务明细列表"""
if not start_time and not end_time:
return HttpResultResponse(code=500, msg="请输入你要查询的时间段")
res, total, count = AccountStatistics(page, size, uuid, user_id, start_time, end_time, type, gift_type,
unique_tag).get_finance_details(is_list=1)
unique_tag, amount_type).get_finance_details(is_list=1)
return HttpResultResponse(total=total, data=res, count=count)
......@@ -100,7 +101,7 @@ def finance_info_excel(data: schemas.FinanceDetails, request: Request,
"""账户财务明细导出"""
headers = request.get("headers")
statement_list = AccountStatistics(data.page, 99999999, data.uuid, data.user_id, data.start_time, data.end_time, data.type,
data.gift_type, data.unique_tag).get_finance_details()
data.gift_type, data.unique_tag, data.amount_type).get_finance_details()
if data.unique_tag in ["knapsack_account", "user_account", "guild_account", "pledgeDeduction"]:
field_head = ['uuid', '入账', '出账', '时间']
statement_list = statement_list[0]
......
import json
import math
import threading
import time
......@@ -564,6 +565,92 @@ class FinanceFix(object):
return [], 0
class BlindBoxRecharge(object):
"""盲盒充值列表"""
def __init__(self, params):
self.page = int(params.get('page'))
self.size = int(params.get('size'))
self.start_time = params.get('start_time')
self.end_time = params.get('end_time')
self.reference_number = params.get('reference_number')
self.uuid = params.get('uuid')
self.uuid_list = []
def _conditions(self):
cond_list = []
cond_list.append("reference_type='blind_box_mall_account_recharge'")
if self.start_time:
cond_list.append(f"create_time >= {time_str_to_timestamp(self.start_time + ' 00:00:00')} ")
if self.end_time:
cond_list.append(f"create_time < {time_str_to_timestamp(self.end_time + ' 23:59:59')} ")
if self.reference_number:
cond_list.append(f"reference_number='{self.reference_number}'")
if self.uuid:
cond_list.append(f"dst_uuid='{self.uuid}'")
return cond_list
@staticmethod
def time_month(y_month):
now_time = datetime.now().strftime('%Y%m')
if int(y_month) > int(now_time):
return now_time
return y_month
@staticmethod
def _recharge_data(query_data):
if not query_data:
return []
for x in query_data:
if x['reference_info']:
reference_info = json.loads(x['reference_info'])
x['sid'] = reference_info.get('business_number')
x['paychannel'] = reference_info.get('channel')
else:
x['paychannel'] = ''
x['sid'] = ''
x['income_money'] = x['amount']
x['payment_time'] = x['create_time']
x['nick_name'] = "商城礼物盲盒"
x['status'] = 1
Logger().logger.info(f"拼接的数据:{query_data[0]}")
return query_data
def box_recharge(self, is_export=None):
conditions = self._conditions()
start_month = self.start_time.replace('-', '')[:-2]
end_month = self.end_time.replace('-', '')[:-2]
if is_export:
self.size = 999999999
# 时间处理,看查询一个月还是两个月
if start_month == end_month:
year_month = self.time_month(start_month)
time_list = [year_month]
else:
eny_month = self.time_month(end_month)
time_list = [start_month, eny_month]
time_list = list(set(time_list))
if len(time_list) == 1:
data_sql = f"SELECT dst_uuid as uuid,amount,FROM_UNIXTIME(create_time) as create_time,reference_type,reference_number,reference_info FROM order_log_{time_list[0]} where {' and '.join(conditions)} ORDER BY create_time desc limit {(int(self.page) - 1) * self.size},{self.size}"
money_sql = f"SELECT sum(amount) as m_sum FROM order_log_{time_list[0]} where {' and '.join(conditions)}"
count_sql = f"SELECT count(id) as c_sum FROM order_log_{time_list[0]} where {' and '.join(conditions)}"
else:
data_sql = f"SELECT dst_uuid as uuid,amount,FROM_UNIXTIME(create_time) as create_time,reference_type,reference_number,reference_info FROM order_log_{time_list[0]} where {' and '.join(conditions)} UNION ALL SELECT dst_uuid as uuid,amount,FROM_UNIXTIME(create_time) as create_time,reference_type,reference_number,reference_info FROM order_log_{time_list[1]} where {' and '.join(conditions)} ORDER BY create_time desc limit {(self.page - 1) * self.size},{self.size}"
money_sql = f"SELECT sum(a.b) as m_sum FROM ("f"SELECT sum(amount) as b FROM order_log_{int(time_list[0])} where {' and '.join(conditions)} UNION ALL SELECT sum(amount)FROM order_log_{int(time_list[1])} where {' and '.join(conditions)}) AS a "
count_sql = "SELECT sum(a.b) as c_sum FROM ("f"SELECT count(id) as b FROM order_log_{int(time_list[0])} where {' and '.join(conditions)} UNION ALL SELECT count(id) FROM order_log_{int(time_list[1])} where {' and '.join(conditions)}) AS a "
with ThreadPoolExecutor(max_workers=3) as pool:
future1 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, data_sql)
future2 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, money_sql)
future3 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, count_sql)
res_data = future1.result()
res_money = future2.result()
res_count = future3.result()
res_data_to = self._recharge_data(res_data)
if res_data_to:
return res_data_to, res_money[0].get('m_sum'), res_count[0].get('c_sum')
else:
return [], 0, 0
def create_menu(db: Session, menu: schemas.MenuAdd):
try:
db_menu = Menuconfig(menu_name=menu.menu_name, menu_label=menu.menu_label, menu_type=menu.menu_type,
......@@ -662,3 +749,21 @@ def guild_data_handle(data):
mat['finalMoney'] = i.get('finalMoney')
guild_mat.append(mat)
return guild_mat
def blind_box_handle(data):
"""盲盒充值数据处理"""
box_mat = []
for i in data:
box = {}
box['reference_number'] = i['reference_number']
box['sid'] = i.get('sid')
box['paychannel'] = i.get('paychannel')
box['uuid'] = i.get('uuid')
box['nick_name'] = i.get('nick_name')
box['status'] = '成功' if i['status'] else '失败'
box['reference_type'] = '盲盒充值'
box['income_money'] = i.get('income_money')
box['payment_time'] = i.get('payment_time')
box_mat.append(box)
return box_mat
......@@ -7,7 +7,8 @@ from app.api.account import schemas as acc_schemas
from app import get_db
from fastapi import Depends, APIRouter, File, Request
from sqlalchemy.orm import Session
from app.api.statement.crud import RechargeStatement, WithdrawStatement, get_menu_list, get_menu_config
from app.api.statement.crud import RechargeStatement, WithdrawStatement, get_menu_list, get_menu_config, \
BlindBoxRecharge
from app.api.statement.guild import GuildSet, paymentset_guild_data, outon_account_data, accout_list_data, \
query_uuid_or_user_number, account_money, transfer_money, transfer_query, GuildSettlementAdd, GuildSettlementmodify
from app.api.statement.schemas import PaymentWithdrawalList, PaymentAdd, PaymentAccountlList, UserNumber, CreateBill
......@@ -316,3 +317,29 @@ def guild_withdrawal_excel(request: Request,
res_data = crud.guild_data_handle(res[1])
url = TableToFile(db, res_data, "公会提现", header_list, field_list).main_method()
return HttpResultResponse(data=url)
@router.get("/blind_box/recharge")
def blind_box_recharge(request: Request, token=Depends(login_required)):
"""盲盒充值"""
query_params = request.query_params
if not all([query_params.get('start_time'), query_params.get('end_time')]):
return HttpResultResponse(code=500, msg='时间为必传参数')
data, money, count = BlindBoxRecharge(query_params).box_recharge()
return HttpResultResponse(total=count, money=float(money/1000), data=data)
@router.get("/blind_box/excel")
def blind_box_excel(request: Request,
db: Session = Depends(get_db),
token=Depends(login_required)):
"""盲盒充值导出"""
query_params = request.query_params
header_list = request.get("headers")
if not all([query_params.get('start_time'), query_params.get('end_time')]):
return HttpResultResponse(code=500, msg='时间为必传参数')
data, _, _ = BlindBoxRecharge(query_params).box_recharge(1)
field_list = ["订单号", "商户订单号", "渠道", "UUID", "昵称", "充值状态", "业务类型", "充值金额(元)", "充值时间"]
res_data = crud.blind_box_handle(data)
url = TableToFile(db, res_data, "盲盒充值", header_list, field_list).main_method()
return HttpResultResponse(data=url)
......@@ -28,7 +28,10 @@ async def add_process_time_header(request: Request, call_next):
hs = request.headers
token = hs.get("authorization")
start_time = time.time()
response = await call_next(request)
try:
response = await call_next(request)
except:
response = add_process_time_header(request, call_next)
process_time = time.time() - start_time
response.headers["X-Process-Time"] = str(process_time)
url_list = ['/api/users/imgCode', '/api/users/login', '/api/users/goodleCode', '/api/users/googleLogin']
......
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