Commit 843e2b79 authored by xupeng's avatar xupeng

查询修改

parent c4567a8d
......@@ -175,7 +175,7 @@ class RechargeStatement(object):
now_month = get_month_last_month(data.month_type,data.start_time)
once_res = self.data_delcy(data.month_type, query, now_month[1])
else:
query_data = self.query_add_time(data.start_time, data.end_time)
query_data = self.query_add_time(query,data.start_time, data.end_time)
now_month = get_month_last_month(data.month_type)
once_res = self.data_delcy(data.month_type, query_data, now_month)
return once_res
......@@ -210,17 +210,10 @@ class WithdrawStatement(object):
user_list.append(info_dict)
self.derive_user_list += user_list
def query_add_time(self, start_time, end_time):
data = []
query = []
query1 = []
def query_add_time(self,query,start_time, end_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 + ' 23:59:59')} ")
query1.append(f" create_time >= {time_str_to_timestamp(end_time + ' 00:00:00')} ")
query1.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
data.append(query)
data.append(query1)
return data
query.append(f" create_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
return query
def get_user_withdraw_cash(self, db, page, size, uuid, status, start_time, end_time, month_type, menu_id):
query = []
......@@ -257,7 +250,7 @@ class WithdrawStatement(object):
now_month = get_month_last_month(month_type,start_time)
count, once_res, moeny_data = self.dispose_user(month_type, query, page, size, now_month[1])
else:
query_data = self.query_add_time(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)
count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month)
return count, once_res, moeny_data
......@@ -272,14 +265,11 @@ class WithdrawStatement(object):
moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(amount)") if \
self.linkmysql.query_mysql(money_sql)[0].get("sum(amount)") != None else 0
else:
count_sql = "SELECT sum(a.b) FROM ("f"SELECT count(*) as b FROM assets_log_{int(now_month[0])} where {(' and '.join(query[0]))} UNION ALL SELECT count(*) FROM assets_log_{int(now_month[1])} where {(' and '.join(query[1]))}) AS a "
count_sql = "SELECT sum(a.b) FROM ("f"SELECT count(*) as b FROM assets_log_{int(now_month[0])} where {(' and '.join(query))} UNION ALL SELECT count(*) FROM assets_log_{int(now_month[1])} where {(' and '.join(query))}) AS a "
count = self.linkmysql.query_mysql(count_sql)[0].get("sum(a.b)")
query1 = (' and '.join(query[0]))
query2 = (' and '.join(query[1]))
sql = f"SELECT id,uuid,amount,amount_type, FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as payment_time,reference_type,reference_number FROM assets_log_{int(now_month[0])} where {query1} UNION ALL SELECT id,uuid,amount,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as payment_time,reference_type,reference_number,amount_type FROM assets_log_{int(now_month[1])} where {query2} ORDER BY id desc limit {(int(page) - 1) * size},{size}"
print(sql)
sql = f"SELECT id,uuid,amount,amount_type, FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as payment_time,reference_type,reference_number FROM assets_log_{int(now_month[0])} where {(' and '.join(query))} UNION ALL SELECT id,uuid,amount,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as payment_time,reference_type,reference_number,amount_type FROM assets_log_{int(now_month[1])} where {(' and '.join(query))} ORDER BY id desc limit {(int(page) - 1) * size},{size}"
once_res = self.linkmysql.query_mysql(sql)
money_sql = f"SELECT sum(a.b) FROM ("f"SELECT sum(amount) as b FROM assets_log_{int(now_month[0])} where {(' and '.join(query[0]))} UNION ALL SELECT sum(amount)FROM assets_log_{int(now_month[1])} where {(' and '.join(query[1]))} ) AS a "
money_sql = f"SELECT sum(a.b) FROM ("f"SELECT sum(amount) as b FROM assets_log_{int(now_month[0])} where {(' and '.join(query))} UNION ALL SELECT sum(amount)FROM assets_log_{int(now_month[1])} where {(' and '.join(query))} ) AS a "
moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(a.b)") if \
self.linkmysql.query_mysql(money_sql)[0].get("sum(a.b)") != None else 0
return count, once_res, moeny_data
......@@ -320,7 +310,7 @@ class WithdrawStatement(object):
now_month = get_month_last_month(month_type,start_time)
count, once_res, moeny_data = self.dispose_user(month_type, query, page, size, now_month[1])
else:
query_data = self.query_add_time(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)
count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month)
return count, once_res, moeny_data
......
......@@ -496,31 +496,28 @@ def transfer_query(data):
调用
'''
payment_sql = f"insert into payment_log(cont,money,create_time,url,uuid) values('{data.cont}','{data.money}',{get_now_timestamp()},'{data.url}','{data.uuid}')"
LinkMysql(env.DB_3YV2).perform_mysql(payment_sql)
platform=LinkMysql(env.DB_3YV2).perform_mysql(payment_sql)
params = {}
if data.money > 0:
method = 'Server.BaseExecute.Increase'
params['dst_uuid'] = data.uuid
params['ip'] = get_ip()
params['dst_amount_type'] = 'Payment'
params['amount'] = 1
params['fee'] = data.money * -1 if data.money < 0 else data.money
params['reference_number'] = get_order()
params['reference_type'] = 'finance_admin_fix'
params['reference_info'] = []
params['timestamp'] = 0
referNum=f'platomOutMoney_{platform}'
referType='Payment'
amount_type='consumable'
uuid =data.uuid
ip=get_ip()
money=data.money * -1 if data.money < 0 else data.money
if money > 0:
params['referNum'] = referNum
params['referType'] = referType
params['amount_type']=amount_type
params['uuid'] = uuid
params['ip'] = ip
params['money'] = money
else:
method = 'Server.BaseExecute.Reduce'
params['dst_uuid'] = data.uuid
params['ip'] = get_ip()
params['dst_amount_type'] = 'Payment'
params['amount'] = 1
params['fee'] = data.money * -1 if data.money < 0 else data.money
params['reference_number'] = get_order()
params['reference_type'] = 'finance_admin_fix'
params['reference_info'] = []
params['timestamp'] = 0
search(params=params, method=method)
params['referNum'] = referNum
params['referType'] = referType
params['dst_uuid'] = uuid
params['money'] = money
params['ip'] = ip
search(params=params, method='Server.BaseExecute.Increase')
return
......@@ -537,6 +534,20 @@ def GuildSettlementAdd(db, data):
if not acc_info:
return 400, {"msg": "财务平台账户数据错误"}
if guild_data.status == 0:
try:
url = "http://106.55.103.148:8787/api/guild/editSettlementLog"
json = {'id': guild_data.work_id, 'status': 2}
res = requests.post(url=url, json=json)
if res.status_code != 200:
return 400, {"msg": "业务请求失败"}
except:
db.query(GuildSettlementLog).filter(GuildSettlementLog.id == data.id).update(
{GuildSettlementLog.status: 3, GuildSettlementLog.update_time: get_now_timestamp()})
db.commit()
return 400, {"msg": "业务请求失败"}
db.query(GuildSettlementLog).filter(GuildSettlementLog.id == data.id).update(
{GuildSettlementLog.status: data.status, GuildSettlementLog.update_time: get_now_timestamp()})
db.commit()
first_sta = 00
# 钻石处理
if guild_data.balance and guild_data.balance > 0:
......@@ -552,20 +563,6 @@ def GuildSettlementAdd(db, data):
if is_lose:
return 400, {"msg": "结算错误"}
first_sta = 1
if first_sta:
try:
url = "http://106.55.103.148:8787/api/guild/editSettlementLog"
json={'id': guild_data.work_id, 'status': 2}
res = requests.post(url=url, json=json)
if res.status_code != 200:
return 400, {"msg": "业务请求失败"}
except:
db.query(GuildSettlementLog).filter(GuildSettlementLog.id == data.id).update(
{GuildSettlementLog.status: 3, GuildSettlementLog.update_time: get_now_timestamp()})
db.commit()
return 400, {"msg": "业务请求失败"}
db.query(GuildSettlementLog).filter(GuildSettlementLog.id == data.id).update({GuildSettlementLog.status: data.status, GuildSettlementLog.update_time: get_now_timestamp()})
db.commit()
else:
db.query(GuildSettlementLog).filter(GuildSettlementLog.id == data.id).update(
{GuildSettlementLog.status: 3, GuildSettlementLog.update_time: get_now_timestamp()})
......
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