Seckill.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. namespace app\mall\controller;
  3. use library\Controller;
  4. /**
  5. * 秒杀活动
  6. * Class NewsManage
  7. * @package app\Nutrition\controller
  8. */
  9. class Seckill extends Controller
  10. {
  11. /**
  12. * 绑定数据表
  13. * @var string
  14. */
  15. protected $table = 'SeckillActivity';
  16. /**
  17. * 列表
  18. * @auth true
  19. * @menu true
  20. * @throws \think\Exception
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. * @throws \think\exception\DbException
  24. * @throws \think\exception\PDOException
  25. */
  26. public function index()
  27. {
  28. $this->title = '活动列表';
  29. $sel_where = [];
  30. $sel_where[] = ['is_deleted','=',0];
  31. if($title = $this->request->get('title')) $sel_where[] = ['title','like','%'.$title.'%'];
  32. $query = $this->_query($this->table);
  33. $query->where($sel_where)->order('status desc ,sort desc,id desc')->page();
  34. }
  35. /**
  36. * 数据列表处理
  37. * @auth true
  38. * @menu true
  39. * @param array $data
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. * @throws \think\exception\DbException
  43. */
  44. protected function _index_page_filter(&$data)
  45. {
  46. }
  47. /**
  48. * 添加
  49. * @auth true
  50. * @menu true
  51. * @throws \think\Exception
  52. * @throws \think\db\exception\DataNotFoundException
  53. * @throws \think\db\exception\ModelNotFoundException
  54. * @throws \think\exception\DbException
  55. * @throws \think\exception\PDOException
  56. */
  57. public function add()
  58. {
  59. $this->title = '添加活动';
  60. $this->_form($this->table, 'form');
  61. }
  62. /**
  63. * 编辑
  64. * @auth true
  65. * @menu true
  66. * @throws \think\Exception
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\ModelNotFoundException
  69. * @throws \think\exception\DbException
  70. * @throws \think\exception\PDOException
  71. */
  72. public function edit()
  73. {
  74. $this->title = '编辑活动';
  75. $this->_form($this->table, 'form');
  76. }
  77. /**
  78. * 禁用
  79. * @auth true
  80. * @menu true
  81. * @throws \think\Exception
  82. * @throws \think\db\exception\DataNotFoundException
  83. * @throws \think\db\exception\ModelNotFoundException
  84. * @throws \think\exception\DbException
  85. * @throws \think\exception\PDOException
  86. */
  87. public function forbidden()
  88. {
  89. $this->_save($this->table, ['status' => '0']);
  90. }
  91. /**
  92. * 启用
  93. * @auth true
  94. * @menu true
  95. * @throws \think\Exception
  96. * @throws \think\db\exception\DataNotFoundException
  97. * @throws \think\db\exception\ModelNotFoundException
  98. * @throws \think\exception\DbException
  99. * @throws \think\exception\PDOException
  100. */
  101. public function enable()
  102. {
  103. $this->_save($this->table, ['status' => 1]);
  104. }
  105. /**
  106. * 删除
  107. * @auth true
  108. * @menu true
  109. * @throws \think\Exception
  110. * @throws \think\db\exception\DataNotFoundException
  111. * @throws \think\db\exception\ModelNotFoundException
  112. * @throws \think\exception\DbException
  113. * @throws \think\exception\PDOException
  114. */
  115. public function del()
  116. {
  117. $this->_save($this->table, ['is_deleted' => 1]);
  118. }
  119. /**
  120. * 表单数据处理
  121. * @auth true
  122. * @menu true
  123. * @param array $data
  124. */
  125. protected function _form_filter(&$data)
  126. {
  127. if($this->request->isPost())
  128. {
  129. }
  130. }
  131. protected function _form_result($result){
  132. $this->success('编辑成功!', 'javascript:history.back()');
  133. }
  134. }