Jelajahi Sumber

Merge branch 'master' into dev

shish 8 bulan lalu
induk
melakukan
95e8a6683c

+ 1 - 1
app-ghs/controllers/ProductController.php

@@ -641,7 +641,7 @@ class ProductController extends BaseController
         }
 
         $shopAdmin = $this->shopAdmin;
-        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+        if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
             util::fail('超管才能修改');
         }
 

+ 24 - 27
biz-ghs/order/classes/StockInOrderClass.php

@@ -191,6 +191,13 @@ class StockInOrderClass extends BaseClass
             util::fail("订单异常");
         }
 
+        $chainShopList = [];
+        $default = $shop->default ?? 0;
+        $sjId = $shop->sjId ?? 0;
+        if ($default == 1) {
+            $chainShopList = \bizGhs\merchant\classes\ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
+        }
+
         $totalCost = $orderData['price'] ?? 0;
         foreach ($itemInfo as $k => $v) {
             $currentItemId = $v['productId'] ?? 0;
@@ -203,15 +210,6 @@ class StockInOrderClass extends BaseClass
             $currentInfo = ProductClass::getById($currentItemId, true);
             if (isset($currentInfo->stock) && floatval($currentInfo->stock) == 0) {
                 $upData = ['cost' => $currentCost];
-                if ($currentHdPrice > 0) {
-                    $upData['price'] = $currentHdPrice;
-                }
-                if ($currentSkPrice > 0) {
-                    $upData['skPrice'] = $currentSkPrice;
-                }
-                if ($currentHjPrice > 0) {
-                    $upData['hjPrice'] = $currentHjPrice;
-                }
                 ProductClass::updateById($currentItemId, $upData);
                 //成本变动记录
                 $changeData = [
@@ -231,24 +229,23 @@ class StockInOrderClass extends BaseClass
                 ];
                 CostChangeClass::addData($changeData);
                 if ($currentHdPrice > 0) {
-                    $changeData = [
-                        'ptStyle' => 2,
-                        'sjId' => $currentInfo->sjId ?? 0,
-                        'mainId' => $mainId,
-                        'itemId' => $currentInfo->id ?? 0,
-                        'ptItemId' => $currentInfo->itemId ?? 0,
-                        'price' => $currentHdPrice,
-                        'skPrice' => $currentSkPrice,
-                        'hjPrice' => $currentHjPrice,
-                        'staffId' => $staffId,
-                        'staffName' => $staffName,
-                        'name' => $currentInfo->name ?? '',
-                        'cover' => $currentInfo->cover ?? '',
-                        'event' => $event,
-                        'targetId' => $orderId,
-                        'type' => 2,
-                    ];
-                    PriceChangeClass::addData($changeData);
+                    $ptItemId = $currentInfo->itemId ?? 0;
+                    $changeParams = ['staffId' => $staffId, 'staffName' => $staffName, 'event' => '调拨入库改价', 'targetId' => $orderId];
+                    ProductClass::changeSinglePrice($shop, $ptItemId, $currentHdPrice, $currentSkPrice, $currentHjPrice, $changeParams);
+                    //在首店修改需要同步到所有直营店
+                    if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
+                        foreach ($chainShopList as $chain) {
+                            if ($chain->id == $shop->id) {
+                                continue;
+                            }
+                            $chainMainId = $chain->mainId ?? 0;
+                            $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
+                            $staffId = $staff->id ?? 0;
+                            $staffName = $staff->name ?? '';
+                            $changeParams2 = ['staffId' => $staffId, 'staffName' => $staffName, 'event' => '调拨入库改价'];
+                            ProductClass::changeSinglePrice($chain, $ptItemId, $currentHdPrice, $currentSkPrice, $currentHjPrice, $changeParams2);
+                        }
+                    }
                 }
             }
 

+ 2 - 1
biz-ghs/product/classes/ProductClass.php

@@ -1317,7 +1317,7 @@ class ProductClass extends BaseClass
         $staffName = $params['staffName'] ?? '';
         $changeType = $params['changeType'] ?? 'normal';
         $targetId = $params['targetId'] ?? 0;
-        $event = '修改';
+        $event = $params['event'] ?? '修改';
         $type = 0;
         if ($changeType == 'cg') {
             $event = '采购后修改';
@@ -1341,6 +1341,7 @@ class ProductClass extends BaseClass
             'targetId' => $targetId,
         ];
         PriceChangeClass::addData($changeData);
+        return true;
     }
 
     //下单时计算商品的价格  lqh 2021.1.28