Activity.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace app\store\controller;
  3. use library\Controller;
  4. use think\Db;
  5. class Activity extends Controller
  6. {
  7. /**
  8. * 绑定数据表
  9. * @var string
  10. */
  11. protected $table = 'store_activity';
  12. /**
  13. * 活动列表管理
  14. * @auth true
  15. * @menu true
  16. * @throws \think\Exception
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\ModelNotFoundException
  19. * @throws \think\exception\DbException
  20. * @throws \think\exception\PDOException
  21. */
  22. public function index()
  23. {
  24. $this->title = '活动列表管理';
  25. $query = $this->_query($this->table)->like('title');
  26. $query->dateBetween('create_at')->order('id desc')->page();
  27. }
  28. /**
  29. * 数据列表处理
  30. * @auth true
  31. * @menu true
  32. * @param array $data
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @throws \think\exception\DbException
  36. */
  37. protected function _index_page_filter(&$data)
  38. {
  39. foreach ($data as &$v){
  40. //1活动未开始、2活动报名中、3报名已满、4报名结束、5活动进中、6活动结束
  41. av_status($v['id']);
  42. }
  43. }
  44. /**
  45. * 添加商品
  46. * @auth true
  47. * @menu true
  48. * @throws \think\Exception
  49. * @throws \think\db\exception\DataNotFoundException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @throws \think\exception\DbException
  52. * @throws \think\exception\PDOException
  53. */
  54. public function add()
  55. {
  56. $this->_form($this->table, 'form');
  57. }
  58. /**
  59. * 编辑商品
  60. * @auth true
  61. * @menu true
  62. * @throws \think\Exception
  63. * @throws \think\db\exception\DataNotFoundException
  64. * @throws \think\db\exception\ModelNotFoundException
  65. * @throws \think\exception\DbException
  66. * @throws \think\exception\PDOException
  67. */
  68. function edit()
  69. {
  70. $this->_form($this->table, 'form');
  71. }
  72. /**
  73. * 商品详情
  74. * @auth true
  75. * @menu true
  76. * @throws \think\Exception
  77. * @throws \think\db\exception\DataNotFoundException
  78. * @throws \think\db\exception\ModelNotFoundException
  79. * @throws \think\exception\DbException
  80. * @throws \think\exception\PDOException
  81. */
  82. function info()
  83. {
  84. $this->_form($this->table, 'info');
  85. }
  86. public function detail(){
  87. $id=$this->request->get('id');
  88. $this->title = Db::name($this->table)->where('id',$id)->value('title').'--参与人员';
  89. $query = $this->_query('store_activity_sing')->alias('ac')->join('store_member m','ac.m_id=m.id')->where('ac.a_id',$id);
  90. $query->order('ac.id desc')->field('m.nickname,ac.create_at,ac.is_sing')->page();
  91. $this->fetch();
  92. }
  93. /**
  94. * 表单数据处理
  95. * @auth true
  96. * @menu true
  97. * @param array $data
  98. */
  99. protected function _form_filter(&$data)
  100. {
  101. if ($this->request->isPost()) {
  102. $data['create_at']=date('Y-m-d H:i:s');
  103. }
  104. }
  105. /**
  106. * 表单数据处理
  107. * @auth true
  108. * @menu true
  109. * @param array $data
  110. */
  111. public function del()
  112. {
  113. $this->_save($this->table, ['is_deleted' => '1']);
  114. }
  115. }