|
|
|
@@ -11,7 +11,7 @@ import ( |
|
|
|
|
|
|
|
func GetSerialNoByRedis() (string, error) { |
|
|
|
now := time.Now() |
|
|
|
r := int64(rand.Intn(4)) + 1 |
|
|
|
r := int64(rand.Intn(3)) + 1 |
|
|
|
n, err := redis_client.IncrBy(redis_key.RewardSerialCounter(now), r) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetSerialNoByRedis RewardSerialCounter error. %v", err) |
|
|
|
@@ -20,5 +20,9 @@ func GetSerialNoByRedis() (string, error) { |
|
|
|
if n == r { |
|
|
|
redis_client.Expire(redis_key.RewardSerialCounter(now), 2*time.Minute) |
|
|
|
} |
|
|
|
//when the counter n exceeds 1000, the length of the serial number will become longer |
|
|
|
if n > 1000 { |
|
|
|
return now.Format("200601021504") + fmt.Sprintf("%d", n) + fmt.Sprint(rand.Intn(10)), nil |
|
|
|
} |
|
|
|
return now.Format("200601021504") + fmt.Sprintf("%03d", n) + fmt.Sprint(rand.Intn(10)), nil |
|
|
|
} |