|
|
@@ -0,0 +1,127 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace hd\controllers;
|
|
|
+
|
|
|
+use bizHd\goods\classes\KindClass;
|
|
|
+use bizHd\goods\services\CategoryService;
|
|
|
+use bizHd\goods\services\GoodsCategoryService;
|
|
|
+use Yii;
|
|
|
+use common\components\util;
|
|
|
+
|
|
|
+class KindController extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ //品类列表
|
|
|
+ public function actionList()
|
|
|
+ {
|
|
|
+ $list = KindClass::getKindList($this->mainId);
|
|
|
+ util::success($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查看详情 ssh 2019.12.8
|
|
|
+ public function actionDetail()
|
|
|
+ {
|
|
|
+ $id = Yii::$app->request->get('categoryId', 0);
|
|
|
+ $category = CategoryService::getById($id);
|
|
|
+ CategoryService::valid($category, $this->mainId);
|
|
|
+ $info = CategoryService::getInfo($id);
|
|
|
+ util::success($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加品类 ssh 2019.12.8
|
|
|
+ public function actionAdd()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['sjId'] = $this->sjId;
|
|
|
+ $post['mainId'] = $this->mainId;
|
|
|
+ $cat = CategoryService::addCategory($post);
|
|
|
+ util::success(['id' => $cat['id']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新品类 ssh 20220404
|
|
|
+ public function actionUpdate()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $categoryId = isset($post['categoryId']) ? $post['categoryId'] : 0;
|
|
|
+ $category = CategoryService::getById($categoryId);
|
|
|
+ CategoryService::valid($category, $this->mainId);
|
|
|
+ CategoryService::updateCategory($category, $post);
|
|
|
+ util::complete('修改成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //品类启用停用 ssh 2019.12.8
|
|
|
+ public function actionChangeStatus()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
|
|
|
+ $status = isset($get['status']) ? $get['status'] : 0;
|
|
|
+ $category = CategoryService::getById($categoryId);
|
|
|
+ CategoryService::valid($category, $this->mainId);
|
|
|
+ CategoryService::changeStatus($categoryId, $status);
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除品类 ssh 2019.12.28
|
|
|
+ public function actionDelete()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
|
|
|
+ $category = CategoryService::getById($categoryId);
|
|
|
+ CategoryService::valid($category, $this->mainId);
|
|
|
+ if ($category['goodsNum'] > 0) {
|
|
|
+ util::fail('品类下还有商品');
|
|
|
+ }
|
|
|
+ $count = CategoryService::deleteCategory($categoryId);
|
|
|
+ if (!$count) {
|
|
|
+ util::fail('删除失败');
|
|
|
+ }
|
|
|
+ util::complete('删除成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //取品类下商品 ssh 20220406
|
|
|
+ public function actionGoodsList()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $catId = $get['catId'] ?? 0;
|
|
|
+ if (empty($catId)) {
|
|
|
+ util::fail('没有品类');
|
|
|
+ }
|
|
|
+ $where = [];
|
|
|
+ $where['mainId'] = $this->mainId;
|
|
|
+ $where['cId'] = $catId;
|
|
|
+ $flower = $get['flower'] ?? '';
|
|
|
+ if (is_numeric($flower)) {
|
|
|
+ $where['flower'] = $flower;
|
|
|
+ }
|
|
|
+ $where['delStatus'] = $get['delStatus'] ?? 0;
|
|
|
+ $status = $get['status'] ?? '';
|
|
|
+ if (is_numeric($status)) {
|
|
|
+ $where['status'] = $status;
|
|
|
+ }
|
|
|
+ $flowerNum = $get['flowerNum'] ?? 0;
|
|
|
+ if (!empty($flowerNum)) {
|
|
|
+ $where['flowerNum'] = $flowerNum;
|
|
|
+ }
|
|
|
+ $data = GoodsCategoryService::getGoodsList($where);
|
|
|
+ util::success($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ //品类排序 ssh 2020.3.11
|
|
|
+ public function actionSort()
|
|
|
+ {
|
|
|
+ $id = Yii::$app->request->get('id', 0);
|
|
|
+ $inTurn = Yii::$app->request->get('inTurn', 0);
|
|
|
+ $category = CategoryService::getById($id);
|
|
|
+ CategoryService::valid($category, $this->mainId);
|
|
|
+ CategoryService::updateById($id, ['inTurn' => $inTurn]);
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取品类 ssh 2019.12.2
|
|
|
+ public function actionMallList()
|
|
|
+ {
|
|
|
+ $return = CategoryService::getEnableList($this->sjId);
|
|
|
+ util::success($return);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|