['cn.contract_id', 'cn.negotiation_name', 'cn.negotiation_no'], ]; } /** * @notes 获取合同洽商列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/04 21:26 */ public function lists(): array { return Db::name('ContractNegotiation')->alias('cn') ->where($this->searchWhere) ->whereNull('cn.delete_time') ->leftJoin('orgs o','o.id = cn.org_id') ->leftJoin('dept d','d.id = cn.dept_id') ->leftJoin('contract c','c.id = cn.contract_id') ->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id') ->leftJoin('project p','p.id = bbbd.project_id') ->leftJoin('custom ct','ct.id = p.custom_id') ->field('cn.*, bbbd.project_id, c.contract_code, c.contract_type, c.contract_pricing_method, c.contract_name, c.business_director, p.name as project_name, p.project_code, p.custom_id, ct.name as custom_name') ->limit($this->limitOffset, $this->limitLength) ->order(['cn.id' => 'desc']) ->select()->each(function($item, $key){ //关联数据后续添加 $item['supplier_name'] = '供应商名称'; $item['approve_no'] = '付款单号'; $item['approve_step'] = '流程步骤'; $item['approve_settle_status'] = 1; if (!empty($item['pay_plan'])) { $planArray = json_decode($item['pay_plan'], true); if (is_array($planArray)) { $item['pay_plan'] = $planArray; } } return $item; }) ->toArray(); } /** * @notes 获取合同洽商数量 * @return int * @author likeadmin * @date 2023/12/04 21:26 */ public function count(): int { return Db::name('ContractNegotiation')->alias('cn') ->where($this->searchWhere) ->whereNull('cn.delete_time') ->leftJoin('orgs o','o.id = cn.org_id') ->leftJoin('dept d','d.id = cn.dept_id') ->leftJoin('contract c','c.id = cn.contract_id') ->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id') ->leftJoin('project p','p.id = bbbd.project_id') ->leftJoin('custom ct','ct.id = p.custom_id')->count(); } }