GoodsController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: admin
  5. * Date: 2019/12/1
  6. * Time: 13:55
  7. */
  8. namespace business\controllers;
  9. use Yii;
  10. use common\components\util;
  11. use biz\goods\services\GoodsService;
  12. class GoodsController extends BaseController
  13. {
  14. //商品列表 shish 2019.12.7
  15. public function actionList()
  16. {
  17. $where = ['merchantId' => $this->merchantId];
  18. $list = GoodsService::getGoodsList($where);
  19. util::success($list);
  20. }
  21. //添加商品 shish 2019.12.7
  22. public function actionAdd()
  23. {
  24. $data = Yii::$app->request->post();
  25. $data['merchantId'] = $this->merchantId;
  26. $info = GoodsService::addGoods($data);
  27. util::success($info);
  28. }
  29. //获取商品详情 shish 2019.12.7
  30. public function actionDetail()
  31. {
  32. $id = Yii::$app->request->get('id');
  33. $goods = GoodsService::getGoodsInfo($id);
  34. util::success($goods);
  35. }
  36. //更新商品 shish 2019.12.7
  37. public function actionUpdate()
  38. {
  39. $data = Yii::$app->request->get();
  40. $id = $data['id'];
  41. $re = GoodsService::updateById($id, $data);
  42. util::success($re);
  43. }
  44. //删除商品 shish 2019.12.7
  45. public function actionDelete()
  46. {
  47. $id = Yii::$app->request->get('id', 0);
  48. GoodsService::deleteGoods($id, $this->admin);
  49. util::success();
  50. }
  51. }