You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.7 KiB

7 years ago
6 years ago
7 years ago
6 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use DB;
  4. use App\Common\Helper;
  5. use App\Common\ReturnData;
  6. use Illuminate\Http\Request;
  7. use App\Http\Logic\BonusLogic;
  8. use App\Http\Model\Bonus;
  9. class BonusController extends CommonController
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function getLogic()
  16. {
  17. return new BonusLogic();
  18. }
  19. public function index(Request $request)
  20. {
  21. $res = '';
  22. $where = function ($query) use ($res) {
  23. if(isset($_REQUEST["keyword"]))
  24. {
  25. $query->where('name', 'like', '%'.$_REQUEST['keyword'].'%');
  26. }
  27. if(isset($_REQUEST["id"]))
  28. {
  29. $query->where('typeid', $_REQUEST["id"]);
  30. }
  31. };
  32. $posts = $this->getLogic()->getPaginate($where, array('status', 'asc'));
  33. if($posts)
  34. {
  35. foreach($posts as $k=>$v)
  36. {
  37. }
  38. }
  39. $data['posts'] = $posts;
  40. return view('admin.bonus.index', $data);
  41. }
  42. public function add(Request $request)
  43. {
  44. if(Helper::isPostRequest())
  45. {
  46. if($_POST["start_time"]>=$_POST["end_time"]){error_jump('参数错误');}
  47. $res = $this->getLogic()->add($_POST);
  48. if($res['code'] == ReturnData::SUCCESS)
  49. {
  50. success_jump($res['msg'], route('admin_bonus'));
  51. }
  52. error_jump($res['msg']);
  53. }
  54. return view('admin.bonus.add');
  55. }
  56. public function edit(Request $request)
  57. {
  58. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  59. $id = $request->input('id');
  60. if(Helper::isPostRequest())
  61. {
  62. $where['id'] = $id;
  63. if($_POST["start_time"]>=$_POST["end_time"]){error_jump('参数错误');}
  64. $res = $this->getLogic()->edit($_POST, $where);
  65. if($res['code'] == ReturnData::SUCCESS)
  66. {
  67. success_jump($res['msg'], route('admin_bonus'));
  68. }
  69. error_jump($res['msg']);
  70. }
  71. $data['id'] = $where['id'] = $id;
  72. $data['post'] = $this->getLogic()->getOne($where);
  73. return view('admin.bonus.edit', $data);
  74. }
  75. public function del(Request $request)
  76. {
  77. if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');}
  78. $id = $request->input('id');
  79. $where['id'] = $id;
  80. $res = $this->getLogic()->del($where);
  81. if($res['code'] == ReturnData::SUCCESS)
  82. {
  83. success_jump($res['msg']);
  84. }
  85. error_jump($res['msg']);
  86. }
  87. }