['contract_id','subpackage_budget_detail_id'], ]; } /** * @notes 获取分包合同-分包明细列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/28 22:08 */ public function lists(): array { return SubcontractingContractDetail::where($this->searchWhere) ->field('id,contract_id,subpackage_budget_detail_id,num,price,tax_rate,amount_excluding_tax,amount_including_tax,remark') ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $contract = SubcontractingContract::field('contract_no,project_id,supplier_id,contract_type')->where('id',$data['contract_id'])->findOrEmpty(); $project = Project::field('name,project_code')->where('id',$contract['project_id'])->findOrEmpty(); $supplier = Supplier::field('supplier_code,supplier_name')->where('id',$contract['supplier_id'])->findOrEmpty(); $subpackage_budget_detail = ProjectSubpackageBudgetDetail::field('work_type,work_content,project_features,unit')->where('id',$data['subpackage_budget_detail_id'])->findOrEmpty(); $data['project_code'] = $project['project_code']; $data['project_name'] = $project['name']; $data['supplier_code'] = $supplier['supplier_code']; $data['supplier_name'] = $supplier['supplier_name']; $data['contract_no'] = $contract['contract_no']; $data['contract_type'] = $contract->contract_type_text; $data['work_type'] = $subpackage_budget_detail['work_type']; $data['work_content'] = $subpackage_budget_detail['work_content']; $data['project_features'] = $subpackage_budget_detail['project_features']; $data['unit'] = $subpackage_budget_detail['unit']; return $data; }) ->toArray(); } /** * @notes 获取分包合同-分包明细数量 * @return int * @author likeadmin * @date 2023/12/28 22:08 */ public function count(): int { return SubcontractingContractDetail::where($this->searchWhere)->count(); } }