Files
selfcare/proxy/Nrestful/alert_sms.go
2025-03-25 09:46:16 +08:00

52 lines
1.1 KiB
Go

package Nrestful
import (
mysql "proxy/Nmysql"
rdb "proxy/Nredis"
"strconv"
"strings"
)
func RdbScanAlertSmsRecord() {
keys := rdb.RdbScanAlertSmsRecord()
for _, key := range keys {
if strings.HasPrefix(key, "AlertSms:") {
smsContent := rdb.RdbGetAlertSmsContent(key)
if smsContent != "" {
ss := strings.Split(key, ":")
if len(ss) >= 3 {
SendNtfSms2Ocs(ss[1], smsContent)
alertId, _ := strconv.Atoi(ss[2])
_ = mysql.SetAlertSmsState2Sent(alertId)
}
}
rdb.RdsDelMsg2OcsKey(key)
} else if strings.HasPrefix(key, "CreateAcct:") {
ai := rdb.RdbGetCreateAcct(key)
if ai != nil {
ss := strings.Split(key, ":")
if len(ss) >= 3 {
cugId, err := mysql.QueryOfrIdByPrdInstId(ai.PrdInstId)
userClass := 1
ofrLevel, err := mysql.QueryOfrLevelByOfrId(ai.OfrId)
if err == nil {
userClass = ofrLevel
}
rent, _ := mysql.QueryRentByOfrId(ai.OfrId)
//SendCrtAcct2Ocs(ss[1], ai, cugId, userClass, rent)
CreateAcct2Ocs(ss[1], ai, cugId, userClass, rent, key)
}
}
}
}
//for _, key := range keys {
// rdb.RdsDelMsg2OcsKey(key)
//}
return
}