You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
4.4 KiB
116 lines
4.4 KiB
<?php
|
|
namespace app\admin\service;
|
|
|
|
use app\admin\service\AdminBaseService;
|
|
use app\model\EmailTemplateModel;
|
|
use app\model\SmsTemplateModel;
|
|
use app\model\VideoOnDemandModel;
|
|
|
|
class ConfigService extends AdminBaseService
|
|
{
|
|
// 获取邮箱模板列表
|
|
public function emailTemplateList($param)
|
|
{
|
|
try {
|
|
if (empty($param['page']) || !is_numeric($param['page'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
$where = [];
|
|
if (isset($param['tpl_type'])) {
|
|
$where['tpl_type'] = $param['tpl_type'];
|
|
}
|
|
$list = EmailTemplateModel::where($where)->order('id', 'desc')->paginate([
|
|
'list_rows' => $param['limit'],
|
|
'page' => $param['page'],
|
|
]);
|
|
return $this->toData('0', 'SUCCESS', [
|
|
'list' => $list->items(), // 当前页的数据
|
|
'page' => $list->currentPage(), // 当前页码
|
|
'total' => $list->total(), // 总记录数
|
|
'last_page' => $list->lastPage(), // 最后一页页码
|
|
]);
|
|
} catch (\Exception $e) {
|
|
return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]);
|
|
}
|
|
}
|
|
|
|
// 编辑邮箱模板
|
|
public function editEmailTemplate($param)
|
|
{
|
|
try {
|
|
if (empty($param['id']) || !is_numeric($param['id'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
if (empty($param['title']) || empty($param['content'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
|
|
$emailTemplate = EmailTemplateModel::where(['id'=>$param['id']])->find();
|
|
if (empty($emailTemplate)) {
|
|
return $this->toData('500', '修改的模板数据不存在');
|
|
}
|
|
$emailTemplate->email = $param['email'] ?? "";
|
|
$emailTemplate->title = $param['title'];
|
|
$emailTemplate->content = $param['content'];
|
|
$emailTemplate->save();
|
|
return $this->toData('0', 'success');
|
|
} catch (\Exception $e) {
|
|
return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]);
|
|
}
|
|
}
|
|
|
|
// 短息模板列表
|
|
public function smsTemplateList($param)
|
|
{
|
|
try {
|
|
if (empty($param['page']) || !is_numeric($param['page'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
$where = [];
|
|
if (isset($param['tpl_type'])) {
|
|
$where['tpl_type'] = $param['tpl_type'];
|
|
}
|
|
$list = SmsTemplateModel::where($where)->order('id', 'desc')->paginate([
|
|
'list_rows' => $param['limit'],
|
|
'page' => $param['page'],
|
|
]);
|
|
return $this->toData('0', 'SUCCESS', [
|
|
'list' => $list->items(),
|
|
'page' => $list->currentPage(),
|
|
'total' => $list->total(),
|
|
'last_page' => $list->lastPage(),
|
|
]);
|
|
} catch (\Exception $e) {
|
|
return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]);
|
|
}
|
|
}
|
|
|
|
// 编辑短信模板
|
|
public function editSmsTemplate($param)
|
|
{
|
|
try {
|
|
if (empty($param['id']) || !is_numeric($param['id'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
if (empty($param['content'])) {
|
|
return $this->toData('400', '参错错误');
|
|
}
|
|
|
|
$smsTemplate = SmsTemplateModel::where(['id'=>$param['id']])->find();
|
|
if (empty($smsTemplate)) {
|
|
return $this->toData('500', '修改的模板数据不存在');
|
|
}
|
|
$smsTemplate->content = $param['content'];
|
|
$smsTemplate->save();
|
|
return $this->toData('0', 'success');
|
|
} catch (\Exception $e) {
|
|
return $this->toData('500', 'The system is busy. Please try again later.', [$e->getMessage(), $e->getTrace()]);
|
|
}
|
|
}
|
|
}
|