Browse Source

咨询商品池商品上线优化

wufeng 2 years ago
parent
commit
f996dec4c3
1 changed files with 39 additions and 5 deletions
  1. 39 5
      app/admin/controller/Goodup.php

+ 39 - 5
app/admin/controller/Goodup.php

@@ -1517,7 +1517,7 @@ class Goodup extends Base
         if($data==false){
             return error_show(1004,"未找到商品数据");
         }
-        if($data['status']!=6 &&$data['status']!=7 ){
+        if ($data['status'] != 6 && $data['status'] != 7 && $data['status'] != 8) {
             return error_show(1004,"商品状态有误");
         }
         $good_name= isset($this->post['good_name'])&&$this->post['good_name']!="" ? trim($this->post['good_name']):"";
@@ -1885,7 +1885,7 @@ class Goodup extends Base
         if (!$val->check($param)) return error_show(1004, $val->getError());
 
         $good_zixun_list = Db::name("good_zixun")
-            ->where("is_del", 0)
+            ->where(["is_del" => 0, 'status' => 1])
             ->whereIn('spuCode', $param['codes'])
             ->column('*', 'spuCode');
         if (empty($good_zixun_list)) return error_show(1004, "未找到相关咨询商品数据");
@@ -1907,7 +1907,7 @@ class Goodup extends Base
         $createrid = isset($user["data"]['id']) ? $user["data"]['id'] : "";
         $creater = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
 
-        $data = $good_insert_data = $good_basic_insert_data = [];
+        $data = $good_insert_data = $good_basic_insert_data = $good_spec_insert_data = [];
         $i = 0;
 
         $all_nakes = Db::name("good_nake")
@@ -1949,6 +1949,7 @@ class Goodup extends Base
             ];
 
 
+            //good表
             if (!isset($all_good[$value])) {
                 $good_insert_data[] = [
                     'spuCode' => $good_zixun_list[$value]['spuCode'],
@@ -1994,7 +1995,7 @@ class Goodup extends Base
                     'demo_fee' => '',
                     'open_fee' => '',
                     'noble_metal' => $good_zixun_list[$value]['noble_metal'],
-                    'noble_weight' => '',
+                    'noble_weight' => $good_zixun_list[$value]['good_weight'],
                     'is_gold_price' => $good_zixun_list[$value]['is_gold_price'],
                     'cgd_gold_price' => '',
                     'market_price' => '',
@@ -2009,9 +2010,13 @@ class Goodup extends Base
                     'addtime' => date('Y-m-d H:i:s'),
                     'updatetime' => date('Y-m-d H:i:s'),
                     'is_exclusive' => '',
+                    'is_diff' => $good_zixun_list[$value]['is_diff'],
+                    'config' => $good_zixun_list[$value]['config'],
+                    'other_config' => $good_zixun_list[$value]['other_config'],
                 ];
             }
 
+            //good_basic表
             if (!isset($all_good_basic[$value])) {
                 $good_basic_insert_data[] = [
                     'spuCode' => $good_zixun_list[$value]['spuCode'],
@@ -2055,7 +2060,7 @@ class Goodup extends Base
                     'demo_fee' => '',
                     'open_fee' => '',
                     'noble_metal' => $good_zixun_list[$value]['noble_metal'],
-                    'noble_weight' => '',
+                    'noble_weight' => $good_zixun_list[$value]['good_weight'],
                     'is_gold_price' => $good_zixun_list[$value]['is_gold_price'],
                     'cgd_gold_price' => '',
                     'market_price' => '',
@@ -2066,11 +2071,38 @@ class Goodup extends Base
                     'createrid' => $createrid,
                     'creater' => $creater,
                     'field_change' => '',
+                    'is_del' => 0,
                     'addtime' => date('Y-m-d H:i:s'),
                     'updatetime' => date('Y-m-d H:i:s'),
+                    'is_diff' => $good_zixun_list[$value]['is_diff'],
+                    'config' => $good_zixun_list[$value]['config'],
+                    'other_config' => $good_zixun_list[$value]['other_config'],
                 ];
             }
 
+            //good_spec
+            if (!empty($good_zixun_list[$value]['specinfo'])) {
+
+                $spec_list = json_decode($good_zixun_list[$value]['specinfo'], true);
+
+                foreach ($spec_list as $spec) {
+                    $temp = Db::name('good_spec')
+                        ->field('id')
+                        ->where(['spuCode' => $value, 'spec_id' => $spec['specid'], 'spec_value_id' => $spec['spec_value_id'], 'is_del' => 0])
+                        ->find();
+                    if (!empty($temp)) {
+                        $good_spec_insert_data[] = [
+                            'spuCode' => $value,
+                            'spec_id' => $spec['specid'],
+                            'spec_value_id' => $spec['spec_value_id'],
+                            'is_del' => 0,
+                            'addtime' => date('Y-m-d H:i:s'),
+                            'updatetime' => date('Y-m-d H:i:s'),
+                        ];
+                    }
+                }
+            }
+
             $i++;
         }
 
@@ -2091,6 +2123,8 @@ class Goodup extends Base
 
             if (!empty($good_basic_insert_data)) Db::name('good_basic')->insertAll($good_basic_insert_data);
 
+            if (!empty($good_spec_insert_data)) Db::name('good_spec')->insertAll($good_spec_insert_data);
+
             if ($create) {
                 foreach ($good_zixun_list as $value) {