This commit is contained in:
parent
025b4e5b33
commit
ff38ec04e9
|
@ -0,0 +1,64 @@
|
|||
from lib.all import *
|
||||
|
||||
service_name = "check_wx_share"
|
||||
# log_dir = "/app/log"
|
||||
log_dir = "."
|
||||
logger = Logger(service_name, log_dir=log_dir, print_terminal=True)
|
||||
|
||||
|
||||
def check_wx_url(url):
|
||||
api_url = "http://wx.rrbay.com/pro/wxUrlCheck2.ashx?key=9dab4264f077aa3697d346f7ac1f5270&url=%s" % url
|
||||
res = requests.get(api_url)
|
||||
r = json.loads(res.text)
|
||||
return r
|
||||
|
||||
|
||||
class S:
|
||||
def __init__(self):
|
||||
self.col_share_url = 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="share",
|
||||
collection="share_url"
|
||||
)
|
||||
|
||||
def __del__(self):
|
||||
self.col_share_url.close()
|
||||
|
||||
def proc(self):
|
||||
try:
|
||||
# 获取要更新的url
|
||||
doc = self.col_share_url.find_one({}, sort_keys=[("ut", 1)])
|
||||
if not doc:
|
||||
logger.Error("get wait update doc fail")
|
||||
return
|
||||
url = safe_get_str(doc, "_id")
|
||||
|
||||
# 检查一下url
|
||||
res = check_wx_url(url)
|
||||
logger.Info("check_url_resp, url: {}, res: {}".format(url, res))
|
||||
code = safe_get_str(res, "Code")
|
||||
if code == "002":
|
||||
return
|
||||
|
||||
# 更新db
|
||||
query = {
|
||||
"_id": url,
|
||||
}
|
||||
up = {
|
||||
"$set": {
|
||||
"ut": int(time.time()),
|
||||
"status": safe_get_str(res, "Code"),
|
||||
"api_res": dict2json(res)
|
||||
}
|
||||
}
|
||||
ret = self.col_share_url.update_one(query, up)
|
||||
logger.Info("mongo ret, modify: {}".format(ret.modified_count))
|
||||
except Exception as e:
|
||||
logger.Error("panic: {}".format(str(e)))
|
||||
|
||||
|
||||
s = S()
|
||||
while True:
|
||||
s.proc()
|
||||
time.sleep(21)
|
7
loop.py
7
loop.py
|
@ -1,7 +0,0 @@
|
|||
from lib.all import *
|
||||
|
||||
while True:
|
||||
time.sleep(0.1)
|
||||
|
||||
res = requests.get("https://testapi.tiefen.fun/test/ip", {})
|
||||
print(res.text)
|
|
@ -0,0 +1,118 @@
|
|||
import json
|
||||
import random
|
||||
import string
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import requests
|
||||
from lib.all import *
|
||||
|
||||
MiZhiBo_Top_Domain = "mizhibo.live"
|
||||
MiZhiBo_Cert_Id = 12
|
||||
|
||||
service_name = 'add_wx_share_url'
|
||||
log_dir = '.'
|
||||
logger = Logger(service_name, log_dir=log_dir)
|
||||
|
||||
|
||||
def add_domain_record(ak, secret, region_id, top_dm, record, typ, value):
|
||||
# 执行一个shell命令,并获取输出
|
||||
command = "/Users/erwin/Downloads/aliyun_go_sdk/adr {} {} {} {} {} {} {}".format(ak, secret, region_id, top_dm, record, typ, value)
|
||||
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
|
||||
# 打印输出和错误信息
|
||||
logger.Info(result.stdout)
|
||||
logger.Info(result.stderr)
|
||||
|
||||
|
||||
def add_wx_share_url_to_nginx(dm, ip, port, cert_id):
|
||||
headers = {
|
||||
'sec-ch-ua-platform': '"macOS"',
|
||||
'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhcGkiLCJzY29wZSI6WyJ1c2VyIl0sImF0dHJzIjp7ImlkIjoxfSwiZXhwaXJlc0luIjoiMWQiLCJqdGkiOiJsVmxUNWIzbHpVd3FkWnhBIiwiaWF0IjoxNzMzMjkzMDQxLCJleHAiOjE3MzMzNzk0NDF9.gA-fJrBh8P_W5QSMs7XYnZDxVpjTRd_epfbs0b-BkTauXBltXiTMeaViKRU-g_DSp5opy8ZhdnqAAWD_Ry5AWDSCtbfg4W6JV1wz10x2TlUkrIDDWwhoDcv71yM8Giw260627LXV6YF0ag_pDXLdp23QOckXWRdGrfT4cDuafyn6iBG7MxOV8Ms6uZ2MjLsKgA4YDnN_-Zxik2MO5-bN4lXRHFAWf6evNLjBSogfZ1uu8MFLHBtRSrwJzXJSD6IMNesDdpZ39ztwqXwcryHD2hHloHFH5_Xu-xWNhvVhMILXwCG_nXDpHgNWdiDM9Q1fIJIxmYdiYTMpBsKDrQX0Yw',
|
||||
'Referer': 'https://nginx.wishpal.cn/nginx/proxy',
|
||||
'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
|
||||
json_data = {
|
||||
'domain_names': [
|
||||
dm,
|
||||
],
|
||||
'forward_scheme': 'http',
|
||||
'forward_host': ip,
|
||||
'forward_port': port,
|
||||
'allow_websocket_upgrade': True,
|
||||
'access_list_id': '0',
|
||||
'certificate_id': cert_id,
|
||||
'ssl_forced': True,
|
||||
'meta': {
|
||||
'letsencrypt_agree': False,
|
||||
'dns_challenge': False,
|
||||
},
|
||||
'advanced_config': '',
|
||||
'locations': [],
|
||||
'block_exploits': False,
|
||||
'caching_enabled': False,
|
||||
'http2_support': False,
|
||||
'hsts_enabled': False,
|
||||
'hsts_subdomains': False,
|
||||
}
|
||||
|
||||
response = requests.post('https://nginx.wishpal.cn/api/nginx/proxy-hosts', headers=headers, json=json_data)
|
||||
res = json.loads(response.text)
|
||||
return res
|
||||
|
||||
|
||||
def generate_random_string(length):
|
||||
letters = string.ascii_lowercase + string.digits
|
||||
return ''.join(random.choice(letters) for _ in range(length))
|
||||
|
||||
|
||||
def proc(cnt, top_dm):
|
||||
col_share_url = 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="share",
|
||||
collection="share_url"
|
||||
)
|
||||
|
||||
for i in range(cnt):
|
||||
l2_host = generate_random_string(19)
|
||||
|
||||
# 添加域名解析
|
||||
add_domain_record(
|
||||
"LTAI5t9GQLk8D63FPZFKiXMH",
|
||||
"QPgrEowuYKEYD0vp8fnW0Egri8lu04",
|
||||
"cn-hangzhou",
|
||||
top_dm,
|
||||
l2_host,
|
||||
"A",
|
||||
"47.98.41.64"
|
||||
)
|
||||
|
||||
# 添加nginx
|
||||
dm = l2_host + "." + top_dm
|
||||
res = add_wx_share_url_to_nginx(dm, "172.16.0.183", 3003, MiZhiBo_Cert_Id)
|
||||
logger.Info(res)
|
||||
|
||||
# 添加db
|
||||
doc = {
|
||||
"_id": dm,
|
||||
"ct": int(time.time()),
|
||||
"ut": 0,
|
||||
"status": "000",
|
||||
"api_res": "",
|
||||
"use_cnt": 0
|
||||
}
|
||||
mongo_ret = col_share_url.insert_one(doc)
|
||||
logger.Info(mongo_ret.inserted_id)
|
||||
|
||||
logger.Info("{}_add_suc:{}".format(i + 1, dm))
|
||||
|
||||
col_share_url.close()
|
||||
|
||||
|
||||
proc(99, MiZhiBo_Top_Domain)
|
38
start.py
38
start.py
|
@ -1,38 +0,0 @@
|
|||
import time
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
duration = 10 * 6000 # 总持续时间,单位为秒
|
||||
interval = 1 # 循环间隔,单位为秒
|
||||
iterations = duration // interval # 循环次数
|
||||
server_status_fd_path = "/Users/erwin/SERVER_STATUS_FD"
|
||||
|
||||
if not os.path.exists(server_status_fd_path):
|
||||
try:
|
||||
with open(server_status_fd_path, "w") as f:
|
||||
print("文件已创建")
|
||||
f.close()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
try:
|
||||
subprocess.run("kill -2 59638", shell=True)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
# 循环执行
|
||||
for i in range(iterations):
|
||||
time.sleep(interval)
|
||||
print("执行代码,当前循环次数:", i + 1)
|
||||
try:
|
||||
with open(server_status_fd_path, "r") as f:
|
||||
var = f.read().replace("\r", "").replace("\n", "").replace("\t", "")
|
||||
if var == "STOP" or var == "":
|
||||
subprocess.run("nohup /Users/erwin/wishpalv2/service/app/mix/cmd_local/cmd_local &", shell=True)
|
||||
f.close()
|
||||
break
|
||||
f.close()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
# time.sleep(interval) # 等待指定的间隔时间
|
|
@ -1,13 +1,15 @@
|
|||
from lib.all import *
|
||||
|
||||
uid = 231638
|
||||
|
||||
csv_w = Csv(
|
||||
"income_11_983565.csv", ["用户id", "昵称", "空间解锁", "主播收入钻石"]
|
||||
"income_11月_{}.csv".format(uid), ["用户id", "昵称", "空间解锁", "主播收入钻石"]
|
||||
)
|
||||
|
||||
st_str = "2024-11-01 00:00:00"
|
||||
et_str = "2024-12-01 00:00:00"
|
||||
|
||||
uids = [983565]
|
||||
uids = [uid]
|
||||
|
||||
|
||||
class S:
|
||||
|
@ -144,6 +146,9 @@ select mid, sum(`change`) as income from vas_ch_income where mid in (%s) and ct>
|
|||
print(doc)
|
||||
csv_w.append([doc])
|
||||
|
||||
exit(1)
|
||||
|
||||
|
||||
s = S()
|
||||
s.proc()
|
||||
exit(1)
|
|
@ -0,0 +1,271 @@
|
|||
from typing import List
|
||||
from lib.all import *
|
||||
|
||||
|
||||
# Assume these classes exist and mimic the Go structs
|
||||
class ConsumeHistory:
|
||||
def __init__(self, ct=None, change=None, s_type=None, type_id=None, uid=None):
|
||||
self.ct = ct
|
||||
self.change = change
|
||||
self.s_type = s_type
|
||||
self.type_id = type_id
|
||||
self.uid = uid
|
||||
|
||||
def GetChange(self):
|
||||
return self.change
|
||||
|
||||
def GetSType(self):
|
||||
return self.s_type
|
||||
|
||||
def GetTypeId(self):
|
||||
return self.type_id
|
||||
|
||||
def GetCt(self):
|
||||
return self.ct
|
||||
|
||||
def GetUid(self):
|
||||
return self.uid
|
||||
|
||||
|
||||
class CHSt:
|
||||
def __init__(self, ct=None, desc=None, change=None):
|
||||
self.ct = ct
|
||||
self.desc = desc
|
||||
self.change = change
|
||||
|
||||
|
||||
# Assume these constants are defined similarly to the Go constants
|
||||
CHTypeCost = 1 # 消费明细(金币)
|
||||
CHTypeCharge = 2 # 充值明细(金币)
|
||||
CHTypeIncome = 3 # 收入明细(钻石)
|
||||
CHTypeWithdraw = 4 # 提现明细(钻石)
|
||||
|
||||
CHSTypeCostContact = 10001 # 消费明细,联系方式
|
||||
CHSTypeCostRefundContactWechat = 10002 # 消费明细,微信联系方式退款
|
||||
CHSTypeCostMembership = 10003 # 消费明细,会员资格解锁(伪金币记录,会员资格解锁中间无转金币过程)
|
||||
CHSTypeCostRefundMembership = 10004 # 消费明细,会员资格解锁退款(伪金币记录,会员资格解锁中间无转金币过程)
|
||||
|
||||
CHSTypeChargeUser = 20001 # 充值明细,用户自己冲
|
||||
CHSTypeChargeOp = 20002 # 充值明细,OP充值
|
||||
CHSTypeChargeRefundCoins = 20003 # 充值明细,金币退款
|
||||
CHSTypeChargeRefundMembership = 20004 # 充值明细,会员退款
|
||||
CHSTypeChargeMembership = 20005 # 充值明细,会员充值
|
||||
CHSTypeChargeRefundContactWechat = 20006 # 充值明细,微信金币退款
|
||||
CHSTypeChargeZoneMoment = 20007 # 充值明细,动态解锁
|
||||
CHSTypeChargeZoneAdmission = 20008 # 充值明细,空间会员
|
||||
CHSTypeChargeZoneSuperfanship = 20009 # 充值明细,空间超粉
|
||||
CHSTypeChargeZoneRefundAdmission = 20010 # 充值明细,空间普通会员退款
|
||||
CHSTypeChargeZoneRefundMoment = 20011 # 充值明细,空间动态退款
|
||||
CHSTypeChargeZoneRefundSuperfanship = 20012 # 充值明细,空间动态退款
|
||||
|
||||
CHSTypeIncomeContact = 30001 # 收入明细,联系方式
|
||||
CHSTypeIncomeInvite = 30002 # 收入明细,邀请分成
|
||||
CHSTypeIncomeRefundMembership = 30003 # 收入明细,会员退款
|
||||
CHSTypeIncomeRefundContactWechat = 30004 # 收入明细,微信退款
|
||||
CHSTypeIncomeThirdPartner = 30005 # 收入明细,代运营
|
||||
CHSTypeIncomeCollaborator = 30006 # 收入明细,协作者
|
||||
CHSTypeIncomeZoneStreamer = 30007 # 收入明细,主播空间收益
|
||||
CHSTypeIncomeMembership = 30008 # 收入明细,会员
|
||||
CHSTypeIncomeRefundZoneAdmission = 30009 # 收入明细,空间普通会员分成退款
|
||||
CHSTypeIncomeRefundThirdPartner = 30010 # 收入明细,代运营
|
||||
CHSTypeIncomeRefundCollaborator = 30011 # 收入明细,协作者
|
||||
CHSTypeIncomeRefundZoneStreamer = 30012 # 收入明细,主播空间收益
|
||||
|
||||
CHSTypeWithdrawDiamondAuto = 40001 # 自动提现明细
|
||||
CHSTypeWithdrawDiamondHvyogo = 40002 # 慧用工提现明细
|
||||
CHSTypeWithdrawDiamondReversal = 40003 # 提现冲正明细
|
||||
|
||||
ProductIdOpCoin = "op_coin" # op充值的金币
|
||||
|
||||
ProductIdH5CustomCoin = "h5_custom_coin" # H5 自定义金币
|
||||
ProductIdH5Coin500 = "h5_coin_500" # H5 500币
|
||||
ProductIdH5Coin1000 = "h5_coin_1000" # H5 1000币
|
||||
ProductIdH5Coin3000 = "h5_coin_3000" # H5 3000币
|
||||
ProductIdH5Coin5000 = "h5_coin_5000" # H5 5000币
|
||||
ProductIdH5Coin8000 = "h5_coin_8000" # H5 8000币
|
||||
ProductIdH5Coin10000 = "h5_coin_10000" # H5 10000币
|
||||
ProductIdH5Coin15000 = "h5_coin_15000" # H5 15000币
|
||||
ProductIdH5Coin18000 = "h5_coin_18000" # H5 18000币
|
||||
ProductIdH5Coin20000 = "h5_coin_20000" # H5 20000币
|
||||
|
||||
ProductIdIosCoin70 = "70_gold"
|
||||
ProductIdIosCoin350 = "350_gold"
|
||||
ProductIdIosCoin686 = "686_gold"
|
||||
ProductIdIosCoin2086 = "2086_gold"
|
||||
ProductIdIosCoin4886 = "4886_gold"
|
||||
ProductIdIosCoin6986 = "6986_gold"
|
||||
ProductIdIosCoin9086 = "9086_gold"
|
||||
ProductIdIosCoin13986 = "13986_gold"
|
||||
ProductIdIosCoin20986 = "20986_gold"
|
||||
|
||||
ProductIdContactWechat = "contact_wechat" # 微信联系方式
|
||||
ProductIdH5ContactWechat = "h5_contact_wechat" # h5的联系方式,rmb直接解锁
|
||||
ProductIdSuperfanGiftContactWechat = "superfan_gift_contact_wechat" # 超粉赠送的联系方式
|
||||
|
||||
ProductIdMembership = "membership" # 会员
|
||||
ProductIdH5Membership = "h5_membership" # 会员
|
||||
|
||||
ProductIdH5ZoneMoment = "h5_zone_moment" # 空间动态
|
||||
ProductIdH5ZoneAdmission = "h5_zone_admission" # 空间普通会员
|
||||
ProductIdH5ZoneIronfanship = "h5_zone_ironfanship" # 空间铁粉
|
||||
ProductIdH5ZoneSuperfanship = "h5_zone_superfanship" # 空间超粉
|
||||
|
||||
ProductIdOuterRaven = "outer_raven" # 瑞文测试
|
||||
|
||||
|
||||
def get_type_id_desc(type_id): # Placeholder function
|
||||
return f" (Type ID: {type_id})"
|
||||
|
||||
|
||||
def ch_list_income(ch_list: List[ConsumeHistory]) -> List[CHSt]:
|
||||
"""
|
||||
Translates the provided Go code snippet to Python.
|
||||
|
||||
Processes a list of ConsumeHistory objects and returns a list of CHSt objects.
|
||||
"""
|
||||
|
||||
list_chst = []
|
||||
for ch_db in ch_list:
|
||||
item = CHSt(ct=ch_db.ct)
|
||||
change_mark = "-"
|
||||
if ch_db.GetChange() >= 0:
|
||||
change_mark = "+"
|
||||
|
||||
if ch_db.GetSType() == CHSTypeIncomeContact:
|
||||
item.desc = "解锁微信"
|
||||
item.change = change_mark + f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeInvite:
|
||||
item.desc = "邀请收益"
|
||||
item.change = change_mark + f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeRefundMembership:
|
||||
item.desc = "用户会员退款"
|
||||
item.change = f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeRefundContactWechat:
|
||||
item.desc = "用户微信退款"
|
||||
item.change = f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeThirdPartner:
|
||||
item.desc = "代运营收益" + get_type_id_desc(ch_db.GetTypeId())
|
||||
if ch_db.GetTypeId() == ProductIdH5ZoneAdmission:
|
||||
item.desc = "空间成员-代运营"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneMoment:
|
||||
item.desc = "空间动态-代运营"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneSuperfanship:
|
||||
item.desc = "空间超粉-代运营"
|
||||
elif ch_db.GetTypeId() == ProductIdContactWechat:
|
||||
if ch_db.GetCt() >= 1722497400:
|
||||
item.desc = f"解锁微信({ch_db.GetUid()})-代运营"
|
||||
elif ch_db.GetTypeId() == ProductIdSuperfanGiftContactWechat:
|
||||
if ch_db.GetCt() >= 1722497400:
|
||||
item.desc = f"超粉送微信({ch_db.GetUid()})-代运营"
|
||||
item.change = change_mark + f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeCollaborator:
|
||||
item.desc = "协作收益" + get_type_id_desc(ch_db.GetTypeId())
|
||||
if ch_db.GetTypeId() == ProductIdH5ZoneAdmission:
|
||||
item.desc = "空间成员-合伙人"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneMoment:
|
||||
item.desc = "空间动态-合伙人"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneSuperfanship:
|
||||
item.desc = "空间超粉-合伙人"
|
||||
elif ch_db.GetTypeId() == ProductIdContactWechat:
|
||||
if ch_db.GetCt() >= 1722497400:
|
||||
item.desc = f"解锁微信({ch_db.GetUid()})-合伙人"
|
||||
elif ch_db.GetTypeId() == ProductIdSuperfanGiftContactWechat:
|
||||
if ch_db.GetCt() >= 1722497400:
|
||||
item.desc = f"超粉送微信({ch_db.GetUid()})-合伙人"
|
||||
item.change = change_mark + f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeZoneStreamer:
|
||||
item.desc = "空间收益" + get_type_id_desc(ch_db.GetTypeId())
|
||||
if ch_db.GetTypeId() == ProductIdH5ZoneAdmission:
|
||||
item.desc = "空间成员"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneMoment:
|
||||
item.desc = "空间动态"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneSuperfanship:
|
||||
item.desc = "空间超粉"
|
||||
item.change = change_mark + f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeMembership:
|
||||
item.desc = "永久会员收益" + get_type_id_desc(ch_db.GetTypeId())
|
||||
item.change = change_mark + f"{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeRefundZoneAdmission:
|
||||
item.desc = "(旧)空间退款" + get_type_id_desc(ch_db.GetTypeId())
|
||||
item.change = f"{ch_db.GetChange()}钻石"
|
||||
if ch_db.GetChange() == 0: # This logic seems unusual, but it's from the original code
|
||||
item.change = f"-{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeRefundThirdPartner:
|
||||
item.desc = "代运营空间退款" + get_type_id_desc(ch_db.GetTypeId())
|
||||
if ch_db.GetTypeId() == ProductIdH5ZoneAdmission:
|
||||
item.desc = "空间成员退款-代运营"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneMoment:
|
||||
item.desc = "空间动态退款-代运营"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneSuperfanship:
|
||||
item.desc = "空间超粉退款-代运营"
|
||||
item.change = f"{ch_db.GetChange()}钻石"
|
||||
if ch_db.GetChange() == 0:
|
||||
item.change = f"-{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeRefundCollaborator:
|
||||
item.desc = "合伙人空间退款" + get_type_id_desc(ch_db.GetTypeId())
|
||||
if ch_db.GetTypeId() == ProductIdH5ZoneAdmission:
|
||||
item.desc = "空间成员退款-合伙人"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneMoment:
|
||||
item.desc = "空间动态退款-合伙人"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneSuperfanship:
|
||||
item.desc = "空间动态退款-合伙人" # This seems like a potential typo (should it be 超粉?)
|
||||
item.change = f"{ch_db.GetChange()}钻石"
|
||||
if ch_db.GetChange() == 0:
|
||||
item.change = f"-{ch_db.GetChange()}钻石"
|
||||
elif ch_db.GetSType() == CHSTypeIncomeRefundZoneStreamer:
|
||||
item.desc = "空间退款" + get_type_id_desc(ch_db.GetTypeId())
|
||||
if ch_db.GetTypeId() == ProductIdH5ZoneAdmission:
|
||||
item.desc = "用户退款-空间成员"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneMoment:
|
||||
item.desc = "用户退款-空间动态"
|
||||
elif ch_db.GetTypeId() == ProductIdH5ZoneSuperfanship:
|
||||
item.desc = "用户退款-空间超粉"
|
||||
item.change = f"{ch_db.GetChange()}钻石"
|
||||
if ch_db.GetChange() == 0:
|
||||
item.change = f"-{ch_db.GetChange()}钻石"
|
||||
|
||||
list_chst.append(item)
|
||||
|
||||
return list_chst
|
||||
|
||||
|
||||
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 proc(self, mid, st, et):
|
||||
sql = "select * from vas_ch_income where mid=%d and ct>=%d and ct<%d" % (mid, st, et)
|
||||
docs = self.mysql_db_vas.query(sql)
|
||||
|
||||
ch_list_db = list()
|
||||
for doc in docs:
|
||||
# print(doc)
|
||||
ch = ConsumeHistory(
|
||||
safe_get_int(doc, "ct"),
|
||||
safe_get_int(doc, "change"),
|
||||
safe_get_int(doc, "stype"),
|
||||
safe_get_str(doc, "type_id"),
|
||||
safe_get_int(doc, "uid")
|
||||
)
|
||||
ch_list_db.append(ch)
|
||||
ch_list = ch_list_income(ch_list_db)
|
||||
|
||||
csv_w = Csv("4104838_11月_主播收益_.csv", ["时间", "钻石变化", "描述"])
|
||||
for ch in ch_list:
|
||||
d = [
|
||||
get_time_str_by_ts(ch.ct), ch.change, ch.desc,
|
||||
]
|
||||
csv_w.append([d])
|
||||
|
||||
|
||||
s = S()
|
||||
s.proc(
|
||||
954725,
|
||||
get_ts_by_str("2024-11-01 00:00:00"),
|
||||
get_ts_by_str("2024-12-01 00:00:00"),
|
||||
)
|
|
@ -0,0 +1,130 @@
|
|||
from lib.all import *
|
||||
|
||||
csv_w = Csv(
|
||||
"income_11月_官方.csv", ["用户id", "昵称", "空间解锁", "主播收入钻石"]
|
||||
)
|
||||
|
||||
|
||||
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"
|
||||
)
|
||||
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 = {
|
||||
"user_id": uid
|
||||
}
|
||||
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_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
|
||||
''' % (get_list_str(zids), st, et)
|
||||
print(sql)
|
||||
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 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):
|
||||
q = {
|
||||
"third_partner_mid": 159
|
||||
}
|
||||
docs = self.col_ztp.find(q)
|
||||
|
||||
zids = list()
|
||||
for d in docs:
|
||||
zid = safe_get_int(d, "zid")
|
||||
zids.append(zid)
|
||||
|
||||
# 空间解锁数
|
||||
zid_cnt_map = self.get_zone_admission_cnt(
|
||||
zids,
|
||||
get_ts_by_str("2024-11-01 00:00:00"),
|
||||
get_ts_by_str("2024-12-05 00:00:00")
|
||||
)
|
||||
print(zid_cnt_map)
|
||||
|
||||
mids = list()
|
||||
for zid in zids:
|
||||
mid = self.zid2mid(zid)
|
||||
mids.append(mid)
|
||||
|
||||
# 收入
|
||||
mid_income_map = self.get_streamer_income(
|
||||
mids,
|
||||
get_ts_by_str("2024-11-01 00:00:00"),
|
||||
get_ts_by_str("2024-12-05 00:00:00")
|
||||
)
|
||||
print(mid_income_map)
|
||||
|
||||
for zid in zids:
|
||||
mid = self.zid2mid(zid)
|
||||
uid, name = self.mid2uid_name(mid)
|
||||
ac = safe_get_int(zid_cnt_map, zid)
|
||||
income = safe_get_int(mid_income_map, mid)
|
||||
|
||||
doc = [uid, name, ac, income]
|
||||
print(doc)
|
||||
csv_w.append([doc])
|
||||
|
||||
|
||||
s = S()
|
||||
s.proc()
|
28
ws/demo.py
28
ws/demo.py
|
@ -1,28 +0,0 @@
|
|||
import asyncio
|
||||
import websockets
|
||||
|
||||
|
||||
async def communicate(uri):
|
||||
async with websockets.connect(uri) as websocket:
|
||||
while True:
|
||||
message_to_send = input("Enter message to send (or 'quit' to exit): ")
|
||||
if message_to_send.lower() == 'quit':
|
||||
break
|
||||
|
||||
await websocket.send(message_to_send)
|
||||
print(f"Sent: {message_to_send}")
|
||||
|
||||
try:
|
||||
received_message = await websocket.recv()
|
||||
print(f"Received: {received_message}")
|
||||
except websockets.ConnectionClosed:
|
||||
print("Connection closed by server.")
|
||||
break
|
||||
|
||||
|
||||
async def main():
|
||||
await communicate("ws://127.0.0.1:7980/ws?mid=111")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
38
x.py
38
x.py
|
@ -1,38 +0,0 @@
|
|||
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