wangshan hai 5 meses
pai
achega
0f0741faf7
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      common/src/qfw/util/jy/jy.go

+ 8 - 3
common/src/qfw/util/jy/jy.go

@@ -10,6 +10,7 @@ import (
 	"regexp"
 	"sort"
 	"strings"
+	"sync"
 	"time"
 
 	util "app.yhyue.com/moapp/jybase/common"
@@ -146,12 +147,12 @@ var (
 		{
 			"3",
 			2,
-			3 * 60,
+			3 * 60 * 60,
 		},
 		{
 			"7",
 			3,
-			7 * 60,
+			7 * 60 * 60,
 		},
 		{
 			"2h",
@@ -163,6 +164,7 @@ var (
 	smsIpKey     = "sms_ip_%s_%s"
 	smsPhoneKey  = "sms_phone_%s_%s"
 	smsCacheCode = "other"
+	smsLock      = &sync.Mutex{}
 )
 
 func SmsStrategy(keys ...string) (abnormalKey []string) {
@@ -171,6 +173,7 @@ 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 {
 				abnormalKey = append(abnormalKey, cacheKey)
 			}
@@ -184,6 +187,8 @@ func SmsStrategy(keys ...string) (abnormalKey []string) {
 	return
 }
 func SendSMS(r *http.Request, BaseMysql *mysql.Mysql, address, mobile string, params ...string) (msg string) {
+	smsLock.Lock()
+	defer smsLock.Unlock()
 	//异常手机号及ip拦截策略
 	ip := util.GetIp(r)
 	if strings.Contains(ip, ",") {
@@ -226,7 +231,7 @@ func SendSMS(r *http.Request, BaseMysql *mysql.Mysql, address, mobile string, pa
 				}
 			}
 		}(aks, ip, mobile)
-		msg = "当前用户发送短信验证次数超过最大限制"
+		msg = "当前用户发送短信验证次数超过最大限制:" + strings.Join(aks, ",")
 		return
 	}
 	sms.SendSms(address, "01", mobile, params...)