| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- /**
- * Created by PhpStorm.
- * User: admin
- * Date: 2019/12/1
- * Time: 13:55
- */
- namespace business\controllers;
- use Yii;
- use common\components\util;
- use biz\goods\services\GoodsService;
- class GoodsController extends BaseController
- {
-
- //商品列表 shish 2019.12.7
- public function actionList()
- {
- $where = ['merchantId' => $this->merchantId];
- $list = GoodsService::getGoodsList($where);
- util::success($list);
- }
-
- //添加商品 shish 2019.12.7
- public function actionAdd()
- {
- $data = Yii::$app->request->post();
- $data['merchantId'] = $this->merchantId;
- $return = GoodsService::addGoods($data);
- $id = $return['id'];
- $info = GoodsService::getById($id);
- util::success($info);
- }
-
- //获取商品详情 shish 2019.12.7
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $goods = GoodsService::getGoodsInfo($id);
- util::success($goods);
- }
-
- //更新商品 shish 2019.12.7
- public function actionUpdate()
- {
- $data = Yii::$app->request->post();
- $id = isset($data['id']) ? $data['id'] : 0;
- unset($data['id']);
- GoodsService::valid($id,$this->merchantId);
- GoodsService::updateGoods($id, $data);
- util::ok();
- }
- //删除商品 shish 2019.12.7
- public function actionDelete()
- {
- $id = Yii::$app->request->get('id', 0);
- GoodsService::deleteGoods($id, $this->admin);
- util::success();
- }
-
- }
|