Explorar el Código

其它门店成本价要一起更新

shish hace 4 años
padre
commit
869efff9a3
Se han modificado 1 ficheros con 13 adiciones y 0 borrados
  1. 13 0
      biz-ghs/order/classes/PurchaseOrderClass.php

+ 13 - 0
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -196,6 +196,19 @@ class PurchaseOrderClass extends BaseClass
                 $product->cost = $unitCost;
                 $product->priceLabel = ProductClass::PRICE_LABEL_AUTO;
                 $product->save();
+
+                //其它门店的成本价也要一起改掉
+                $allShop = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
+                if (!empty($allShop)) {
+                    $currentItemId = $product->itemId ?? 0;
+                    foreach ($allShop as $currentShop) {
+                        $currentId = $currentShop->id ?? 0;
+                        if ($currentId == $shopId) {
+                            continue;
+                        }
+                        ProductClass::updateByCondition(['shopId' => $currentId, 'itemId' => $currentItemId], ['cost' => $unitCost]);
+                    }
+                }
             }
 
             //写入详情表