dever 3 years ago
parent
commit
11529b7f2d
4 changed files with 85 additions and 42 deletions
  1. 80 40
      app/goods/lib/Sku.php
  2. 3 0
      app/mshop/src/Data.php
  3. 1 1
      app/shop/database/goods.php
  4. 1 1
      app/shop/lib/Coupon.php

+ 80 - 40
app/goods/lib/Sku.php

@@ -414,7 +414,7 @@ class Sku
 
         if (!$group_attr) {
 
-            $prefix = '[总价设置]:';
+            $prefix = '[总价]:';
 
             if (!$update && $col_num <= 1) {
                 $head = '';
@@ -454,56 +454,73 @@ class Sku
 
         } else {
             
-            $prefix = '[组合价格设置]:';
+            $prefix = '[组合价格]:';
 
             $group_attr = Dever::cartesian($group_attr);
 
+            if ($sku_value) {
+                foreach ($group_attr as $k => $v) {
+                    $key = array();
+                    foreach ($v['name'] as $k1 => $v1) {
+                        $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
+                    }
+                    $key = implode('_', $key);
+                    if (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
+                        unset($group_attr[$k]);
+                    }
+                }
+            }
+
             $show = false;
 
-            foreach ($group_attr as $k => $v) {
-                $body .= '<tr data-row="' .($k+1). '">';
+            if ($group_attr) {
+                foreach ($group_attr as $k => $v) {
+                    $body .= '<tr data-row="' .($k+1). '">';
 
-                if ($parent_goods) {
-                    $body .= '<td>'.$parent_goods['name'].'</td>';
-                }
+                    if ($parent_goods) {
+                        $body .= '<td>'.$parent_goods['name'].'</td>';
+                    }
 
-                $key = $id = array();
-                foreach ($v['name'] as $k1 => $v1) {
-                    $rows = 1;
-                    $body .= '<td width="50" rowspan="'.$rows.'">'.$v1.'</td>';
-                    $id[] = array
-                    (
-                        'id' => $v['id'][$k1],
-                        'attr_id' => $v['info_id'][$k1],
-                    );
-                    $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
-                }
-                $key = implode('_', $key);
+                    $key = $id = array();
+                    foreach ($v['name'] as $k1 => $v1) {
+                        $rows = 1;
+                        $body .= '<td width="50" rowspan="'.$rows.'">'.$v1.'</td>';
+                        $id[] = array
+                        (
+                            'id' => $v['id'][$k1],
+                            'attr_id' => $v['info_id'][$k1],
+                        );
+                        $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
+                    }
+                    $key = implode('_', $key);
 
-                foreach ($set['col'] as $k1 => $v1) {
-                    if (!$update && strstr($v1, '^')) {
-                        continue;
-                    } 
-                    $value = $this->getValue($k1, $key, $sku_value, $sku);
-                    
-                    if ($update) {
-                        if (strstr($v1, '|')) {
-                            $v1 = str_replace('|', '', $v1);
-                            $body .= '<td width="30">'.$value.'</td>';
+                    foreach ($set['col'] as $k1 => $v1) {
+                        if (!$update && strstr($v1, '^')) {
+                            continue;
+                        } 
+                        $value = $this->getValue($k1, $key, $sku_value, $sku);
+                        
+                        if ($update) {
+                            if (strstr($v1, '|')) {
+                                $v1 = str_replace('|', '', $v1);
+                                $body .= '<td width="30">'.$value.'</td>';
+                            } else {
+                                $body .= '<td width="30"><input type="text" class="layui-input" name="'.$k1.'['.$k.']"  value="'.$value.'"/></td>';
+                            }
+                            
                         } else {
-                            $body .= '<td width="30"><input type="text" class="layui-input" name="'.$k1.'['.$k.']"  value="'.$value.'"/></td>';
+                            $body .= '<td width="30">'.$value.'</td>';
                         }
-                        
-                    } else {
-                        $body .= '<td width="30">'.$value.'</td>';
                     }
-                }
 
-                if ($update) {
-                    $body .= '<input type="hidden" name="key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="attr['.$k.']">'.json_encode($id).'</textarea>';
+                    if ($update) {
+                        $body .= '<input type="hidden" name="key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="attr['.$k.']">'.json_encode($id).'</textarea>';
+                    }
+                    
+                    $body .= '</tr>';
                 }
-                
-                $body .= '</tr>';
+            } else {
+                $prefix = $head = $body = '';
             }
         }
 
@@ -517,6 +534,15 @@ class Sku
             $html = '<table class="layui-table">' . $html . '</table>';
         }
 
+        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']])) {
+                    unset($single_attr[$k]);
+                }
+            }
+        }
+
         if ($single_attr) {
             $html = $prefix . $html;
             foreach ($single_attr as $k => $v) {
@@ -563,7 +589,21 @@ class Sku
                 $single_body .= '</tr>';
             }
 
-            $html = $html . '<br />[单选价格设置]:<table class="layui-table">' . $single_head . $single_body . '</table>';;
+            $html = $html . '[单选价格]:<table class="layui-table">' . $single_head . $single_body . '</table>';
+        }
+
+        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']])) {
+                    unset($input_attr[$k]);
+                }
+            }
         }
 
         if ($input_attr) {
@@ -623,7 +663,7 @@ class Sku
                 $input_body .= '</tr>';
             }
 
-            $html = $html . '<br />[计算价设置]:<table class="layui-table">' . $input_head . $input_body . '</table>';;
+            $html = $html . '[计算价]:<table class="layui-table">' . $input_head . $input_body . '</table>';
         }
         
 

+ 3 - 0
app/mshop/src/Data.php

@@ -208,6 +208,8 @@ class Data extends Core
                 $this->data[$k]['shop'] = array();
                 $shop_num = Dever::db('shop/coupon')->total(array('coupon_id' => $v['coupon_id'], 'city' => $v['city']));
 
+                $this->data[$k] = Dever::load('shop/lib/coupon')->getShop($this->data[$k], false, true);
+                /*
                 $shop = Dever::db('shop/info')->getOne($v['shop_id']);
                 if ($this->data[$k]['info']['method'] == 1) {
                     $this->data[$k]['shop_name'] = '平台通用';
@@ -219,6 +221,7 @@ class Data extends Core
                 } elseif ($this->data[$k]['info']['method'] == 3) {
                     $this->data[$k]['shop_name'] = $shop['name'];
                 }
+                */
             }
         }
 

+ 1 - 1
app/shop/database/goods.php

@@ -161,7 +161,7 @@ return array
         # 列表里的按钮
         'list_button' => array
         (
-            //'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=shop&other_id={shop_id}&page_type=1"', '{price_type} <= 3'),
+            'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=shop&other_id={shop_id}&page_type=1"', '{price_type} <= 3'),
         ),
     ),
 

+ 1 - 1
app/shop/lib/Coupon.php

@@ -132,7 +132,7 @@ class Coupon
             $data['shop_name'] = $shop['name'];
         }
         if ($data['method'] == 1) {
-            $data['shop_name'] = '平台通用';
+            $data['shop_name'] = '全国门店通用';
         } elseif ($data['method'] == 2) {
             $where = array('coupon_id' => $data['coupon_id'], 'city' => $data['city']);
             if ($shop_list) {