|
|
@@ -61,6 +61,7 @@ class SmsService extends BaseService
|
|
|
$cacheKey = "stores:codes:sms_{$scene}:" . substr($mobile, -3, 3) . '_' . md5($mobile);
|
|
|
$apiUrl = isset($this->config['sms_api_url']['value']) ? $this->config['sms_api_url']['value'] : '';
|
|
|
if (empty($mobile) || empty($apiUrl)) {
|
|
|
+ $this->error = '1013';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -84,17 +85,20 @@ class SmsService extends BaseService
|
|
|
'sendTime' => '', // 发送时间:空立即发送
|
|
|
];
|
|
|
|
|
|
+ RedisService::set($cacheKey . '_temp', ['mobile' => $mobile, 'code' => $code, 'date' => date('Y-m-d H:i:s')], 600);
|
|
|
RedisService::set($cacheKey . '_lock', ['mobile' => $mobile, 'code' => $code, 'date' => date('Y-m-d H:i:s')], rand(10, 20));
|
|
|
$result = curl_post($apiUrl, $data);
|
|
|
$result = $result ? xmlToArray($result) : [];
|
|
|
$status = isset($result['returnstatus']) ? $result['returnstatus'] : '';
|
|
|
- if ($status == 'Success') {
|
|
|
+ if ($status === 'Success') {
|
|
|
RedisService::set($cacheKey, ['mobile' => $mobile, 'code' => $code, 'date' => date('Y-m-d H:i:s')], 300);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ $this->error = '1011';
|
|
|
return false;
|
|
|
} catch (\Exception $exception) {
|
|
|
+
|
|
|
$this->error = $exception->getMessage();
|
|
|
return false;
|
|
|
}
|