108 lines
2.4 KiB
PHP
108 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\config;
|
|
|
|
use app\common\controller\Backend;
|
|
use think\Db;
|
|
/**
|
|
* 支付配置
|
|
*
|
|
* @icon fa fa-circle-o
|
|
*/
|
|
class Pay extends Backend
|
|
{
|
|
|
|
/**
|
|
* Column模型对象
|
|
* @var \app\admin\model\course\Column
|
|
*/
|
|
protected $model = null;
|
|
protected $AddonContro = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = new \app\admin\model\config\Pay;
|
|
$this->AddonContro = new \app\admin\controller\Addon;
|
|
|
|
}
|
|
|
|
public function getList(){
|
|
return $this->success("获取成功",$this->model->getList());
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return mixed
|
|
*/
|
|
public function getConfig(){
|
|
$name = $this->request->post("name");
|
|
|
|
$config = $this->AddonContro->getConfig('epay',false);
|
|
|
|
if(!$config['config']){
|
|
return $this->error("获取失败");
|
|
}
|
|
|
|
foreach ($config['config'] as $item){
|
|
if($item['name'] == $name){
|
|
$config['config'] = [$item];
|
|
break;
|
|
}
|
|
}
|
|
return $this->success("获取成功",$config);
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return mixed
|
|
*/
|
|
public function setConfig(){
|
|
$name = $this->request->post("name");
|
|
|
|
$params = $this->request->post("row/a", [], 'trim');
|
|
|
|
$config = $this->AddonContro->getConfig('epay',false)['config'];
|
|
|
|
$data = [];
|
|
|
|
foreach ($config as $k => &$v) {
|
|
|
|
if($v['name'] == $name){
|
|
$data[$v['name']] = $params[$name];
|
|
}else{
|
|
if($v['type'] == 'array'){
|
|
$arr = [];
|
|
foreach ($v['value'] as $option){
|
|
$arr[$option['key']] = $option['value'];
|
|
}
|
|
$data[$v['name']] = $arr;
|
|
}else{
|
|
$data[$v['name']] = $v['value'];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$this->AddonContro->setConfig('epay',$data);
|
|
}
|
|
|
|
/**
|
|
* 设置状态
|
|
* @return void
|
|
*/
|
|
public function setStatus(){
|
|
$name = $this->request->post("name");
|
|
$status = $this->request->post("status",false);
|
|
|
|
if(!$name){
|
|
$this->error(__("Invalid parameters"));
|
|
}
|
|
|
|
$this->model->setStatus($name,$status);
|
|
|
|
return $this->success("操作成功");
|
|
}
|
|
|
|
}
|