wuggemail@foxmail.com há 2 meses atrás
pai
commit
8903dfbceb
1 ficheiros alterados com 7 adições e 4 exclusões
  1. 7 4
      app/cxinv/controller/Index.php

+ 7 - 4
app/cxinv/controller/Index.php

@@ -43,10 +43,13 @@ class Index extends Base
        $where=[["status","<>",0]];
        if($param['goodName']!='') $where[]=['goodName','like','%'.$param['goodName'].'%'];
        if($param['code']!='') $where[]=['code','like','%'.$param['code'].'%'];
-       $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;
-       });
+       if($param['companyNo']!=''){
+           $inTax = TaxCompany::with(['tax'])->where(['companyNo'=>$param['companyNo'],'income'=>1])->select();
+           $magerCode= array_column($inTax->toArray(),'merge_code');
+           $where[]=['cat_code','in',$magerCode];
+       }
+
+       $list = GodTemp::with(['tax_info'])->where($where)->order('id desc')->paginate(['page'=>$param['page'],'list_rows'=>$param['size']]);
        return success("获取成功",['list'=>$list->items(),'count'=>$list->total()]);
     }