From c2a4c9bce53acb97d137992370a7e667d0680c90 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Wed, 8 May 2024 16:33:22 +0800 Subject: [PATCH] add bi --- bi/vas_yoy_flow.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bi/vas_yoy_flow.py diff --git a/bi/vas_yoy_flow.py b/bi/vas_yoy_flow.py new file mode 100644 index 0000000..e3391bc --- /dev/null +++ b/bi/vas_yoy_flow.py @@ -0,0 +1,40 @@ +from lib.all import * + + +# 流水同比 + +class S: + def __init__(self): + self.mysql_db_vas = Mysql( + "rm-bp11t1616a1kjvmx5.mysql.rds.aliyuncs.com", 3306, "vas", "root", "Wishpal2024" + ) + self.mysql_db_bi = Mysql( + "1Panel-mysql-TUA1", 3306, "metabase_bi", "metabase_bi", "Wishpal_2024" + ) + + def __del__(self): + self.mysql_db_vas.close() + self.mysql_db_bi.close() + + def get_last_ptime(self): + sql = '''select * from vas_yoy_flow order by ptime desc limit 1''' + rows = self.mysql_db_vas.query(sql) + if len(rows) > 0: + return rows[0].get("ptime") + return "" + + def get_flow(self, st, et): + sql = '''select sum(pay_amount) flow from vas_order where ct>={} and ct<{}'''.format(st, et) + rows = self.mysql_db_vas.query(sql) + if len(rows) > 0: + return safe_get_int(rows[0], "flow") + return 0 + + def proc(self): + zero_time = get_today_zero_time() - 86400 + + print(zero_time) + + +s = S() +s.proc()