76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
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):
|
|
print("mid: {}".format(mid))
|
|
hds = [
|
|
"order_id",
|
|
"change",
|
|
"typ",
|
|
"order_status",
|
|
"结算状态"
|
|
]
|
|
csv_ = Csv("{}_incom.csv".format(mid), hds)
|
|
rows = self.get_ch_income(mid)
|
|
print("len(rows): {}".format(len(rows)))
|
|
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)
|