['project_id', 'contract_id','invoice_type'], '%like%' => ['invoicing_code'], ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/13 15:01 */ public function lists(): array { $params = $this->request->get(['custom_id']); $where = []; 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 FinanceInvoiceApply::where($this->searchWhere)->where($where) ->field('id,contract_id,project_id,invoicing_code,invoicing_date,period,tax_rate,invoice_type,invoicing_amount,tax_amount,amount_including_tax') ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $contract = Contract::field('contract_code,contract_name,amount')->where('id',$data['contract_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['custom_name'] = $custom['name']; $data['contract_code'] = $contract['contract_code']; $data['contract_name'] = $contract['contract_name']; $data['period'] = $data->period_text; $data['tax_rate'] = $data->tax_rate_text; $data['invoice_type'] = $data->invoice_type_text; return $data; }) ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2023/12/13 15:01 */ public function count(): int { $params = $this->request->get(['custom_id']); $where = []; 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 FinanceInvoiceApply::where($this->searchWhere)->where($where)->count(); } }