|
@@ -173,11 +173,11 @@ func SmsStrategy(keys ...string) (abnormalKey []string) {
|
|
|
cacheKey := fmt.Sprintf(key, s.Day)
|
|
|
num := redis.GetInt(smsCacheCode, cacheKey)
|
|
|
ttl := redis.GetTTL(smsCacheCode, cacheKey)
|
|
|
- log.Println(cacheKey, "---------", num, "-------", ttl, "---", s.Num)
|
|
|
- if num > s.Num {
|
|
|
+ log.Println(cacheKey, "-----num----", num, "----ttl---", ttl, "--s.Num--", s.Num)
|
|
|
+ if num >= s.Num {
|
|
|
abnormalKey = append(abnormalKey, cacheKey)
|
|
|
}
|
|
|
- if num == 0 || ttl <= 0 {
|
|
|
+ if num == 0 {
|
|
|
ttl = s.Date
|
|
|
}
|
|
|
num++
|
|
@@ -194,7 +194,8 @@ func SendSMS(r *http.Request, BaseMysql *mysql.Mysql, address, mobile string, pa
|
|
|
if strings.Contains(ip, ",") {
|
|
|
ip = strings.Split(ip, ",")[0]
|
|
|
}
|
|
|
- if aks := SmsStrategy(fmt.Sprintf(smsIpKey, "%s", ip), fmt.Sprintf(smsPhoneKey, "%s", mobile)); len(aks) > 0 {
|
|
|
+ aks := SmsStrategy(fmt.Sprintf(smsIpKey, "%s", ip), fmt.Sprintf(smsPhoneKey, "%s", mobile))
|
|
|
+ if len(aks) > 0 {
|
|
|
go func(aks []string, ip, mobile string) {
|
|
|
var (
|
|
|
ipState, phoneState int
|
|
@@ -232,9 +233,9 @@ func SendSMS(r *http.Request, BaseMysql *mysql.Mysql, address, mobile string, pa
|
|
|
}
|
|
|
}(aks, ip, mobile)
|
|
|
msg = "当前用户发送短信验证次数超过最大限制:" + strings.Join(aks, ",")
|
|
|
- return
|
|
|
+ } else {
|
|
|
+ sms.SendSms(address, "01", mobile, params...)
|
|
|
}
|
|
|
- sms.SendSms(address, "01", mobile, params...)
|
|
|
return
|
|
|
}
|
|
|
|