69 lines
2.1 KiB
Python
69 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"
|
|
)
|
|
self.col_ztp = 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_third_partner",
|
|
collection="zone_third_partner"
|
|
)
|
|
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"
|
|
)
|
|
|
|
def __del__(self):
|
|
self.mysql_db_vas.close()
|
|
self.col_ztp.close()
|
|
self.col_account.close()
|
|
|
|
def uid2mid(self, uid):
|
|
q = {
|
|
"user_id": uid
|
|
}
|
|
doc = self.col_account.find_one(q)
|
|
return safe_get_int(doc, "_id")
|
|
|
|
# 获取代运营管理的空间
|
|
def get_tp_zids(self, tp_mids):
|
|
q = {
|
|
"third_partner_mid": {"$in": tp_mids}
|
|
}
|
|
docs = self.col_ztp.find(q)
|
|
zids = list()
|
|
for d in docs:
|
|
zid = safe_get_int(d, "zid")
|
|
zids.append(zid)
|
|
return zids
|
|
|
|
# 获取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 ct>=%d and ct<%d
|
|
''' % (get_list_str(zids), st, et)
|
|
rows = self.mysql_db_vas.query(sql)
|
|
zid_cnt_map = dict()
|
|
for row in rows:
|
|
zid = safe_get_int(row, "zid")
|
|
ac = safe_get_int(row, "admission_cnt")
|
|
zid_cnt_map[zid] = ac
|
|
return zid_cnt_map
|
|
|
|
def proc(self):
|
|
tp_uids = [983565, 231638]
|
|
tp_mids = list()
|
|
for uid in tp_uids:
|
|
tp_mids.append(self.uid2mid(uid))
|
|
print(tp_mids)
|
|
|
|
|
|
s = S()
|
|
s.proc()
|