shish il y a 4 ans
Parent
commit
73c9fe72cf

+ 0 - 16
app-ghs/controllers/ItemController.php

@@ -14,13 +14,6 @@ class ItemController extends BaseController
 
     public function actionList()
     {
-        $classId = Yii::$app->request->get('classId', 0);
-        $where['sjId'] = $this->sjId;
-        if (!empty($classId)) {
-            $where['classId'] = $classId;
-        }
-        $list = ItemClass::getGhsItemList($where);
-        util::success($list);
     }
 
     public function actionAdd()
@@ -86,15 +79,6 @@ class ItemController extends BaseController
         }
     }
 
-    public function actionUpdate()
-    {
-        $data = Yii::$app->request->post();
-        $data['adminId'] = $this->adminId;
-        $data['sjId'] = $this->sjId;
-        ItemService::updateGshItem($data);
-        util::complete('修改成功');
-    }
-
     public function actionDelete()
     {
         util::fail('不能删除哦!');

+ 2 - 4
app-hd/controllers/ItemClassController.php

@@ -23,7 +23,7 @@ class ItemClassController extends BaseController
     public function actionGetAllClass()
     {
         $list = ItemClassClass::getGhsItemClassAll($this->sjId);
-        util::success(['list'=>$list]);
+        util::success(['list' => $list]);
     }
 
     public function actionAdd()
@@ -64,9 +64,7 @@ class ItemClassController extends BaseController
 
     public function actionDelete()
     {
-        $id = Yii::$app->request->get('id', 0);
-        ItemClassService::deleteGhsItemClass($id, $this->sjId);
-        util::complete('操作成功');
+        util::complete('没有删除成功');
     }
 
     //开单: 获取所有分类

+ 0 - 19
app-hd/controllers/ItemController.php

@@ -16,13 +16,6 @@ class ItemController extends BaseController
 {
     public function actionList()
     {
-        $classId = Yii::$app->request->get('classId', 0);
-        $where['sjId'] = $this->sjId;
-        if (!empty($classId)) {
-            $where['classId'] = $classId;
-        }
-        $list = ItemClass::getGhsItemList($where);
-        util::success($list);
     }
 
     public function actionAdd()
@@ -56,20 +49,8 @@ class ItemController extends BaseController
 
     }
 
-    public function actionUpdate()
-    {
-        $data = Yii::$app->request->post();
-        $data['adminId'] = $this->adminId;
-        $data['sjId'] = $this->sjId;
-        ItemService::updateGshItem($data);
-        util::complete('修改成功');
-    }
-
     public function actionDelete()
     {
-//        $get = Yii::$app->request->get();
-//        $id = isset($get['id']) ? $get['id'] : 0;
-//        ItemService::deleteGhsItem($id, $this->shopId, $this->sjId, $this->adminId);
         util::fail('不能删除哦!');
     }
 

+ 0 - 15
biz-ghs/item/services/ItemClassService.php

@@ -15,19 +15,4 @@ use common\components\util;
 class ItemClassService extends BaseService
 {
 
-
-    //删除花材分类. 有花材不让删除
-    public static function deleteGhsItemClass($id,$sjId)
-    {
-        //判断是否存在
-        $model = ItemClassClass::getById($id);
-
-        $exist = ItemClass::exists(['classId'=>$id,'sjId'=>$model['sjId']]);
-        if($exist){
-            util::fail("该花材分类还有花材,不能删除");
-        }
-        ItemClassClass::deleteById($id);
-
-    }
-
 }

+ 0 - 68
biz-ghs/item/services/ItemService.php

@@ -84,7 +84,6 @@ class ItemService extends BaseService
         $data['hjAddPrice'] = $ptItem['hjAddPrice'] ?? 0;
         $data['zsAddPrice'] = $ptItem['zsAddPrice'] ?? 0;
 
-        ItemClass::add($data);
         $shopIds = ShopService::getShopIds($sjId);
         if (empty($shopIds)) {
             util::fail("没有找到门店");
@@ -105,7 +104,6 @@ class ItemService extends BaseService
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            ItemClass::batchAdd($data);
             ProductClass::batchAdd($data);
             $transaction->commit();
         } catch (\Exception $exception) {
@@ -114,71 +112,6 @@ class ItemService extends BaseService
         }
     }
 
