印度包网
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.
 
 
 

111 lines
4.0 KiB

package call
import (
"fmt"
"server/common"
"server/db"
"server/util"
"time"
)
var (
SystemTitle = "System Notice"
EmailWithdrawPass = "Your order %v, amount: ₹%v is in the payment status, please be patient."
EmailWithdrawSuccess = "Your order %v, amount: ₹%v has been credited, please check. If you have any questions, you can contact customer service."
EmailWithdrawFail = "Your order %v, Amount: ₹%v\nYour withdrawal failed due to incorrect information. Please verify or change your withdrawal details and resubmit"
EmailShareWithdrawFail = "Your friend's invitation reward withdrawal order: %v, Amount: %v\nYour withdrawal failed due to incorrect information. Please verify or change your withdrawal details and resubmit.\n"
EmailDiscount = "Congratulations, you have received a ₹%v coupon for a top-up of ₹%v or more."
EmailShareRank = "Congratulations on achieving Rank %v in the million giveaway event. You have received a bonus of ₹%v. Thank you for participating!"
)
func checkMail(uid int, red *common.PlayerRed) (unReadCount int) {
data := &common.PlayerData{UID: uid}
db.Mysql().Get(data)
user := &common.PlayerDBInfo{Id: uid}
db.Mysql().Get(user)
rechargeInfo := &common.RechargeInfo{UID: uid}
db.Mysql().Get(rechargeInfo)
t := data.LastSysEmailDraw
all := []common.Mail{}
// mailCount := db.Mysql().QueryNewMailCount(uid)
mailCount := 0
today := util.GetZeroTime(time.Now())
sql := fmt.Sprintf(`receiver = %v and time > %v
and (
user_tag = 0
or (user_tag = 1 and max_birth_at >= %v)
or (user_tag = 2 and %v > 0)
or (user_tag = 3 and %v > %v)
or (user_tag = 4 and %v < %v)
or (user_tag = 5 and %v >= recharge_amount)
or (user_tag = 6 and JSON_CONTAINS(channel_id, CAST(%v AS JSON)))
)`,
0, t,
user.Birth,
rechargeInfo.TotalRecharge,
user.Birth, today.Unix(),
user.Birth, today.Unix(),
rechargeInfo.TotalRecharge,
user.ChannelID,
)
db.Mysql().QueryAll(sql, "", &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
one.Time = now
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)})
//}
}
unReadCount = int(db.Mysql().Count(&common.Mail{}, fmt.Sprintf("receiver = %d and `status` = %d", uid, common.MailStatusNew)))
//red.Mail += mailCount
return
}
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 SendMailWithContent(uid int, title, content string) {
one := &common.Mail{
Sender: "System",
Receiver: uid,
Title: title,
Content: content,
Tag: 1,
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)
}