From dd10535a0741f29ed0082992a8acc05996209632 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 28 Oct 2019 15:31:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0->=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E7=AE=A1=E7=90=86->=E6=96=B0=E5=A2=9E=E5=90=88?= =?UTF-8?q?=E4=BD=9C=E6=96=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 14 ++ .../Controller/PartnerController.class.php | 188 ++++++++++++++++++ Application/Admin/View/Game/add.html | 11 + Application/Admin/View/Game/edit.html | 13 ++ Application/Admin/View/Game/lists.html | 4 + Application/Admin/View/Partner/add.html | 85 ++++++++ Application/Admin/View/Partner/edit.html | 88 ++++++++ Application/Admin/View/Partner/lists.html | 169 ++++++++++++++++ Data/update.sql | 16 +- 9 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 Application/Admin/Controller/PartnerController.class.php create mode 100644 Application/Admin/View/Partner/add.html create mode 100644 Application/Admin/View/Partner/edit.html create mode 100644 Application/Admin/View/Partner/lists.html diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 687ec4204..239e890ab 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -528,3 +528,17 @@ function getServerType($serverType) return (($serverType == 1) ? '专服' : '混服'); } +//获取合作方 +function getPartnerList($id = 0) +{ + if ($id > 0) { + return M('Partner', 'tab_')->field('id,partner')->find($id); + } else { + return M('Partner', 'tab_')->field('id,partner')->where(array('status' => 1))->select(); + } +} + +function getPartnerName($id = 0) +{ + return M('Partner', 'tab_')->where(array('id' => intval($id)))->getField('partner'); +} \ No newline at end of file diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php new file mode 100644 index 000000000..3be4e66f1 --- /dev/null +++ b/Application/Admin/Controller/PartnerController.class.php @@ -0,0 +1,188 @@ + + */ +class PartnerController extends ThinkController +{ + private $modelName = 'Partner'; + + //列表 + public function lists() + { + $model = M($this->modelName, 'tab_'); + $map = []; + $id = intval(I('id', 0)); + if (!empty($id)) { + $map['tab_partner.id'] = $id; + $parameter['id'] = $id; + } + + if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') { + $status = intval($_REQUEST['status']); + $map['tab_partner.status'] = $status; + $parameter['status'] = $status; + } + + $page = intval(I('get.p', 0)); + $page = $page ? $page : 1; //默认显示第一页数据 + $row = intval(I('row', 0)); + $row = empty($row) ? 10 : $row;//每页条数 + + $data = $model + ->field('tab_partner.id,tab_partner.partner,tab_partner.status,tab_partner.create_time,sys_member.nickname') + ->join('left join sys_member on sys_member.uid = tab_partner.uid') + ->where($map) + ->order('id desc') + ->page($page, $row) + ->select(); + + /* 查询记录总数 */ + $count = $model + ->where($map) + ->count(); + + if (!empty($data)) { + foreach ($data as &$list) { + $list['status'] = ($list['status'] == 0) ? '已关闭' : '已开启'; + $list['create_time'] = date('Y-m-d H:i:s', $list['create_time']); + } + } + + //分页 + $parameter['p'] = $page; + $parameter['row'] = $row; + $page = set_pagination($count, $row, $parameter); + if ($page) { + $this->assign('_page', $page); + } + + $this->assign('listData', $data); + $this->assign('count', $count); + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/lists'])->find()); + $this->meta_title = '合作方管理'; + $this->display(); + } + + //添加 + public function add() + { + if ($_POST) { + $partner = I('post.partner', ''); + $status = intval(I('post.status', 1)); + + if (empty($partner)) { + $this->error('请输入合作方名称'); + } + if (!in_array($status, [0, 1])) { + $this->error('参数异常'); + } + + $model = M($this->modelName, 'tab_'); + $map['partner'] = $partner; + $res = $model->where($map)->getField('id'); + if ($res) { + $this->error('合作方已存在'); + } + + $time = time(); + $save['partner'] = $partner; + $save['status'] = $status; + $save['uid'] = UID; + $save['create_time'] = $time; + $save['last_up_time'] = $time; + + $res = $model->add($save); + if ($res) { + \Think\Log::actionLog('Partner/add', 'partner', $res); + $this->success('保存成功', U('lists')); + } else { + $this->error('保存失败'); + } + } else { + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/add'])->find()); + $this->meta_title = '新增合作方'; + $this->display(); + } + } + + //编辑 + public function edit() + { + $model = M($this->modelName, 'tab_'); + + if ($_POST) { + $partner = I('post.partner', ''); + $status = intval(I('post.status', 1)); + $id = intval(I('post.id', 0)); + + if (empty($partner)) { + $this->error('请输入合作方名称'); + } + if (!in_array($status, [0, 1]) || $id == 0) { + $this->error('参数异常'); + } + + $data = $model->field('id,partner')->find($id); + if (empty($data)) { + $this->error('数据异常'); + } + + $map['partner'] = $partner; + $res = $model->where($map)->getField('id'); + if ($res && $res != $id) { + $this->error('合作方已存在'); + } + + $time = time(); + $save['id'] = $id; + $save['partner'] = $partner; + $save['status'] = $status; + $save['last_up_time'] = $time; + + $res = $model->save($save); + if ($res === false) { + $this->error('保存失败'); + } else { + \Think\Log::actionLog('Partner/edit', 'partner', $id); + $this->success('保存成功', U('lists')); + } + } else { + $id = intval(I('get.id', 0)); + $map['id'] = $id; + $data = $model->field('id,partner,status')->find($id); + if (empty($data)) { + $this->error('数据异常', U('lists')); + } + + $this->assign('data', $data); + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/edit'])->find()); + $this->meta_title = '编辑合作方'; + $this->display(); + } + } + + //删除 + public function del() + { + $id = intval(I('get.id', 0)); + if ($id == 0) { + $this->error('参数异常'); + } + + $res = M($this->modelName, 'tab_')->delete($id); + if ($res === false) { + $this->error('删除失败'); + } + + $this->success('删除成功', U('lists')); + } +} diff --git a/Application/Admin/View/Game/add.html b/Application/Admin/View/Game/add.html index a967b6986..e4a8cb55b 100644 --- a/Application/Admin/View/Game/add.html +++ b/Application/Admin/View/Game/add.html @@ -188,6 +188,17 @@ +