Procházet zdrojové kódy

零售端 花材分类管理,花材管理

林琦海 před 5 roky
rodič
revize
7cdb81444d

+ 9 - 9
app-hd/controllers/ItemClassController.php

@@ -6,16 +6,16 @@
 
 namespace hd\controllers;
 
-use bizHd\item\classes\ItemClassClass;
-use bizHd\item\services\ItemClassService;
+use bizGhs\item\classes\ItemClassClass;
+use bizGhs\item\services\ItemClassService;
 use common\components\util;
 use Yii;
 class ItemClassController extends BaseController
 {
     public function actionList()
     {
-        $where = ['sjId' => $this->sjId];
-        $list = ItemClassClass::getItemClassList($where);
+        $where = ['merchantId' => $this->sjId];
+        $list = ItemClassClass::getGhsItemClassList($where);
         util::success($list);
     }
 
@@ -23,7 +23,7 @@ class ItemClassController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
-        $res = ItemClassClass::addItemClass($this->sjId,$post);
+        $res = ItemClassClass::addGhsItemClass($this->sjId,$post);
         util::complete('添加成功');
     }
 
@@ -32,22 +32,22 @@ class ItemClassController extends BaseController
         $data = Yii::$app->request->post();
 
         $data['adminId'] = $this->adminId;
-        $data['sjId'] = $this->sjId;
-        ItemClassClass::updateItemClass($data);
+        $data['merchantId'] = $this->sjId;
+        ItemClassClass::updateGhsItemClass($data);
         util::complete('修改成功');
     }
 
     public function actionDelete()
     {
         $id = Yii::$app->request->get('id',0);
-        ItemClassService::deleteItemClass($id,$this->sjId);
+        ItemClassService::deleteGhsItemClass($id,$this->sjId);
         util::complete('操作成功');
     }
 
     //开单: 获取所有分类
     public function actionAll()
     {
-        $data = ItemClassClass::getItemClassAll($this->sjId);
+        $data = ItemClassClass::getGhsItemClassAll($this->sjId);
         util::success($data);
     }
 }

+ 40 - 33
app-hd/controllers/ItemController.php

@@ -7,8 +7,8 @@
 namespace hd\controllers;
 
 use biz\item\classes\PtItemClass;
-use bizHd\item\classes\ItemClass;
-use bizHd\item\services\ItemService;
+use bizGhs\item\classes\ItemClass;
+use bizGhs\item\services\ItemService;
 use common\components\util;
 use common\services\xhItemService;
 use Yii;
@@ -16,11 +16,12 @@ class ItemController extends BaseController
 {
     public function actionList()
     {
-        //classId
-        $classId = Yii::$app->request->get('classId',0);
-        $where['sjId'] =  $this->sjId;
-        $where['classId'] =  $classId;
-        $list = ItemClass::getItemList($where);
+        $classId = Yii::$app->request->get('classId', 0);
+        $where['merchantId'] = $this->sjId;
+        if (!empty($classId)) {
+            $where['classId'] = $classId;
+        }
+        $list = ItemClass::getGhsItemList($where);
         util::success($list);
     }
 
@@ -28,50 +29,56 @@ class ItemController extends BaseController
     {
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
-        $post['shopId'] = $this->shopId;
-        $post['sjId'] = $this->sjId;
-        ItemService::addItem($post);
+        // $post['shopId'] = $this->shopId;
+        $post['merchantId'] = $this->sjId;
+        ItemService::addGhsItem($post);
         util::complete('添加成功');
     }
 
-    public function actionUpdate()
-    {
-        $data = Yii::$app->request->post();
-        $data['adminId'] = $this->adminId;
-        $data['sjId'] = $this->sjId;
-        ItemService::updateItem($data);
-        util::complete('修改成功');
-    }
-
-    //排序
-    public function actionChangeSort()
+    public function actionBatchAdd()
     {
-        //[id=>sort]
-        $data = Yii::$app->request->post();
+        $post = Yii::$app->request->post();
+        $data = $post['data']; //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
         if(empty($data)){
-            util::fail('参数错误');
+            util::fail("参数错误");
+        }
+        $data = json_decode($data,true);
+        if(!is_array($data) || empty($data)){
+            util::fail("参数格式错误");
         }
-        //循环修改排序值
-        // todo
 
+        foreach ($data as $v){
+            $v['adminId'] = $this->adminId;
+            $v['merchantId'] = $this->sjId;
+            ItemService::addGhsItem($v);
+        }
+        util::complete('添加成功');
+
+    }
 
+    public function actionUpdate()
+    {
+        $data = Yii::$app->request->post();
+        $data['adminId'] = $this->adminId;
+        $data['merchantId'] = $this->sjId;
+        ItemService::updateGshItem($data);
+        util::complete('修改成功');
     }
 
     public function actionDelete()
     {
-        $get = Yii::$app->request->get();
-        $id = isset($get['id']) ? $get['id'] : 0;
-        ItemService::deleteItem($id,$this->shopId,$this->adminId);
-        util::complete('操作成功');
+//        $get = Yii::$app->request->get();
+//        $id = isset($get['id']) ? $get['id'] : 0;
+//        ItemService::deleteGhsItem($id, $this->shopId, $this->sjId, $this->adminId);
+        util::fail('不能删除哦!');
     }
 
     //获取平台里的花材信息
     public function actionPlatformItem()
     {
-        $py = Yii::$app->request->get('py','');
+        $py = Yii::$app->request->get('py', '');
         $where = [];
-        if($py){
-            $py = strtolower($py);
+        if ($py) {
             $where = ['py' => $py];
         }
         $list = PtItemClass::getItemList($where);