-    //修改花材信息
-    public static function updateGshItem($data)
-    {
-        $id = $data['id'] ?? 0;
-        $stockWarning = $data['stockWarning'] ?? 0;
-        $addPrice = $data['addPrice'] ?? 0;
-        $weight = $data['weight'] ?? 0;
-        $cost = $data['cost'] ?? 0; //成本价
-        if ($stockWarning < 0) {
-            util::fail("库存预警不能小于0");
-        }
-        if ($addPrice < 0) {
-            util::fail("每扎加价不能小于0");
-        }
-        if ($weight < 0) {
-            // util::fail("每扎重量不能小于0");
-        }
-        if ($cost < 0) {
-            util::fail("成本价不能小于0");
-        }
-
-        $model = self::getById($id);
-        if (!$model) {
-            util::fail("该花材不存在");
-        }
-        if ($model['sjId'] !== $data['sjId']) {
-            util::fail("参数错误");
-        }
-
-        ItemClass::updateGshItem($id, $stockWarning, $addPrice, $weight, $cost);
-    }
-
-    //删除花材,同时修改itemInfo 的状态值 delStatus = 1
-    public static function deleteGhsItem($id, $shopId, $sjId, $adminId)
-    {
-        $model = ItemClass::getById($id);
-        if (!$model) {
-            util::fail("该花材不存在");
-        }
-        if ($model['sjId'] !== $sjId) {
-            util::fail("参数错误");
-        }
-        $connection = Yii::$app->db;
-        $transaction = $connection->beginTransaction();
-        try {
-            ItemClass::deleteGhsItem($id);
-            $condition = [
-                'itemId' => $model['itemId'],
-                'shopId' => $shopId,
-            ];
-            ProductClass::updateByCondition($condition, ['delStatus' => 1, 'adminId' => $adminId]);
-            $transaction->commit();
-        } catch (\Exception $exception) {
-            $transaction->rollBack();
-            util::fail("操作失败");
-        }
-    }
-
-    //获取所有的花材ID
-    public static function getGhsItemIds($sjId)
-    {
-        $data = ItemClass::getGhsItemAll($sjId, 'classId,itemId');
-        return $data;
-    }
-
     //初始化 花材 ghsItemClass, ghsItem  ghsProduct  linqh 2021.4.12  modify shish 20210711
     public static function initItem($sjId, $shopId)
     {
@@ -262,7 +195,6 @@ class ItemService extends BaseService
             if (empty($itemAddData)) {
                 continue;
             }
-            ItemClass::batchAdd($itemAddData);
             ProductClass::batchAdd($productAddData);
 
         }

+ 0 - 39
biz-ghs/product/classes/ProductClass.php

@@ -543,38 +543,6 @@ class ProductClass extends BaseClass
         }
     }
 
-
-    //库存告警的itemIds (库存数量少于告警数量)  linqh 2021.1.26
-    public static function getItemIdsWarning($sjId, $shopId)
-    {
-        //获取当前门店下的 itemId=>stock
-        $productData = ProductClass::getAllList("itemId,stock", ['shopId' => $shopId]);
-        $productItemStock = [];
-        if ($productData) {
-            foreach ($productData as $v) {
-                $productItemStock[$v['itemId']] = $v['stock'];
-            }
-        }
-
-        //获取sjId 下 对应的itemId=>stockWaring
-        $itemData = ItemClass::getAllList("itemId,stockWarning", ['sjId' => $sjId]);
-        $itemStockWaring = [];
-        if ($itemData) {
-            foreach ($itemData as $v) {
-                $itemStockWaring[$v['itemId']] = $v['stockWarning'];
-            }
-        }
-        //取库存数量少于告警数量 的itemId
-        $itemIds = [];
-        foreach ($productItemStock as $k => $v) {
-            $stockWaring = $itemStockWaring[$k] ?? 0;
-            if ($v <= $stockWaring) {
-                $itemIds[] = $k;
-            }
-        }
-        return $itemIds;
-    }
-
     //获取当前门店下商品信息 linqh 2021.1.28
     public static function getProductData($id, $shopId, $obj = false)
     {
@@ -1267,13 +1235,6 @@ class ProductClass extends BaseClass
         return $data;
     }
 
