Active.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\shop\controller\plus\bargain;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\plus\bargain\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. */
  34. public function edit($bargain_activity_id)
  35. {
  36. if($this->request->isGet()){
  37. $detail = ActiveModel::detailWithTrans($bargain_activity_id);
  38. return $this->renderSuccess('', compact('detail'));
  39. }
  40. $model = ActiveModel::detail($bargain_activity_id);
  41. // 新增记录
  42. if ($model->edit($this->postData())) {
  43. return $this->renderSuccess('修改成功');
  44. }
  45. return $this->renderError($model->getError() ?: '修改失败');
  46. }
  47. /**
  48. *删除砍价活动
  49. */
  50. public function delete($bargain_activity_id)
  51. {
  52. // 活动会场详情
  53. $model = ActiveModel::detail($bargain_activity_id);
  54. if ($model->del()) {
  55. return $this->renderSuccess('删除成功');
  56. }
  57. return $this->renderError($model->getError() ?: '删除失败');
  58. }
  59. }