From b854b9fd807f71ee1c2b6f626ce6d113288147b8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 4 Dec 2020 16:09:10 +0800 Subject: [PATCH] 1 --- server/mailman/game2005.go | 139 ++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 78 deletions(-) diff --git a/server/mailman/game2005.go b/server/mailman/game2005.go index 3a9beac..7fd7b48 100644 --- a/server/mailman/game2005.go +++ b/server/mailman/game2005.go @@ -142,34 +142,55 @@ func (this *Game2005) SetDBIdx(instanceId int32, idx int64) { this.dbIdxHash.Store(instanceId, idx) } -func (this *Game2005) SendVipLvUpMail(accountId string, oldLv int32, newLv int32, upTime int32) bool { +func (this *Game2005) internalSendMail(to string, + mailSubType int32, + content string, + subject string, + sendTime int32, + expireTime int32, + attachments string) bool { gameMailApiUrl := "https://gamemail.kingsome.cn/webapp/index.php" if !f5.IsOnlineEnv() { gameMailApiUrl = "https://gamemail-test.kingsome.cn/webapp/index.php" } + params := q5.NewMxoObject() + params.SetXValue("c", q5.NewXString("MailMgr")) + params.SetXValue("a", q5.NewXString("sendMail")) + params.SetXValue("gameid", q5.NewXInt32(this.GetGameId())) + params.SetXValue("to", q5.NewXString(to)) + params.SetXValue("mailtype", q5.NewXInt32(1)) + params.SetXValue("mailsubtype", q5.NewXInt32(mailSubType)) + params.SetXValue("usertype", q5.NewXInt32(2)) + params.SetXValue("content", q5.NewXString(content)) + params.SetXValue("subject", q5.NewXString(subject)) + params.SetXValue("sendtime", q5.NewXInt32(sendTime)) + params.SetXValue("expiretime", q5.NewXInt32(expireTime)) + params.SetXValue("attachments", q5.NewXString(attachments)) + respObj, respStr, err := q5.HttpGetAsJson(gameMailApiUrl, params.AsXObject()) + if err != nil { + f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) + return false + } + if !(respObj.GetSimpleStr("errcode", "") == "0" && + respObj.GetSimpleStr("errcode", "") == "1008") { + f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) + return false + } + return true +} + +func (this *Game2005) SendVipLvUpMail(accountId string, oldLv int32, newLv int32, upTime int32) bool { mailMeta := this.vipLvUpMailMeta for vipLv := oldLv + 1; vipLv <= newLv; vipLv++ { - params := q5.NewMxoObject() - params.SetXValue("c", q5.NewXString("MailMgr")) - params.SetXValue("a", q5.NewXString("sendMail")) - params.SetXValue("gameid", q5.NewXInt32(this.GetGameId())) - params.SetXValue("to", q5.NewXString(accountId)) - params.SetXValue("mailtype", q5.NewXInt32(1)) - params.SetXValue("mailsubtype", q5.NewXInt32(-2)) - params.SetXValue("usertype", q5.NewXInt32(2)) - params.SetXValue("content", q5.NewXString(mailMeta.GetContent())) - params.SetXValue("subject", q5.NewXString(mailMeta.GetSubject())) - params.SetXValue("sendtime", q5.NewXInt32(upTime)) - params.SetXValue("expiretime", q5.NewXInt32(upTime + 3600 * 24 * 30)) - params.SetXValue("attachments", q5.NewXString(mailMeta.GetAttachmentsByLv(vipLv))) - respObj, respStr, err := q5.HttpGetAsJson(gameMailApiUrl, params.AsXObject()) - if err != nil { - f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) - return false - } - if !(respObj.GetSimpleStr("errcode", "") == "0" && - respObj.GetSimpleStr("errcode", "") == "1008") { - f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) + ok := this.internalSendMail( + accountId, + -2, + mailMeta.GetContent(), + mailMeta.GetSubject(), + upTime, + upTime + 3600 * 24 * 30, + mailMeta.GetAttachmentsByLv(vipLv)) + if !ok { return false } } @@ -177,67 +198,29 @@ func (this *Game2005) SendVipLvUpMail(accountId string, oldLv int32, newLv int32 } func (this *Game2005) SendPriviDailyMail(accountId string, priviLv int32, sendTime int32) bool { - gameMailApiUrl := "https://gamemail.kingsome.cn/webapp/index.php" - if !f5.IsOnlineEnv() { - gameMailApiUrl = "https://gamemail-test.kingsome.cn/webapp/index.php" - } mailMeta := this.priviDailyMailMeta - params := q5.NewMxoObject() - params.SetXValue("c", q5.NewXString("MailMgr")) - params.SetXValue("a", q5.NewXString("sendMail")) - params.SetXValue("gameid", q5.NewXInt32(this.GetGameId())) - params.SetXValue("to", q5.NewXString(accountId)) - params.SetXValue("mailtype", q5.NewXInt32(1)) - params.SetXValue("mailsubtype", q5.NewXInt32(-2)) - params.SetXValue("usertype", q5.NewXInt32(2)) - params.SetXValue("content", q5.NewXString(mailMeta.GetContent())) - params.SetXValue("subject", q5.NewXString(mailMeta.GetSubject())) - params.SetXValue("sendtime", q5.NewXInt32(sendTime)) - params.SetXValue("expiretime", q5.NewXInt32(sendTime + 3600 * 24 * 30)) - params.SetXValue("attachments", q5.NewXString(mailMeta.GetAttachmentsByLv(priviLv))) - respObj, respStr, err := q5.HttpGetAsJson(gameMailApiUrl, params.AsXObject()) - if err != nil { - f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) - return false - } - if !(respObj.GetSimpleStr("errcode", "") == "0" && - respObj.GetSimpleStr("errcode", "") == "1008") { - f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) - return false - } - return true + ok := this.internalSendMail( + accountId, + -3, + mailMeta.GetContent(), + mailMeta.GetSubject(), + sendTime, + sendTime + 3600 * 24 * 30, + mailMeta.GetAttachmentsByLv(priviLv)) + return ok } func (this *Game2005) SendVipWeeklyMail(accountId string, vipLv int32, sendTime int32) bool { - gameMailApiUrl := "https://gamemail.kingsome.cn/webapp/index.php" - if !f5.IsOnlineEnv() { - gameMailApiUrl = "https://gamemail-test.kingsome.cn/webapp/index.php" - } mailMeta := this.vipWeeklyMailMeta - params := q5.NewMxoObject() - params.SetXValue("c", q5.NewXString("MailMgr")) - params.SetXValue("a", q5.NewXString("sendMail")) - params.SetXValue("gameid", q5.NewXInt32(this.GetGameId())) - params.SetXValue("to", q5.NewXString(accountId)) - params.SetXValue("mailtype", q5.NewXInt32(1)) - params.SetXValue("mailsubtype", q5.NewXInt32(-2)) - params.SetXValue("usertype", q5.NewXInt32(2)) - params.SetXValue("content", q5.NewXString(mailMeta.GetContent())) - params.SetXValue("subject", q5.NewXString(mailMeta.GetSubject())) - params.SetXValue("sendtime", q5.NewXInt32(sendTime)) - params.SetXValue("expiretime", q5.NewXInt32(sendTime + 3600 * 24 * 30)) - params.SetXValue("attachments", q5.NewXString(mailMeta.GetAttachmentsByLv(vipLv))) - respObj, respStr, err := q5.HttpGetAsJson(gameMailApiUrl, params.AsXObject()) - if err != nil { - f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) - return false - } - if !(respObj.GetSimpleStr("errcode", "") == "0" && - respObj.GetSimpleStr("errcode", "") == "1008") { - f5.SysLog().Warning("url:%s resp:%s", gameMailApiUrl, respStr) - return false - } - return true + ok := this.internalSendMail( + accountId, + -4, + mailMeta.GetContent(), + mailMeta.GetSubject(), + sendTime, + sendTime + 3600 * 24 * 30, + mailMeta.GetAttachmentsByLv(vipLv)) + return ok } func (this *Game2005) FetchEventOneDB(conf *MtwGame2005MysqlConf, conn *q5.Mysql, sendTime int32) bool {