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("操作成功"); } }