This commit is contained in:
lwl0608 2024-09-03 22:56:13 +08:00
parent 22c1435e2b
commit ab909b1fb4
1 changed files with 50 additions and 1 deletions

View File

@ -18,11 +18,18 @@ class S:
db="account",
collection="account"
)
self.col_zone = 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="zone",
collection="zone"
)
def __del__(self):
self.mysql_db_vas.close()
self.col_ztp.close()
self.col_account.close()
self.col_zone.close()
def uid2mid(self, uid):
q = {
@ -31,6 +38,20 @@ class S:
doc = self.col_account.find_one(q)
return safe_get_int(doc, "_id")
def zid2mid(self, zid):
q = {
"_id": zid
}
doc = self.col_zone.find_one(q)
return safe_get_int(doc, "mid")
def mid2uid_name(self, mid):
q = {
"_id": mid
}
doc = self.col_account.find_one(q)
return safe_get_int(doc, "user_id"), safe_get_str(doc, "name")
# 获取代运营管理的空间
def get_tp_zids(self, tp_mids):
q = {
@ -46,7 +67,7 @@ class S:
# 获取zid解锁空间
def get_zone_admission_cnt(self, zids, st, et):
sql = '''
select zid, count(1) as admission_cnt from vas_zone_member where zid in (%s) and member_type=1 and ct>=%d and ct<%d group by zid
select zid, count(1) as admission_cnt from vas_zone_member where zid in (%s) and member_type=1 and ct>=%d and ct<%d group by zid
''' % (get_list_str(zids), st, et)
print(sql)
rows = self.mysql_db_vas.query(sql)
@ -57,6 +78,20 @@ class S:
zid_cnt_map[zid] = ac
return zid_cnt_map
# 获取主播净收入
def get_streamer_income(self, mids, st, et):
sql = '''
select mid, sum(`change`) as income from vas_ch_income where mid in (%s) and ct>=%d and ct<%d group by mid
''' % (get_list_str(mids), st, et)
print(sql)
rows = self.mysql_db_vas.query(sql)
mid_income_map = dict()
for row in rows:
mid = safe_get_int(row, "mid")
income = safe_get_int(row, "income")
mid_income_map[mid] = income
return mid_income_map
def proc(self):
tp_uids = [983565, 231638]
tp_mids = list()
@ -76,6 +111,20 @@ class S:
)
print(zid_cnt_map)
# 获取空间对应的mid
streamer_mids = list()
for zid in zids:
streamer_mids.append(self.zid2mid(zid))
print(streamer_mids)
# 收入
# mid_income_map = self.get_streamer_income(
# ,
# get_ts_by_str("2024-08-01 00:00:00"),
# get_ts_by_str("2024-09-01 00:00:00")
# )
# print(zid_cnt_map)
s = S()
s.proc()