shish 2 年 前
コミット
895cf5ce97
1 ファイル変更6 行追加4 行削除
  1. 6 4
      biz-ghs/product/classes/ProductClass.php

+ 6 - 4
biz-ghs/product/classes/ProductClass.php

@@ -1922,8 +1922,7 @@ class ProductClass extends BaseClass
     public static function toggleProductList($productList, $hdShopId, $hdSjId, $hdMainId, $ghs)
     {
         $itemIds = array_column($productList, "itemId");
-        $hdProductData = self::getProductInfoByItemIds($itemIds, $hdMainId);
-        $hdProductData = array_column($hdProductData, null, "itemId");
+        $hdProductData = self::getAllByCondition(['mainId' => $hdMainId, 'itemId' => ['in', $itemIds]], null, '*', 'itemId', true);
         $defaultClassId = ItemClassClass::getDefaultClassId($hdMainId);
         if (empty($defaultClassId)) {
             util::fail('没有找到花材的默认分类');
@@ -1931,7 +1930,7 @@ class ProductClass extends BaseClass
         foreach ($productList as $k => $v) {
             $itemId = $v['itemId'] ?? 0;
             $ghsProductId = $v['productId'] ?? 0;
-            if (!isset($hdProductData[$itemId])) {
+            if (isset($hdProductData[$itemId]) == false) {
                 //不存在,则从平台新增
                 $ptItem = PtItemClass::getById($itemId);
                 unset($ptItem['addTime']);
@@ -1971,7 +1970,10 @@ class ProductClass extends BaseClass
                 NotifyClass::cgGetNewProduct($addProduct, $hdMainId, $hdShopId, $ghs);
 
             } else {
-                $hdProductId = $hdProductData[$itemId]['id'];
+                $current = $hdProductData[$itemId];
+                $hdProductId = $current->id ?? 0;
+                $current->delStatus = 0;
+                $current->save();
             }
             $productList[$k]['productId'] = $hdProductId;
             $productList[$k]['ghsProductId'] = $ghsProductId;