['id' => 0, 'sign' => 'applyMember'], ]; //用户今天还有没触发短信的机会 ssh 2020.3.3 public static function getRightToSend($userId) { $ip = httpUtil::ip(); $statusKey = 'SMS_STATUS_' . $userId . '_' . $ip; $hasSend = Yii::$app->redis->executeCommand('GET', [$statusKey]); if (!empty($hasSend)) { util::fail('请60秒后再操作'); } $todayKey = 'SMS_NUM_' . date("Ymd") . '_' . $userId . '_' . $ip; $num = Yii::$app->redis->executeCommand('GET', [$todayKey]); $num = is_numeric($num) ? $num : 0; if ($num > self::SMS_LIMIT) { util::fail('您今天已经申请了'.self::SMS_LIMIT.'条短信,请明天再试'); } Yii::$app->redis->executeCommand('SETEX', [$statusKey, 60, 'hasSend']); Yii::$app->redis->executeCommand('SETEX', [$todayKey, 86400, ++$num]); } }