<?php
namespace application\pay\controller;
use application\admin\controller\auth as auth;
use ticky\request;
use ticky\response;
use application\pay\model\payment;
class pay extends auth {
public function index() {
$ret = db('pay_mode a')
->field('a.*')
->newpage();
$this->assign('page', $ret['page']);
$this->assign('items', $ret['items']);
$this->display('pay_list');
}
public function edit() {
if (request::isPost()) {
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$data['enabled'] = intval($_POST['enabled']);
$data['config'] = array2string($_POST['config']);
db('pay_mode')->where(array('id' => $id))->update($data);
if (request::isAjax()) {
response::ajax(['code' => 200, 'msg' => '修改成功']);
} else {
showmsg('修改成功', '/pay/pay');
}
} else {
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$data = db('pay_mode')->where(array('id' => $id))->find();
$config = string2array($data['config']);
$result = array_merge($data, $config);
$this->assign('id', $id);
$this->assign('item', $result);
$this->display($data['template']);
}
}
}