wugg 2 years ago
parent
commit
64552844a8
1 changed files with 11 additions and 5 deletions
  1. 11 5
      app/command/good.php

+ 11 - 5
app/command/good.php

@@ -21,9 +21,14 @@ class good extends Command
     protected function execute(Input $input, Output $output)
     {
         // 指令输出
-        $output->writeln('good');
-        $this->goodBasic();
-        $this->goodZx();
+	    $this->date=date("Y-m-d 00:00:00",time());
+	    try{
+		    $this->goodBasic();
+		    $this->goodZx();
+	    }catch (\Exception $e){
+		    $output->writeln("【".date("Y-m-d H:i:s")."】".$e->getMessage());
+	    }
+
     }
 
     public function addGood($data){
@@ -51,6 +56,7 @@ class good extends Command
 					"updatetime"=>date("Y-m-d H:i:s")
 				];
 				Db::name("good")->insert($array);
+				echo "【".date("Y-m-d H:i:s")."】 添加商品{$v['spuCode']}进入类目表\r\n";
 			}
         }
     }
@@ -68,7 +74,7 @@ class good extends Command
             ->withAttr("good_unit",function ($m){
             	return Db::connect('mysql_wsm')->name('unit')->where("id",$m)->value("unit","");
             })->field("spuCode,good_name,cat_id,good_unit,craft_desc,after_sales,supplierNo,companyNo,good_img,good_info_img,good_thumb_img,creater,createrid,is_stock")
-            ->where("addtime",">=","2022-10-01 00:00:00")
+            ->where("addtime",">=", $this->date)
             ->select()->toArray();
     	    return $this->addGood($list);
     }
@@ -83,7 +89,7 @@ class good extends Command
             	return Db::connect('mysql_wsm')->name('unit')->where("id",$v)->value("unit","");
             })
             ->field("spuCode,good_name,craft_desc,'' after_sales,cat_id,good_unit,supplierNo,companyNo,good_img,good_info_img,good_thumb_img,creater,createrid,0 is_stock")
-            ->where("addtime",">=","2022-10-01 00:00:00")
+            ->where("addtime",">=", $this->date)
             ->select()->toArray();
     	     return $this->addGood($list);
     }