From 2195bb4c5553e9f8f463a9d980da3abb2854da0d Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 16 Jan 2020 18:57:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9F=AD=E4=BF=A1=E5=8F=91?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PublicController.class.php | 2 +- Application/Base/Tool/TaskClient.class.php | 22 +++++++++++++++++-- .../Controller/CommonController.class.php | 2 +- .../Mobile/Controller/SsgController.class.php | 2 +- .../Controller/UserController.class.php | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index 0b76890d8..a7a43a3ea 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -345,7 +345,7 @@ class PublicController extends \Think\Controller public function telsafecode($phone = '', $delay = 10, $flag = true) { $taskClient = new TaskClient(); - $result = $taskClient->sendSms($phone, get_client_ip()); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); $data = []; if ($result['code'] == TaskClient::SUCCESS) { $data['status'] = 1; diff --git a/Application/Base/Tool/TaskClient.class.php b/Application/Base/Tool/TaskClient.class.php index 0b8371c94..f65f50949 100644 --- a/Application/Base/Tool/TaskClient.class.php +++ b/Application/Base/Tool/TaskClient.class.php @@ -28,9 +28,27 @@ class TaskClient return json_decode($result, true); } - public function sendSms($mobile, $clientIp, $type = 'common') + public function sendSmsCode(string $mobile, string $clientIp) { - return $this->post('/message/sms-send', ['mobile' => $mobile, 'type' => $type, 'client_ip' => $clientIp]); + $options = ['type' => 'code', 'client_ip' => $clientIp]; + return $this->sendSms($mobile, $options); + } + + public function sendSmsContent(string $mobile, string $content) + { + $options = ['type' => 'content', 'content' => $content]; + return $this->sendSms($mobile, $options); + } + + public function sendSmsBatch(array $mobiles, string $content) + { + $options = ['type' => 'batch', 'content' => $content]; + return $this->sendSms($mobiles, $options); + } + + private function sendSms($mobile, array $options) + { + return $this->post('/message/sms-send', ['mobile' => $mobile, 'options' => $options]); } public function checkSms($mobile, $code) diff --git a/Application/Mobile/Controller/CommonController.class.php b/Application/Mobile/Controller/CommonController.class.php index 34778e276..d1b0e631a 100644 --- a/Application/Mobile/Controller/CommonController.class.php +++ b/Application/Mobile/Controller/CommonController.class.php @@ -220,7 +220,7 @@ class CommonController extends BaseController { { $phone = I('phone'); $taskClient = new TaskClient(); - $result = $taskClient->sendSms($phone, get_client_ip()); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); $data = []; if ($result['code'] == TaskClient::SUCCESS) { $this->respondSuccess('发送成功'); diff --git a/Application/Mobile/Controller/SsgController.class.php b/Application/Mobile/Controller/SsgController.class.php index 7ff8cae37..3d41bf19c 100644 --- a/Application/Mobile/Controller/SsgController.class.php +++ b/Application/Mobile/Controller/SsgController.class.php @@ -409,7 +409,7 @@ class SsgController extends BaseController { { $phone = I('phone'); $taskClient = new TaskClient(); - $result = $taskClient->sendSms($phone, get_client_ip()); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); $data = []; if ($result['code'] == TaskClient::SUCCESS) { $data['status'] = 1; diff --git a/Application/Mobile/Controller/UserController.class.php b/Application/Mobile/Controller/UserController.class.php index fffb9cd55..afdfcdbde 100644 --- a/Application/Mobile/Controller/UserController.class.php +++ b/Application/Mobile/Controller/UserController.class.php @@ -581,7 +581,7 @@ class UserController extends BaseController public function telsafecode($phone = '', $delay = 10, $flag = true) { $taskClient = new TaskClient(); - $result = $taskClient->sendSms($phone, get_client_ip()); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); $data = []; if ($result['code'] == TaskClient::SUCCESS) { $data['status'] = 1;