You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
|
1 year ago
|
package call
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
"gorm.io/gorm"
|
||
|
|
)
|
||
|
|
|
||
|
|
func checkMail(uid int, red *common.PlayerRed) {
|
||
|
|
data := &common.PlayerData{UID: uid}
|
||
|
|
db.Mysql().Get(data)
|
||
|
|
t := data.LastSysEmailDraw
|
||
|
|
all := []common.Mail{}
|
||
|
|
// mailCount := db.Mysql().QueryNewMailCount(uid)
|
||
|
|
mailCount := 0
|
||
|
|
db.Mysql().QueryAll(fmt.Sprintf("receiver = %v and time > %v", 0, t), "", &common.Mail{}, &all)
|
||
|
|
if len(all) > 0 {
|
||
|
|
now := time.Now().Unix()
|
||
|
|
u, err := db.Mysql().UpdateRes(&common.PlayerData{UID: uid, LastSysEmailDraw: data.LastSysEmailDraw}, &common.PlayerData{LastSysEmailDraw: now})
|
||
|
|
if err != nil || u == 0 {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
for _, v := range all {
|
||
|
|
one := v
|
||
|
|
one.ID = 0
|
||
|
|
one.Receiver = uid
|
||
|
|
db.Mysql().Create(&one)
|
||
|
|
mailCount++
|
||
|
|
}
|
||
|
|
if red.ID == 0 {
|
||
|
|
red.Mail = mailCount
|
||
|
|
db.Mysql().Create(red)
|
||
|
|
} else {
|
||
|
|
db.Mysql().Update(red, map[string]interface{}{"mail": gorm.Expr("mail + ?", mailCount)})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
red.Mail += mailCount
|
||
|
|
}
|
||
|
|
|
||
|
|
const (
|
||
|
|
MailWithdrawType2 = "Your withdrawal order is already in payment. We've paid cash to bank, the final time is determined by the bank, please be patient!\nIf cash has not yet arrived, please click online customer service on the upper right corner or WhatsApp us at %v."
|
||
|
|
MailWithdrawType3 = "1.Please check your bank/UPI information and try to withdraw again: Bank IFSC Code is formatted as 'AAAA0XXXXXX'; there shouldn't be space in UPI account;\n2.If withdrawal still fails, please click online customer service on the upper right corner or WhatsApp us at %v."
|
||
|
|
)
|
||
|
|
|
||
|
|
func SendWithdrawMail(uid int, contentType string) {
|
||
|
|
one := &common.Mail{
|
||
|
|
Sender: "System",
|
||
|
|
Receiver: uid,
|
||
|
|
Title: "Withdraw Notice",
|
||
|
|
Content: fmt.Sprintf(contentType, GetConfigPlatform().Whatsapp),
|
||
|
|
Time: time.Now().Unix(),
|
||
|
|
}
|
||
|
|
db.Mysql().Create(one)
|
||
|
|
UpsertRedPointAndNotify(uid, 1, ModuleMail)
|
||
|
|
}
|
||
|
|
|
||
|
|
func SendMail(mail *common.Mail) {
|
||
|
|
db.Mysql().Create(mail)
|
||
|
|
UpsertRedPointAndNotify(mail.Receiver, 1, ModuleMail)
|
||
|
|
}
|