Commit 16f0204d authored by xupeng's avatar xupeng

打款提交

parent d1b46b71
...@@ -97,11 +97,11 @@ class RechargeStatement(object): ...@@ -97,11 +97,11 @@ class RechargeStatement(object):
if end_time: if end_time:
query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ") query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
query = ' and '.join(query) query = ' and '.join(query)
now_month = get_month_last_month(month_type,start_time) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data = self.statistics_data(month_type, query, page, size, now_month[1]) count, once_res, moeny_data = self.statistics_data(month_type, query, page, size, now_month[1])
else: else:
query_data = self.query_add_time(start_time, end_time, query) 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,start_time) count, once_res, moeny_data = self.thread_data(month_type, query_data, page, size,start_time,end_time)
return count, once_res, moeny_data return count, once_res, moeny_data
def query_add_time(self, start_time, end_time, old_query): def query_add_time(self, start_time, end_time, old_query):
...@@ -142,8 +142,8 @@ class RechargeStatement(object): ...@@ -142,8 +142,8 @@ class RechargeStatement(object):
self.linkmysql.query_mysql(money_sql)[0].get("sum(a.b)") != None else 0 self.linkmysql.query_mysql(money_sql)[0].get("sum(a.b)") != None else 0
return count, once_res, moeny_data/1000 return count, once_res, moeny_data/1000
def thread_data(self, month_type, query, page, size,start_time): def thread_data(self, month_type, query, page, size,start_time,end_time):
now_month = get_month_last_month(month_type,start_time) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data = self.statistics_data(month_type, query, page, size, now_month) count, once_res, moeny_data = self.statistics_data(month_type, query, page, size, now_month)
return count, once_res, moeny_data return count, once_res, moeny_data
...@@ -231,6 +231,7 @@ class WithdrawStatement(object): ...@@ -231,6 +231,7 @@ class WithdrawStatement(object):
else: else:
reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')" reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')"
query.append(f"reference_type in {reference_type}") query.append(f"reference_type in {reference_type}")
query.append(f"type=0")
else: else:
querydata = db.query(Menuconfig).filter(Menuconfig.menu_type == 3) # 3是用户提现 querydata = db.query(Menuconfig).filter(Menuconfig.menu_type == 3) # 3是用户提现
reference_data = [ reference_data = [
...@@ -241,17 +242,18 @@ class WithdrawStatement(object): ...@@ -241,17 +242,18 @@ class WithdrawStatement(object):
else: else:
reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')" reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')"
query.append(f"reference_type in {reference_type}") query.append(f"reference_type in {reference_type}")
query.append(f"type = 0")
if month_type == 1: if month_type == 1:
if start_time: if start_time:
query.append(f" create_time >= {time_str_to_timestamp(start_time + ' 00:00:00')} ") query.append(f" create_time >= {time_str_to_timestamp(start_time + ' 00:00:00')} ")
if end_time: if end_time:
query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ") query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
query = ' and '.join(query) query = ' and '.join(query)
now_month = get_month_last_month(month_type,start_time) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data = self.dispose_user(month_type, query, page, size, now_month[1]) count, once_res, moeny_data = self.dispose_user(month_type, query, page, size, now_month[1])
else: else:
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) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month) count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month)
return count, once_res, moeny_data return count, once_res, moeny_data
...@@ -259,7 +261,7 @@ class WithdrawStatement(object): ...@@ -259,7 +261,7 @@ class WithdrawStatement(object):
if month_type == 1: if month_type == 1:
count_sql = f"SELECT count(*) FROM assets_log_{now_month} where {query}" count_sql = f"SELECT count(*) FROM assets_log_{now_month} where {query}"
count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)") count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)")
sql = f'SELECT uuid,a.reference_type,a.reference_number,FROM_UNIXTIME(a.create_time,"%Y-%c-%d %h:%i:%s") as payment_time,a.amount_type FROM assets_log_{now_month} as a where {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}' sql = f'SELECT uuid,amount,a.reference_type,a.reference_number,FROM_UNIXTIME(a.create_time,"%Y-%c-%d %h:%i:%s") as payment_time,a.amount_type FROM assets_log_{now_month} as a where {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
once_res = self.linkmysql.query_mysql(sql) once_res = self.linkmysql.query_mysql(sql)
money_sql = f"SELECT sum(amount) FROM assets_log_{now_month} where {query} " money_sql = f"SELECT sum(amount) FROM assets_log_{now_month} where {query} "
moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(amount)") if \ moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(amount)") if \
...@@ -291,6 +293,7 @@ class WithdrawStatement(object): ...@@ -291,6 +293,7 @@ class WithdrawStatement(object):
else: else:
reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')" reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')"
query.append(f"reference_type in {reference_type}") query.append(f"reference_type in {reference_type}")
query.append(f"type = 0")
else: else:
querydata = db.query(Menuconfig).filter(Menuconfig.menu_type == 4) # 4是公会提现 querydata = db.query(Menuconfig).filter(Menuconfig.menu_type == 4) # 4是公会提现
reference_data = [ reference_data = [
...@@ -301,17 +304,18 @@ class WithdrawStatement(object): ...@@ -301,17 +304,18 @@ class WithdrawStatement(object):
else: else:
reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')" reference_type = "('" + [item.get("menu_label") for item in reference_data][0] + "')"
query.append(f"reference_type in {reference_type}") query.append(f"reference_type in {reference_type}")
query.append(f"type = 0")
if month_type == 1: if month_type == 1:
if start_time: if start_time:
query.append(f" create_time >= {time_str_to_timestamp(start_time + ' 00:00:00')} ") query.append(f" create_time >= {time_str_to_timestamp(start_time + ' 00:00:00')} ")
if end_time: if end_time:
query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ") query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
query = ' and '.join(query) query = ' and '.join(query)
now_month = get_month_last_month(month_type,start_time) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data = self.dispose_user(month_type, query, page, size, now_month[1]) count, once_res, moeny_data = self.dispose_user(month_type, query, page, size, now_month[1])
else: else:
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) now_month = get_month_last_month(month_type,start_time,end_time)
count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month) count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month)
return count, once_res, moeny_data return count, once_res, moeny_data
......
...@@ -121,10 +121,10 @@ def paymentset_guild_data(page, size, start_time, end_time): ...@@ -121,10 +121,10 @@ def paymentset_guild_data(page, size, start_time, end_time):
query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ") query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
if query != []: if query != []:
count_sql = f"SELECT count(*) FROM `payment_log` where {' and '.join(query)}" count_sql = f"SELECT count(*) FROM `payment_log` where {' and '.join(query)}"
list_sql = f"SELECT money,cont,url,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as create_time FROM `payment_log` where {' and '.join(query)} ORDER BY id desc limit {(int(page) - 1) * page},{size} " list_sql = f"SELECT money,cont,url,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as create_time FROM `payment_log` where {' and '.join(query)} ORDER BY id desc limit {(int(page) - 1) * size},{size} "
else: else:
count_sql = f"SELECT count(*) FROM `payment_log`" count_sql = f"SELECT count(*) FROM `payment_log`"
list_sql = f"SELECT money,cont,url,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as create_time FROM `payment_log` ORDER BY id desc limit {(int(page) - 1) * page},{size} " list_sql = f"SELECT money,cont,url,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as create_time FROM `payment_log` ORDER BY id desc limit {(int(page) - 1) * size},{size} "
paymentset_sql = LinkMysql(env.DB_3YV2).query_mysql(count_sql) paymentset_sql = LinkMysql(env.DB_3YV2).query_mysql(count_sql)
total = paymentset_sql[0].get("count(*)") total = paymentset_sql[0].get("count(*)")
payment_list = LinkMysql(env.DB_3YV2).query_mysql(list_sql) payment_list = LinkMysql(env.DB_3YV2).query_mysql(list_sql)
...@@ -505,25 +505,17 @@ def transfer_query(data): ...@@ -505,25 +505,17 @@ def transfer_query(data):
ip=get_ip() ip=get_ip()
money=data.money * -1 if data.money < 0 else data.money money=data.money * -1 if data.money < 0 else data.money
if money > 0: if money > 0:
params['dst_amount_type'] = 'consumable' params['src_amount_type'] = 'consumable'
params['amount'] = money params['amount'] = money
params['fee']=0 params['fee']=0
params['reference_info']=[] params['reference_info']=[]
params['reference_number']=referNum params['reference_number']=referNum
params['reference_type']=reference_type params['reference_type']=reference_type
params['dst_uuid'] = uuid params['src_uuid'] = uuid
params['ip'] = ip params['ip'] =ip
params['timestamp'] = get_now_timestamp() params['timestamp'] = get_now_timestamp()
else: status =search(params=params, method='Server.BaseExecute.Reduce')
pass return status
# params['referNum'] = referNum
# params['referType'] = referType
# params['dst_uuid'] = uuid
# params['money'] = money
# params['ip'] = ip
print(params)
search(params=params, method='Server.BaseExecute.Reduce')
return
def GuildSettlementAdd(db, data): def GuildSettlementAdd(db, data):
......
...@@ -86,10 +86,13 @@ async def uploadFile(a_file: bytes = File(...), token=Depends(login_required), ) ...@@ -86,10 +86,13 @@ async def uploadFile(a_file: bytes = File(...), token=Depends(login_required), )
@router.post("/payment/add") @router.post("/payment/add")
def guild_payment_list(data: PaymentAdd, db: Session = Depends(get_db)): def guild_payment_list(data: PaymentAdd, db: Session = Depends(get_db),token=Depends(login_required)):
"""提交打款""" """提交打款"""
transfer_query(data) status=transfer_query(data)
if status:
return HttpResultResponse(code=200,data='') return HttpResultResponse(code=200,data='')
else:
return HttpResultResponse(code=500,msg="打款失败")
@router.get("/onaccount") @router.get("/onaccount")
......
...@@ -113,8 +113,10 @@ def search(params, method): ...@@ -113,8 +113,10 @@ def search(params, method):
if response.status_code != 200: if response.status_code != 200:
return {} return {}
text = json.loads(response.text) text = json.loads(response.text)
print(text) if text.get("data").get("result").get("msg")=='success':
return text return True
else:
return False
def get_ip(): def get_ip():
...@@ -122,14 +124,16 @@ def get_ip(): ...@@ -122,14 +124,16 @@ def get_ip():
return res return res
def get_month_last_month(month_type,start_time): def get_month_last_month(month_type,start_time,end_time):
last_month=0 last_month=0
if month_type==2: if month_type==2:
month_date = datetime.now().date() - relativedelta(months=1) # month_date = datetime.now().date() - relativedelta(months=1)
last_month = month_date.strftime("%Y%m") # last_month = month_date.strftime("%Y%m")
now_month =datetime.now().strftime("%Y%m") last_month =''.join(end_time.split('-')[0:2])
now_month =''.join(start_time.split('-')[0:2])
else: else:
now_month= ''.join(start_time.split('-')[0:2]) now_month= ''.join(start_time.split('-')[0:2])
print(last_month,now_month)
return last_month,now_month return last_month,now_month
def time_format(utc_timestamp: int): def time_format(utc_timestamp: int):
......
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