sql=f'SELECT d.id as order_number,d.userid as user_id,u.user_number,u.nick_name,d.money,d.paychannel as pay_channel,d.sid,d.current,FROM_UNIXTIME(d.payment_time,"%Y-%c-%d %h:%i:%s") as payment_time,FROM_UNIXTIME(d.lastupdate,"%Y-%c-%d %h:%i:%s") as last_update FROM `orders` as d inner join v2_user as u on d.userid=u.user_id where status=1 ORDER BY id desc limit {(int(page) - 1) * size},{size}'
sql=f'SELECT id,a.uuid,a.amount,FROM_UNIXTIME(a.create_time,"%Y-%c-%d %h:%i:%s") as payment_time,a.amount_type,a.reference_number FROM assets_log_{now_month} as a where type=1 and {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
once_res=self.linkmysql.query_mysql(sql)
money_sql=f"SELECT sum(d.balanceadd) FROM `orders` as d inner join v2_user as u on d.userid=u.user_id where status=1"
sql=f'SELECT d.id as order_number,d.userid as user_id,u.user_number,u.nick_name,d.money,d.paychannel as pay_channel,d.sid,d.current,FROM_UNIXTIME(d.payment_time,"%Y-%c-%d %h:%i:%s") as payment_time,FROM_UNIXTIME(d.lastupdate,"%Y-%c-%d %h:%i:%s") as last_update FROM `orders` as d inner join v2_user as u on d.userid=u.user_id where status=1 and {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
once_res=self.linkmysql.query_mysql(sql)
money_sql=f"SELECT sum(d.balanceadd) FROM `orders` as d inner join v2_user as u on d.userid=u.user_id where status=1 and {query}"
count_sql="SELECT sum(a.b) FROM ("f"SELECT count(*) as b FROM assets_log_{int(now_month[0])} where {(' and '.join(query[0]))} and type=1 UNION ALL SELECT count(*) FROM assets_log_{int(now_month[1])} where {(' and '.join(query[1]))} and type=1 ) AS a "
sql=f'SELECT id,uuid,amount,FROM_UNIXTIME(create_time,"%Y-%c-%d %h:%i:%s") as payment_time,amount_type,reference_number FROM assets_log_{int(now_month[0])} where {query1} and type=1 UNION ALL SELECT id,uuid,amount,FROM_UNIXTIME(create_time,"%Y-%c-%d %h:%i:%s") as payment_time,amount_type,reference_number FROM assets_log_{int(now_month[1])} where {query2} and type=1 ORDER BY id desc limit {(int(page) - 1) * size},{size}'
print(sql)
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]))} and type=1 UNION ALL SELECT sum(amount)FROM assets_log_{int(now_month[1])} where {(' and '.join(query[1]))} and type=1 ) AS a "
@@ -142,21 +128,39 @@ class RechargeStatement(object):
query.append(f"user_id={data.user_id} ")
elifdata.sid:
query.append(f"sid='{data.sid}' ")
ifquery==[]:
sql=f'SELECT d.id as order_number,d.userid as user_id,u.user_number,u.nick_name,d.money,d.paychannel as pay_channel,d.sid,d.current,FROM_UNIXTIME(d.payment_time,"%Y-%c-%d %h:%i:%s") as payment_time,FROM_UNIXTIME(d.lastupdate,"%Y-%c-%d %h:%i:%s") as last_update FROM `orders` as d inner join v2_user as u on d.userid=u.user_id where status=1 ORDER BY id desc'
sql=f'SELECT a.uuid,a.amount,FROM_UNIXTIME(a.create_time,"%Y-%c-%d %h:%i:%s") as payment_time,a.amount_type,a.order_number FROM assets_log_{now_month} as a where type=1 and {query}'
once_res=self.linkmysql.query_mysql(sql)
else:
query=' and '.join(query)
sql=f'SELECT d.id as order_number,d.userid as user_id,u.user_number,u.nick_name,d.money,d.paychannel as pay_channel,d.sid,d.current,FROM_UNIXTIME(d.payment_time,"%Y-%c-%d %h:%i:%s") as payment_time,FROM_UNIXTIME(d.lastupdate,"%Y-%c-%d %h:%i:%s") as last_update FROM `orders` as d inner join v2_user as u on d.userid=u.user_id where status=1 and {query} ORDER BY id desc'
query1=(' and '.join(query[0]))
query2=(' and '.join(query[1]))
sql=f'SELECT id,uuid,amount,FROM_UNIXTIME(create_time,"%Y-%c-%d %h:%i:%s") as payment_time,amount_type,order_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,amount_type,order_number FROM assets_log_{int(now_month[1])} where {query2}'
once_res=self.linkmysql.query_mysql(sql)
returnonce_res
classWithdrawStatement(object):
"""提现报表"""
def__init__(self):
self.derive_user_list=[]
self.linkmysql=LinkMysql(env.DB_3YV2)
self.linkmysql=LinkMysql(env.DB_HISTORY)
self.derive_guild_list=[]
defthread_to_data(self,db,num):
...
...
@@ -169,83 +173,125 @@ class WithdrawStatement(object):
sql=f'SELECT t.usernumber as user_number,t.status,t.id as bank_code,t.nickname as nick_name,t.truename as true_name ,t.money,t.current,t.final_money,t.idcard as id_card,t.account,t.platformServiceFee as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `tixian_order` as t where choice={choice} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
# sql = f'SELECT t.usernumber as user_number,t.status,t.id as bank_code,t.nickname as nick_name,t.truename as true_name ,t.money,t.current,t.final_money,t.idcard as id_card,t.account,t.platformServiceFee as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `tixian_order` as t where choice={choice} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
# sql = f'SELECT t.usernumber as user_number,t.status,t.id as bank_code,t.nickname as nick_name,t.truename as true_name ,t.money,t.current,t.final_money,t.idcard as id_card,t.account,t.platformServiceFee as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `tixian_order` as t where choice={choice} and {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
sql=f'SELECT t.usernumber as user_number,t.status,t.id as bank_code,t.nickname as nick_name,t.truename as true_name ,t.money,t.current,t.final_money,t.idcard as id_card,t.account,t.platformServiceFee as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `tixian_order` as t where choice={choice} and {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
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}'
once_res=self.linkmysql.query_mysql(sql)
money_sql=f"SELECT sum(amount) FROM assets_log_{now_month} where {query} "
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 "
sql=f"SELECT id,uuid,amount,FROM_UNIXTIME(create_time,'%Y-%c-%d %h:%i:%s') as payment_time,amount_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,amount_type,reference_number FROM assets_log_{int(now_month[1])} where {query2} 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 "
sql=f'SELECT t.guild_id,t.parent_id as merchants_id,g.guild_name,t.money,t.account,t.`status`,t.finalMoney as final_money,t.update_time,t.taxRate as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `guild_ti_xian` as t inner join guild as g on g.id=t.guild_id ORDER BY t.id desc limit {(int(page) - 1) * size},{size}'
query_time=' and '.join(query).replace('create_time','t.create_time').replace('update_time','t.update_time').replace('guild_id','t.guild_id').replace('status','t.status')
count_sql=f'SELECT count(*) FROM `guild_ti_xian` where {query1}'
sql=f'SELECT t.guild_id,t.parent_id as merchants_id,g.guild_name,t.money,t.account,t.`status`,t.finalMoney as final_money,t.update_time,t.taxRate as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `guild_ti_xian` as t inner join guild as g on g.id=t.guild_id where {query_time} ORDER BY t.id desc limit {(int(page) - 1) * size},{size}'
# sql = f'SELECT t.guild_id,t.parent_id as merchants_id,g.guild_name,t.money,t.account,t.`status`,t.finalMoney as final_money,t.update_time,t.taxRate as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `guild_ti_xian` as t inner join guild as g on g.id=t.guild_id ORDER BY t.id desc limit {(int(page) - 1) * size},{size}'
# query_time=' and '.join(query).replace('create_time','t.create_time').replace('update_time','t.update_time').replace('guild_id','t.guild_id').replace('status','t.status')
# count_sql = f'SELECT count(*) FROM `guild_ti_xian` where {query1}'
# sql = f'SELECT t.guild_id,t.parent_id as merchants_id,g.guild_name,t.money,t.account,t.`status`,t.finalMoney as final_money,t.update_time,t.taxRate as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `guild_ti_xian` as t inner join guild as g on g.id=t.guild_id where {query_time} ORDER BY t.id desc limit {(int(page) - 1) * size},{size}'
sum_sql=f"select count(e.id) as num from finance_error_transverse_log as e inner join fi_account as f on e.uuid=f.uuid where {' and '.join(recovery_list)}"
query_sql=f"select e.id,f.name,e.cont,e.out_money,e.entry_money,e.uuid,e.type,e.create_time,e.from_time from finance_error_transverse_log as e inner join fi_account as f on e.uuid=f.uuid where {' and '.join(recovery_list)} order by e.id DESC limit {(int(params.get('page')) - 1) * params.get('size')},{params.get('size')}"
sum_sql=f"select count(e.id) as num from finance_error_transverse_log as e left join fi_account as f on e.uuid=f.uuid where {' and '.join(recovery_list)}"
query_sql=f"select e.id,f.name,e.cont,e.out_money,e.entry_money,e.uuid,e.type,e.create_time,e.from_time from finance_error_transverse_log as e left join fi_account as f on e.uuid=f.uuid where {' and '.join(recovery_list)} order by e.id DESC limit {(int(params.get('page')) - 1) * params.get('size')},{params.get('size')}"
else:
query_sql=f"select e.id,f.name,e.cont,e.out_money,e.entry_money,e.uuid,e.type,e.create_time,e.from_time from finance_error_transverse_log as e inner join fi_account as f on e.uuid=f.uuid order by e.id DESC limit {(int(params.get('page')) - 1) * params.get('size')},{params.get('size')}"
sum_sql=f"select count(e.id) as num from finance_error_transverse_log as e inner join fi_account as f on e.uuid=f.uuid "
query_sql=f"select e.id,f.name,e.cont,e.out_money,e.entry_money,e.uuid,e.type,e.create_time,e.from_time from finance_error_transverse_log as e left join fi_account as f on e.uuid=f.uuid order by e.id DESC limit {(int(params.get('page')) - 1) * params.get('size')},{params.get('size')}"
sum_sql=f"select count(e.id) as num from finance_error_transverse_log as e left join fi_account as f on e.uuid=f.uuid "