wugg 7 月之前
父节点
当前提交
a57d6450d4
共有 2 个文件被更改,包括 20 次插入3 次删除
  1. 2 2
      app/admin/model/GoodTax.php
  2. 18 1
      app/command/sysGood.php

+ 2 - 2
app/admin/model/GoodTax.php

@@ -28,12 +28,12 @@ class GoodTax extends Base
     protected $deleteTime='delete_time';
 
     public function outCategory(){
-        return $this->hasOne(TaxCategory::class,'out_tax_id','id')
+        return $this->hasOne(TaxCategory::class,"id",'out_tax_id')
         ->bind(["out_tax_name"=>"cat_name","out_tax_short_name"=>"short_name","out_tax_merge_code"=>"merge_code","out_tax_cat_code"=>"cat_code","out_bind_tax"=>"tax"]);
     }
 
     public function inCategory(){
-        return $this->hasOne(TaxCategory::class,'tax_id','id')
+        return $this->hasOne(TaxCategory::class,'id','tax_id')
         ->bind(["in_tax_name"=>"cat_name","in_tax_short_name"=>"short_name","in_tax_merge_code"=>"merge_code","in_tax_cat_code"=>"cat_code","in_bind_tax"=>"tax","addTax"=>"addtax","sumitem"]);
     }
 }

+ 18 - 1
app/command/sysGood.php

@@ -4,7 +4,7 @@ declare (strict_types = 1);
 namespace app\command;
 
 use app\admin\model\GoodBasic;
-use app\admin\model\GoodZixun;
+use app\admin\model\GoodCombind;use app\admin\model\GoodZixun;
 use app\user\model\TaxRelation;
 use think\console\Command;
 use think\console\Input;
@@ -31,6 +31,7 @@ class sysGood extends Command
         try {
             $this->processGoods('goodBasic');
             $this->processGoods('goodZx');
+            $this->goodCombind();
         } catch (\Exception $e) {
             $output->writeln('【' . date('Y-m-d H:i:s') . '】' . $e->getMessage());
         }
@@ -118,4 +119,20 @@ class sysGood extends Command
             }
         }
     }
+
+    protected function goodCombind()
+    {
+        $list =GoodCombind::where('createtime','>=', $this->date)
+    	 ->select();
+    	if(empty($list)==false){
+    		$add=[];
+    		foreach($list as $item){
+    			unset($item['id']);
+    			$ist=GoodCombind::where(['spuCode'=>$item['spuCode'],'childCode'=>$item['childCode']])->findOrEmpty();
+    			if($ist->isEmpty())$add[]=$item;
+    		}
+    	   (new \app\cxinv\model\GoodCombind)->saveAll($add);
+    	}
+
+    }
 }