| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <?php
- namespace app\admin\controller;
- use app\common\library\OneFileUpload;
- use think\Loader;
- use think\Db;
- class Ziyuan extends Admin
- {
- protected $gameList;
- public function _initialize()
- {
- parent::_initialize(); // TODO: Change the autogenerated stub
- }
- /**
- *玩家福利列表
- */
- public function index()
- {
- $order = 'create_time desc';
- $welfareModel = Db::name('cy_ziyuan');
- $list = $welfareModel
- ->field('*')
- ->order($order)
- ->paginate();
- $this->assign('list', $list);
- $this->assign('page', $list->render());
- return $this->fetch();
- }
- /**
- *增
- */
- public function add()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- $data['create_time'] = time();
- $m = Db::name('cy_ziyuan')->insertGetId($data);
- if (!empty($m)) {
- $this->success('添加成功',url('index'));
- }
- $this->error($appModel->getError() ?: '添加失败');
- }
- return $this->fetch();
- }
- /**
- *删
- */
- public function delete()
- {
- $id = $this->request->param('id', '', 'intval');
- if (empty($id)) {
- $this->error('参数错误!');
- }
- $appModel = model('Common/Welfare');
- if (!$appModel->find($id)) {
- $this->error('参数错误,不存在该数据');
- }
- if ($appModel->where('id', '=', $id)->delete()) {
- $this->success('删除成功',url('index'));
- }
- $error = $appModel->getError();
- $this->error($error ?: '删除失败');
- }
- /**
- *编辑
- */
- public function edit()
- {
- $id = $this->request->param('id', '', 'intval');
- $appModel = Db::name('cy_ziyuan');
- if (!$data = $appModel->find($id)) {
- $this->error('参数错误,不存在该数据');
- }
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if ($this->request->isPost()) {
- $data = $this->request->post();
- Db::name('cy_ziyuan')->where(['id'=>$id])->update($data);
- if (!empty($id)) {
- $this->success('修改成功',url('index'));
- }
- $this->error($appModel->getError() ?: '修改失败');
- }
- $this->assign('data', $data);
- return $this->fetch();
- }
- /**
- *玩家福利列表
- */
- public function typelist()
- {
- $order = 'create_time desc';
- $welfareModel = Db::name('cy_ziyuan_type');
- $list = $welfareModel
- ->field('*')
- ->order($order)
- ->paginate();
- $this->assign('list', $list);
- $this->assign('page', $list->render());
- return $this->fetch();
- }
- /**
- *增
- */
- public function typeadd()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- $data['create_time'] = time();
- $m = Db::name('cy_ziyuan_type')->insertGetId($data);
- if (!empty($m)) {
- $this->success('添加成功',url('index'));
- }
- $this->error($appModel->getError() ?: '添加失败');
- }
- return $this->fetch();
- }
- /**
- *编辑
- */
- public function typeedit()
- {
- $id = $this->request->param('id', '', 'intval');
- $appModel = Db::name('cy_ziyuan_type');
- if (!$data = $appModel->find($id)) {
- $this->error('参数错误,不存在该数据');
- }
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if ($this->request->isPost()) {
- $data = $this->request->post();
- Db::name('cy_ziyuan_type')->where(['id'=>$id])->update($data);
- if (!empty($id)) {
- $this->success('修改成功',url('index'));
- }
- $this->error($appModel->getError() ?: '修改失败');
- }
- $this->assign('data', $data);
- return $this->fetch();
- }
- /**
- * 资源审核记录
- * @return mixed
- * @throws \think\exception\DbException
- */
- public function ziyuanshlist()
- {
- $where = [];
- $sh_status = $this->request->get('sh_status', '', 'trim');
- if(!empty($sh_status))
- {
- $where['record.sh_status'] = $sh_status;
- }
- $infoList = Db::table('cy_ziyuan_apply_record')->alias('record')
- ->join('cy_members member', 'member.id = record.member_id')
- ->join('cy_game game', 'game.id = record.gameid')
- ->join('nw_channel channel', 'channel.id = record.channel_id')
- ->field(['record.id','channel.name as dep_name','member.username','game.name','record.sh_status','record.rolename','record.servername','record.roleid_id','record.rolename','record.create_time','record.ziyuan_type','record.content','record.remark','record.sh_time'])
- ->where($where)
- ->order('record.sh_status', 'desc')
- ->paginate();
- $this->assign('list', $infoList);
- $this->assign('page', $infoList->render());
- return $this->fetch();
- }
- public function shstatus()
- {
- $id = $this->request->param('id', '', 'intval');
- $info = Db::table('cy_ziyuan_apply_record')->where(['id'=>$id])->find();
- $this->assign('info', $info);
- return $this->fetch();
- }
- /**
- * 资源审核保存
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function shziyuan()
- {
- if ($this->request->isPost()) {
- $data = $this->request->post();
- $info = Db::table('cy_ziyuan_apply_record')->where(['id'=>$data['id']])->find();
- if(!empty($info))
- {
- $info_list['sh_status'] = $data['sh_status'];
- $info_list['sh_time'] = time();
- Db::table('cy_ziyuan_apply_record')->where(['id'=>$data['id']])->update($info_list);
- $this->success('审核成功',url('index'));
- }
- $this->error('审核失败');
- }
- }
- }
|