Explorar o código

没有找到门店

shish %!s(int64=5) %!d(string=hai) anos
pai
achega
c4997b9382

+ 28 - 23
app-ghs/controllers/StockOutController.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace ghs\controllers;
 
 use bizGhs\merchant\classes\ShopClass;
@@ -6,6 +7,7 @@ use bizGhs\order\classes\StockOutOrderClass;
 use bizGhs\product\classes\ProductClass;
 use common\components\util;
 use Yii;
+
 //出库 linqh 2021.1.23
 class StockOutController extends BaseController
 {
@@ -31,50 +33,53 @@ class StockOutController extends BaseController
         $post['merchantId'] = $this->sjId;
         $post['outShopId'] = $this->shopId;
         $post['adminId'] = $this->adminId;
-        $inShopId = $post['inShopId']??0;
+        $inShopId = $post['inShopId'] ?? 0;
         $now = date('Y-m-d H:i:s');
-        $date = $post['date']??$now;
+        $date = $post['date'] ?? $now;
         $post['outTime'] = $date;
-        $action = $post['action']??'wait'; //confirm(直接出库) wait(待出库中)
+        $action = $post['action'] ?? 'wait'; //confirm(直接出库) wait(待出库中)
         $post['action'] = $action;
         //判断 入库的门店ID是否有效
         $post['inShopId'] = $inShopId;
         //是否判断 inShopId 下还有未完成出库的订单?
-        $check = StockOutOrderClass::getByCondition(['outShopId'=>$this->shopId,'inShopId'=>$inShopId,'status'=>StockOutOrderClass::STATUS_WAIT]);
-        if($check){
+        $check = StockOutOrderClass::getByCondition(['outShopId' => $this->shopId, 'inShopId' => $inShopId, 'status' => StockOutOrderClass::STATUS_WAIT]);
+        if ($check) {
             util::fail('还有待出库的订单');
         }
-        $ghsItemInfo = $post['itemInfo']??'';
-        if(empty($ghsItemInfo)){
+        $ghsItemInfo = $post['itemInfo'] ?? '';
+        if (empty($ghsItemInfo)) {
             util::fail('请选择花材');
         }
-        $ghsItemInfo = json_decode($ghsItemInfo,true); // [{productId:0,bigNum:1,smallNum:0}]
-        if(!is_array($ghsItemInfo)){
+        $ghsItemInfo = json_decode($ghsItemInfo, true); // [{productId:0,bigNum:1,smallNum:0}]
+        if (!is_array($ghsItemInfo)) {
             util::fail('花材格式不正确');
         }
 
         //入库门店有效性判断
-        if($this->shopId==$inShopId){
+        if ($this->shopId == $inShopId) {
             util::fail('不能出库给当前门店');
         }
         $inShop = ShopClass::getById($inShopId);
-        ShopClass::valid($inShop,$this->sjId);
-        
+        if (empty($inShop)) {
+            util::fail('没有找到门店');
+        }
+        ShopClass::valid($inShop, $this->sjId);
+
 
-        ProductClass::valid($ghsItemInfo,$this->shopId);
+        ProductClass::valid($ghsItemInfo, $this->shopId);
         //判断花材里的信息
-        foreach ($ghsItemInfo as $v){
-            $bigNum = $v['bigNum']??0;
-            $smallNum = $v['smallNum']??0;
-            if($bigNum <=0 && $smallNum <=0){
+        foreach ($ghsItemInfo as $v) {
+            $bigNum = $v['bigNum'] ?? 0;
+            $smallNum = $v['smallNum'] ?? 0;
+            if ($bigNum <= 0 && $smallNum <= 0) {
                 util::fail('花材数量不能为0');
             }
         }
         $post['itemInfo'] = $ghsItemInfo;
         $order = StockOutOrderClass::addOrder($post);
-        if($order){
+        if ($order) {
             util::success($order);
-        }else{
+        } else {
             util::fail();
         }
     }
@@ -84,8 +89,8 @@ class StockOutController extends BaseController
     //出库详情 linqh 2021.1.23
     public function actionDetail()
     {
-        $orderSn = Yii::$app->request->get('orderSn','');
-        $orderData = StockOutOrderClass::getOrderDetail($orderSn,$this->shopId);
+        $orderSn = Yii::$app->request->get('orderSn', '');
+        $orderData = StockOutOrderClass::getOrderDetail($orderSn, $this->shopId);
         util::success($orderData);
     }
 
@@ -94,7 +99,7 @@ class StockOutController extends BaseController
     {
         $get = Yii::$app->request->get();
         $orderSn = $get['orderSn'];
-        StockOutOrderClass::confirmOrder($orderSn,$this->shopId,$this->adminId);
+        StockOutOrderClass::confirmOrder($orderSn, $this->shopId, $this->adminId);
         util::complete("出库成功");
     }
 
@@ -104,7 +109,7 @@ class StockOutController extends BaseController
     {
         $get = Yii::$app->request->get();
         $orderSn = $get['orderSn'];
-        StockOutOrderClass::cancelOrder($orderSn,$this->shopId,$this->adminId);
+        StockOutOrderClass::cancelOrder($orderSn, $this->shopId, $this->adminId);
         util::complete("取消成功");
     }
 }

+ 6 - 17
app-hd/controllers/ProductController.php

@@ -115,26 +115,16 @@ class ProductController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
-        $shopId = $get['shopId'] ?? 0;
-
+        $ghs = GhsClass::getGhsInfo($id);
+        if (empty($ghs)) {
+            util::fail('没有找到供应商');
+        }
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();
         try {
 
-            if (empty($id)) {
-                if (!empty($this->shopId)) {
-                    $ghs = GhsClass::build($shopId, $this->shopId);
-                    $sjId = $ghs['sjId'] ?? 0;
-                } else {
-                    $shop = ShopClass::getShopInfo($shopId);
-                    $sjId = $shop['merchantId'] ?? 0;
-                }
-            } else {
-                $ghs = GhsClass::getGhsInfo($id);
-                $sjId = $ghs['sjId'] ?? 0;
-                $shopId = $ghs['shopId'] ?? 0;
-            }
-            $transaction->commit();
+            $sjId = $ghs['sjId'] ?? 0;
+            $shopId = $ghs['shopId'] ?? 0;
 
             //获取所有当前供应商的分类 (全部、常用)
             //根据分类组装分类下的花材信息
@@ -153,7 +143,6 @@ class ProductController extends BaseController
             //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
             $data = ProductService::assembleData($classIds, $itemIdsInfo, $itemInfoData, $oftenItemIds, '');
 
-
             util::success($data);
         } catch (Exception $e) {
             $transaction->rollBack();