diff --git a/backstage/application/backstage/controllers/Order.php b/backstage/application/backstage/controllers/Order.php index ced04c3..286dceb 100644 --- a/backstage/application/backstage/controllers/Order.php +++ b/backstage/application/backstage/controllers/Order.php @@ -912,4 +912,267 @@ class Order extends CI_Controller } + // 瑞克斯VIP餐 个人化要求统计 + public function index_bj() + { + $data['asset'] = $this->asset; + $data['pageTitle'] = $this->pageTitle; + $data['breadcrumb'] = array(array('包间订单管理', null)); + $hallId = $this->session->userdata('hallId'); + $data['deliverPlaceList'] = $this->order_model->get_deliver_place($hallId); + $data['mealList'] = $this->meal_model->getbjMealTypeList(); + $this->lw_load->normalLoad($data, 'order/bj/bjorder_index'); + } + + public function orderListBj($page){ + $this->load->library('lw_pagination2'); + $hallId = $this->session->userdata('hallId'); + + //处理参数 + //处理提交参数 + $dishDateStart = $this->input->post("dishDateStart", true); + $dishDateEnd = $this->input->post("dishDateEnd", true); + $searchPlaceType = $this->input->post("searchPlaceType", true); + $searchMealType= $this->input->post("searchMealType", true); + + + //处理参数 + if (is_array($searchPlaceType)) { + if (count($searchPlaceType) == 1 && $searchPlaceType[0] == -1) { + unset($searchUserType); + } + } + + if (is_array($searchMealType)) { + if (count($searchMealType) == 1 && $searchMealType[0] == -1) { + unset($searchMealType); + } + } + + $dishDateStart = $this->db->escape_str($dishDateStart); + $dishDateEnd = $this->db->escape_str($dishDateEnd); + + $where = " 1 "; + + //处理数组 + if ($searchPlaceType) { + $tstr = "0"; + foreach ($searchPlaceType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and a.deliver_place_id in (" . $tstr . ")"; + } + + if ($searchMealType) { + $tstr = "0"; + foreach ($searchMealType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and d.id in (" . $tstr . ")"; + } + + + if ($dishDateStart) { + if ($dishDateEnd) { + $where .= " and c.dc_date between '" . $dishDateStart . "' and '" . $dishDateEnd . "' "; + } else { + $where .= " and c.dc_date >'" . $dishDateStart . "'"; + } + } + + $where .= " and g.dining_hall_id = ".$hallId; + + + $sql = " + SELECT + a.id, + c.dc_date, + d.NAME, + b.username, + g.`name`, + a.reason, + a.total_price, + h.name as stateName, + a.date_id + FROM + tb_order a + LEFT JOIN tb_user b ON a.uid = b.id + LEFT JOIN tb_date c ON c.id = a.date_id + LEFT JOIN tb_meal_type d ON c.dc_type = d.id + LEFT JOIN tb_date_dish e ON a.date_id = e.date_id + LEFT JOIN tb_order_deliver_place g ON g.id = a.deliver_place_id + left join tb_order_state h on h.id = a.state_id + where + ". $where; + $param = array(); + $group = "a.id"; + $order = "a.id desc"; + $action = "getListByPage"; + $hasWhere = true; + $dataName = 'orderList'; + $paramFilter = array(); + $rowData = $this->lw_pagination2->lists($sql, $param, $page, $hasWhere, $group, $order, $action, $dataName, $paramFilter); +// echo "
"; +// print_r($rowData); +// echo ""; +// exit(); + + $data = $rowData; + // 获取菜品名称并且拼接 + foreach ($rowData['orderList'] as $k => $v){ + $sql = "select a.* from tb_dish a, tb_date_dish b WHERE a.id = b.dish_id and b.date_id = ".$v['date_id']; + $dishList = array(); + $mealName = ""; + $dishList = $this->db->query($sql)->result_array(); + if (count($dishList)>0){ + foreach ($dishList as $dk => $dv){ + if (empty($mealName) || $mealName == "")$mealName = $dv['dish_name']; + else $mealName .= "/".$dv['dish_name']; + } + $data['orderList'][$k]['dish_name'] = $mealName; + } + else $data['orderList'][$k]['dish_name'] = "-"; + + } + + echo $this->load->view('order/bj/bjorder_list', $data, true); + } + + public function orderExcelBj(){ + $this->load->library('lw_db', array('tb_name' => 'tb_admin'), 'tb_admin'); + $this->load->library('lw_pagination2'); + $this->load->database(); + $this->load->library('lw_string'); + $this->load->helper('excel'); + $hallId = $this->session->userdata('hallId'); + + //处理参数 + //处理提交参数 + $dishDateStart = $this->input->post("dishDateStart", true); + $dishDateEnd = $this->input->post("dishDateEnd", true); + $searchPlaceType = $this->input->post("searchPlaceType", true); + $searchMealType= $this->input->post("searchMealType", true); + + + //处理参数 + if (is_array($searchPlaceType)) { + if (count($searchPlaceType) == 1 && $searchPlaceType[0] == -1) { + unset($searchUserType); + } + } + + if (is_array($searchMealType)) { + if (count($searchMealType) == 1 && $searchMealType[0] == -1) { + unset($searchMealType); + } + } + + $dishDateStart = $this->db->escape_str($dishDateStart); + $dishDateEnd = $this->db->escape_str($dishDateEnd); + + $where = " 1 "; + + //处理数组 + if ($searchPlaceType) { + $tstr = "0"; + foreach ($searchPlaceType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and a.deliver_place_id in (" . $tstr . ")"; + } + + if ($searchMealType) { + $tstr = "0"; + foreach ($searchMealType as $k => $v) { + $tstr .= "," . intval($v); + } + $where .= " and d.id in (" . $tstr . ")"; + } + + + if ($dishDateStart) { + if ($dishDateEnd) { + $where .= " and c.dc_date between '" . $dishDateStart . "' and '" . $dishDateEnd . "' "; + } else { + $where .= " and c.dc_date >'" . $dishDateStart . "'"; + } + } + + $where .= " and g.dining_hall_id = ".$hallId; + + $sql = " + SELECT + a.date_id, + c.dc_date, + d.NAME, + b.username, + g.`name`, + a.reason, + a.total_price, + h.name as stateName + FROM + tb_order a + LEFT JOIN tb_user b ON a.uid = b.id + LEFT JOIN tb_date c ON c.id = a.date_id + LEFT JOIN tb_meal_type d ON c.dc_type = d.id + LEFT JOIN tb_date_dish e ON a.date_id = e.date_id + LEFT JOIN tb_order_deliver_place g ON g.id = a.deliver_place_id + left join tb_order_state h on h.id = a.state_id + where + ". $where. " group by a.id order by a.id desc"; + + // echo $sql;exit; + $excelData = $this->order_model->getExcelInfoBySql($sql); + + // 获取菜品名称并且拼接 + foreach ($excelData as $k => $v){ + + $sql = "select a.* from tb_dish a, tb_date_dish b WHERE a.id = b.dish_id and b.date_id = ".$v['date_id']; + $dishList = array(); + $mealName = ""; + $dishList = $this->db->query($sql)->result_array(); + if (count($dishList)>0){ + foreach ($dishList as $dk => $dv){ + if (empty($mealName) || $mealName == "")$mealName = $dv['dish_name']; + else $mealName .= "/".$dv['dish_name']; + } + $excelData[$k]['dish_name'] = $mealName; + } + else $excelData[$k]['dish_name'] = "-"; + unset($excelData[$k]['date_id']); + + } + + $title = array( + '日期', + '餐次', + '下单人', + '房间', + '备注内容', + '金额', + '状态', + '菜式', + ); + + + for($i=0;$i
# | +日期 | +餐次 | +下单人 | +房间 | +菜式 | +备注内容 | +金额 | +状态 | +
---|---|---|---|---|---|---|---|---|
=$i?> | +=$order['dc_date']?> | +=$order['NAME']?> | +=$order['username']?> | +=$order['name']?> | +=$order['dish_name']?> | +=$order['reason']?> | +=$order['total_price']?> | +=$order['stateName']?> | +