0 ? round($order['discount_amount'] / $order['actual_consumption'], 2) : 0); $total['actual_consumption'] = isset($total['actual_consumption']) ? $total['actual_consumption'] + $order['actual_consumption'] : 0; $total['discount_amount'] = isset($total['discount_amount']) ? $total['discount_amount'] + $order['discount_amount'] : 0; $key = $order['proejct_name'].'@'.$order['month']; if (isset($monthData[$key])) { if ($monthData[$key]['month'] == date('m月', strtotime($order['month']))) { $monthData[$key]['actual_consumption'] += $order['actual_consumption']; $monthData[$key]['discount_amount'] += $order['discount_amount']; } } else { $monthData[$key]['actual_consumption'] = $order['actual_consumption']; $monthData[$key]['discount_amount'] = $order['discount_amount']; $monthData[$key]['month'] = date('m月', strtotime($order['month'])); } $order['month'] = date('Y年m月', strtotime($order['month'])); $monthData[$key]['row'][] = $order; } return ['list' => array_values($monthData), 'total' => $total]; } }