wuggemail@foxmail.com 2 months ago
parent
commit
721a55077d
2 changed files with 13 additions and 4 deletions
  1. 6 2
      app/cxinv/controller/Index.php
  2. 7 2
      app/cxinv/model/GodTemp.php

+ 6 - 2
app/cxinv/controller/Index.php

@@ -5,6 +5,7 @@ namespace app\cxinv\controller;
 
 use app\common\Ocr;
 use app\cxinv\model\GodTemp;
+use app\user\model\TaxCompany;
 use think\App;
 use think\Request;
 
@@ -38,11 +39,14 @@ class Index extends Base
     //商品库模糊查询
     public function List()
     {
-        $param = $this->request->param(['goodName'=>"","code"=>"","page"=>1,"size"=>20],"post",'trim');
+        $param = $this->request->param(['goodName'=>"","code"=>"","companyNo"=>"","page"=>1,"size"=>20],"post",'trim');
        $where=[];
        if($param['goodName']!='') $where[]=['goodName','like','%'.$param['goodName'].'%'];
        if($param['code']!='') $where[]=['code','like','%'.$param['code'].'%'];
-       $list = GodTemp::where($where)->order('id desc')->paginate(['page'=>$param['page'],'list_rows'=>$param['size']]);
+       $list = GodTemp::with(['tax_info'])->where($where)->order('id desc')->paginate(['page'=>$param['page'],'list_rows'=>$param['size']])->each(function($item) use($param){
+           $inTax = TaxCompany::where(['companyNo'=>$param['companyNo'],'tax_id'=>$item['tax_id']])->findOrEmpty();
+           $item['inTax']=$inTax->income??0;
+       });
        return success("获取成功",['list'=>$list->items(),'count'=>$list->total()]);
     }
 

+ 7 - 2
app/cxinv/model/GodTemp.php

@@ -3,6 +3,8 @@
 namespace app\cxinv\model;
 
 
+use app\user\model\TaxCategory;
+
 class GodTemp extends Base
 {
     protected $schema = [
@@ -10,12 +12,15 @@ class GodTemp extends Base
         'code' => 'varchar:255',
         'goodName' => 'varchar:255',
         'cat_info' => 'varchar:255',
+        'cat_tax'=> 'varchar:255',
         'cat_code' => 'varchar:255',
         'cat_name' => 'varchar:255',
         'status_cn' => 'varchar:255',
+        'status' => 'tinyint:4',
         'check_uname' => 'varchar:255',
         'companyName' => 'varchar:255',
     ];
-
-
+    public function TaxInfo(){
+        return $this->hasOne(TaxCategory::class,'merge_code','cat_code')->bind(['tax_id'=>'id']);
+    }
 }