123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\index\controller;
- use app\index\service\HelperService;
- use app\index\service\SmsService;
- class Sms extends CmsController
- {
- /**
- * 发送短信接口
- */
- public function sendCode(){
- $param_list = [
- 'mobile'=>'mobile',
- 'temp_id'=>'number'
- ];
- HelperService::diffParam($param_list,$this->post);
- $smsService = new SmsService();
- $res = $smsService->sendCode($this->post['mobile'],$this->post['temp_id']);
- if($res['status'] === false){
- $this->returnJson($res,400,'sms fail');
- }
- $this->returnJson($res);
- }
- /**
- * 批量发送短信接口
- */
- public function sendBatchCode(){
- $param_list = [
- 'recipients'=>'array',
- 'temp_id'=>'number'
- ];
- HelperService::diffParam($param_list,$this->post);
- $smsService = new SmsService();
- $res = $smsService->sendBatchCode($this->post['recipients'],$this->post['temp_id']);
-
- $this->returnJson($res);
- }
-
- /**
- * 批量发送短信状态
- */
- public function sendReportCode(){
- $smsService = new SmsService();
- $res = $smsService->sendReportCode();
- if($res['status'] === false){
- $this->returnJson($res,400,'sms fail');
- }
- $this->returnJson($res);
- }
-
- /**
- * 发送短信模板消息
- */
- public function sendMessage(){
- $param_list = [
- 'mobile'=>'mobile',
- 'temp_id'=>'number'
- ];
- HelperService::diffParam($param_list,$this->post);
- $smsService = new SmsService();
- $res = $smsService->sendMessage($this->post['mobile'],$this->post['temp_id'],$this->post['temp_params']);
- $this->returnJson($res);
- }
- /**
- * 验证短信接口
- */
- public function checkCode(){
- $param_list = [
- 'code'=>'number',
- 'msg_id'=>'string'
- ];
- HelperService::diffParam($param_list,$this->post);
- $smsService = new SmsService();
- $res = $smsService->checkCode($this->post['code'],$this->post['msg_id']);
- if($res) {
- $this->returnJson($res);
- }else{
- $this->returnJson('',400,'error');
- }
- }
- }
|