This commit is contained in:
parent
7b202ee67c
commit
662dd35765
|
@ -0,0 +1,80 @@
|
||||||
|
from lib.all import *
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
# 主播当日收入明细
|
||||||
|
|
||||||
|
class S:
|
||||||
|
def __init__(self):
|
||||||
|
self.col_streamer = MongoDB(
|
||||||
|
host="mongodb://root:Wishpal2024@dds-bp1da1ddd62bede41.mongodb.rds.aliyuncs.com:3717,dds-bp1da1ddd62bede42.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-77304659",
|
||||||
|
port=3717,
|
||||||
|
db="streamer",
|
||||||
|
collection="streamer"
|
||||||
|
)
|
||||||
|
self.col_account = MongoDB(
|
||||||
|
host="mongodb://root:Wishpal2024@dds-bp1da1ddd62bede41.mongodb.rds.aliyuncs.com:3717,dds-bp1da1ddd62bede42.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-77304659",
|
||||||
|
port=3717,
|
||||||
|
db="account",
|
||||||
|
collection="account"
|
||||||
|
)
|
||||||
|
self.mysql_db_vas = Mysql(
|
||||||
|
"rm-bp11t1616a1kjvmx5.mysql.rds.aliyuncs.com", 3306, "vas", "root", "Wishpal2024"
|
||||||
|
)
|
||||||
|
self.mysql_db_bi = Mysql(
|
||||||
|
"127.0.0.1", 3306, "metabase_bi", "metabase_bi", "Wishpal_2024"
|
||||||
|
)
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.col_streamer.close()
|
||||||
|
self.col_account.close()
|
||||||
|
self.mysql_db_vas.close()
|
||||||
|
self.mysql_db_bi.close()
|
||||||
|
|
||||||
|
# 更新主播信息
|
||||||
|
def update_steamer_info(self):
|
||||||
|
# 获取主播信息
|
||||||
|
prj = {"mid": 1}
|
||||||
|
docs = self.col_streamer.find({}, projection=prj)
|
||||||
|
streamer_mids = list()
|
||||||
|
for doc in docs:
|
||||||
|
mid = safe_get_int(doc, "mid")
|
||||||
|
streamer_mids.append(mid)
|
||||||
|
print("len(docs): {}".format(len(docs)))
|
||||||
|
|
||||||
|
# 获取账号信息并更新
|
||||||
|
acnt_docs = self.col_account.find({"_id": {"$in": streamer_mids}})
|
||||||
|
for doc in acnt_docs:
|
||||||
|
mid = safe_get_int(doc, "_id")
|
||||||
|
user_id = safe_get_int(doc, "user_id")
|
||||||
|
name = safe_get_str(doc, "name")
|
||||||
|
|
||||||
|
sql_q = "select * from streamer where mid='{}'".format(mid)
|
||||||
|
rows = self.mysql_db_bi.query(sql_q)
|
||||||
|
if len(rows) > 0:
|
||||||
|
sql_u = "update streamer set user_id=%s, name=%s where mid=%s"
|
||||||
|
self.mysql_db_bi.exec(sql_u, (user_id, name, mid))
|
||||||
|
else:
|
||||||
|
sql_i = "insert into streamer (mid, user_id, name) values (%s,%s,%s)"
|
||||||
|
self.mysql_db_bi.exec(sql_i, (mid, user_id, name))
|
||||||
|
|
||||||
|
def update_day_flow(self, flow):
|
||||||
|
t = get_today_zero_time()
|
||||||
|
dt = datetime.datetime.fromtimestamp(t)
|
||||||
|
formatted_dt = dt.strftime('%Y-%m-%d 00:00:00')
|
||||||
|
|
||||||
|
sql_q = "select * from vas_day_flow where pdate='{}'".format(get_time_str_by_ts(t))
|
||||||
|
rows = self.mysql_db_bi.query(sql_q)
|
||||||
|
if len(rows) > 0:
|
||||||
|
sql_u = "update vas_day_flow set flow=%s where pdate=%s"
|
||||||
|
return self.mysql_db_bi.exec(sql_u, (flow, formatted_dt))
|
||||||
|
else:
|
||||||
|
sql_i = "insert into vas_day_flow (pdate, flow) values (%s,%s)"
|
||||||
|
return self.mysql_db_bi.exec(sql_i, (formatted_dt, flow))
|
||||||
|
|
||||||
|
def proc(self):
|
||||||
|
self.update_steamer_info()
|
||||||
|
|
||||||
|
|
||||||
|
s = S()
|
||||||
|
s.proc()
|
|
@ -64,7 +64,7 @@ class S:
|
||||||
|
|
||||||
def get_one_wait_compress_video(self):
|
def get_one_wait_compress_video(self):
|
||||||
param = {
|
param = {
|
||||||
# "ids": [23431],
|
"ids": [52062],
|
||||||
"status": 0,
|
"status": 0,
|
||||||
"offset": 0,
|
"offset": 0,
|
||||||
"limit": 1,
|
"limit": 1,
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
from lib.all import *
|
||||||
|
|
||||||
|
s = '''
|
||||||
|
db.product.insert({
|
||||||
|
"_id" : "%d_gold",
|
||||||
|
"name" : "%dx",
|
||||||
|
"subject" : "发货A",
|
||||||
|
"desc" : "%dx",
|
||||||
|
"real_price" : NumberLong(%d),
|
||||||
|
"ori_price" : NumberLong(%d),
|
||||||
|
"value_coins" : %d,
|
||||||
|
"type" : "coins",
|
||||||
|
"pay_means" : 1,
|
||||||
|
"price_fix_type" : 1,
|
||||||
|
"mid" : NumberLong(0),
|
||||||
|
"dev_type" : 1,
|
||||||
|
"real_coin_price" : NumberLong(0),
|
||||||
|
"ori_coin_price" : NumberLong(0),
|
||||||
|
"del_flag" : 0,
|
||||||
|
"image_ids" : null,
|
||||||
|
"video_ids" : null,
|
||||||
|
"ct" : NumberLong(1702381979),
|
||||||
|
"ut" : NumberLong(1702381979)
|
||||||
|
})
|
||||||
|
'''
|
||||||
|
|
||||||
|
# 70_gold
|
||||||
|
# 350_gold
|
||||||
|
# 686_gold
|
||||||
|
# 2086_gold
|
||||||
|
# 4886_gold
|
||||||
|
# 6986_gold
|
||||||
|
# 9086_gold
|
||||||
|
# 13986_gold
|
||||||
|
# 20986_gold
|
||||||
|
lis = [70, 350, 686, 2086, 4886, 6986, 9086, 13986, 20986]
|
||||||
|
for i in lis:
|
||||||
|
print(s % (i, i, i, int(i / 0.7 * 10), int(i / 0.7 * 10), i))
|
Loading…
Reference in New Issue