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

112 lines
4.0 KiB

1 year ago
package call
import (
"fmt"
"server/common"
"server/db"
3 months ago
"server/util"
1 year ago
"time"
)
var (
1 year ago
SystemTitle = "System Notice"
2 months ago
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"
1 year ago
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"
2 months ago
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) {
1 year ago
data := &common.PlayerData{UID: uid}
db.Mysql().Get(data)
3 months ago
user := &common.PlayerDBInfo{Id: uid}
db.Mysql().Get(user)
rechargeInfo := &common.RechargeInfo{UID: uid}
db.Mysql().Get(rechargeInfo)
1 year ago
t := data.LastSysEmailDraw
all := []common.Mail{}
// mailCount := db.Mysql().QueryNewMailCount(uid)
mailCount := 0
3 months ago
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)
1 year ago
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
//}
1 year ago
for _, v := range all {
one := v
one.ID = 0
one.Receiver = uid
one.Time = now
1 year ago
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)})
//}
1 year ago
}
unReadCount = int(db.Mysql().Count(&common.Mail{}, fmt.Sprintf("receiver = %d and `status` = %d", uid, common.MailStatusNew)))
//red.Mail += mailCount
return
1 year ago
}
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)
}
1 year ago
func SendMail(mail *common.Mail) {
db.Mysql().Create(mail)
1 year ago
// UpsertRedPointAndNotify(mail.Receiver, 1, ModuleMail)
1 year ago
}