redis->executeCommand('GET', [$statusKey]); if (!empty($hasSend)) { util::fail('请60秒后再操作'); } $todayKey = 'SMS_NUM_' . date("Ymd") . '_' . $uniqueId . '_' . $ip; $num = Yii::$app->redis->executeCommand('GET', [$todayKey]); $num = is_numeric($num) ? $num : 0; if ($num > 10) { util::fail('您今天申请的短信条数达到上限'); } Yii::$app->redis->executeCommand('SETEX', [$statusKey, 60, 'hasSend']); Yii::$app->redis->executeCommand('SETEX', [$todayKey, 86400, ++$num]); $sms->send($mobile, $msg); } }