['code', 'bid_document_no', 'invite_tenders_company_name', 'bid_company_name'], '=' => ['project_id'] ]; } /** * @notes 获取购买标书列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/11/27 18:22 */ public function lists(): array { $params = $this->request->get(['project_name','custom_name','custom_id']); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$project_ids]; } if(isset($params['custom_name']) && $params['custom_name'] != ''){ $custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id'); $project_ids = Project::where('custom_id','in',$custom_ids)->column('id'); $where[] = ['project_id','in',$project_ids]; } if(isset($params['custom_id']) && $params['custom_id'] != ''){ $project_ids = Project::where('custom_id',$params['custom_id'])->column('id'); $where[] = ['project_id','in',$project_ids]; } return BidBuyBiddingDocument::field('id,org_id,dept_id,project_id,bid_decision_id,code,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,buy_date,bid_address') ->where($this->searchWhere)->where($where) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('custom_id,name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $bid_decision = BidBiddingDecision::field('code,bidding_project_fund_source,bidding_time,bid_type,is_margin,margin_amount')->where('id',$item['bid_decision_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$item['buyer'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; $item['custom_name'] = $custom['name']; $item['bid_decision_code'] = $bid_decision['code']; $item['buyer'] = $admin['name']; $item['bidding_time'] = $bid_decision['bidding_time']; $item['bidding_project_fund_source'] = $bid_decision->bidding_project_fund_source_text; $item['bid_type'] = $bid_decision->bid_type_text; $item['is_margin'] = $bid_decision->is_margin_text; $item['margin_amount'] = $bid_decision['margin_amount']; return $item; }) ->toArray(); } /** * @notes 获取购买标书数量 * @return int * @author likeadmin * @date 2023/11/27 18:22 */ public function count(): int { $params = $this->request->get(['project_name','custom_name','custom_id']); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$project_ids]; } if(isset($params['custom_name']) && $params['custom_name'] != ''){ $custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id'); $project_ids = Project::where('custom_id','in',$custom_ids)->column('id'); $where[] = ['project_id','in',$project_ids]; } if(isset($params['custom_id']) && $params['custom_id'] != ''){ $project_ids = Project::where('custom_id',$params['custom_id'])->column('id'); $where[] = ['project_id','in',$project_ids]; } return BidBuyBiddingDocument::where($this->searchWhere)->where($where)->count(); } }