-    //获取所有的花材ID
-    public static function getGhsItemIds($sjId)
-    {
-        $data = self::getGhsItemAll($sjId, 'classId,itemId');
-        return $data;
-    }
-
     //库存预警通知 shish 20210909
     public static function stockWarningAddQueue($product, $stock)
     {

+ 1 - 1
biz-ghs/product/models/Product.php

@@ -5,6 +5,6 @@ class Product extends Base
 {
     public static function tableName()
     {
-        return 'xhGhsProduct';
+        return 'xhGhsItem';
     }
 }

+ 4 - 17
biz-hd/item/services/ItemClassService.php

@@ -1,32 +1,19 @@
 <?php
-namespace bizHd\item\services;
 
+namespace bizHd\item\services;
 
 use bizHd\base\services\BaseService;
 use bizHd\item\classes\ItemClass;
 use bizHd\item\classes\ItemClassClass;
 use common\components\util;
+
 class ItemClassService extends BaseService
 {
     public static $baseFile = '\bizHd\item\classes\ItemClassClass';
 
-    //删除花材分类. 有花材不让删除
-    public static function deleteItemClass($id,$sjId)
+    public static function deleteItemClass($id, $sjId)
     {
-        //判断是否存在
-        $model = ItemClassClass::getById($id);
-        if(!$model){
-            util::fail("该花材分类不存在");
-        }
-        if($model['sjId'] !== $sjId){
-            util::fail("参数错误");
-        }
-        $exist = ItemClass::exists(['classId'=>$id,'sjId'=>$model['sjId']]);
-        if($exist){
-            util::fail("该花材分类还有花材,不能删除");
-        }
-        ItemClassClass::deleteById($id);
-
+        util::fail('删除失败');
     }
 
 }

+ 2 - 56
biz-hd/item/services/ItemService.php

@@ -1,7 +1,5 @@
 <?php
 namespace bizHd\item\services;
-
-
 use bizHd\base\services\BaseService;
 use bizHd\item\classes\ItemClass;
 use bizHd\item\classes\ItemClassClass;
@@ -32,20 +30,13 @@ class ItemService extends BaseService
         }
         //判断花材是否存在 调用平台花材的方法
         //todo
-
         $existItemClass = ItemClassClass::exists(['id'=>$classId,'sjId'=>$sjId]);
         if(!$existItemClass){
             util::fail("花材分类不存在");
         }
-        $existItem = ItemClass::exists(['itemId'=>$itemId,'sjId'=>$sjId]);
-        if($existItem){
-            util::fail("花材已存在");
-        }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try{
-            //写入一条item,同时写入一条itemInfo(初始化库存)
-            ItemClass::add($data);
             //所有门店一起添加
             $shopIds = ShopService::getShopIds($sjId);
             if(empty($shopIds)){
@@ -70,7 +61,6 @@ class ItemService extends BaseService
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try{
-            ItemClass::batchAdd($data);
             ProductClass::batchAdd($data);
             $transaction->commit();
         }catch (\Exception $exception){
@@ -82,57 +72,13 @@ class ItemService extends BaseService
     //修改花材信息
     public static function updateItem($data)
     {
-        $id = $data['id']??0;
-        $stockWarning = $data['stockWarning']??0;
-        $addPrice = $data['addPrice']??0;
-        $weight = $data['weight']??0;
-        $cost = $data['cost']??0; //成本价
-        if($stockWarning < 0 ){
-            util::fail("库存预警不能小于0");
-        }
-        if($addPrice < 0 ){
-            util::fail("每扎加价不能小于0");
-        }
-        if($weight < 0 ){
-            // util::fail("每扎重量不能小于0");
-        }
-        if($cost < 0 ){
-            util::fail("成本价不能小于0");
-        }
 
-        ItemClass::updateItem($id,$stockWarning,$addPrice,$weight,$cost);
     }
 
-    //删除花材,同时修改itemInfo 的状态值 delStatus = 1
+    //删除花材
     public static function deleteItem($id,$shopId,$adminId)
     {
-        $model = ItemClass::getById($id);
-        if(!$model){
-            util::fail("该花材不存在");
-        }
-
-        $connection = Yii::$app->db;
-        $transaction = $connection->beginTransaction();
-        try{
-            ItemClass::deleteItem($id);
-            $condition = [
-                'itemId'=>$model['itemId'],
-                'shopId'=>$shopId,
-            ];
-            ProductClass::updateByCondition($condition,['delStatus'=>1,'adminId'=>$adminId]);
-            $transaction->commit();
-        }catch (\Exception $exception){
-            $transaction->rollBack();
-            util::fail("操作失败");
-        }
-    }
-
-    //获取所有的花材ID
-    public static function getItemIds($sjId)
-    {
-        $data = ItemClass::getItemAll($sjId,'classId,itemId');
-        return $data;
+        util::fail("删除失败");
     }
 
-    //
 }

+ 0 - 1
biz-hd/product/classes/ProductClass.php

@@ -9,5 +9,4 @@ class ProductClass extends BaseClass
 
     public static $baseFile = '\bizHd\product\models\Product';
 
-
 }

+ 0 - 1
biz/item/classes/PtItemClass.php

@@ -205,7 +205,6 @@ class PtItemClass extends BaseClass
                 $newCover = $upData['cover'];
                 $syncData['cover'] = $newCover;
                 ProductClass::updateByCondition(['itemId' => $id], $syncData);
-                ItemClass::updateByCondition(['itemId' => $id], $syncData);
             }
         }
     }

