108 lines
2.5 KiB
PHP
108 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\app\msgpush;
|
|
|
|
use app\common\controller\Backend;
|
|
/**
|
|
* 分销配置
|
|
*/
|
|
class Option extends Backend
|
|
{
|
|
|
|
/**
|
|
* AttachmentGroup模型对象
|
|
* @var \app\admin\model\attachment\AttachmentGroup
|
|
*/
|
|
protected $model = null;
|
|
|
|
protected $configName = 'msg_push_option';
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
|
|
$this->model = new \app\admin\model\app\msgpush\Config;
|
|
|
|
\app\common\model\fill\Handle::check('app_config',$this->configName);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return mixed
|
|
*/
|
|
public function getOptions(){
|
|
|
|
$options = config('message_push_options');
|
|
|
|
|
|
$list = [];
|
|
|
|
$data = [];
|
|
foreach ($options as $tag => $option){
|
|
$data[$option['category_type']]['category_type'] = $option['category_type'];
|
|
$option['tag'] = $tag;
|
|
$data[$option['category_type']]['scenes'][] = $option;
|
|
}
|
|
|
|
foreach ($data as $option){
|
|
|
|
foreach ($option['scenes'] as $idx => $scene){
|
|
$scene['rowspan'] = 0;
|
|
if($idx == 0){
|
|
$scene['rowspan'] = count($option['scenes']);
|
|
}
|
|
$scene['category_type'] = $option['category_type'];
|
|
$scene['val'] = $this->model->getSenceConfig($scene['tag']);
|
|
$list[] = $scene;
|
|
}
|
|
}
|
|
return $this->success("获取成功",$list);
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return mixed
|
|
*/
|
|
public function setConfig(){
|
|
$row = $this->request->post("row/a", [], 'trim');
|
|
$senceName = $this->request->post("sence", [], 'trim');
|
|
|
|
$config = \app\common\model\app\Config::getConfig($this->configName);
|
|
|
|
if(!$config){
|
|
$config = [];
|
|
}
|
|
|
|
$config[$senceName] = $row;
|
|
|
|
$data = \app\common\model\app\Config::setConfig($this->configName,$config);
|
|
return $this->success("保存成功",$data);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取场景配置
|
|
* @return mixed
|
|
*/
|
|
public function getSenceConfig(){
|
|
$senceName = $this->request->post("sence", [], 'trim');
|
|
|
|
$val = $this->model->getSenceConfig($senceName);
|
|
|
|
$structure = config('message_push_options')[$senceName]['config'];
|
|
|
|
if(!$val['config']){
|
|
foreach ($structure as $key => $option){
|
|
$val['config'][$key] = '';
|
|
}
|
|
}
|
|
|
|
return $this->success("获取成功",[
|
|
'val'=>$val,
|
|
'structure'=>$structure
|
|
]);
|
|
}
|
|
|
|
}
|