This commit is contained in:
aozhiwei 2020-11-26 10:09:56 +08:00
parent d1d5c17353
commit b20a1f8836

View File

@ -8,14 +8,53 @@ import f7
import os
import json
import time
import urllib.parse
import urllib.request
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/mailsender/config'
db_idx_hash = {}
def httpGet(url, params):
param = urllib.parse.urlencode(params)
url = url + param
response = urllib.request.urlopen(url=url)
def getMailConf(mailid):
mail_conf = json.loads(open(CONFIG_DIR + '/6000@game2005.mail.json', 'r').read())
for conf in mail_conf:
if conf['mailid'] == mailid:
return conf
return None
def getMailAttachmentsByVip(mail_conf, vip_lv):
items = mail_conf['attachments'].split('|')[vip_lv - 1]
return items.replace('$', '|')
def getMailAttachmentsByPriv(mail_conf, itemid):
items = mail_conf['attachments'].split('|')[vip_lv - 1]
return items.replace('$', '|')
def sendVipLvUpMail(account_id, old_vip_lv, new_vip_lv):
url = 'https://gamemail.kingsome.cn/webapp/index.php?' if f7.isOnlineEnv() else 'https://gamemail-test.kingsome.cn/webapp/index.php?'
for vip_lv in range(old_vip_lv + 1, new_vip_lv):
pass
mail_conf = getMailConf(1)
params = {
'c': 'MailMgr',
'a': 'sendMail',
'gameid': 2005,
'to': account_id,
'mailtype': 1,
'mailsubtype': -2,
'usertype': 2,
'content': mail_conf['content'],
'subject': mail_conf['subject'],
'sendtime': time.time(),
'expiretime': time.time() + 3600 * 24 * 30,
'attachments': getMailAttachmentsByVip(mail_conf, vip_lv)
}
httpGet(url, params)
def fetchEvent():
global db_idx_hash