params = $params; } public function handle() { $mobile = $this->params['mobile'] ?? null; $options = $this->params['options'] ?? []; $type = $options['type'] ?? ''; if (!$mobile) { throw new BusinessException('缺少手机号'); } if (!$type) { throw new BusinessException('缺少类型'); } /** * @var SmsService $smsService */ $smsService = make(SmsService::class); if ($type == 'content') { $content = $options['content'] ?? ''; $smsService->send($mobile, $content); } elseif ($type == 'code') { $clientIp = $options['client_ip'] ?? ''; $smsService->sendCode($mobile, ['client_ip' => $clientIp]); } elseif ($type == 'batch') { if (!is_array($mobile)) { $mobile = [$mobile]; } $content = $options['content'] ?? ''; $smsService->sendBatch($mobile, $content); } else { throw new BusinessException('类型错误'); } } }