dever 3 years ago
parent
commit
ecd7d89a1c
3 changed files with 25 additions and 7 deletions
  1. 13 7
      app/goods/lib/Sku.php
  2. 6 0
      app/shop/lib/Set.php
  3. 6 0
      app/store/lib/Set.php

+ 13 - 7
app/goods/lib/Sku.php

@@ -340,7 +340,7 @@ class Sku
         $sku_value = array();
         if ($other) {
             $other_col = $other . '_id';
-            $sku_value = Dever::db($other . '/goods_sku')->getData(array('goods_id' => $info['id'], $other_col => $other_id));
+            $sku_value = Dever::db($other . '/goods_sku')->getData(array('goods_id' => $info['id'], $other_col => $other_id, 'state_1' => 1));
 
             $input = '<input type="hidden" name="goods_id" value="'.$info['id'].'"/><input type="hidden" name="'.$other_col.'" value="'.$other_id.'"/>';
         }
@@ -465,7 +465,9 @@ class Sku
                         $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
                     }
                     $key = implode('_', $key);
-                    if (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
+                    if (!isset($sku[$key])) {
+                        unset($group_attr[$k]);
+                    } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
                         unset($group_attr[$k]);
                     }
                 }
@@ -526,7 +528,7 @@ class Sku
 
         $body .= $input;
                 
-        $html = $head . $body;
+        $html = $prefix . $head . $body;
 
         if ($update) {
             $html = '<table class="layui-table">' . $html . '</table>';
@@ -537,14 +539,16 @@ class Sku
         if ($single_attr && $sku_value) {
             foreach ($single_attr as $k => $v) {
                 $key = $v['info_id'] . '-' . $v['id'];
-                if (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
+                if (!isset($sku[$key])) {
+                    unset($single_attr[$k]);
+                } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
                     unset($single_attr[$k]);
                 }
             }
         }
 
         if ($single_attr) {
-            $html = $prefix . $html;
+            $html = $html;
             foreach ($single_attr as $k => $v) {
 
                 $id = array();
@@ -593,14 +597,16 @@ class Sku
         }
 
         if ($input_attr && $sku_value) {
-            print_r($input_attr);die;
+
             foreach ($input_attr as $k => $v) {
                 $key = array();
                 foreach ($v['option'] as $k1 => $v1) {
                     $key[] = $v1['price_key'];
                 }
                 $key = implode('_', $key);
-                if (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
+                if (!isset($sku[$key])) {
+                    unset($input_attr[$k]);
+                } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
                     unset($input_attr[$k]);
                 }
             }

+ 6 - 0
app/shop/lib/Set.php

@@ -49,6 +49,12 @@ class Set
         $goods = Dever::json_decode($goods);
         $shop_id = Dever::input('shop_id');
 
+        $where['option_shop_id'] = $shop_id;
+        $where['set_state'] = 2;
+        Dever::db('shop/goods')->updates($where);
+
+        Dever::db('shop/goods_sku')->updates($where);
+
         foreach ($goods as $k => $v) {
             $temp = explode('-', $k);
             $goods_id = $temp[0];

+ 6 - 0
app/store/lib/Set.php

@@ -49,6 +49,12 @@ class Set
         $goods = Dever::json_decode($goods);
         $store_id = Dever::input('store_id');
 
+        $where['option_store_id'] = $store_id;
+        $where['set_state'] = 2;
+        Dever::db('store/goods')->updates($where);
+
+        Dever::db('store/goods_sku')->updates($where);
+
         foreach ($goods as $k => $v) {
             $temp = explode('-', $k);
             $goods_id = $temp[0];