| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- declare(strict_types=1);
- namespace app\finance\controller;
- use app\base\BaseController;
- use app\finance\model\VccPaymentCate as VccPaymentCateModel;
- use think\facade\View;
- class VccPaymentCate extends BaseController
- {
- protected $model;
- public function __construct()
- {
- parent::__construct();
- $this->model = new VccPaymentCateModel();
- }
- public function datalist()
- {
- if (request()->isAjax()) {
- $param = get_params();
- $type = isset($param['type']) ? (int) $param['type'] : 0;
- $where = [['delete_time', '=', 0]];
- if ($type > 0) {
- $where[] = ['type', '=', $type];
- }
- $list = $this->model->where($where)->order('sort asc, id asc')->select();
- return to_assign(0, '', $list);
- }
- return view();
- }
- public function add()
- {
- $param = get_params();
- if (request()->isAjax()) {
- if (!empty($param['id']) && $param['id'] > 0) {
- $this->model->edit($param);
- } else {
- $this->model->add($param);
- }
- } else {
- $id = isset($param['id']) ? (int) $param['id'] : 0;
- if ($id > 0) {
- View::assign('detail', $this->model->getById($id));
- }
- return view();
- }
- }
- public function set()
- {
- if (request()->isAjax()) {
- $param = get_params();
- $res = $this->model->strict(false)->field('id,status')->update($param);
- if ($res) {
- add_log($param['status'] == 1 ? 'recovery' : 'disable', $param['id'], $param);
- return to_assign();
- }
- return to_assign(0, '操作失败');
- }
- return to_assign(1, '错误的请求');
- }
- public function del()
- {
- if (request()->isDelete()) {
- $param = get_params();
- $id = isset($param['id']) ? (int) $param['id'] : 0;
- return $this->model->delById($id);
- }
- return to_assign(1, '错误的请求');
- }
- }
|