Product.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\shop\controller\plus\bargain;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\plus\bargain\Product as BargainProductModel;
  5. /**
  6. * 产品控制器
  7. */
  8. class Product extends Controller
  9. {
  10. /**
  11. * 产品列表
  12. */
  13. public function index()
  14. {
  15. $data = $this->postData();
  16. $model = new BargainProductModel;
  17. $list = $model->getAllList($data);
  18. return $this->renderSuccess('', compact('list'));
  19. }
  20. //审核产品
  21. public function edit($bargain_product_id){
  22. if($this->request->isGet()){
  23. $detail = BargainProductModel::detail($bargain_product_id,['product.sku', 'bargainSku','active','product.image.file']);
  24. return $this->renderSuccess('', compact('detail'));
  25. }
  26. $data = $this->postData();
  27. // 修改
  28. $model = BargainProductModel::detail($bargain_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($bargain_product_id)
  38. {
  39. // 详情
  40. $model = BargainProductModel::detail($bargain_product_id);
  41. if ($model->setDelete()) {
  42. return $this->renderSuccess('删除成功');
  43. }
  44. return $this->renderError($model->getError() ?: '删除失败');
  45. }
  46. }