['budget_doc_id'], ]; } /** * @notes 获取财务管理--部门收入结算列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/03/27 09:46 */ public function lists(): array { $params = $this->request->get(); $where = []; if (!empty($params['contract_id'])) { $budget_doc_ids = FinancialBudgetDoc::where('contract_id', $params['contract_id'])->column('id'); $where[] = ['budget_doc_id', 'in', $budget_doc_ids]; } if (!empty($params['create_time'])) { $date = explode(',', $params['create_time']); $where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]]; } return FinancialDepartmentIncomeSettlement::where($this->searchWhere)->where($where) ->field(['id', 'budget_doc_id', 'create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($data) { $budget_doc = FinancialBudgetDoc::field('contract_id,code,name,issue_date')->where('id', $data['budget_doc_id'])->findOrEmpty(); $contract = MarketingContract::field('contract_name,signed_amount')->where('id', $budget_doc['contract_id'])->findOrEmpty(); $data['budget_doc_code'] = $budget_doc['code']; $data['budget_doc_name'] = $budget_doc['name']; $data['contract_name'] = $contract['contract_name']; $data['contract_money'] = $contract['signed_amount']; $data['issue_date'] = $budget_doc['issue_date']; $data['amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', $data['id'])->sum('amount'); $data['settlement_amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', $data['id'])->sum('settlement_amount'); unset($data['budget_doc_id']); }) ->toArray(); } /** * @notes 获取财务管理--部门收入结算数量 * @return int * @author likeadmin * @date 2024/03/27 09:46 */ public function count(): int { $params = $this->request->get(); $where = []; if (!empty($params['contract_id'])) { $budget_doc_ids = FinancialBudgetDoc::where('contract_id', $params['contract_id'])->column('id'); $where[] = ['budget_doc_id', 'in', $budget_doc_ids]; } if (!empty($params['create_time'])) { $date = explode(',', $params['create_time']); $where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]]; } return FinancialDepartmentIncomeSettlement::where($this->searchWhere)->where($where)->count(); } }