From 040e52770452ce265736475fe52134f005e6c6f6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 19:17:19 +0800 Subject: [PATCH] 1 --- server/light_backtask/task/olduser.go | 81 ++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/server/light_backtask/task/olduser.go b/server/light_backtask/task/olduser.go index 1800fc67..056ae223 100644 --- a/server/light_backtask/task/olduser.go +++ b/server/light_backtask/task/olduser.go @@ -1,6 +1,12 @@ package task import ( + "q5" + "f5" + "main/constant" + "encoding/json" + "fmt" + "jccommon" ) type oldUser struct { @@ -8,7 +14,80 @@ type oldUser struct { } func (this *oldUser) init() { - + oldUsers := []struct { + Idx int32 `json:"idx"` + AccountId string `json:"account_id"` + Diamond int32 `json:"diamond"` + }{} + { + if jsonStr, err := f5.ReadJsonFile("/home/kingsome/pub/game2006web3/server/web3tools/1.json"); err == nil { + if err := json.Unmarshal([]byte(jsonStr), &oldUsers); err != nil { + panic(fmt.Sprintf("load oldUser json decode error %s %s", "nets.json", err)) + } + } else { + panic(fmt.Sprintf("load oldUser error %s %s", "nets.json", err)) + } + } + type AttachmentDto struct { + ItemId int32 `json:"itemid"` + ItemNum int32 `json:"itemnum"` + } + //fmt.Println("%s", oldUsers) + for _, user := range oldUsers { + if user.Idx <= 0 { + panic("") + } + if user.AccountId == "" { + panic("") + } + if user.Diamond <= 0 { + panic("") + } + mailId := q5.ToString(f5.GetApp().NewLockNodeUuid()) + unikey := "oldUser.return.20240823:" + user.AccountId + subject := "Claim Your Diamonds" + content := "Thanks for participating in P2E S1! The gold you earned in Gold Mode has been converted to diamonds at a 1:1 ratio. Click “Claim” to receive your rewards now." + nowTime := f5.GetApp().GetRealSeconds() + sendTime := f5.GetApp().GetRealSeconds() + expireTime := nowTime + 3600 * 24 * 15 + userRegEndTime := nowTime + 3600 * 24 * 365 + f5.GetGoStyleDb().Upsert( + constant.BCNFT_DB, + "t_mail", + [][]string{ + {"unikey", unikey}, + }, + [][]string{ + }, + [][]string{ + {"mail_id", mailId}, + {"mail_type", q5.ToString(jccommon.MAIL_TYPE_GROUP)}, + {"unikey", unikey}, + {"subject", subject}, + {"content", content}, + {"recipients", q5.EncodeJson([]string{ + user.AccountId, + })}, + {"attachments", q5.EncodeJson([]AttachmentDto{ + AttachmentDto{ + ItemId : 10014, + ItemNum : user.Diamond}, + })}, + {"sendtime", q5.ToString(sendTime)}, + {"user_reg_start_time", q5.ToString(0)}, + {"user_reg_end_time", q5.ToString(userRegEndTime)}, + {"tag1", q5.ToString(jccommon.MAIL_TAG1_OLD_USER)}, + {"tag2", q5.ToString(jccommon.MAIL_TAG2_OLD_USER)}, + {"expiretime", q5.ToString(expireTime)}, + {"createtime", q5.ToString(nowTime)}, + {"modifytime", q5.ToString(nowTime)}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + if err != nil { + panic("") + } + }) + } } func (this *oldUser) unInit() {