0 ? round($order['discount_amount'] / $order['actual_consumption'], 4) : 0); $total['actual_consumption'] = isset($total['actual_consumption']) ? $total['actual_consumption'] + $order['actual_consumption'] : $order['actual_consumption']; $total['discount_amount'] = isset($total['discount_amount']) ? $total['discount_amount'] + $order['discount_amount'] : $order['discount_amount']; $total['link_fee'] = isset($total['link_fee']) ? $total['link_fee'] + $order['link_fee'] : $order['link_fee']; $total['top_fee'] = isset($total['top_fee']) ? $total['top_fee'] + $order['top_fee'] : $order['top_fee']; $total['flow_boost_back_point'] = isset($total['flow_boost_back_point']) ? $total['flow_boost_back_point'] + $order['flow_boost_back_point'] : $order['flow_boost_back_point']; $total['total_amount'] = isset($total['total_amount']) ? $total['total_amount'] + $order['total_amount'] : $order['total_amount']; $key = $order['sort_month'].'@'.$order['proejct_name']; if (isset($monthData[$key])) { if($monthData[$key]['sort_month_format'] == $order['sort_month']) { $monthData[$key]['actual_consumption'] += $order['actual_consumption']; $monthData[$key]['discount_amount'] += $order['discount_amount']; $monthData[$key]['link_fee'] += $order['link_fee']; $monthData[$key]['top_fee'] += $order['top_fee']; $monthData[$key]['flow_boost_back_point'] += $order['flow_boost_back_point']; $monthData[$key]['total_amount'] += $order['total_amount']; } } else { $monthData[$key]['actual_consumption'] = $order['actual_consumption']; $monthData[$key]['discount_amount'] = $order['discount_amount']; $monthData[$key]['link_fee'] = $order['link_fee']; $monthData[$key]['top_fee'] = $order['top_fee']; $monthData[$key]['flow_boost_back_point'] = $order['flow_boost_back_point']; $monthData[$key]['total_amount'] = $order['total_amount']; $monthData[$key]['sort_month'] = date('Y年m月', strtotime($order['sort_month'])); $monthData[$key]['sort_month_format'] = $order['sort_month']; } // 将当月数据写入 $order['sort_month'] = date('Y年m月', strtotime($order['sort_month'])); $order['month'] = date('Y年m月', strtotime($order['month'])); $order['order_original_month'] = !empty($order['order_original_month']) ? date('Y年m月', strtotime($order['order_original_month'])) : ''; $monthData[$key]['row'][] = $order; } ksort($monthData); return ['list' => array_values($monthData), 'total' => $total]; } }