This commit is contained in:
lwl0608 2024-07-10 14:16:15 +08:00
parent f9ad1c808c
commit 39742d9aa5
1 changed files with 73 additions and 0 deletions

73
vas/calc_diamonds.py Normal file
View File

@ -0,0 +1,73 @@
from lib.all import *
class S:
def __init__(self):
self.mysql_db_vas = Mysql(
"rm-bp11t1616a1kjvmx5.mysql.rds.aliyuncs.com", 3306, "vas", "root", "Wishpal2024"
)
def __del__(self):
self.mysql_db_vas.close()
def get_ch_income(self, mid):
sql = "select * from vas_ch_income where mid={} order by order_id".format(mid)
rows = self.mysql_db_vas.query(sql)
return rows
def get_withdraw_his(self, order_id):
sql = "select * from vas_withdraw_diamonds_his where order_id='{}'".format(order_id)
rows = self.mysql_db_vas.query(sql)
return rows
def get_order(self, order_id):
sql = "select * from vas_order where id='{}'".format(order_id)
rows = self.mysql_db_vas.query(sql)
if not rows:
return None
if len(rows) > 0:
return rows[0]
def get_coin_order(self, order_id):
sql = "select * from vas_coin_order where id='{}'".format(order_id)
rows = self.mysql_db_vas.query(sql)
if not rows:
return None
if len(rows) > 0:
return rows[0]
def proc(self, mid):
hds = [
"order_id",
"change",
"typ",
"order_status",
"结算状态"
]
csv_ = Csv("{}_incom.csv".format(mid), hds)
rows = self.get_ch_income(mid)
for row in rows:
order_id = safe_get_str(row, "order_id")
typ = "money"
o = self.get_order(order_id)
if not o:
typ = "coin"
o = self.get_coin_order(order_id)
if not o:
typ = "error"
order_stats = safe_get_int(o, "order_status")
data = [
order_id, safe_get_int(row, "change"), typ, order_stats
]
w_his = self.get_withdraw_his(order_id)
if w_his:
pass
else:
data.append("未结算")
csv_.append([data])
s = S()
s.proc(74)