Browse Source

议价单管理,列表增加所属部门筛选条件

wufeng 2 years ago
parent
commit
9c2abff4dc
1 changed files with 23 additions and 13 deletions
  1. 23 13
      app/admin/controller/Consult.php

+ 23 - 13
app/admin/controller/Consult.php

@@ -1927,59 +1927,68 @@ class Consult extends Base
     public function bragain_list(){
         $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
         $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
-        $where=[['is_del',"=",0]];
+        $where=[['bo.is_del',"=",0]];
         $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
         if($bidsNo!=""){
-            $where[]=["bidsNo","=",$bidsNo];
+            $where[]=["bo.bidsNo","=",$bidsNo];
         }
         $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
         if ($zxNo !== "") {
-            $where[] = ['zxNo','=',$zxNo];
+            $where[] = ['bo.zxNo','=',$zxNo];
         }
         $bargainNo = isset($this->post['bargainNo']) && $this->post['bargainNo'] !== "" ? trim($this->post['bargainNo']) : "";
         if ($bargainNo !== "") {
-            $where[] = ['bargainNo','=',$bargainNo];
+            $where[] = ['bo.bargainNo','=',$bargainNo];
         }
 
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
         if ($status!== "") {
-            $where[] = ['status','=',$status];
+            $where[] = ['bo.status','=',$status];
         }
 
         $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
         if ($infoNo !== "") {
-            $where[] = ['infoNo','=',$infoNo];
+            $where[] = ['bo.infoNo','=',$infoNo];
         }
 
         $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
         if ($projectNo !== "") {
             $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
             ("zxNo");
-            $where[] = ['zxNo','in',$zxlist];
+            $where[] = ['bo.zxNo','in',$zxlist];
         }
         $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
         if ($pgNo !== "") {
             $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
-            $where[] = ['infoNo','in',$bidinfo];
+            $where[] = ['bo.infoNo','in',$bidinfo];
         }
         $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
         $end= isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
         if($start!=""){
-            $where[]=["addtime",">=",date("Y-m-d H:i:s",strtotime($start))];
+            $where[]=["bo.addtime",">=",date("Y-m-d H:i:s",strtotime($start))];
         }
         if($end!=""){
-            $where[]=["addtime","<=",date("Y-m-d H:i:s",strtotime($end))];
+            $where[]=["bo.addtime","<=",date("Y-m-d H:i:s",strtotime($end))];
         }
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["bo.createrid", 'in', get_company_item_user_by_name($company_name)];
 
         $role=$this->checkRole();
         if(!empty($role['write'])){
-            $where[]=["createrid","in",$role['write']];
+            $where[]=["bo.createrid","in",$role['write']];
         }
 
-        $count=Db::name("bargain_order")->where($where)->count();
+        $count=Db::name("bargain_order")->alias('bo')->leftJoin("depart_user u", "u.uid=bo.createrid AND u.is_del=0")->where($where)->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list =Db::name('bargain_order')->where($where)->page($page,$size)->order('addtime','desc')->select();
+        $list = Db::name('bargain_order')
+            ->alias('bo')
+            ->field('bo.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=bo.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($page, $size)
+            ->order('bo.addtime', 'desc')
+            ->cursor();
         $data=[];
         foreach ($list as $value){
            $bidinfos =   Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
@@ -2025,6 +2034,7 @@ class Consult extends Base
             $value['cost_before_price'] =round($bidinfos['origin_cost_fee'],2);
 
             $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
             $data[]=$value;
         }