Ziyuan.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\library\OneFileUpload;
  4. use think\Loader;
  5. use think\Db;
  6. class Ziyuan extends Admin
  7. {
  8. protected $gameList;
  9. public function _initialize()
  10. {
  11. parent::_initialize(); // TODO: Change the autogenerated stub
  12. }
  13. /**
  14. *玩家福利列表
  15. */
  16. public function index()
  17. {
  18. $order = 'create_time desc';
  19. $welfareModel = Db::name('cy_ziyuan');
  20. $list = $welfareModel
  21. ->field('*')
  22. ->order($order)
  23. ->paginate();
  24. $this->assign('list', $list);
  25. $this->assign('page', $list->render());
  26. return $this->fetch();
  27. }
  28. /**
  29. *增
  30. */
  31. public function add()
  32. {
  33. if ($this->request->isPost()) {
  34. $data = $this->request->post();
  35. $data['create_time'] = time();
  36. $m = Db::name('cy_ziyuan')->insertGetId($data);
  37. if (!empty($m)) {
  38. $this->success('添加成功',url('index'));
  39. }
  40. $this->error($appModel->getError() ?: '添加失败');
  41. }
  42. return $this->fetch();
  43. }
  44. /**
  45. *删
  46. */
  47. public function delete()
  48. {
  49. $id = $this->request->param('id', '', 'intval');
  50. if (empty($id)) {
  51. $this->error('参数错误!');
  52. }
  53. $appModel = model('Common/Welfare');
  54. if (!$appModel->find($id)) {
  55. $this->error('参数错误,不存在该数据');
  56. }
  57. if ($appModel->where('id', '=', $id)->delete()) {
  58. $this->success('删除成功',url('index'));
  59. }
  60. $error = $appModel->getError();
  61. $this->error($error ?: '删除失败');
  62. }
  63. /**
  64. *编辑
  65. */
  66. public function edit()
  67. {
  68. $id = $this->request->param('id', '', 'intval');
  69. $appModel = Db::name('cy_ziyuan');
  70. if (!$data = $appModel->find($id)) {
  71. $this->error('参数错误,不存在该数据');
  72. }
  73. if (empty($id)) {
  74. $this->error('参数错误!');
  75. }
  76. if ($this->request->isPost()) {
  77. $data = $this->request->post();
  78. Db::name('cy_ziyuan')->where(['id'=>$id])->update($data);
  79. if (!empty($id)) {
  80. $this->success('修改成功',url('index'));
  81. }
  82. $this->error($appModel->getError() ?: '修改失败');
  83. }
  84. $this->assign('data', $data);
  85. return $this->fetch();
  86. }
  87. /**
  88. *玩家福利列表
  89. */
  90. public function typelist()
  91. {
  92. $order = 'create_time desc';
  93. $welfareModel = Db::name('cy_ziyuan_type');
  94. $list = $welfareModel
  95. ->field('*')
  96. ->order($order)
  97. ->paginate();
  98. $this->assign('list', $list);
  99. $this->assign('page', $list->render());
  100. return $this->fetch();
  101. }
  102. /**
  103. *增
  104. */
  105. public function typeadd()
  106. {
  107. if ($this->request->isPost()) {
  108. $data = $this->request->post();
  109. $data['create_time'] = time();
  110. $m = Db::name('cy_ziyuan_type')->insertGetId($data);
  111. if (!empty($m)) {
  112. $this->success('添加成功',url('index'));
  113. }
  114. $this->error($appModel->getError() ?: '添加失败');
  115. }
  116. return $this->fetch();
  117. }
  118. /**
  119. *编辑
  120. */
  121. public function typeedit()
  122. {
  123. $id = $this->request->param('id', '', 'intval');
  124. $appModel = Db::name('cy_ziyuan_type');
  125. if (!$data = $appModel->find($id)) {
  126. $this->error('参数错误,不存在该数据');
  127. }
  128. if (empty($id)) {
  129. $this->error('参数错误!');
  130. }
  131. if ($this->request->isPost()) {
  132. $data = $this->request->post();
  133. Db::name('cy_ziyuan_type')->where(['id'=>$id])->update($data);
  134. if (!empty($id)) {
  135. $this->success('修改成功',url('index'));
  136. }
  137. $this->error($appModel->getError() ?: '修改失败');
  138. }
  139. $this->assign('data', $data);
  140. return $this->fetch();
  141. }
  142. /**
  143. * 资源审核记录
  144. * @return mixed
  145. * @throws \think\exception\DbException
  146. */
  147. public function ziyuanshlist()
  148. {
  149. $where = [];
  150. $sh_status = $this->request->get('sh_status', '', 'trim');
  151. if(!empty($sh_status))
  152. {
  153. $where['record.sh_status'] = $sh_status;
  154. }
  155. $infoList = Db::table('cy_ziyuan_apply_record')->alias('record')
  156. ->join('cy_members member', 'member.id = record.member_id')
  157. ->join('cy_game game', 'game.id = record.gameid')
  158. ->join('nw_channel channel', 'channel.id = record.channel_id')
  159. ->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'])
  160. ->where($where)
  161. ->order('record.sh_status', 'desc')
  162. ->paginate();
  163. $this->assign('list', $infoList);
  164. $this->assign('page', $infoList->render());
  165. return $this->fetch();
  166. }
  167. public function shstatus()
  168. {
  169. $id = $this->request->param('id', '', 'intval');
  170. $info = Db::table('cy_ziyuan_apply_record')->where(['id'=>$id])->find();
  171. $this->assign('info', $info);
  172. return $this->fetch();
  173. }
  174. /**
  175. * 资源审核保存
  176. * @throws \think\Exception
  177. * @throws \think\db\exception\DataNotFoundException
  178. * @throws \think\db\exception\ModelNotFoundException
  179. * @throws \think\exception\DbException
  180. * @throws \think\exception\PDOException
  181. */
  182. public function shziyuan()
  183. {
  184. if ($this->request->isPost()) {
  185. $data = $this->request->post();
  186. $info = Db::table('cy_ziyuan_apply_record')->where(['id'=>$data['id']])->find();
  187. if(!empty($info))
  188. {
  189. $info_list['sh_status'] = $data['sh_status'];
  190. $info_list['sh_time'] = time();
  191. Db::table('cy_ziyuan_apply_record')->where(['id'=>$data['id']])->update($info_list);
  192. $this->success('审核成功',url('index'));
  193. }
  194. $this->error('审核失败');
  195. }
  196. }
  197. }