فهرست منبع

花材修改时,如果是首店,则更新其他门店花材

林琦海 5 سال پیش
والد
کامیت
25572d766d
2فایلهای تغییر یافته به همراه30 افزوده شده و 2 حذف شده
  1. 13 2
      app-ghs/controllers/ProductController.php
  2. 17 0
      biz-ghs/product/classes/ProductClass.php

+ 13 - 2
app-ghs/controllers/ProductController.php

@@ -115,12 +115,23 @@ class ProductController extends BaseController
         $type = Yii::$app->request->get('type', '');
         $showPage = Yii::$app->request->get('showPage', 0);
         if ($showPage) {
-            $respond = ProductClass::getList("*", $where, "inTurn desc");
+            if($type=='waring'){
+                $respond = ProductClass::getList("*", $where, "stock asc");
+            }else{
+                $respond = ProductClass::getList("*", $where, "inTurn desc");
+            }
+
             $respond['list'] = ProductClass::groupProductInfo($respond['list']);
             $respond['list'] = ProductClass::groupClassName($this->sjId, $respond['list']);
             util::success($respond);
         }
-        $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
+        if($type=='waring'){
+            //库存预警 按库存从小到大排序
+            $data = ProductClass::getAllByCondition($where, ['stock' => SORT_ASC, 'inTurn' => SORT_DESC], "*");
+        }else{
+            $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
+        }
+
 
         $data = ProductClass::groupProductInfo($data);
         $data = ProductClass::groupClassName($this->sjId, $data);

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

@@ -683,6 +683,23 @@ class ProductClass extends BaseClass
             util::fail("参数错误");
         }
         self::updateById($id, $upData);
+
+        //如果是首店,则更新全部分店
+        $shopId = $model['shopId'];
+        $shopInfo = ShopClass::getById($shopId);
+        $itemId = $model['itemId'];
+        if($shopInfo['default']==1){
+            //首店
+            $sjId = $shopInfo['sjId'];
+            $shopAll = ShopClass::getAllShop($sjId);
+            if($shopAll){
+                foreach ($shopAll as $s){
+                    if($s['id'] != $shopId){
+                        ProductClass::updateByCondition(['itemId' => $itemId, 'shopId' => $s['id']], $upData);
+                    }
+                }
+            }
+        }
     }
 
     //自动改价 2021.4.14