|
@@ -0,0 +1,90 @@
|
|
|
+<?php
|
|
|
+declare (strict_types = 1);
|
|
|
+
|
|
|
+namespace app\command;
|
|
|
+
|
|
|
+use think\console\Command;
|
|
|
+use think\console\Input;
|
|
|
+use think\console\input\Argument;
|
|
|
+use think\console\input\Option;
|
|
|
+use think\console\Output;use think\facade\Db;
|
|
|
+
|
|
|
+class good extends Command
|
|
|
+{
|
|
|
+ protected function configure()
|
|
|
+ {
|
|
|
+ // 指令配置
|
|
|
+ $this->setName('good')
|
|
|
+ ->setDescription('the good command');
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function execute(Input $input, Output $output)
|
|
|
+ {
|
|
|
+ // 指令输出
|
|
|
+ $output->writeln('good');
|
|
|
+ $this->goodBasic();
|
|
|
+ $this->goodZx();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addGood($data){
|
|
|
+ if(empty($data)) return;
|
|
|
+ foreach ($data as $v){
|
|
|
+ $is=Db::name("good")->where("spuCode",$v['spuCode'])->findOrEmpty();
|
|
|
+ if(empty($is)){
|
|
|
+ $array=[
|
|
|
+ "spuCode"=>$v['spuCode'],
|
|
|
+ "good_name"=>$v['good_name'],
|
|
|
+ "companyNo"=>$v['companyNo'],
|
|
|
+ "supplierNo"=>$v['supplierNo'],
|
|
|
+ "is_stock"=>$v['is_stock'],
|
|
|
+ "craft_desc"=>$v['craft_desc'],
|
|
|
+ "after_sales"=>$v['after_sales'],
|
|
|
+ "good_img"=>$v['good_img'],
|
|
|
+ "good_thumb_img"=>$v['good_thumb_img'],
|
|
|
+ "good_info_img"=>$v['good_info_img'],
|
|
|
+ "creater"=>$v['creater'],
|
|
|
+ "createrid"=>$v['createrid'],
|
|
|
+ "cat_name"=>$v['cat_id'],
|
|
|
+ "unit_name"=>$v['good_unit'],
|
|
|
+ "status"=>0,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ Db::name("good")->insert($array);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function goodBasic(){
|
|
|
+ $list =Db::connect('mysql_wsm')
|
|
|
+ ->name('good_basic')
|
|
|
+ ->withAttr("cat_id",function ($v){
|
|
|
+ return Db::connect('mysql_wsm')->name('cat')->where("id",$v)->value("cat_name","");
|
|
|
+ })
|
|
|
+ ->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")
|
|
|
+ ->select()->toArray();
|
|
|
+ return $this->addGood($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function goodZx(){
|
|
|
+ $list =Db::connect('mysql_wsm')
|
|
|
+ ->name('good_zixun')
|
|
|
+ ->withAttr("cat_id",function ($v){
|
|
|
+ return Db::connect('mysql_wsm')->name('cat')->where("id",$v)->value("cat_name","");
|
|
|
+ })
|
|
|
+ ->withAttr("good_nuit",function ($v){
|
|
|
+ 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")
|
|
|
+ ->select()->toArray();
|
|
|
+ return $this->addGood($list);
|
|
|
+ }
|
|
|
+}
|