Active.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\shop\controller\plus\assemble;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\plus\assemble\Active as ActiveModel;
  5. /**
  6. * 拼团活动控制器
  7. */
  8. class Active extends Controller
  9. {
  10. /**
  11. * 活动会场列表
  12. */
  13. public function index()
  14. {
  15. $model = new ActiveModel;
  16. $list = $model->getList($this->postData());
  17. return $this->renderSuccess('', compact('list'));
  18. }
  19. /**
  20. * 新增活动会场
  21. */
  22. public function add()
  23. {
  24. $model = new ActiveModel;
  25. // 新增记录
  26. if ($model->add($this->postData())) {
  27. return $this->renderSuccess('添加成功');
  28. }
  29. return $this->renderError($model->getError() ?: '添加失败');
  30. }
  31. /**
  32. * 获取秒杀活动详情
  33. * @param $seckill_activity_id int 秒杀活动id
  34. * @return \think\response\Json
  35. */
  36. public function edit($assemble_activity_id)
  37. {
  38. if($this->request->isGet()){
  39. $detail = ActiveModel::detailWithTrans($assemble_activity_id);
  40. return $this->renderSuccess('', compact('detail'));
  41. }
  42. $model = ActiveModel::detail($assemble_activity_id);
  43. // 新增记录
  44. if ($model->edit($this->postData())) {
  45. return $this->renderSuccess('修改成功');
  46. }
  47. return $this->renderError($model->getError() ?: '修改失败');
  48. }
  49. /**
  50. * 删除活动
  51. */
  52. public function delete($assemble_activity_id)
  53. {
  54. // 活动会场详情
  55. $model = ActiveModel::detail($assemble_activity_id);
  56. if ($model->del()) {
  57. return $this->renderSuccess('删除成功');
  58. }
  59. return $this->renderError($model->getError() ?: '删除失败');
  60. }
  61. }