model('ar'); $count = $arMdl->count($filter); $arLists = $arMdl->getList('*', $filter, $offset, $limit,'ar_id asc'); if (!$arLists){ return [ 'lists' => [], 'count' => $count, ]; } $monthlyIds = $arLists ? array_column($arLists, 'monthly_id') : [0]; $reportList = app::get("finance")->model("monthly_report")->getList('monthly_id,monthly_date', ['monthly_id' => $monthlyIds]); $reportList = $reportList ? array_column($reportList, 'monthly_date', 'monthly_id') : []; $arInfos = []; foreach ($arLists as $k => $ar) { $arInfos[$ar['ar_id']] = $ar; $arInfos[$ar['ar_id']]['monthly_name'] = $reportList[$ar['monthly_id']] ?: '';//账期名称 $arInfos[$ar['ar_id']]['ar_items'] = array(); } $ar_items = app::get('finance')->model('ar_items')->getList('*', [ 'ar_id' => array_column($arLists, 'ar_id'), ]); //items foreach ($ar_items as $k => $item) { $arInfos[$item['ar_id']]['ar_items'][] = $item; } return [ 'lists' => array_values($arInfos), 'count' => $count, ]; } }