GoodsController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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->get();
  25. GoodsService::add($data);
  26. }
  27. //获取商品详情 shish 2019.12.7
  28. public function actionDetail()
  29. {
  30. $id = Yii::$app->request->get('id');
  31. $goods = GoodsService::getGoodsInfo($id);
  32. util::success($goods);
  33. }
  34. //更新商品 shish 2019.12.7
  35. public function actionUpdate()
  36. {
  37. $data = Yii::$app->request->get();
  38. $id = $data['id'];
  39. $re = GoodsService::updateById($id, $data);
  40. util::success($re);
  41. }
  42. //删除商品 shish 2019.12.7
  43. public function actionDelete()
  44. {
  45. $id = Yii::$app->request->get('id', 0);
  46. GoodsService::deleteGoods($id, $this->admin);
  47. util::success();
  48. }
  49. }