|
@@ -3,6 +3,7 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\api\ApiBaseController;
|
|
|
+use app\common\model\SettingModel;
|
|
|
use app\common\model\SmsAuthModel;
|
|
|
use app\common\model\SmsLogModel;
|
|
|
use app\common\model\SmsTemplateModel;
|
|
@@ -13,6 +14,7 @@ class Sms extends ApiBaseController
|
|
|
{
|
|
|
private $ip;
|
|
|
private $token;
|
|
|
+
|
|
|
public function _init()
|
|
|
{
|
|
|
//权限校验
|
|
@@ -32,7 +34,7 @@ class Sms extends ApiBaseController
|
|
|
ajax_success();
|
|
|
}
|
|
|
|
|
|
- $this->ip = $ip;
|
|
|
+ $this->ip = $ip;
|
|
|
$this->token = $token;
|
|
|
}
|
|
|
|
|
@@ -43,8 +45,8 @@ class Sms extends ApiBaseController
|
|
|
$mobile = input('post.mobile', '');
|
|
|
$template_code = input('post.template_code', '');
|
|
|
$template_param = input('post.template_param', []);
|
|
|
- if (empty($mobile) || empty($template_code) || empty($template_param)) {
|
|
|
- ajax_error('手机号或模板号或模板参数不能为空!');
|
|
|
+ if (empty($mobile) || empty($template_code)) {
|
|
|
+ ajax_error('手机号或模板号不能为空!');
|
|
|
}
|
|
|
|
|
|
//短信内容
|
|
@@ -59,6 +61,14 @@ class Sms extends ApiBaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //默认平台
|
|
|
+ if (empty($type)) {
|
|
|
+ $type = SettingModel::getConfigValue('sms_type');
|
|
|
+ if (empty($type)) {
|
|
|
+ return ['code' => 1, 'msg' => '未配置默认模板'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$res = SmsService::apiSend($mobile, $content, $type, $template, $template_param);
|
|
|
|
|
|
//记录日志
|
|
@@ -66,6 +76,7 @@ class Sms extends ApiBaseController
|
|
|
'ip' => $this->ip,
|
|
|
'token' => $this->token,
|
|
|
'mobile' => $mobile,
|
|
|
+ 'type' => $type,
|
|
|
'content' => $content,
|
|
|
'template_code' => $template_code,
|
|
|
'template_param' => json_encode($template_param),
|
|
@@ -85,13 +96,13 @@ class Sms extends ApiBaseController
|
|
|
{
|
|
|
$map = $this->dealLikeInput(['code']);
|
|
|
|
|
|
- $list = SmsTemplateModel::field(['code','content','comment'])
|
|
|
+ $list = SmsTemplateModel::field(['code', 'content', 'comment'])
|
|
|
->where($map)
|
|
|
- ->limit(input('limit',10))
|
|
|
- ->page(input('page',1))
|
|
|
+ ->limit(input('limit', 10))
|
|
|
+ ->page(input('page', 1))
|
|
|
->select();
|
|
|
$count = SmsTemplateModel::where($map)->count();
|
|
|
|
|
|
- ajax_success(['list'=>$list,'count'=>$count]);
|
|
|
+ ajax_success(['list' => $list, 'count' => $count]);
|
|
|
}
|
|
|
}
|