Commit 07444494 authored by xianyang's avatar xianyang

优化财务修复报表

parent 86c4be44
...@@ -48,8 +48,9 @@ class FixTable(BaseModel): ...@@ -48,8 +48,9 @@ class FixTable(BaseModel):
type: int type: int
uuid: str = '' uuid: str = ''
money: float money: float
amount_type: str = "consumable" amount_type: Optional[str] = "consumable"
remark: str remark: str
unique_tag: Optional[str] = ""
class AccountTypeUpdate(BaseModel): class AccountTypeUpdate(BaseModel):
......
...@@ -335,9 +335,15 @@ def transfer_money(db: Session, param, h_list): ...@@ -335,9 +335,15 @@ def transfer_money(db: Session, param, h_list):
def create_fix_table(db: Session, param, h_list): def create_fix_table(db: Session, param, h_list):
"""增加修复报表""" """增加修复报表"""
uuid = param.uuid
unique_res = []
if param.type == 0:
acc_sql = f"select unique_tag,uuid from fi_account where unique_tag='{param.unique_tag}'"
unique_res = LinkMysql(env.DB_3YV2).query_mysql(acc_sql)
uuid = unique_res[0]['uuid']
if param.amount_type == 'backpack': if param.amount_type == 'backpack':
guild_sql = f"select count(id) as num from guild where uuid='{param.uuid}'" guild_sql = f"select count(id) as num from guild where uuid='{uuid}'"
user_sql = f"select user_id,nick_name,user_number from v2_user where uuid='{param.uuid}'" user_sql = f"select user_id,nick_name,user_number from v2_user where uuid='{uuid}'"
with ThreadPoolExecutor(max_workers=2) as pool: with ThreadPoolExecutor(max_workers=2) as pool:
future1 = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, guild_sql) future1 = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, guild_sql)
future2 = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, user_sql) future2 = pool.submit(LinkMysql(env.DB_3YV2).query_mysql, user_sql)
...@@ -360,7 +366,7 @@ def create_fix_table(db: Session, param, h_list): ...@@ -360,7 +366,7 @@ def create_fix_table(db: Session, param, h_list):
method = 'Server.BaseExecute.Increase' method = 'Server.BaseExecute.Increase'
data = { data = {
"ip": ip, "ip": ip,
"dst_uuid": param.uuid, "dst_uuid": uuid,
"dst_amount_type": param.amount_type, "dst_amount_type": param.amount_type,
"amount": param.money, "amount": param.money,
"fee": 0, "fee": 0,
...@@ -373,7 +379,7 @@ def create_fix_table(db: Session, param, h_list): ...@@ -373,7 +379,7 @@ def create_fix_table(db: Session, param, h_list):
method = 'Server.BaseExecute.Reduce' method = 'Server.BaseExecute.Reduce'
data = { data = {
"ip": ip, "ip": ip,
"src_uuid": param.uuid, "src_uuid": uuid,
"src_amount_type": param.amount_type, "src_amount_type": param.amount_type,
"amount": param.money, "amount": param.money,
"fee": 0, "fee": 0,
...@@ -385,11 +391,7 @@ def create_fix_table(db: Session, param, h_list): ...@@ -385,11 +391,7 @@ def create_fix_table(db: Session, param, h_list):
clearing_res = search(data, method) clearing_res = search(data, method)
print(clearing_res) print(clearing_res)
if clearing_res['status']: if clearing_res['status']:
unique_res = [] unique_tag = unique_res[0]['unique_tag'] if unique_res else uuid
if param.type == 0:
acc_sql = f"select unique_tag from fi_account where uuid='{param.uuid}'"
unique_res = LinkMysql(env.DB_3YV2).query_mysql(acc_sql)
unique_tag = unique_res[0]['unique_tag'] if unique_res else param.uuid
user = query_token(db, h_list) user = query_token(db, h_list)
try: try:
insert_fix_sql = f"insert into finance_fix_log(type, money, create_time, unique_tag, amount_type, remark, operator,operator_id) " \ insert_fix_sql = f"insert into finance_fix_log(type, money, create_time, unique_tag, amount_type, remark, operator,operator_id) " \
......
...@@ -154,7 +154,7 @@ def finance_fix(page: int, ...@@ -154,7 +154,7 @@ def finance_fix(page: int,
def finance_fix(data: acc_schemas.FixTable, request: Request, def finance_fix(data: acc_schemas.FixTable, request: Request,
token=Depends(login_required), db: Session = Depends(get_db)): token=Depends(login_required), db: Session = Depends(get_db)):
"""新增修复报表""" """新增修复报表"""
if not all([data.uuid, data.money, data.amount_type, data.remark]): if not all([data.money, data.amount_type, data.remark]):
return HttpResultResponse(code=500, msg='缺少必传参数') return HttpResultResponse(code=500, msg='缺少必传参数')
header_list = request.get("headers") header_list = request.get("headers")
res = guild.create_fix_table(db, data, header_list) res = guild.create_fix_table(db, data, header_list)
......
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