Browse Source

Merge branch 'dev_wf' of wugg/phpstock into version1.5

wufeng 2 years ago
parent
commit
a301cf4748
1 changed files with 21 additions and 10 deletions
  1. 21 10
      app/admin/controller/Consult.php

+ 21 - 10
app/admin/controller/Consult.php

@@ -2116,34 +2116,34 @@ class Consult extends Base
     {
         $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 = [['cb.is_del', "=", 0]];
         $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
         if ($zxNo !== "") {
-            $where[] = ['zxNo', 'like', '%' . $zxNo . '%'];
+            $where[] = ['cb.zxNo', 'like', '%' . $zxNo . '%'];
         }
         $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
         if ($infoNo !== "") {
-            $where[] = ['infoNo', 'like', '%' . $infoNo . '%'];
+            $where[] = ['cb.infoNo', 'like', '%' . $infoNo . '%'];
         }
         $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
         if ($bidNo !== "") {
-            $where[] = ['bidNo', 'like', '%' . $bidNo . '%'];
+            $where[] = ['cb.bidNo', 'like', '%' . $bidNo . '%'];
         }
         $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[] = ['cb.infoNo', 'in', $bidinfo];
         }
         $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
         if ($bargain_status !== "") {
             $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
-            $where[] = ['infoNo', 'in', $bidinfo];
+            $where[] = ['cb.infoNo', 'in', $bidinfo];
         }
         $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[] = ['cb.zxNo', 'in', $zxlist];
         }
         $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
         if ($is_own == 1) {
@@ -2156,13 +2156,23 @@ class Consult extends Base
                 return error_show(1002, "申请人数据不存在");
             }
             $rm = isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
-            $where[] = ['createrid', "=", $rm];
+            $where[] = ['cb.createrid', "=", $rm];
         }
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["cb.createrid", 'in', get_company_item_user_by_name($company_name)];
 
-        $count = Db::name('consult_bids')->where($where)->count();
+
+        $count = Db::name('consult_bids')->alias('cb')->where($where)->count();
         $total = ceil($count / $size);
         $page = $page >= $total ? $total : $page;
-        $list = Db::name('consult_bids')->where($where)->page($page, $size)->order('addtime', 'desc')->select()->toArray();
+        $list = Db::name('consult_bids')
+            ->alias('cb')
+            ->field('cb.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($page, $size)
+            ->order('cb.addtime', 'desc')
+            ->cursor();
         $data = [];
         foreach ($list as $value) {
             $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
@@ -2231,6 +2241,7 @@ class Consult extends Base
 //                $addr= GetAddr(json_encode($temp));
 //                $value['origin_addr'] = $addr;
 //            }
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
             $data[] = $value;
         }
         return app_show(0, "获取成功", ['count' => $count, 'list' => $data]);