+ 1 - 1
biz/product/models/Product.php

@@ -9,7 +9,7 @@ class Product extends Base
 
     public static function tableName()
     {
-        return 'xhGhsProduct';
+        return 'xhGhsItem';
     }
 
 }

+ 0 - 25
console/controllers/GhsInitController.php

@@ -15,38 +15,13 @@ use yii\console\Controller;
 class GhsInitController extends Controller
 {
 
-    //初始化
     public function actionInit()
     {
-
-        $itemIds = [1002,1003,1004,1005,1007];
-        foreach ($itemIds as $v){
-            $itemInfo = PtItemClass::getById($v);
-            $data = [
-                'name'=>$itemInfo['name'],
-                'alias'=>$itemInfo['alias'],
-                'py'=>$itemInfo['py'],
-                'ratio'=>$itemInfo['ratio'],
-                'weight'=>$itemInfo['weight'],
-                'stockWarning'=>$itemInfo['stockWarning'],
-                'cost'=>$itemInfo['cost'],
-                'addPrice'=>$itemInfo['addPrice'],
-                'bigUnit'=>$itemInfo['bigUnit'],
-                'smallUnit'=>$itemInfo['smallUnit'],
-            ];
-            //ProductClass::updateByCondition(['itemId'=>$v],$data);
-            ItemClass::updateByCondition(['itemId'=>$v],$data);
-
-        }
-        echo "done";
     }
 
     //清空某个商户的product
     public function actionClearItem($sjId)
     {
-        //ProductClass::deleteByCondition(['sjId'=>$sjId]);
-        //ItemClass::deleteByCondition(['sjId'=>$sjId]);
-        //ItemClassClass::deleteByCondition(['sjId'=>$sjId]);
     }
 
     public function actionPtUnit()

+ 0 - 62
console/controllers/ItemController.php

@@ -96,69 +96,7 @@ class ItemController extends Controller
     //花材初始化 ./yii item/init
     public function actionInit()
     {
-        $phpExcelFile = Yii::getAlias("@vendor/phpoffice/phpexcel/");
-        require_once($phpExcelFile . 'Classes/PHPExcel/IOFactory.php');//查询接口
-        $dir = Yii::$app->basePath;
-        $filename = $dir . '/goods.xls';
-
-        $fileType = \PHPExcel_IOFactory::identify($filename); //文件名自动判断文件类型
-
-        $excelReader = \PHPExcel_IOFactory::createReader($fileType);
-
-        $objPHPExcel = $excelReader->load($filename);//$file_url即Excel文件的路径
-
-        $sheet = $objPHPExcel->getSheet(0);//获取第一个工作表
-
-        $highestRow = $sheet->getHighestRow();//取得总行数
-
-        $highestColumn = $sheet->getHighestColumn(); //取得总列数
-
-        $changeData = [];
-        for ($j = 2; $j <= $highestRow; $j++) {
-            $str = '';
-            for ($k = 'A'; $k <= $highestColumn; $k++) {
-                $str .= $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue() . '\\';
-            }
-            //explode:函数把字符串分割为数组。
-            $string = explode("\\", $str);
-            array_pop($string);
-            array_push($changeData, $string);
-        }
-        if (!empty($changeData)) {
 
-            $classList = ItemClassClass::getAllByCondition([], null, '*', 'name');
-
-            $unitList = UnitClass::getAllByCondition([], null, '*', 'name');
-
-            foreach ($changeData as $key => $item) {
-                $name = $item[1];
-                $alias = $item[2];
-                $className = $item[3];
-                $classId = isset($classList[$className]['id']) ? $classList[$className]['id'] : 0;
-                $py = strtolower($item[4]);
-                $big = $item[5] ?? '';
-                $big = $big == '枝' ? '支' : $big;
-                $bigId = isset($unitList[$big]['id']) ? $unitList[$big]['id'] : 0;
-                $small = $item[6] ?? '';
-                $small = $small == '枝' ? '支' : $small;
-                $smallId = isset($unitList[$small]['id']) ? $unitList[$small]['id'] : 0;
-                $ratio = isset($item[7]) && !empty($item[7]) ? $item[7] : 0;
-                if (empty($name)) {
-                    continue;
-                }
-                $data = [
-                    'name' => $name,
-                    'alias' => $alias,
-                    'py' => $py,
-                    'classId' => $classId,
-                    'unitNum' => $ratio,
-                    'bigUnit' => $bigId,
-                    'smallUnit' => $smallId,
-                ];
-                print_r($data);
-                ItemClass::add($data);
-            }
-        }
     }
 
     //命令: ./yii  item/sync name,cover     同步name 和cover