
- 添加AfterSales类处理售后服务相关接口 - 新增ContentTemplate控制器和模型用于内容模板管理 - 添加diandian渠道服务类 - 更新Feedov控制器和添加FeedovHfAuto命令类 - 新增autoCard视图用于自动发卡设置
99 lines
2.5 KiB
PHP
99 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\setting\controller;
|
|
|
|
use think\admin\Controller;
|
|
use think\admin\helper\QueryHelper;
|
|
use app\setting\model\ContentTemplate as ContentTemplateModel;
|
|
|
|
/**
|
|
* 内容模板管理
|
|
* @class ContentTemplate
|
|
* @package app\setting\controller
|
|
*/
|
|
class ContentTemplate extends Controller
|
|
{
|
|
/**
|
|
* 内容模板管理
|
|
* @auth true
|
|
* @menu true
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function index()
|
|
{
|
|
ContentTemplateModel::mQuery()->layTable(function () {
|
|
$this->title = '内容模板管理';
|
|
$this->types = ContentTemplateModel::types();
|
|
$this->type = $this->get['type'] ?? ($this->types[0] ?? '-');
|
|
}, static function (QueryHelper $query) {
|
|
$query->where(['deleted' => 0])->equal('type');
|
|
$query->like('code,name,status')->dateBetween('create_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 添加内容模板
|
|
* @auth true
|
|
*/
|
|
public function add()
|
|
{
|
|
ContentTemplateModel::mForm('form');
|
|
}
|
|
|
|
/**
|
|
* 编辑内容模板
|
|
* @auth true
|
|
*/
|
|
public function edit()
|
|
{
|
|
ContentTemplateModel::mForm('form');
|
|
}
|
|
|
|
/**
|
|
* 表单数据处理
|
|
* @param array $data
|
|
* @throws \think\db\exception\DbException
|
|
*/
|
|
protected function _form_filter(array &$data)
|
|
{
|
|
if ($this->request->isGet()) {
|
|
$this->types = ContentTemplateModel::types();
|
|
$this->types[] = '--- ' . lang('新增类型') . ' ---';
|
|
$this->type = $this->get['type'] ?? ($this->types[0] ?? '-');
|
|
} else {
|
|
$map = [];
|
|
$map[] = ['deleted', '=', 0];
|
|
$map[] = ['code', '=', $data['code']];
|
|
$map[] = ['type', '=', $data['type']];
|
|
$map[] = ['id', '<>', $data['id'] ?? 0];
|
|
if (ContentTemplateModel::mk()->where($map)->count() > 0) {
|
|
$this->error("数据编码已经存在!");
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 修改内容模板状态
|
|
* @auth true
|
|
*/
|
|
public function state()
|
|
{
|
|
ContentTemplateModel::mSave($this->_vali([
|
|
'status.in:0,1' => '状态值范围异常!',
|
|
'status.require' => '状态值不能为空!',
|
|
]));
|
|
}
|
|
|
|
/**
|
|
* 删除内容模板记录
|
|
* @auth true
|
|
*/
|
|
public function remove()
|
|
{
|
|
ContentTemplateModel::mDelete();
|
|
}
|
|
} |