- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
73 lines
2.0 KiB
PHP
73 lines
2.0 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\controller\admin\v1\notification\sms;
|
|
|
|
use app\controller\admin\AuthController;
|
|
use crmeb\exceptions\AdminException;
|
|
use crmeb\services\sms\Sms;
|
|
use crmeb\services\SystemConfigService;
|
|
|
|
/**
|
|
* 公共短信模板
|
|
* Class SmsPublicTemp
|
|
* @package app\controller\admin\v1\notification\sms
|
|
*/
|
|
class SmsPublicTemp extends AuthController
|
|
{
|
|
/**
|
|
* @var Sms
|
|
*/
|
|
protected $smsHandle;
|
|
|
|
/**
|
|
* 初始化短信配置
|
|
* @return void
|
|
*/
|
|
public function initialize()
|
|
{
|
|
parent::initialize();
|
|
$data = SystemConfigService::more(['sms_account', 'sms_token', 'site_url']);
|
|
$this->smsHandle = new Sms('yunxin', $data);
|
|
if (!$this->smsHandle->isLogin()) {
|
|
return $this->fail('请先填写短息配置');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 异步获取公共模板列表
|
|
*/
|
|
public function index()
|
|
{
|
|
$where = $this->request->getMore([
|
|
['is_have', ''],
|
|
['page', 1],
|
|
['limit', 20],
|
|
]);
|
|
$templateList = $this->smsHandle->publictemp($where);
|
|
if ($templateList['status'] == 400) return $this->fail($templateList['msg']);
|
|
$arr = $templateList['data']['data'];
|
|
foreach ($arr as $key => $value) {
|
|
switch ($value['type']) {
|
|
case 1:
|
|
$arr[$key]['type'] = '验证码';
|
|
break;
|
|
case 2:
|
|
$arr[$key]['type'] = '通知';
|
|
break;
|
|
case 3:
|
|
$arr[$key]['type'] = '推广';
|
|
break;
|
|
default:
|
|
$arr[$key]['type'] = '';
|
|
break;
|
|
}
|
|
}
|
|
$templateList['data']['data'] = $arr;
|
|
return $this->success($templateList['data']);
|
|
}
|
|
|
|
}
|