Product.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\shop\controller\plus\seckill;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\plus\seckill\Product as SeckillProductModel;
  5. /**
  6. * 产品控制器
  7. */
  8. class Product extends Controller
  9. {
  10. /**
  11. * 产品列表
  12. */
  13. public function index()
  14. {
  15. $data = $this->postData();
  16. $model = new SeckillProductModel;
  17. $list = $model->getAllList($data);
  18. return $this->renderSuccess('', compact('list'));
  19. }
  20. //审核产品
  21. public function edit($seckill_product_id){
  22. if($this->request->isGet()){
  23. $detail = SeckillProductModel::detail($seckill_product_id);
  24. return $this->renderSuccess('', compact('detail'));
  25. }
  26. $data = $this->postData();
  27. // 修改
  28. $model = SeckillProductModel::detail($seckill_product_id);
  29. if ($model->editProduct($data)) {
  30. return $this->renderSuccess('修改成功');
  31. }
  32. return $this->renderError($model->getError() ?: '修改失败');
  33. }
  34. /**
  35. * 删除商品
  36. */
  37. public function delete($seckill_product_id)
  38. {
  39. // 详情
  40. $model = SeckillProductModel::detail($seckill_product_id);
  41. if ($model->setDelete()) {
  42. return $this->renderSuccess('删除成功');
  43. }
  44. return $this->renderError($model->getError() ?: '删除失败');
  45. }
  46. }