fix: send verification SMS synchronously
This commit is contained in:
@@ -35,11 +35,13 @@ class SmsSendServices extends BaseServices
|
||||
$services = app()->make(ServeServices::class);
|
||||
|
||||
$type = $this->smsType[sys_config('sms_type', 0)];
|
||||
$templateMark = strtolower($template);
|
||||
//获取短信ID
|
||||
$templateId = CacheService::handler('TEMPLATE')->remember('NOTICE_SMS_' . $type . '_' . $template, function () use ($services, $template) {
|
||||
$templateId = CacheService::handler('TEMPLATE')->remember('NOTICE_SMS_' . $type . '_' . $templateMark, function () use ($template, $templateMark) {
|
||||
/** @var SystemNotificationServices $notifyServices */
|
||||
$notifyServices = app()->make(SystemNotificationServices::class);
|
||||
return $notifyServices->value(['mark' => $template], 'sms_id') ?? 0;
|
||||
return $notifyServices->value(['mark' => $template], 'sms_id')
|
||||
?: ($templateMark === $template ? 0 : ($notifyServices->value(['mark' => $templateMark], 'sms_id') ?? 0));
|
||||
});
|
||||
//获取发送短信驱动类型
|
||||
$smsMake = $services->sms($type);
|
||||
|
||||
@@ -7,9 +7,9 @@ declare (strict_types=1);
|
||||
|
||||
namespace app\services\user;
|
||||
|
||||
use app\jobs\notice\SmsJob;
|
||||
use app\services\BaseServices;
|
||||
use app\dao\user\UserDao;
|
||||
use app\services\message\sms\SmsSendServices;
|
||||
use app\services\message\sms\SmsRecordServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
@@ -165,7 +165,9 @@ class LoginServices extends BaseServices
|
||||
$code = rand(100000, 999999);
|
||||
$data['code'] = $code;
|
||||
$data['time'] = $time;
|
||||
$res = SmsJob::dispatch([$phone, $data, 'VERIFICATION_CODE_TIME']);
|
||||
/** @var SmsSendServices $smsServices */
|
||||
$smsServices = app()->make(SmsSendServices::class);
|
||||
$res = $smsServices->send(true, $phone, $data, 'VERIFICATION_CODE_TIME');
|
||||
if (!$res)
|
||||
throw new ValidateException('短信平台验证码发送失败');
|
||||
return $code;
|
||||
|
||||
Reference in New Issue
Block a user