diff --git a/backstage/application/api/controllers/api/Dishes.php b/backstage/application/api/controllers/api/Dishes.php index 8b5ac38..4fa859f 100644 --- a/backstage/application/api/controllers/api/Dishes.php +++ b/backstage/application/api/controllers/api/Dishes.php @@ -13,257 +13,257 @@ require APPPATH . '/libraries/REST_Controller.php'; class Dishes extends REST_Controller { - private $user; + private $user; - function __construct() - { - // Construct the parent class - parent::__construct(); + function __construct() + { + // Construct the parent class + parent::__construct(); - $this->load->model('Common_model', '', TRUE); - $this->load->model('Dishes_model', '', TRUE); - $this->load->model('Cart_model', '', TRUE); - $this->load->model('Order_model', '', TRUE); + $this->load->model('Common_model', '', TRUE); + $this->load->model('Dishes_model', '', TRUE); + $this->load->model('Cart_model', '', TRUE); + $this->load->model('Order_model', '', TRUE); - $this->user = $this->common->check_token(); + $this->user = $this->common->check_token(); // $this->common->check_cart($this->user); - } - public function get_extra_menus($cid) { - $cid = intval($cid); - return $this->Common_model->sql_get_all("select * from tb_company_extra_menus where cid={$cid} and enabled=1 order by idx desc, id asc"); - } - public function index_get() - { - $this->common->check_cart($this->user); + } + public function get_extra_menus($cid) { + $cid = intval($cid); + return $this->Common_model->sql_get_all("select * from tb_company_extra_menus where cid={$cid} and enabled=1 order by idx desc, id asc"); + } + public function index_get() + { + $this->common->check_cart($this->user); - $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; + $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; - $data = array(); + $data = array(); - $user = $this->user; + $user = $this->user; - $data['user'] = $user; + $data['user'] = $user; - $data['title'] = '选择菜式'; + $data['title'] = '选择菜式'; - //获取饭堂列表 - $dining_halls = $this->Common_model->get_dining_halls($this->user->company_id); - $data['dining_halls'] = $dining_halls; + //获取饭堂列表 + $dining_halls = $this->Common_model->get_dining_halls($this->user->company_id); + $data['dining_halls'] = $dining_halls; - $dining_hall_id = $this->input->get('dining_hall_id'); - $dining_hall_id = intval($dining_hall_id) ? intval($dining_hall_id) : ($this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]); + $dining_hall_id = $this->input->get('dining_hall_id'); + $dining_hall_id = intval($dining_hall_id) ? intval($dining_hall_id) : ($this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]); - //获取菜品类别 - $dishes_types = $this->Dishes_model->get_dishes_type($this->user->type_id, 1, $this->user->area_id, $dining_hall_id); + //获取菜品类别 + $dishes_types = $this->Dishes_model->get_dishes_type($this->user->type_id, 1, $this->user->area_id, $dining_hall_id); - $dishes_type = $this->input->get('dish_type'); - $dishes_type = $dishes_type ? $dishes_type : $dishes_types[0]->cpid; + $dishes_type = $this->input->get('dish_type'); + $dishes_type = $dishes_type ? $dishes_type : $dishes_types[0]->cpid; - $type = $this->get_type($dishes_type); + $type = $this->get_type($dishes_type); - //获取当前时间 - $today = time(); + //获取当前时间 + $today = time(); - //就餐信息 - //if (in_array($this->user->type_id, array(USERTYPE_STAFF, USERTYPE_PROPERTY, USERTYPE_NO_STAFF, USERTYPE_FIVE_TYPE))) { + //就餐信息 + //if (in_array($this->user->type_id, array(USERTYPE_STAFF, USERTYPE_PROPERTY, USERTYPE_NO_STAFF, USERTYPE_FIVE_TYPE))) { - $user_default_dining_hall_id = $this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]; + $user_default_dining_hall_id = $this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]; - $data['take_info'] = $this->common->get_take_info($user_default_dining_hall_id, $this->user); - //} + $data['take_info'] = $this->common->get_take_info($user_default_dining_hall_id, $this->user); + //} - //待选饭堂,日期数据,发送客户端,格式已整理 - $jcdata = array(); - //待选日期数据,格式未整理 - $meal_dates = array(); + //待选饭堂,日期数据,发送客户端,格式已整理 + $jcdata = array(); + //待选日期数据,格式未整理 + $meal_dates = array(); - //按饭堂获取可就餐日期 - foreach ($dining_halls as $dh) { + //按饭堂获取可就餐日期 + foreach ($dining_halls as $dh) { // $rule = $this->Common_model->get_rule($type, $dh->id, DISHES_TYPE_LANUCH, RULE_PRICE_TYPE_STOP_TIME); // $end_time = $this->get_max_stop_time($rule); - //判断能否订当天餐,获取可订餐时间,按日期获取,下面根据时间段做剔除 + //判断能否订当天餐,获取可订餐时间,按日期获取,下面根据时间段做剔除 - $t_meal_dates = $this->get_meal_dates($type, $dh->id, $max_book_date); + $t_meal_dates = $this->get_meal_dates($type, $dh->id, $max_book_date); // print_r($t_meal_dates); - if (count($t_meal_dates) > 0) { - $meal_dates[$dh->id] = $t_meal_dates; + if (count($t_meal_dates) > 0) { + $meal_dates[$dh->id] = $t_meal_dates; - //按客户端需要格式,整理数据 - $book_date = $this->get_book_date($t_meal_dates); + //按客户端需要格式,整理数据 + $book_date = $this->get_book_date($t_meal_dates); - $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => $book_date); - } else { + $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => $book_date); + } else { // $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => array("id" => 0, "jcvalue" => "", "jcname" => "暂无订餐安排")); - $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => array()); - } - } + $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => array()); + } + } - $data['jcdata'] = $jcdata; - $jctime = array(); - $dateInfo = array(); - foreach($jcdata as $item) { - foreach($item['jctime'] as $item2) { - $dateInfo[$item2['dc_date']][] = $item2; - } - } - $xq = array(0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六',); - foreach($dateInfo as $date => $item) { - $info = array(); - $t = strtotime($date); - $info['date'] = date('n月j日', $t); - $info['weekday'] = "周".$xq[date('w', $t)]; - $d = array(); - foreach($item as $item2) { - $d[] = array( - 'id' => $item2['id'], - 'name' => $this->Common_model->get_meal_type_by_id($item2['dc_type'])->name, - ); - } - $info['data'] = $d; - $jctime[] = $info; - } + $data['jcdata'] = $jcdata; + $jctime = array(); + $dateInfo = array(); + foreach($jcdata as $item) { + foreach($item['jctime'] as $item2) { + $dateInfo[$item2['dc_date']][] = $item2; + } + } + $xq = array(0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六',); + foreach($dateInfo as $date => $item) { + $info = array(); + $t = strtotime($date); + $info['date'] = date('n月j日', $t); + $info['weekday'] = "周".$xq[date('w', $t)]; + $d = array(); + foreach($item as $item2) { + $d[] = array( + 'id' => $item2['id'], + 'name' => $this->Common_model->get_meal_type_by_id($item2['dc_type'])->name, + ); + } + $info['data'] = $d; + $jctime[] = $info; + } - $data['jctime2'] = $jctime; + $data['jctime2'] = $jctime; - $date_id = $this->input->get('date_id'); - $vaild_dates = array(); - $meal_date = array(); - $rise_info = array(); - if (count($meal_dates) == 0 || count(@$meal_dates[$dining_hall_id]) == 0) { - $date_id = 0; + $date_id = $this->input->get('date_id'); + $vaild_dates = array(); + $meal_date = array(); + $rise_info = array(); + if (count($meal_dates) == 0 || count(@$meal_dates[$dining_hall_id]) == 0) { + $date_id = 0; // $dining_hall_name = $this->Common_model->get_dining_hall_by_id($dining_hall_id)->name; // $data['page'] = $dining_hall_name . '-' . '该日期无订餐安排'; - $data['page'] = '该日期无订餐安排'; + $data['page'] = '该日期无订餐安排'; - $status = 0; - } else { - //整理获取当前饭堂可选日期 - $jcd = $this->get_jcdata_by_dining_hall_id($jcdata, $dining_hall_id); + $status = 0; + } else { + //整理获取当前饭堂可选日期 + $jcd = $this->get_jcdata_by_dining_hall_id($jcdata, $dining_hall_id); - $book_date = $jcd['jctime']; + $book_date = $jcd['jctime']; // print_r($book_date); - //整理当前饭堂可选日期,方便判断 - $vaild_dates = $this->get_vaild_dates($book_date); - $date_id = $date_id ? $date_id : $book_date[0]['id']; - if (count($vaild_dates) > 0) { - if (!in_array($date_id, $vaild_dates)) { - $this->response(array( - 'status' => 0, - 'message' => '该日期无订餐安排或已超过订餐时间', - ), REST_Controller::HTTP_OK); - } - } + //整理当前饭堂可选日期,方便判断 + $vaild_dates = $this->get_vaild_dates($book_date); + $date_id = $date_id ? $date_id : $book_date[0]['id']; + if (count($vaild_dates) > 0) { + if (!in_array($date_id, $vaild_dates)) { + $this->response(array( + 'status' => 0, + 'message' => '该日期无订餐安排或已超过订餐时间', + ), REST_Controller::HTTP_OK); + } + } - $data['page'] = $this->get_book_title($book_date, $date_id); + $data['page'] = $this->get_book_title($book_date, $date_id); - $status = 1; + $status = 1; - //print_r($meal_dates); + //print_r($meal_dates); - //整理当前饭堂,当前日期 - $meal_date = $this->get_meal_date($meal_dates[$dining_hall_id], $date_id); + //整理当前饭堂,当前日期 + $meal_date = $this->get_meal_date($meal_dates[$dining_hall_id], $date_id); - } + } - $is_birth = $this->common->is_birth_date($user, $date_id); - if($is_birth) { //生日餐 - $dishList = $this->Common_model->sql_get_all("select * from tb_dish where dish_type = ".BIRTH_DISH_TYPE." and enabled = 1 and dining_hall_id = {$dining_hall_id}"); - foreach($dishList as $item) { - $dish_id = $item['id']; - $row = $this->Common_model->sql_get_one("select * from tb_date_dish where date_id = {$date_id} and dish_id = {$dish_id}"); - if(!$row) { - $this->Common_model->sql_query("insert into tb_date_dish set date_id = {$date_id}, dish_id = {$dish_id}, max_num = 1, is_normal_dish = 1, total_max_num = 0, book_num = 0"); - } - } - } else { - //if($dishes_type == BIRTH_DISH_TYPE) exit; - $dishes_types2 = array(); - foreach($dishes_types as $item) { - if($item->cpid == BIRTH_DISH_TYPE) continue; - $dishes_types2[] = $item; - } - $dishes_types = $dishes_types2; - } + $is_birth = $this->common->is_birth_date($user, $date_id); + if($is_birth) { //生日餐 + $dishList = $this->Common_model->sql_get_all("select * from tb_dish where dish_type = ".BIRTH_DISH_TYPE." and enabled = 1 and dining_hall_id = {$dining_hall_id}"); + foreach($dishList as $item) { + $dish_id = $item['id']; + $row = $this->Common_model->sql_get_one("select * from tb_date_dish where date_id = {$date_id} and dish_id = {$dish_id}"); + if(!$row) { + $this->Common_model->sql_query("insert into tb_date_dish set date_id = {$date_id}, dish_id = {$dish_id}, max_num = 1, is_normal_dish = 1, total_max_num = 0, book_num = 0"); + } + } + } else { + //if($dishes_type == BIRTH_DISH_TYPE) exit; + $dishes_types2 = array(); + foreach($dishes_types as $item) { + if($item->cpid == BIRTH_DISH_TYPE) continue; + $dishes_types2[] = $item; + } + $dishes_types = $dishes_types2; + } - //print_r($dishes_types);exit; - //按客户端需要整理菜品类别格式 - $cp_dishes_types = $this->get_dishes_types($dishes_types, $dishes_type, $dining_hall_id, $date_id); - $data['cp'] = $cp_dishes_types; + //print_r($dishes_types);exit; + //按客户端需要整理菜品类别格式 + $cp_dishes_types = $this->get_dishes_types($dishes_types, $dishes_type, $dining_hall_id, $date_id); + $data['cp'] = $cp_dishes_types; - $isdefault = false; - foreach($cp_dishes_types as $item) { - if($item->cpid == $dishes_type) { - $isdefault =true; - break; - } - } - if(!$isdefault && $cp_dishes_types) { //无每日菜式 - $dishes_type = $cp_dishes_types[0]->cpid; - $cp_dishes_types[0]->cpactive = 'active'; - $data['cp'] = $cp_dishes_types; - } + $isdefault = false; + foreach($cp_dishes_types as $item) { + if($item->cpid == $dishes_type) { + $isdefault =true; + break; + } + } + if(!$isdefault && $cp_dishes_types) { //无每日菜式 + $dishes_type = $cp_dishes_types[0]->cpid; + $cp_dishes_types[0]->cpactive = 'active'; + $data['cp'] = $cp_dishes_types; + } - //获取当前饭堂,当前日期菜单 + //获取当前饭堂,当前日期菜单 // $dishes = $this->Dishes_model->get_dishes_by_type_id($date_id, $dishes_type, $dining_hall_id); - $real_dishes_type = $this->Dishes_model->get_dishes_real_type($dishes_type); + $real_dishes_type = $this->Dishes_model->get_dishes_real_type($dishes_type); - $real_type = $real_dishes_type->real_type; - if(!$real_type) $real_type = "(".$dishes_type.")"; - $dishes = $this->Dishes_model->get_dishes_by_type_id($date_id, $real_type, $dining_hall_id, $this->user->type_id); + $real_type = $real_dishes_type->real_type; + if(!$real_type) $real_type = "(".$dishes_type.")"; + $dishes = $this->Dishes_model->get_dishes_by_type_id($date_id, $real_type, $dining_hall_id, $this->user->type_id); - //按客户端需要整理当前菜单格式 - $dishes = $this->sort_dishes($dishes, @$meal_date->is_free ? $meal_date->is_free : 0, $dining_hall_id, $date_id, $dishes_type); - $data['cs'] = $dishes; + //按客户端需要整理当前菜单格式 + $dishes = $this->sort_dishes($dishes, @$meal_date->is_free ? $meal_date->is_free : 0, $dining_hall_id, $date_id, $dishes_type); + $data['cs'] = $dishes; - //获取购物车总价 - $total = $this->common->get_cart_total_price($this->user, $type); - $cart_total_price = $total['total_price']; - $cart_total_num = $total['total_num']; + //获取购物车总价 + $total = $this->common->get_cart_total_price($this->user, $type); + $cart_total_price = $total['total_price']; + $cart_total_num = $total['total_num']; - $data['order'] = array('num' => $cart_total_num, 'price' => $cart_total_price, 'status' => $status); - $data['dining_hall_id'] = $dining_hall_id; - $data['date_id'] = $date_id; - //涨价信息 - $data['rise_info'] = $this->common->get_rise_info($type, @$meal_date, ACTION_BOOK); + $data['order'] = array('num' => $cart_total_num, 'price' => $cart_total_price, 'status' => $status); + $data['dining_hall_id'] = $dining_hall_id; + $data['date_id'] = $date_id; + //涨价信息 + $data['rise_info'] = $this->common->get_rise_info($type, @$meal_date, ACTION_BOOK); - $data['noticelist'] = $this->Common_model->get_notice_list($this->user->id); - $data['notice_noread'] = $this->Common_model->get_notice_noread($this->user->id); + $data['noticelist'] = $this->Common_model->get_notice_list($this->user->id); + $data['notice_noread'] = $this->Common_model->get_notice_noread($this->user->id); - $data['extra_menus'] = $this->get_extra_menus($this->user->company_id); + $data['extra_menus'] = $this->get_extra_menus($this->user->company_id); - //生日餐祝福 - $birthInfo = $this->common->get_birth_date($user); - if($birthInfo) { - $birthMsg = ''; - $today = date("Y-m-d"); - $birth = $birthInfo[0]; - $dateInfo = $birthInfo[1]; - if($dateInfo) { - $dc_date = $dateInfo['dc_date']; - $b_date_id = $dateInfo['id']; - $row = $this->Common_model->sql_get_one("select * from tb_order where uid = ".$user->id." and state_id in (3, 6) and date_id = {$b_date_id}"); - if(!$row) { //未订餐 - if($dc_date == $today) $day = '今天'; - else if($dc_date == date("Y-m-d", time()+86400)) $day = '明天'; - else $day = $dc_date; - $birthMsg = '生日快乐!您可订'.$day.'的生日菜式!'; - } - } else { - //if($today == $birth) { - //$birthMsg = '生日快乐!'; - //} - } - $data['birthMsg'] = $birthMsg; - } + //生日餐祝福 + $birthInfo = $this->common->get_birth_date($user); + if($birthInfo) { + $birthMsg = ''; + $today = date("Y-m-d"); + $birth = $birthInfo[0]; + $dateInfo = $birthInfo[1]; + if($dateInfo) { + $dc_date = $dateInfo['dc_date']; + $b_date_id = $dateInfo['id']; + $row = $this->Common_model->sql_get_one("select * from tb_order where uid = ".$user->id." and state_id in (3, 6) and date_id = {$b_date_id}"); + if(!$row) { //未订餐 + if($dc_date == $today) $day = '今天'; + else if($dc_date == date("Y-m-d", time()+86400)) $day = '明天'; + else $day = $dc_date; + $birthMsg = '生日快乐!您可订'.$day.'的生日菜式!'; + } + } else { + //if($today == $birth) { + //$birthMsg = '生日快乐!'; + //} + } + $data['birthMsg'] = $birthMsg; + } // 2023-07-28 开始实行 $init_pass_modify_time = -1; @@ -272,246 +272,246 @@ class Dishes extends REST_Controller } $data['user']->init_pass_modify_time = $init_pass_modify_time; - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - public function index2_get($p_dining_hall_id = '', $p_date_id = '') - { - global $max_book_date, $dining_halls, $dishes_typesInfo, $t_meal_datesInfo, $userCartList, $cart_totalInfo, $extra_menus; - if(!$p_dining_hall_id) $this->common->check_cart($this->user); + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + public function index2_get($p_dining_hall_id = '', $p_date_id = '') + { + global $max_book_date, $dining_halls, $dishes_typesInfo, $t_meal_datesInfo, $userCartList, $cart_totalInfo, $extra_menus; + if(!$p_dining_hall_id) $this->common->check_cart($this->user); - if(!$max_book_date) $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; + if(!$max_book_date) $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; - $data = array(); + $data = array(); - $data['user'] = $this->user; - $user = $this->user; + $data['user'] = $this->user; + $user = $this->user; - $data['title'] = '选择菜式'; + $data['title'] = '选择菜式'; - //获取饭堂列表 - if(!$dining_halls) $dining_halls = $this->Common_model->get_dining_halls($this->user->company_id); - $data['dining_halls'] = $dining_halls; + //获取饭堂列表 + if(!$dining_halls) $dining_halls = $this->Common_model->get_dining_halls($this->user->company_id); + $data['dining_halls'] = $dining_halls; - if($p_dining_hall_id) { - $dining_hall_id = $p_dining_hall_id; - } else { - $dining_hall_id = $this->input->get('dining_hall_id'); - $dining_hall_id = intval($dining_hall_id) ? intval($dining_hall_id) : ($this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]); - } + if($p_dining_hall_id) { + $dining_hall_id = $p_dining_hall_id; + } else { + $dining_hall_id = $this->input->get('dining_hall_id'); + $dining_hall_id = intval($dining_hall_id) ? intval($dining_hall_id) : ($this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]); + } - //获取菜品类别 - if(!$dishes_typesInfo[$dining_hall_id]) $dishes_typesInfo[$dining_hall_id] = $this->Dishes_model->get_dishes_type($this->user->type_id, 1, $this->user->area_id, $dining_hall_id); - $dishes_types = $dishes_typesInfo[$dining_hall_id]; + //获取菜品类别 + if(!$dishes_typesInfo[$dining_hall_id]) $dishes_typesInfo[$dining_hall_id] = $this->Dishes_model->get_dishes_type($this->user->type_id, 1, $this->user->area_id, $dining_hall_id); + $dishes_types = $dishes_typesInfo[$dining_hall_id]; - $dishes_type = $this->input->get('dish_type'); - $dishes_type = $dishes_type ? $dishes_type : $dishes_types[0]->cpid; + $dishes_type = $this->input->get('dish_type'); + $dishes_type = $dishes_type ? $dishes_type : $dishes_types[0]->cpid; - $type = $this->get_type($dishes_type); + $type = $this->get_type($dishes_type); - //获取当前时间 - $today = time(); + //获取当前时间 + $today = time(); - //就餐信息 + //就餐信息 - $user_default_dining_hall_id = $this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]; - if(!$p_dining_hall_id) $data['take_info'] = $this->common->get_take_info($user_default_dining_hall_id, $this->user); + $user_default_dining_hall_id = $this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]; + if(!$p_dining_hall_id) $data['take_info'] = $this->common->get_take_info($user_default_dining_hall_id, $this->user); - //待选饭堂,日期数据,发送客户端,格式已整理 - $jcdata = array(); - //待选日期数据,格式未整理 - $meal_dates = array(); + //待选饭堂,日期数据,发送客户端,格式已整理 + $jcdata = array(); + //待选日期数据,格式未整理 + $meal_dates = array(); - //按饭堂获取可就餐日期 - foreach ($dining_halls as $dh) { + //按饭堂获取可就餐日期 + foreach ($dining_halls as $dh) { - //判断能否订当天餐,获取可订餐时间,按日期获取,下面根据时间段做剔除 - if(!$t_meal_datesInfo[$type."_".$dh->id."_".$max_book_date]) $t_meal_datesInfo[$type."_".$dh->id."_".$max_book_date] = $this->get_meal_dates($type, $dh->id, $max_book_date); - $t_meal_dates = $t_meal_datesInfo[$type."_".$dh->id."_".$max_book_date]; - if (count($t_meal_dates) > 0) { - $meal_dates[$dh->id] = $t_meal_dates; + //判断能否订当天餐,获取可订餐时间,按日期获取,下面根据时间段做剔除 + if(!$t_meal_datesInfo[$type."_".$dh->id."_".$max_book_date]) $t_meal_datesInfo[$type."_".$dh->id."_".$max_book_date] = $this->get_meal_dates($type, $dh->id, $max_book_date); + $t_meal_dates = $t_meal_datesInfo[$type."_".$dh->id."_".$max_book_date]; + if (count($t_meal_dates) > 0) { + $meal_dates[$dh->id] = $t_meal_dates; - //按客户端需要格式,整理数据 - $book_date = $this->get_book_date($t_meal_dates); - $book_date2 = array(); - foreach($book_date as $item) { - $book_date2[$item['dc_date']][] = $item; - } - $book_date3 = array(); - foreach($book_date2 as $dc_date => $item) { - $date = strtotime($dc_date); - $month = date('n', $date); - $day = date('j', $date); - $date_text = $month . '月' . $day . '日' . '(周' . cnWeek($date) . ')'; - foreach($item as $key2 => $item2) { - $item[$key2]['jcname'] = str_replace($date_text, '', $item2['jcname']); - $item[$key2]['active'] = '0'; - //$item[$key2]['cart_num'] = '0'; - } - $book_date3[] = array('datename' => $date_text, 'meal_list' => $item); - } - $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => $book_date3); - } else { - $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => array()); - } - } + //按客户端需要格式,整理数据 + $book_date = $this->get_book_date($t_meal_dates); + $book_date2 = array(); + foreach($book_date as $item) { + $book_date2[$item['dc_date']][] = $item; + } + $book_date3 = array(); + foreach($book_date2 as $dc_date => $item) { + $date = strtotime($dc_date); + $month = date('n', $date); + $day = date('j', $date); + $date_text = $month . '月' . $day . '日' . '(周' . cnWeek($date) . ')'; + foreach($item as $key2 => $item2) { + $item[$key2]['jcname'] = str_replace($date_text, '', $item2['jcname']); + $item[$key2]['active'] = '0'; + //$item[$key2]['cart_num'] = '0'; + } + $book_date3[] = array('datename' => $date_text, 'meal_list' => $item); + } + $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => $book_date3); + } else { + $jcdata[] = array('jcplace' => (array)$dh, 'jctime' => array()); + } + } - $data['jcdata'] = $jcdata; + $data['jcdata'] = $jcdata; - $vaild_dates = array(); - $meal_date = array(); - $rise_info = array(); - if (count($meal_dates) == 0 || count(@$meal_dates[$dining_hall_id]) == 0) { - $date_id = 0; + $vaild_dates = array(); + $meal_date = array(); + $rise_info = array(); + if (count($meal_dates) == 0 || count(@$meal_dates[$dining_hall_id]) == 0) { + $date_id = 0; // $dining_hall_name = $this->Common_model->get_dining_hall_by_id($dining_hall_id)->name; // $data['page'] = $dining_hall_name . '-' . '该日期无订餐安排'; - $data['page'] = '该日期无订餐安排'; + $data['page'] = '该日期无订餐安排'; - $status = 0; - } else { - //整理获取当前饭堂可选日期 - $jcd = $this->get_jcdata_by_dining_hall_id($jcdata, $dining_hall_id); + $status = 0; + } else { + //整理获取当前饭堂可选日期 + $jcd = $this->get_jcdata_by_dining_hall_id($jcdata, $dining_hall_id); - $book_date = $jcd['jctime']; + $book_date = $jcd['jctime']; // print_r($book_date); - //整理当前饭堂可选日期,方便判断 - $vaild_dates = array(); - foreach($book_date as $item) { - foreach($item['meal_list'] as $item2) { - $vaild_dates[] = $item2['id']; - } - } - //print_r($vaild_dates);exit; - if($p_date_id) { - $date_id = $p_date_id; - } else { - $date_id = $this->input->get('date_id'); - $date_id = $date_id ? $date_id : $vaild_dates[0]; - } + //整理当前饭堂可选日期,方便判断 + $vaild_dates = array(); + foreach($book_date as $item) { + foreach($item['meal_list'] as $item2) { + $vaild_dates[] = $item2['id']; + } + } + //print_r($vaild_dates);exit; + if($p_date_id) { + $date_id = $p_date_id; + } else { + $date_id = $this->input->get('date_id'); + $date_id = $date_id ? $date_id : $vaild_dates[0]; + } - $is_birth = $this->common->is_birth_date($user, $date_id); - if($is_birth) { //生日餐 - $dishList = $this->Common_model->sql_get_all("select * from tb_dish where dish_type = ".BIRTH_DISH_TYPE." and enabled = 1 and dining_hall_id = {$dining_hall_id}"); - foreach($dishList as $item) { - $dish_id = $item['id']; - $row = $this->Common_model->sql_get_one("select * from tb_date_dish where date_id = {$date_id} and dish_id = {$dish_id}"); - if(!$row) { - $this->Common_model->sql_query("insert into tb_date_dish set date_id = {$date_id}, dish_id = {$dish_id}, max_num = 1, is_normal_dish = 1, total_max_num = 0, book_num = 0"); - } - } - } else { - //if($dishes_type == BIRTH_DISH_TYPE) exit; - $dishes_types2 = array(); - foreach($dishes_types as $item) { - if($item->cpid == BIRTH_DISH_TYPE) continue; - $dishes_types2[] = $item; - } - $dishes_types = $dishes_types2; - } + $is_birth = $this->common->is_birth_date($user, $date_id); + if($is_birth) { //生日餐 + $dishList = $this->Common_model->sql_get_all("select * from tb_dish where dish_type = ".BIRTH_DISH_TYPE." and enabled = 1 and dining_hall_id = {$dining_hall_id}"); + foreach($dishList as $item) { + $dish_id = $item['id']; + $row = $this->Common_model->sql_get_one("select * from tb_date_dish where date_id = {$date_id} and dish_id = {$dish_id}"); + if(!$row) { + $this->Common_model->sql_query("insert into tb_date_dish set date_id = {$date_id}, dish_id = {$dish_id}, max_num = 1, is_normal_dish = 1, total_max_num = 0, book_num = 0"); + } + } + } else { + //if($dishes_type == BIRTH_DISH_TYPE) exit; + $dishes_types2 = array(); + foreach($dishes_types as $item) { + if($item->cpid == BIRTH_DISH_TYPE) continue; + $dishes_types2[] = $item; + } + $dishes_types = $dishes_types2; + } - if (count($vaild_dates) <= 0 || !in_array($date_id, $vaild_dates)) { - if($p_dining_hall_id) return false; - $this->response(array( - 'status' => 0, - 'message' => '该日期无订餐安排或已超过订餐时间', - ), REST_Controller::HTTP_OK); - } - $page = ''; - foreach($book_date as $key1 => $item) { - foreach($item['meal_list'] as $key2 => $item2) { - if($item2['id'] == $date_id) { - $page = $item['datename']; - foreach($data['jcdata'] as $key3 => $item3) { - if($item3['jcplace']['id'] == $dining_hall_id) { - $data['jcdata'][$key3]['jctime'][$key1]['meal_list'][$key2]['active'] = '1'; - break; - } - } - //break; - } - //$dishes_type_num = intval($this->Cart_model->get_cart_dishes_total_num($this->user->id, 0, $dining_hall_id, $item2['id'], '')->total_num); - if(!$userCartList) $userCartList = $this->Common_model->sql_get_all("select a.*, c.dining_hall_id, b.date_id, b.dish_id, c.dc_type, d.dish_type from tb_cart a, tb_date_dish b, tb_date c, tb_dish d where a.date_dish_id=b.id and b.date_id=c.id and b.dish_id=d.id and a.uid = '".$this->user->id."' and d.enabled = '1'"); - //print_r($userCartList);exit; - $dishes_type_num = 0; - foreach($userCartList as $cItem) { - if($cItem['dining_hall_id'] == $dining_hall_id && $cItem['date_id'] == $item2['id']) { - $dishes_type_num += $cItem['num']; - } - } + if (count($vaild_dates) <= 0 || !in_array($date_id, $vaild_dates)) { + if($p_dining_hall_id) return false; + $this->response(array( + 'status' => 0, + 'message' => '该日期无订餐安排或已超过订餐时间', + ), REST_Controller::HTTP_OK); + } + $page = ''; + foreach($book_date as $key1 => $item) { + foreach($item['meal_list'] as $key2 => $item2) { + if($item2['id'] == $date_id) { + $page = $item['datename']; + foreach($data['jcdata'] as $key3 => $item3) { + if($item3['jcplace']['id'] == $dining_hall_id) { + $data['jcdata'][$key3]['jctime'][$key1]['meal_list'][$key2]['active'] = '1'; + break; + } + } + //break; + } + //$dishes_type_num = intval($this->Cart_model->get_cart_dishes_total_num($this->user->id, 0, $dining_hall_id, $item2['id'], '')->total_num); + if(!$userCartList) $userCartList = $this->Common_model->sql_get_all("select a.*, c.dining_hall_id, b.date_id, b.dish_id, c.dc_type, d.dish_type from tb_cart a, tb_date_dish b, tb_date c, tb_dish d where a.date_dish_id=b.id and b.date_id=c.id and b.dish_id=d.id and a.uid = '".$this->user->id."' and d.enabled = '1'"); + //print_r($userCartList);exit; + $dishes_type_num = 0; + foreach($userCartList as $cItem) { + if($cItem['dining_hall_id'] == $dining_hall_id && $cItem['date_id'] == $item2['id']) { + $dishes_type_num += $cItem['num']; + } + } - foreach($data['jcdata'] as $key3 => $item3) { - if($item3['jcplace']['id'] == $dining_hall_id) { - $data['jcdata'][$key3]['jctime'][$key1]['meal_list'][$key2]['cart_num'] = $dishes_type_num; - break; - } - } + foreach($data['jcdata'] as $key3 => $item3) { + if($item3['jcplace']['id'] == $dining_hall_id) { + $data['jcdata'][$key3]['jctime'][$key1]['meal_list'][$key2]['cart_num'] = $dishes_type_num; + break; + } + } - } - } + } + } - $data['page'] = $page; + $data['page'] = $page; - $status = 1; + $status = 1; - //print_r($meal_dates); + //print_r($meal_dates); - //整理当前饭堂,当前日期 - $meal_date = $this->get_meal_date($meal_dates[$dining_hall_id], $date_id); + //整理当前饭堂,当前日期 + $meal_date = $this->get_meal_date($meal_dates[$dining_hall_id], $date_id); - if ($type == DISHES_TYPE_COMMON) { - } - } + if ($type == DISHES_TYPE_COMMON) { + } + } - $dishes = $this->Dishes_model->get_dishes_by_type_id($date_id, '', $dining_hall_id, $this->user->type_id); - //print_r($dishes); - //按客户端需要整理当前菜单格式 - $dishes = $this->sort_dishes($dishes, @$meal_date->is_free ? $meal_date->is_free : 0, $dining_hall_id, $date_id, 0); + $dishes = $this->Dishes_model->get_dishes_by_type_id($date_id, '', $dining_hall_id, $this->user->type_id); + //print_r($dishes); + //按客户端需要整理当前菜单格式 + $dishes = $this->sort_dishes($dishes, @$meal_date->is_free ? $meal_date->is_free : 0, $dining_hall_id, $date_id, 0); - if(!$is_birth) { //生日餐 - $dishes2 = array(); - foreach($dishes as $key => $item) { - if($item['dish_type'] == BIRTH_DISH_TYPE) continue; - $dishes2[] = $item; - } - $dishes = $dishes2; - } + if(!$is_birth) { //生日餐 + $dishes2 = array(); + foreach($dishes as $key => $item) { + if($item['dish_type'] == BIRTH_DISH_TYPE) continue; + $dishes2[] = $item; + } + $dishes = $dishes2; + } - // 设置菜品名称 针对交通局 + // 设置菜品名称 针对交通局 if($user->company_id == 54){ foreach ($dishes as $k => $v){ $dishes[$k]['csname'] = $v['type_name'] . ':' . $dishes[$k]['csname']; } } - $data['cs'] = $dishes; + $data['cs'] = $dishes; - //获取购物车总价 - if(!$cart_totalInfo) { - $cart_totalInfo = $this->common->get_cart_total_price($this->user, $type); - } - $cart_total_price = $cart_totalInfo['total_price']; - $cart_total_num = $cart_totalInfo['total_num']; + //获取购物车总价 + if(!$cart_totalInfo) { + $cart_totalInfo = $this->common->get_cart_total_price($this->user, $type); + } + $cart_total_price = $cart_totalInfo['total_price']; + $cart_total_num = $cart_totalInfo['total_num']; - $data['order'] = array('num' => $cart_total_num, 'price' => $cart_total_price, 'status' => $status); - $data['dining_hall_id'] = $dining_hall_id; - $data['date_id'] = $date_id; - //涨价信息 - //$data['rise_info'] = $this->common->get_rise_info($type, @$meal_date, ACTION_BOOK); - $data['rise_info'] = array(); + $data['order'] = array('num' => $cart_total_num, 'price' => $cart_total_price, 'status' => $status); + $data['dining_hall_id'] = $dining_hall_id; + $data['date_id'] = $date_id; + //涨价信息 + //$data['rise_info'] = $this->common->get_rise_info($type, @$meal_date, ACTION_BOOK); + $data['rise_info'] = array(); - if(!$extra_menus) { - $extra_menus = $this->get_extra_menus($this->user->company_id); - } + if(!$extra_menus) { + $extra_menus = $this->get_extra_menus($this->user->company_id); + } $serial_num = ''; if($this->user->company_id == 66){ @@ -522,35 +522,35 @@ class Dishes extends REST_Controller } } - $data['serial_num'] = $serial_num; - $data['extra_menus'] = $extra_menus; + $data['serial_num'] = $serial_num; + $data['extra_menus'] = $extra_menus; - if($p_dining_hall_id) return $data; + if($p_dining_hall_id) return $data; - //生日餐祝福 - $birthInfo = $this->common->get_birth_date($user); - if($birthInfo) { - $birthMsg = ''; - $today = date("Y-m-d"); - $birth = $birthInfo[0]; - $dateInfo = $birthInfo[1]; - if($dateInfo) { - $dc_date = $dateInfo['dc_date']; - $b_date_id = $dateInfo['id']; - $row = $this->Common_model->sql_get_one("select * from tb_order where uid = ".$user->id." and state_id in (3, 6) and date_id = {$b_date_id}"); - if(!$row) { //未订餐 - if($dc_date == $today) $day = '今天'; - else if($dc_date == date("Y-m-d", time()+86400)) $day = '明天'; - else $day = $dc_date; - $birthMsg = '生日快乐!您可订'.$day.'的生日菜式!'; - } - } else { - //if($today == $birth) { - //$birthMsg = '生日快乐!'; - //} - } - $data['birthMsg'] = $birthMsg; - } + //生日餐祝福 + $birthInfo = $this->common->get_birth_date($user); + if($birthInfo) { + $birthMsg = ''; + $today = date("Y-m-d"); + $birth = $birthInfo[0]; + $dateInfo = $birthInfo[1]; + if($dateInfo) { + $dc_date = $dateInfo['dc_date']; + $b_date_id = $dateInfo['id']; + $row = $this->Common_model->sql_get_one("select * from tb_order where uid = ".$user->id." and state_id in (3, 6) and date_id = {$b_date_id}"); + if(!$row) { //未订餐 + if($dc_date == $today) $day = '今天'; + else if($dc_date == date("Y-m-d", time()+86400)) $day = '明天'; + else $day = $dc_date; + $birthMsg = '生日快乐!您可订'.$day.'的生日菜式!'; + } + } else { + //if($today == $birth) { + //$birthMsg = '生日快乐!'; + //} + } + $data['birthMsg'] = $birthMsg; + } // 2023-07-28 开始实行 $init_pass_modify_time = -1; if(!empty($user->register_datetime) && strtotime($user->register_datetime) >= '1690473600'){ @@ -558,92 +558,92 @@ class Dishes extends REST_Controller } $data['user']->init_pass_modify_time = $init_pass_modify_time; - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - public function index3_get() { - $dining_hall_id = intval($this->user->dining_hall_id); - $data = $this->Common_model->sql_get_all("select a.*,b.name as meal_name from tb_date a, tb_meal_type b where a.dc_type=b.id and a.dining_hall_id = '{$dining_hall_id}' and dc_date >= '".date("Y-m-d")."' order by dc_date,b.idx desc limit 50"); - $all = array(); - $dining_halls = ''; - $extra_menus = ''; - $meal_list2 = array(); - $meal_list = array(); - foreach($data as $item) { - $meal_list2[$item['dc_type']] = $item['meal_name']; - } - foreach($meal_list2 as $meal_id => $meal_name) { - $meal_list[] = array('id' => $meal_id, 'meal_name' => $meal_name); - } - $meal_id = intval($_GET['meal_id']); - if($meal_id) { - if(!$meal_list2[$meal_id]) exit; - $meal_name = $meal_list2[$meal_id]; - } else { - $meal_id = $meal_list[0]['id']; - $meal_name = $meal_list[0]['meal_name']; - } + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + public function index3_get() { + $dining_hall_id = intval($this->user->dining_hall_id); + $data = $this->Common_model->sql_get_all("select a.*,b.name as meal_name from tb_date a, tb_meal_type b where a.dc_type=b.id and a.dining_hall_id = '{$dining_hall_id}' and dc_date >= '".date("Y-m-d")."' order by dc_date,b.idx desc limit 50"); + $all = array(); + $dining_halls = ''; + $extra_menus = ''; + $meal_list2 = array(); + $meal_list = array(); + foreach($data as $item) { + $meal_list2[$item['dc_type']] = $item['meal_name']; + } + foreach($meal_list2 as $meal_id => $meal_name) { + $meal_list[] = array('id' => $meal_id, 'meal_name' => $meal_name); + } + $meal_id = intval($_GET['meal_id']); + if($meal_id) { + if(!$meal_list2[$meal_id]) exit; + $meal_name = $meal_list2[$meal_id]; + } else { + $meal_id = $meal_list[0]['id']; + $meal_name = $meal_list[0]['meal_name']; + } - $data2 = array(); - foreach($data as $item) { - if($item['dc_type'] != $meal_id) continue; - $data2[] = $item; - } - $order = array(); - $cart_numInfo = array(); - $jcdata = array(); - $has1 = array(); - foreach($data2 as $item) { - $date_id = $item['id']; - $info = $this->index2_get($dining_hall_id, $date_id); - if(!$info) continue; + $data2 = array(); + foreach($data as $item) { + if($item['dc_type'] != $meal_id) continue; + $data2[] = $item; + } + $order = array(); + $cart_numInfo = array(); + $jcdata = array(); + $has1 = array(); + foreach($data2 as $item) { + $date_id = $item['id']; + $info = $this->index2_get($dining_hall_id, $date_id); + if(!$info) continue; - foreach($info['cs'] as $key => $item2) { - $info['cs'][$key]['commentInfo'] = $this->Common_model->sql_get_one("select * from tb_comment where dish_id = ".$item2['csid']); - } - unset($info['user']); - unset($info['title']); - if(!$dining_halls) $dining_halls = $info['dining_halls']; - unset($info['dining_halls']); - $page = $info['page']; - unset($info['page']); - unset($info['rise_info']); - if(!$extra_menus) $extra_menus = $info['extra_menus']; - unset($info['extra_menus']); - unset($info['take_info']); - foreach($info['jcdata'] as $item2) { - foreach($item2['jctime'] as $item3) { - foreach($item3['meal_list'] as $item4) { - if($has1[$item4['id']]) continue; - $cart_numInfo[$item4['dc_type']] += $item4['cart_num']; - $has1[$item4['id']] = 1; - } - } - } - if(!$jcdata) $jcdata = $info['jcdata']; - unset($info['jcdata']); - if(!$order) $order = $info['order']; - unset($info['order']); - $all[] = array( - 'date_id' => $date_id, - 'page' => $page, - 'info' => $info, - ); - } + foreach($info['cs'] as $key => $item2) { + $info['cs'][$key]['commentInfo'] = $this->Common_model->sql_get_one("select * from tb_comment where dish_id = ".$item2['csid']); + } + unset($info['user']); + unset($info['title']); + if(!$dining_halls) $dining_halls = $info['dining_halls']; + unset($info['dining_halls']); + $page = $info['page']; + unset($info['page']); + unset($info['rise_info']); + if(!$extra_menus) $extra_menus = $info['extra_menus']; + unset($info['extra_menus']); + unset($info['take_info']); + foreach($info['jcdata'] as $item2) { + foreach($item2['jctime'] as $item3) { + foreach($item3['meal_list'] as $item4) { + if($has1[$item4['id']]) continue; + $cart_numInfo[$item4['dc_type']] += $item4['cart_num']; + $has1[$item4['id']] = 1; + } + } + } + if(!$jcdata) $jcdata = $info['jcdata']; + unset($info['jcdata']); + if(!$order) $order = $info['order']; + unset($info['order']); + $all[] = array( + 'date_id' => $date_id, + 'page' => $page, + 'info' => $info, + ); + } if(empty($data2)){ $dining_halls = $this->Common_model->get_dining_halls($this->user->company_id); } - foreach($meal_list as $key => $item) { - $meal_list[$key]['cart_num'] = intval($cart_numInfo[$item['id']]); - } - //print_r($cart_numInfo);exit; + foreach($meal_list as $key => $item) { + $meal_list[$key]['cart_num'] = intval($cart_numInfo[$item['id']]); + } + //print_r($cart_numInfo);exit; - if(!$extra_menus) { - $extra_menus = $this->get_extra_menus($this->user->company_id); - } + if(!$extra_menus) { + $extra_menus = $this->get_extra_menus($this->user->company_id); + } // 临时修改饭堂 $new_dining_halls = array(); @@ -655,7 +655,7 @@ class Dishes extends REST_Controller } }else{ // if($v->id == $this->user->dining_hall_id){ - $new_dining_halls[] = $v; + $new_dining_halls[] = $v; // } } } @@ -663,7 +663,7 @@ class Dishes extends REST_Controller $new_dining_halls = $dining_halls; } - $take_info = $this->common->get_take_info($this->user->dining_hall_id, $this->user); + $take_info = $this->common->get_take_info($this->user->dining_hall_id, $this->user); // 小岛获取生日积分 if($this->user->company_id == 58){ @@ -671,19 +671,19 @@ class Dishes extends REST_Controller $this->user->srjf = floatval($srjf['all_account']); } - $data = array( - 'dining_halls' => $new_dining_halls, - 'extra_menus' => $extra_menus, - 'title' => '选择菜式', - 'date_list' => $all, - 'meal_list' => $meal_list, - 'take_info' => $take_info, - 'jcdata' => $jcdata, - 'now_meal_id' => $meal_id, - 'now_meal_name' => $meal_name, - 'order' => $order, - 'user' => $this->user, - ); + $data = array( + 'dining_halls' => $new_dining_halls, + 'extra_menus' => $extra_menus, + 'title' => '选择菜式', + 'date_list' => $all, + 'meal_list' => $meal_list, + 'take_info' => $take_info, + 'jcdata' => $jcdata, + 'now_meal_id' => $meal_id, + 'now_meal_name' => $meal_name, + 'order' => $order, + 'user' => $this->user, + ); //生日餐祝福 $birthInfo = $this->common->get_birth_date($this->user); @@ -716,114 +716,315 @@ class Dishes extends REST_Controller } $data['user']->init_pass_modify_time = $init_pass_modify_time; - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - public function noticelist_get() - { - $data = array(); + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } - $data['user'] = $this->user; + // 珠海的电信需要把日期放左边,右边是日期菜品 + public function index6_get(){ + global $max_book_date, $dining_halls, $dishes_typesInfo, $t_meal_datesInfo, $userCartList, $cart_totalInfo, $extra_menus; - $data['title'] = '公告列表'; + // 最长预定天数 + if(!$max_book_date) $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; - $data['list'] = $this->Common_model->get_notice_list($this->user->id); + $data = array(); + $data['user'] = $this->user; + $user = $this->user; + $data['title'] = '选择菜式'; + //获取饭堂列表 + if(!$dining_halls) $dining_halls = $this->Common_model->get_dining_halls($this->user->company_id); + $dining_halls = json_decode(json_encode($dining_halls), 1); + $data['dining_halls'] = $dining_halls; - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - public function get_notice_get() - { - $data = array(); + $dining_hall_id = $this->input->get('dining_hall_id'); + $dining_hall_id = intval($dining_hall_id) ? intval($dining_hall_id) : ($this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]->id); - $data['user'] = $this->user; + // 获取最近50个的菜单 + $list = $this->Common_model->sql_get_all("select a.*,b.name as meal_name from tb_date a, tb_meal_type b where a.dc_type=b.id and a.dining_hall_id = '{$dining_hall_id}' and dc_date >= '".date("Y-m-d")."' order by dc_date,b.idx desc limit 50"); - $data['title'] = '查看通知'; + // 左边tab里面所有的菜品(早午晚餐的菜品) + $all = array(); + // 最左侧菜单 + $extra_menus = ''; + // 左侧的列表2 + $meal_list2 = array(); + // 左侧的列表 + $date_list = array(); - $notice_id = intval($_REQUEST['notice_id']); + $date_get = $this->input->get('date'); + // 当前展示的日期 + $currentDateInfo = ''; + foreach($list as $item) { + if(!empty($date_get)){ + if($date_get == $item['dc_date']){ + $currentDateInfo = $item['dc_date']; + } + }else{ + $currentDateInfo = $list[0]['dc_date']; + } + $date_list[$item['dc_date']][] = $item; + } - $data['info'] = $this->Common_model->get_notice_info($this->user->id, $notice_id); + // 就是cp的id, 改为日期(当前日期) + if(empty($date_get)){ + $date_key = array_keys($date_list); + $date_get = $date_key ? $date_key[0] : ''; + } - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - public function check_num_by_sql($sql, $num, $maxnum, $errmsg) { - $db2 = $GLOBALS['CI']->rest->db; - $rows = $db2->query($sql)->result_array(); - $dids = array(0); - foreach($rows as $row) { - $dids[] = $row['id']; - } - $sql = "select * from tb_cart where uid =".intval($this->user->id)." and date_dish_id in (".implode(",", $dids).")"; - $rows = $db2->query($sql)->result_array(); - $hasNum = $num; - foreach($rows as $row) { - $hasNum += $row['num']; - } - if($hasNum > $maxnum) { - $this->response(array( - 'status' => 0, - 'message' => str_replace('%n', $maxnum, $errmsg), - 'data' => array() - ), REST_Controller::HTTP_OK); - exit; - } - } - //特色服务 - public function services_get() - { - $data = array(); + $data['date'] = $date_get; - $data['user'] = $this->user; + if(!$dishes_typesInfo[$dining_hall_id]) $dishes_typesInfo[$dining_hall_id] = $this->Dishes_model->get_dishes_type($this->user->type_id, 1, $this->user->area_id, $dining_hall_id); + $dishes_types = $dishes_typesInfo[$dining_hall_id]; + $dishes_type = $this->input->get('dish_type'); + $dishes_type = $dishes_type ? $dishes_type : $dishes_types[0]->cpid; + $type = $this->get_type($dishes_type); - $data['title'] = '特色服务'; - $service_types = $this->Common_model->sql_get_all("select id,name,icon from tb_special_service where enabled = '1' and company_id = ".$this->user->company_id." order by id "); + //待选饭堂,日期数据,发送客户端,格式已整理 + $jcplace = array(); + $jcdata = array(); + $jcmeal = array(); - /* - $service_types = array(); - foreach ($account_types_list as $item) { - $type = $item['id']; - $name = $item['serv_name']; + // 获取购物车 + if(!$userCartList) $userCartList = $this->Common_model->sql_get_all("select a.*, c.dining_hall_id, b.date_id, b.dish_id, c.dc_type, d.dish_type from tb_cart a, tb_date_dish b, tb_date c, tb_dish d where a.date_dish_id=b.id and b.date_id=c.id and b.dish_id=d.id and a.uid = '".$this->user->id."' and d.enabled = '1'"); + $cart_arr = array(); + //print_r($userCartList);exit; - $account_list = $this->Common_model->sql_get_all("select a.id, a.account, b.areaname from tb_account a, tb_area b where a.area_id=b.id and user_id = " . $this->user->id . " and type_id = '{$type}'"); - $service_types[] = array( - 'type_id' => $type, - 'name' => $name, - 'icon' => $item['icon'], - 'account_list' => $account_list, - ); - }*/ + // 遍历左侧日期cp + foreach ($date_list as $dc_date => $dateInfo){ + if($date_get != $dc_date){ + foreach ($dateInfo as $dateInfo_k => $dateInfo_v) { + $date_id = $dateInfo_v['id']; + $dishes_type_num = 0; + foreach($userCartList as $cItem) { + if($cItem['dining_hall_id'] == $dining_hall_id && $cItem['date_id'] == $date_id) { + $dishes_type_num += $cItem['num']; + } + } + $cart_arr[$dateInfo_v['dc_date']] += $dishes_type_num; + } + $jcmeal[$dc_date] = array( + 'cart_num' => $cart_arr[$dc_date], + 'meal_list' => array(), + 'active' => 0 + ); + continue; + } + $dining_hall_ids = array_column($dining_halls, 'id'); + $key = array_search($dining_hall_id, $dining_hall_ids); + $dining_hall_info = array(); + if($key !== false){ + $dining_hall_info = (array)$dining_halls[$key]; + } - $data['service_types'] = $service_types; - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - public function add_post() - { - $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; + // 获取当前日期的dc_type有什么菜式 ------------------- + $t_meal_dates = $this->get_meal_dates($type, $dining_hall_id, $max_book_date); + $date_dish_list = $this->get_book_date($t_meal_dates); - $data = array(); - $data['user'] = $this->user; - //获取当前时间 - $today = time(); + $meal_list = array(); - $date_dishes_id = $this->input->post('date_dish_id'); - $num = $this->input->post('num'); - $date_dishes_ids = stripslashes($this->input->post('date_dish_ids')); + $date = strtotime($dc_date); + $month = date('n', $date); + $day = date('j', $date); + $date_text = $month . '月' . $day . '日' . '(周' . cnWeek($date) . ')'; + foreach ($date_dish_list as $book_k => $book_v) { + $date_id = $book_v['id']; + + if($book_v['dc_date'] == $dc_date){ + // 获取当天 + $dishes = $this->Dishes_model->get_dishes_by_type_id($date_id, '', $dining_hall_id, $this->user->type_id); + + $dishes = $this->sort_dishes($dishes, '' , $dining_hall_id, $date_id, 0); + + $explode = explode(')', $book_v['jcname']); + $meal_list[$explode[1]]['cs'] = $dishes; + $date_dish_list[$book_k]['jcname'] = str_replace($date_text, '', $book_v['jcname']); + + $dishes_type_num = 0; + foreach($userCartList as $cItem) { + + if($cItem['dining_hall_id'] == $dining_hall_id && $cItem['date_id'] == $date_id) { + $dishes_type_num += $cItem['num']; + } + } + $cart_arr[$book_v['dc_date']] += $dishes_type_num; + } + } + + if(!empty($meal_list)){ + $jcmeal[$dc_date] = array( + 'cart_num' => $cart_arr[$dc_date], + 'meal_list' => $meal_list, + 'active' => $dc_date == $date_get ? 1 : 0 + ); + } + } + $data['jcdata'] = array( + 'jcplace' => $dining_hall_info, + 'jcdate' => $date_key, + 'jcmeal' => $jcmeal + ); + + $vaild_dates = array(); + $meal_date = array(); + $rise_info = array(); + if (count($jcdata) == 0) { + $date_id = 0; + $data['page'] = '该日期无订餐安排'; + $status = 0; + } + + //获取购物车总价 + if(!$cart_totalInfo) { + $cart_totalInfo = $this->common->get_cart_total_price($this->user, $type); + } + $cart_total_price = $cart_totalInfo['total_price']; + $cart_total_num = $cart_totalInfo['total_num']; + + $data['order'] = array('num' => $cart_total_num, 'price' => $cart_total_price, 'status' => $status); + $data['dining_hall_id'] = $dining_hall_id; + //涨价信息 + //$data['rise_info'] = $this->common->get_rise_info($type, @$meal_date, ACTION_BOOK); + $data['rise_info'] = array(); + + if(!$extra_menus) { + $extra_menus = $this->get_extra_menus($this->user->company_id); + } + + $user_default_dining_hall_id = $this->user->dining_hall_id ? $this->user->dining_hall_id : $dining_halls[0]; + $data['take_info'] = $this->common->get_take_info($user_default_dining_hall_id, $this->user); + $serial_num = ''; + + if($this->user->company_id == 66){ + $order_info = $this->Common_model->sql_get_one("select * from tb_order where id='{$data['take_info']['take_orderid']}'"); + $receive_meal_num_info = $this->Common_model->sql_get_one("select * from tb_dish_receive_meal_num where company_id='{$this->user->company_id}' and uid='{$this->user->id}' and date_id='{$order_info['date_id']}' and oid='{$data['take_info']['take_orderid']}'"); + if(!empty($receive_meal_num_info)){ + $serial_num = $receive_meal_num_info['serial_num']; + } + } + + $data['serial_num'] = $serial_num; + $data['extra_menus'] = $extra_menus; + + // 2023-07-28 开始实行 + $init_pass_modify_time = -1; + if(!empty($user->register_datetime) && strtotime($user->register_datetime) >= '1690473600'){ + $init_pass_modify_time = $user->init_pass_modify_time; + } + $data['user']->init_pass_modify_time = $init_pass_modify_time; + + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + public function noticelist_get() + { + $data = array(); + + $data['user'] = $this->user; + + $data['title'] = '公告列表'; + + $data['list'] = $this->Common_model->get_notice_list($this->user->id); + + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + public function get_notice_get() + { + $data = array(); + + $data['user'] = $this->user; + + $data['title'] = '查看通知'; + + $notice_id = intval($_REQUEST['notice_id']); + + $data['info'] = $this->Common_model->get_notice_info($this->user->id, $notice_id); + + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + public function check_num_by_sql($sql, $num, $maxnum, $errmsg) { + $db2 = $GLOBALS['CI']->rest->db; + $rows = $db2->query($sql)->result_array(); + $dids = array(0); + foreach($rows as $row) { + $dids[] = $row['id']; + } + $sql = "select * from tb_cart where uid =".intval($this->user->id)." and date_dish_id in (".implode(",", $dids).")"; + $rows = $db2->query($sql)->result_array(); + $hasNum = $num; + foreach($rows as $row) { + $hasNum += $row['num']; + } + if($hasNum > $maxnum) { + $this->response(array( + 'status' => 0, + 'message' => str_replace('%n', $maxnum, $errmsg), + 'data' => array() + ), REST_Controller::HTTP_OK); + exit; + } + } + //特色服务 + public function services_get() + { + $data = array(); + + $data['user'] = $this->user; + + $data['title'] = '特色服务'; + + $service_types = $this->Common_model->sql_get_all("select id,name,icon from tb_special_service where enabled = '1' and company_id = ".$this->user->company_id." order by id "); + + /* + $service_types = array(); + foreach ($account_types_list as $item) { + $type = $item['id']; + $name = $item['serv_name']; + + $account_list = $this->Common_model->sql_get_all("select a.id, a.account, b.areaname from tb_account a, tb_area b where a.area_id=b.id and user_id = " . $this->user->id . " and type_id = '{$type}'"); + $service_types[] = array( + 'type_id' => $type, + 'name' => $name, + 'icon' => $item['icon'], + 'account_list' => $account_list, + ); + }*/ + + $data['service_types'] = $service_types; + + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + public function add_post() + { + $max_book_date = $this->Common_model->get_config('MAX_BOOK_DATE')->value; + + $data = array(); + $data['user'] = $this->user; + //获取当前时间 + $today = time(); + + $date_dishes_id = $this->input->post('date_dish_id'); + $num = $this->input->post('num'); + $date_dishes_ids = stripslashes($this->input->post('date_dish_ids')); // 限制订餐时间 order/add 也有判断 $companyInfo = $this->Common_model->sql_get_one("select * from tb_company where id=".$this->user->company_id); @@ -852,96 +1053,96 @@ class Dishes extends REST_Controller } - //单个还是多个 - if ($num == null || $date_dishes_id == null) { - $date_dishes_ids = json_decode($date_dishes_ids); - if ($date_dishes_ids == null || count($date_dishes_ids) == 0) { - $this->response(array( - 'status' => 0, - 'message' => '缺少参数', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - } else { - if (!is_numeric($num) || $num < 0) { - $this->response(array( - 'status' => 0, - 'message' => '参数错误', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - if (!is_numeric($date_dishes_id) || $date_dishes_id < 1) { - $this->response(array( - 'status' => 0, - 'message' => '参数错误', - 'data' => $data - ), REST_Controller::HTTP_OK); - } + //单个还是多个 + if ($num == null || $date_dishes_id == null) { + $date_dishes_ids = json_decode($date_dishes_ids); + if ($date_dishes_ids == null || count($date_dishes_ids) == 0) { + $this->response(array( + 'status' => 0, + 'message' => '缺少参数', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + } else { + if (!is_numeric($num) || $num < 0) { + $this->response(array( + 'status' => 0, + 'message' => '参数错误', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + if (!is_numeric($date_dishes_id) || $date_dishes_id < 1) { + $this->response(array( + 'status' => 0, + 'message' => '参数错误', + 'data' => $data + ), REST_Controller::HTTP_OK); + } - $t_date_dishes_id = new stdClass(); - $t_date_dishes_id->date_dish_id = $date_dishes_id; - $t_date_dishes_id->num = $num; - $date_dishes_ids = array($t_date_dishes_id); - } + $t_date_dishes_id = new stdClass(); + $t_date_dishes_id->date_dish_id = $date_dishes_id; + $t_date_dishes_id->num = $num; + $date_dishes_ids = array($t_date_dishes_id); + } - $count = count($date_dishes_ids); - $type = 0; - $date = 0; - $r_date_dishes_ids = array(); + $count = count($date_dishes_ids); + $type = 0; + $date = 0; + $r_date_dishes_ids = array(); - foreach ($date_dishes_ids as $k => $v) { - if (!@$v->date_dish_id) continue; + foreach ($date_dishes_ids as $k => $v) { + if (!@$v->date_dish_id) continue; - $dishes_info = $this->Dishes_model->get_dishes_info($v->date_dish_id); + $dishes_info = $this->Dishes_model->get_dishes_info($v->date_dish_id); - if($dishes_info->fixed_amount > 0){ - $dishes_info->dish_price = $dishes_info->fixed_amount; - } + if($dishes_info->fixed_amount > 0){ + $dishes_info->dish_price = $dishes_info->fixed_amount; + } - if($dishes_info->dish_type == BIRTH_DISH_TYPE && $v->num > 0) { - $is_birth = $this->common->is_birth_date($this->user, $dishes_info->date_id); - if(!$is_birth) { - $this->response(array( - 'status' => 0, - 'message' => "您今天不能订生日餐!", - 'data' => array() - ), REST_Controller::HTTP_OK); - exit; - } - } + if($dishes_info->dish_type == BIRTH_DISH_TYPE && $v->num > 0) { + $is_birth = $this->common->is_birth_date($this->user, $dishes_info->date_id); + if(!$is_birth) { + $this->response(array( + 'status' => 0, + 'message' => "您今天不能订生日餐!", + 'data' => array() + ), REST_Controller::HTTP_OK); + exit; + } + } // $dishes_info = $this->Dishes_model->get_dishes_info($v->date_dish_id); - $date_dishes_ids[$k]->dishes_info = $dishes_info; + $date_dishes_ids[$k]->dishes_info = $dishes_info; - if($dishes_info->is_free == 1 && $dishes_info->book_limit == 0) { //免费餐限制选3样菜 - $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b, tb_dish_type c where is_normal_dish = 1 and a.dish_id=b.id and b.dish_type=c.id and a.date_id = ".intval($dishes_info->date_id)." and c.book_limit=0 and a.id != ".$v->date_dish_id; - $this->check_num_by_sql($sql, $v->num, 3, '免费餐只能选3样!'); - } + if($dishes_info->is_free == 1 && $dishes_info->book_limit == 0) { //免费餐限制选3样菜 + $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b, tb_dish_type c where is_normal_dish = 1 and a.dish_id=b.id and b.dish_type=c.id and a.date_id = ".intval($dishes_info->date_id)." and c.book_limit=0 and a.id != ".$v->date_dish_id; + $this->check_num_by_sql($sql, $v->num, 3, '免费餐只能选3样!'); + } - if($dishes_info->book_limit > 0) { //餐后水果只能订一样 - $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b where is_normal_dish = 1 and a.dish_id=b.id and a.date_id=".intval($dishes_info->date_id)." and b.dish_type=".intval($dishes_info->dish_type)." and a.id != ".$v->date_dish_id; - $this->check_num_by_sql($sql, $v->num, $dishes_info->book_limit, '该类型菜品只能订%n份'); - } + if($dishes_info->book_limit > 0) { //餐后水果只能订一样 + $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b where is_normal_dish = 1 and a.dish_id=b.id and a.date_id=".intval($dishes_info->date_id)." and b.dish_type=".intval($dishes_info->dish_type)." and a.id != ".$v->date_dish_id; + $this->check_num_by_sql($sql, $v->num, $dishes_info->book_limit, '该类型菜品只能订%n份'); + } - if($dishes_info->book_limit_day > 0) { //每日订限制 + if($dishes_info->book_limit_day > 0) { //每日订限制 - $orow = $this->Common_model->sql_get_one("select sum(b.dish_amount) as c from tb_order a, tb_order_detail b, tb_date c, tb_dish d where b.order_id=a.id and b.dish_id=d.id and a.date_id=c.id and a.uid = ".$this->user->id." and c.dc_date = '".$dishes_info->dc_date."' and a.state_id in ('3','6') and d.dish_type=".intval($dishes_info->dish_type)); + $orow = $this->Common_model->sql_get_one("select sum(b.dish_amount) as c from tb_order a, tb_order_detail b, tb_date c, tb_dish d where b.order_id=a.id and b.dish_id=d.id and a.date_id=c.id and a.uid = ".$this->user->id." and c.dc_date = '".$dishes_info->dc_date."' and a.state_id in ('3','6') and d.dish_type=".intval($dishes_info->dish_type)); - $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b, tb_date c where is_normal_dish = 1 and a.dish_id=b.id and a.date_id=c.id and c.dc_date='".$dishes_info->dc_date."' and b.dish_type=".intval($dishes_info->dish_type)." and a.id != ".$v->date_dish_id; - $this->check_num_by_sql($sql, $v->num + intval($orow['c']), $dishes_info->book_limit_day, '该类型菜品每日只能订%n份'); - } + $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b, tb_date c where is_normal_dish = 1 and a.dish_id=b.id and a.date_id=c.id and c.dc_date='".$dishes_info->dc_date."' and b.dish_type=".intval($dishes_info->dish_type)." and a.id != ".$v->date_dish_id; + $this->check_num_by_sql($sql, $v->num + intval($orow['c']), $dishes_info->book_limit_day, '该类型菜品每日只能订%n份'); + } - if($dishes_info->all_book_limit > 0) { //对于大类 存在限制的情况 - $relate_dish_type_id = "0".$dishes_info->relate_dish_type_id."0"; - $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b where is_normal_dish = 1 and a.dish_id=b.id and a.date_id=".intval($dishes_info->date_id)." and b.dish_type in (".$relate_dish_type_id.") and a.id != ".$v->date_dish_id; + if($dishes_info->all_book_limit > 0) { //对于大类 存在限制的情况 + $relate_dish_type_id = "0".$dishes_info->relate_dish_type_id."0"; + $sql = "select a.id,b.dish_name from tb_date_dish a, tb_dish b where is_normal_dish = 1 and a.dish_id=b.id and a.date_id=".intval($dishes_info->date_id)." and b.dish_type in (".$relate_dish_type_id.") and a.id != ".$v->date_dish_id; - $this->check_num_by_sql($sql, $v->num, $dishes_info->all_book_limit, $dishes_info->foot_type_name.'类型菜品只能订%n份'); - } + $this->check_num_by_sql($sql, $v->num, $dishes_info->all_book_limit, $dishes_info->foot_type_name.'类型菜品只能订%n份'); + } - // 深圳的电信 + // 深圳的电信 if($this->user->company_id == 66){ $check_dish_max = $this->Dishes_model->check_dish_max_amount($this->user->id, $this->user->company_id, $dishes_info->dish_id, $dishes_info->date_id, $v->num); if(is_array($check_dish_max)){ @@ -950,505 +1151,505 @@ class Dishes extends REST_Controller } } - } - $date_dishes_ids = $this->Dishes_model->set_dish_user_price($date_dishes_ids, $this->user->type_id, 'dishes_info', 'dish_id', 'dish_price'); + } + $date_dishes_ids = $this->Dishes_model->set_dish_user_price($date_dishes_ids, $this->user->type_id, 'dishes_info', 'dish_id', 'dish_price'); - //print_r($date_dishes_ids);exit; + //print_r($date_dishes_ids);exit; - foreach ($date_dishes_ids as $k => $v) { - if (@$v->date_dish_id) { + foreach ($date_dishes_ids as $k => $v) { + if (@$v->date_dish_id) { // var_dump($v); - $dishes_info = $v->dishes_info; + $dishes_info = $v->dishes_info; - //print_r($dishes_info); - if (count($dishes_info) == 0) { + //print_r($dishes_info); + if (count($dishes_info) == 0) { // unset($date_dishes_ids[$k]); - continue; - } - $type = $this->get_type($dishes_info->dish_type); - //$date = $this->Common_model->get_date_by_date_id($dishes_info->date_id); + continue; + } + $type = $this->get_type($dishes_info->dish_type); + //$date = $this->Common_model->get_date_by_date_id($dishes_info->date_id); - $result = $this->update_cart_single_dishes($dishes_info, $type, $v->num); - if ($result['status'] != 1) { - $result['data'] = $data; - $this->response($result, REST_Controller::HTTP_OK); - } else { - $r_date_dishes_ids[] = $v; - } - } else { - continue; - } - } + $result = $this->update_cart_single_dishes($dishes_info, $type, $v->num); + if ($result['status'] != 1) { + $result['data'] = $data; + $this->response($result, REST_Controller::HTTP_OK); + } else { + $r_date_dishes_ids[] = $v; + } + } else { + continue; + } + } - $total = $this->common->get_cart_total_price($this->user, $type); - $cart_total_price = $total['total_price']; - $cart_total_num = $total['total_num']; + $total = $this->common->get_cart_total_price($this->user, $type); + $cart_total_price = $total['total_price']; + $cart_total_num = $total['total_num']; - $count = count($date_dishes_ids); - if ($count > 0 && $type > 0) { - if ($date_dishes_id == null) { - $data['cart'] = array("date_dish_ids" => $r_date_dishes_ids, 'orderNum' => $cart_total_num, 'price' => $cart_total_price); - } else { - $data['cart'] = array("csnum" => $num, 'orderNum' => $cart_total_num, 'price' => $cart_total_price); + $count = count($date_dishes_ids); + if ($count > 0 && $type > 0) { + if ($date_dishes_id == null) { + $data['cart'] = array("date_dish_ids" => $r_date_dishes_ids, 'orderNum' => $cart_total_num, 'price' => $cart_total_price); + } else { + $data['cart'] = array("csnum" => $num, 'orderNum' => $cart_total_num, 'price' => $cart_total_price); - $data['cart']['rise_info'] = $this->common->get_rise_info($type, $date, ACTION_BOOK); - } + $data['cart']['rise_info'] = $this->common->get_rise_info($type, $date, ACTION_BOOK); + } - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } else { - $this->response(array( - 'status' => 0, - 'message' => '参数无效', - 'data' => $data - ), REST_Controller::HTTP_OK); - } - } + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } else { + $this->response(array( + 'status' => 0, + 'message' => '参数无效', + 'data' => $data + ), REST_Controller::HTTP_OK); + } + } - private function update_cart_single_dishes($dishes_info, $type, $num) - { - //print_r($dishes_info); - $cart_dishes = $this->Cart_model->get_cart_dishes($this->user->id, $dishes_info->id); - $cart_expire_time = $this->Common_model->get_config('CART_EXPIRE_TIME')->value; + private function update_cart_single_dishes($dishes_info, $type, $num) + { + //print_r($dishes_info); + $cart_dishes = $this->Cart_model->get_cart_dishes($this->user->id, $dishes_info->id); + $cart_expire_time = $this->Common_model->get_config('CART_EXPIRE_TIME')->value; - if($dishes_info->is_free) { //免费餐处理 - //购物车价格为真实价格,方便计算 - $dish_price = $this->get_free_price($dishes_info->dish_price, $dishes_info->is_free); - } else { - //处理某些需要区别对待价格的菜品 - $dish_price = $this->get_fee_deal_price($dishes_info->dish_price,$dishes_info->fee_deal); - } + if($dishes_info->is_free) { //免费餐处理 + //购物车价格为真实价格,方便计算 + $dish_price = $this->get_free_price($dishes_info->dish_price, $dishes_info->is_free); + } else { + //处理某些需要区别对待价格的菜品 + $dish_price = $this->get_fee_deal_price($dishes_info->dish_price,$dishes_info->fee_deal); + } - if (count($cart_dishes) > 0) { - $cart_dishes = $cart_dishes[0]; - if ($num > 0) { - $t_data = array("id" => $cart_dishes->id, "uid" => $this->user->id, "date_dish_id" => $dishes_info->id, - "num" => $num, "price" => $dish_price, "type" => $type, "expire_time" => time() + $cart_expire_time); + if (count($cart_dishes) > 0) { + $cart_dishes = $cart_dishes[0]; + if ($num > 0) { + $t_data = array("id" => $cart_dishes->id, "uid" => $this->user->id, "date_dish_id" => $dishes_info->id, + "num" => $num, "price" => $dish_price, "type" => $type, "expire_time" => time() + $cart_expire_time); - $r = $this->Cart_model->replace_cart($t_data); - if (!$r) { - return array( - 'status' => 0, - 'message' => '系统错误,请重试', - ); - } - } elseif ($num == 0) { - $r = $this->Cart_model->clear_dishes($cart_dishes->id); - if (!$r) { - return array( - 'status' => 0, - 'message' => '系统错误,请重试', - ); - } - } - } else if ($num > 0) { - $t_data = array("uid" => $this->user->id, "date_dish_id" => $dishes_info->id, - "num" => $num, "price" => $dish_price, "type" => $type, "expire_time" => time() + $cart_expire_time); + $r = $this->Cart_model->replace_cart($t_data); + if (!$r) { + return array( + 'status' => 0, + 'message' => '系统错误,请重试', + ); + } + } elseif ($num == 0) { + $r = $this->Cart_model->clear_dishes($cart_dishes->id); + if (!$r) { + return array( + 'status' => 0, + 'message' => '系统错误,请重试', + ); + } + } + } else if ($num > 0) { + $t_data = array("uid" => $this->user->id, "date_dish_id" => $dishes_info->id, + "num" => $num, "price" => $dish_price, "type" => $type, "expire_time" => time() + $cart_expire_time); - $r = $this->Cart_model->insert_cart($t_data); - if ($r > 0) { + $r = $this->Cart_model->insert_cart($t_data); + if ($r > 0) { // $cart_id = $r; - } else { - return array( - 'status' => 0, - 'message' => '系统错误,请重试', - ); - } - } + } else { + return array( + 'status' => 0, + 'message' => '系统错误,请重试', + ); + } + } - $error = $this->common->check_cart($this->user); - if (count($error) > 0) { - return array( - 'status' => SYSTEM_ERROR_CART, - 'message' => $this->common->parse_error($error), - ); - } + $error = $this->common->check_cart($this->user); + if (count($error) > 0) { + return array( + 'status' => SYSTEM_ERROR_CART, + 'message' => $this->common->parse_error($error), + ); + } - return array( - 'status' => 1, - 'message' => '', - ); - } + return array( + 'status' => 1, + 'message' => '', + ); + } - public function cart_get() - { - $data = array(); + public function cart_get() + { + $data = array(); - $data['user'] = $this->user; - $data['title'] = '我的订单'; - $data['page'] = '确认订单'; + $data['user'] = $this->user; + $data['title'] = '我的订单'; + $data['page'] = '确认订单'; - $dishes_info = $this->Cart_model->get_cart_dishes($this->user->id); - //$dishes_info = $this->Dishes_model->set_dish_user_price($dishes_info, 'dish_id', ''); + $dishes_info = $this->Cart_model->get_cart_dishes($this->user->id); + //$dishes_info = $this->Dishes_model->set_dish_user_price($dishes_info, 'dish_id', ''); - if (count($dishes_info) == 0) { - $data['cart'] = array("data" => array(), "total_price" => 0, "total_num" => 0); - $this->response(array( - 'status' => 1, - 'message' => '购物车为空,请先添加菜品', - 'data' => $data - ), REST_Controller::HTTP_OK); - } + if (count($dishes_info) == 0) { + $data['cart'] = array("data" => array(), "total_price" => 0, "total_num" => 0); + $this->response(array( + 'status' => 1, + 'message' => '购物车为空,请先添加菜品', + 'data' => $data + ), REST_Controller::HTTP_OK); + } - $error = $this->common->check_cart($this->user); - if (count($error) > 0) { - $this->response(array( - 'status' => SYSTEM_ERROR_CART, - 'message' => $this->common->parse_error($error), - 'data' => $data - ), REST_Controller::HTTP_OK); - } + $error = $this->common->check_cart($this->user); + if (count($error) > 0) { + $this->response(array( + 'status' => SYSTEM_ERROR_CART, + 'message' => $this->common->parse_error($error), + 'data' => $data + ), REST_Controller::HTTP_OK); + } - $dishes_info = $this->sort_cart_dishes_by_dining_hall_id_date_id($dishes_info); + $dishes_info = $this->sort_cart_dishes_by_dining_hall_id_date_id($dishes_info); - $dishes_info = $this->get_cart_item_total_price($dishes_info); + $dishes_info = $this->get_cart_item_total_price($dishes_info); - $data['cart'] = $dishes_info; + $data['cart'] = $dishes_info; - $this->response(array( - 'status' => 1, - 'message' => 'ok', - 'data' => $data - ), REST_Controller::HTTP_OK); - } + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => $data + ), REST_Controller::HTTP_OK); + } - private function sort_cart_dishes_by_date_id($cart_dishes) - { - $result = array(); - foreach ($cart_dishes as $cd) { - $result[$cd->date_id][] = $cd; - } - return $result; - } + private function sort_cart_dishes_by_date_id($cart_dishes) + { + $result = array(); + foreach ($cart_dishes as $cd) { + $result[$cd->date_id][] = $cd; + } + return $result; + } - private function sort_cart_dishes_by_dining_hall_id_date_id($cart_dishes) - { - $result = array(); - foreach ($cart_dishes as $k => $cd) { + private function sort_cart_dishes_by_dining_hall_id_date_id($cart_dishes) + { + $result = array(); + foreach ($cart_dishes as $k => $cd) { // $result[$cd->dining_hall_id]['data'][$cd->date_id][] = $cd; - $result[$cd->dining_hall_id]['dining_hall_id'] = $cd->dining_hall_id; - $result[$cd->dining_hall_id]['dining_hall_name'] = $this->Common_model->get_dining_hall_by_id($cd->dining_hall_id)->name; - $date = strtotime($cd->dc_date); - $month = date('n', $date); - $day = date('j', $date); - $date_text = $month . '月' . $day . '日' . '(周' . cnWeek($date) . ')'; + $result[$cd->dining_hall_id]['dining_hall_id'] = $cd->dining_hall_id; + $result[$cd->dining_hall_id]['dining_hall_name'] = $this->Common_model->get_dining_hall_by_id($cd->dining_hall_id)->name; + $date = strtotime($cd->dc_date); + $month = date('n', $date); + $day = date('j', $date); + $date_text = $month . '月' . $day . '日' . '(周' . cnWeek($date) . ')'; $dc_type_info = $this->Common_model->get_meal_type_by_id($cd->dc_type); - $result[$cd->dining_hall_id]['data'][$cd->dc_date]['date_name'] = $date_text; - $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['type'] = $cd->type; - $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['date_id'] = $cd->date_id; + $result[$cd->dining_hall_id]['data'][$cd->dc_date]['date_name'] = $date_text; + $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['type'] = $cd->type; + $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['date_id'] = $cd->date_id; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['meal_name'] = $dc_type_info->name; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['notes'] = $dc_type_info->notes; - $dishes = $this->Dishes_model->get_dishes_by_dishes_id($cd->dish_id); - $cd->dish_name = $dishes->dish_name; - $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['data'][] = $cd; - } - return $result; - } + $dishes = $this->Dishes_model->get_dishes_by_dishes_id($cd->dish_id); + $cd->dish_name = $dishes->dish_name; + $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['data'][] = $cd; + } + return $result; + } - private function get_cart_item_total_price($data) - { - $result = array(); - $total_price = 0; - $total_num = 0; - foreach ($data as &$v1) { + private function get_cart_item_total_price($data) + { + $result = array(); + $total_price = 0; + $total_num = 0; + foreach ($data as &$v1) { // print_r($v1); - $total_price1 = 0; - $total_num1 = 0; + $total_price1 = 0; + $total_num1 = 0; - foreach ($v1['data'] as &$v2) { + foreach ($v1['data'] as &$v2) { // print_r($v2); - $total_price2 = 0; - $total_num2 = 0; + $total_price2 = 0; + $total_num2 = 0; - foreach ($v2['data'] as &$v3) { + foreach ($v2['data'] as &$v3) { // print_r($v3); - $total = $this->common->get_cart_total_price($this->user, $v3['type'], $v3['date_id']); + $total = $this->common->get_cart_total_price($this->user, $v3['type'], $v3['date_id']); - $total_price3 = $total['total_price']; - $total_num3 = $total['total_num']; + $total_price3 = $total['total_price']; + $total_num3 = $total['total_num']; - $total_price2 += $total_price3; - $total_num2 += $total_num3; + $total_price2 += $total_price3; + $total_num2 += $total_num3; - $v3['total_price'] = $total_price3; - $v3['total_num'] = $total_num3; + $v3['total_price'] = $total_price3; + $v3['total_num'] = $total_num3; - $v3['rise_info'] = $this->common->get_rise_info($v3['type'], $v3['data'][0], ACTION_BOOK); - } + $v3['rise_info'] = $this->common->get_rise_info($v3['type'], $v3['data'][0], ACTION_BOOK); + } - $total_price1 += $total_price2; - $total_num1 += $total_num2; + $total_price1 += $total_price2; + $total_num1 += $total_num2; - $v2['total_price'] = $total_price2; - $v2['total_num'] = $total_num2; - } + $v2['total_price'] = $total_price2; + $v2['total_num'] = $total_num2; + } - $total_price += $total_price1; - $total_num += $total_num1; + $total_price += $total_price1; + $total_num += $total_num1; - $v1['total_price'] = $total_price1; - $v1['total_num'] = $total_num1; - } + $v1['total_price'] = $total_price1; + $v1['total_num'] = $total_num1; + } - $result['data'] = $data; - $result['total_price'] = $total_price; - $result['total_num'] = $total_num; + $result['data'] = $data; + $result['total_price'] = $total_price; + $result['total_num'] = $total_num; - return $result; - } + return $result; + } - /* private function get_fee($type, $dining_hall_id, $dc_type) - { - $rise_rule = $this->Common_model->get_rule($type, $dining_hall_id, $dc_type, RULE_PRICE_TYPE_RISE_TIME); - // $stop_rule = $this->Common_model->get_rule($type, $dining_hall_id, $dc_type, RULE_PRICE_TYPE_STOP_TIME); + /* private function get_fee($type, $dining_hall_id, $dc_type) + { + $rise_rule = $this->Common_model->get_rule($type, $dining_hall_id, $dc_type, RULE_PRICE_TYPE_RISE_TIME); + // $stop_rule = $this->Common_model->get_rule($type, $dining_hall_id, $dc_type, RULE_PRICE_TYPE_STOP_TIME); - if (strtotime($rise_rule[0]->time) - $rise_rule[0]->relative_day * 24 * 60 * 60 < time()) { - return $rise_rule[0]->fee; - } - return 0; - }*/ + if (strtotime($rise_rule[0]->time) - $rise_rule[0]->relative_day * 24 * 60 * 60 < time()) { + return $rise_rule[0]->fee; + } + return 0; + }*/ - private function check_meal_date($meal_dates, $date) - { - foreach ($meal_dates as $md) { - if ($md->id == $date->date_id) { - return true; - } - } - return false; - } + private function check_meal_date($meal_dates, $date) + { + foreach ($meal_dates as $md) { + if ($md->id == $date->date_id) { + return true; + } + } + return false; + } - private function get_type($dish_type) - { - return $this->common->get_type($this->user, $dish_type); - } + private function get_type($dish_type) + { + return $this->common->get_type($this->user, $dish_type); + } - private function get_meal_dates($type, $dining_hall_id, $max_book_date) - { - $t_meal_dates = $this->Common_model->get_meal_date($this->user, $type, $max_book_date, $dining_hall_id); - return $t_meal_dates; - } + private function get_meal_dates($type, $dining_hall_id, $max_book_date) + { + $t_meal_dates = $this->Common_model->get_meal_date($this->user, $type, $max_book_date, $dining_hall_id); + return $t_meal_dates; + } - private function get_rule_time($rule, $meal_type, $price_type) - { - foreach ($rule as $r) { - if ($r->meal_type = $meal_type && $r->price_type == $price_type) { - return $r->time; - } - } - } + private function get_rule_time($rule, $meal_type, $price_type) + { + foreach ($rule as $r) { + if ($r->meal_type = $meal_type && $r->price_type == $price_type) { + return $r->time; + } + } + } - private function get_book_date($meal_dates) - { - $result1 = array(); //堂食 - $result2 = array(); //外带 - foreach ($meal_dates as $key => $meal_date) { + private function get_book_date($meal_dates) + { + $result1 = array(); //堂食 + $result2 = array(); //外带 + foreach ($meal_dates as $key => $meal_date) { - //增加针对半成品的处理 - $jcname = $this->common->get_meal_text($meal_date->dc_date, $meal_date->dc_type); - $jcmealtype = (strpos($jcname,BANCHENGPIN_NAME) !== false )?COMMON_TAKEAWAY_MEAL_TYPE:COMMON_DINGINGHALL_MEAL_TYPE; - $jcmealtypename = (strpos($jcname,BANCHENGPIN_NAME) !== false )?COMMON_TAKEAWAY_MEAL:COMMON_DINGINGHALL_MEAL; + //增加针对半成品的处理 + $jcname = $this->common->get_meal_text($meal_date->dc_date, $meal_date->dc_type); + $jcmealtype = (strpos($jcname,BANCHENGPIN_NAME) !== false )?COMMON_TAKEAWAY_MEAL_TYPE:COMMON_DINGINGHALL_MEAL_TYPE; + $jcmealtypename = (strpos($jcname,BANCHENGPIN_NAME) !== false )?COMMON_TAKEAWAY_MEAL:COMMON_DINGINGHALL_MEAL; - $arr = array('id' => $meal_date->id,'dc_date' => $meal_date->dc_date,'dc_type' => $meal_date->dc_type,'is_free' => $meal_date->is_free,'dining_hall_id' => $meal_date->dining_hall_id, 'jcname' => $jcname, 'jcmealtype' => $jcmealtype, 'jcmealtypename' => $jcmealtypename); - if($jcmealtype == COMMON_TAKEAWAY_MEAL_TYPE) { - $result2[] = $arr; - } else { - $result1[] = $arr; - } - } + $arr = array('id' => $meal_date->id,'dc_date' => $meal_date->dc_date,'dc_type' => $meal_date->dc_type,'is_free' => $meal_date->is_free,'dining_hall_id' => $meal_date->dining_hall_id, 'jcname' => $jcname, 'jcmealtype' => $jcmealtype, 'jcmealtypename' => $jcmealtypename); + if($jcmealtype == COMMON_TAKEAWAY_MEAL_TYPE) { + $result2[] = $arr; + } else { + $result1[] = $arr; + } + } - $result = array_merge($result1, $result2); - return $result; - } + $result = array_merge($result1, $result2); + return $result; + } - private function get_vaild_dates($book_date) - { - $result = array(); - foreach ($book_date as $bd) { + private function get_vaild_dates($book_date) + { + $result = array(); + foreach ($book_date as $bd) { // $result[] = $bd['jcvalue']; - $result[] = $bd['id']; - } - return $result; - } + $result[] = $bd['id']; + } + return $result; + } - function get_jcdata_by_dining_hall_id($data, $id) - { - foreach ($data as $d) { - if ($id == $d['jcplace']['id']) { - return $d; - } - } - } + function get_jcdata_by_dining_hall_id($data, $id) + { + foreach ($data as $d) { + if ($id == $d['jcplace']['id']) { + return $d; + } + } + } - private function get_dishes_types($dishes_types, $dishes_type, $dining_hall_id, $date_id) - { - foreach ($dishes_types as $key => $dt) { + private function get_dishes_types($dishes_types, $dishes_type, $dining_hall_id, $date_id) + { + foreach ($dishes_types as $key => $dt) { // $dishes_type_num = $this->Cart_model->get_cart_dishes_num_by_type_id($this->user->id, $dt->cpid); // $dishes_type_num = $this->Cart_model->get_cart_dishes($this->user->id, 0, $dining_hall_id, $date_id, $dt->cpid); // $dishes_type_num = $this->Cart_model->get_cart_dishes_total_num($this->user->id, 0, $dining_hall_id, $date_id, $dt->cpid); - $real_dishes_type = $this->Dishes_model->get_dishes_real_type($dt->cpid); - $dishes_type_num = $this->Cart_model->get_cart_dishes_total_num($this->user->id, 0, $dining_hall_id, $date_id, "(".$dt->cpid.")"); + $real_dishes_type = $this->Dishes_model->get_dishes_real_type($dt->cpid); + $dishes_type_num = $this->Cart_model->get_cart_dishes_total_num($this->user->id, 0, $dining_hall_id, $date_id, "(".$dt->cpid.")"); - if ($dishes_type_num) { - $dishes_type_num = $dishes_type_num->total_num ? $dishes_type_num->total_num : 0; - } else { - $dishes_type_num = 0; - } + if ($dishes_type_num) { + $dishes_type_num = $dishes_type_num->total_num ? $dishes_type_num->total_num : 0; + } else { + $dishes_type_num = 0; + } - $dishes_types[$key]->cpnum = $dishes_type_num; - $dishes_types[$key]->cpdatenum = $this->Dishes_model->get_dishe_type_num($date_id, $dt->cpid); - if ($dishes_type == $dt->cpid) { - $dishes_types[$key]->cpactive = 'active'; - } else { - $dishes_types[$key]->cpactive = null; - } - } - $data2 = array(); - foreach ($dishes_types as $dt) { - if($dt->cpdatenum <= 0) continue; - $data2[] = $dt; - } + $dishes_types[$key]->cpnum = $dishes_type_num; + $dishes_types[$key]->cpdatenum = $this->Dishes_model->get_dishe_type_num($date_id, $dt->cpid); + if ($dishes_type == $dt->cpid) { + $dishes_types[$key]->cpactive = 'active'; + } else { + $dishes_types[$key]->cpactive = null; + } + } + $data2 = array(); + foreach ($dishes_types as $dt) { + if($dt->cpdatenum <= 0) continue; + $data2[] = $dt; + } - return $data2; - } + return $data2; + } - private function get_meal_date($meal_dates, $date_id) - { - foreach ($meal_dates as $meal_date) { + private function get_meal_date($meal_dates, $date_id) + { + foreach ($meal_dates as $meal_date) { // if ($date == str_replace(' - ', '', $meal_date->dc_date) . $meal_date->dc_type) { - if ($date_id == $meal_date->id) { - return $meal_date; - } - } - } + if ($date_id == $meal_date->id) { + return $meal_date; + } + } + } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private function sort_dishes($dishes, $is_free, $dining_hall_id, $date_id, $dishes_type) - { - foreach ($dishes as &$d) { - if($dishes_type == 0) $real_dishes_type = ''; - else $real_dishes_type = $this->Dishes_model->get_dishes_real_type($dishes_type); - //var_dump($dishes_type);exit; - //echo $real_dishes_type."vvvv"; - $dishes_num = $this->Cart_model->get_cart_dishes($this->user->id, 0, $dining_hall_id, $date_id, $real_dishes_type->real_type, $d->csid); - $date_dish_id = $this->Dishes_model->get_date_dish($date_id, $d->csid); - if ($date_dish_id) { - $date_dish_id = $date_dish_id->id; - } else { - $date_dish_id = 0; - } + private function sort_dishes($dishes, $is_free, $dining_hall_id, $date_id, $dishes_type) + { + foreach ($dishes as &$d) { + if($dishes_type == 0) $real_dishes_type = ''; + else $real_dishes_type = $this->Dishes_model->get_dishes_real_type($dishes_type); + //var_dump($dishes_type);exit; + //echo $real_dishes_type."vvvv"; + $dishes_num = $this->Cart_model->get_cart_dishes($this->user->id, 0, $dining_hall_id, $date_id, $real_dishes_type->real_type, $d->csid); + $date_dish_id = $this->Dishes_model->get_date_dish($date_id, $d->csid); + if ($date_dish_id) { + $date_dish_id = $date_dish_id->id; + } else { + $date_dish_id = 0; + } - if (count($dishes_num) > 0) { - $dishes_num = $dishes_num[0]->num; - } else { - $dishes_num = 0; - } + if (count($dishes_num) > 0) { + $dishes_num = $dishes_num[0]->num; + } else { + $dishes_num = 0; + } - $tmp_array = (array)$d; - $tmp_array['date_dish_id'] = $date_dish_id; - $tmp_array['csnum'] = $dishes_num; - //显示原价 - // 判断是否有固定金额 - if($tmp_array['fixed_amount'] != null && $tmp_array['fixed_amount'] > 0){ - $tmp_array['csprice'] = $tmp_array['fixed_amount']; - } + $tmp_array = (array)$d; + $tmp_array['date_dish_id'] = $date_dish_id; + $tmp_array['csnum'] = $dishes_num; + //显示原价 + // 判断是否有固定金额 + if($tmp_array['fixed_amount'] != null && $tmp_array['fixed_amount'] > 0){ + $tmp_array['csprice'] = $tmp_array['fixed_amount']; + } // $tmp_array['csprice'] = $this->get_free_price($tmp_array['csprice'], $is_free); - $tmp_array['image'] = base_url($tmp_array['image']); - $d = $tmp_array; - } - return $dishes; - } + $tmp_array['image'] = base_url($tmp_array['image']); + $d = $tmp_array; + } + return $dishes; + } - private function get_free_price($price, $is_free) - { - //工作账号正价 - if ($this->user->type_id == USERTYPE_OFFICIAL) { - return $price; - } - //是否免费餐 - if ($is_free == 1) { - $user_type = $this->User_model->get_user_type($this->user->type_id); + private function get_free_price($price, $is_free) + { + //工作账号正价 + if ($this->user->type_id == USERTYPE_OFFICIAL) { + return $price; + } + //是否免费餐 + if ($is_free == 1) { + $user_type = $this->User_model->get_user_type($this->user->type_id); - if ($user_type->free == 0) { - return 0; - } else if ($user_type->free == 1) { - $rate = $this->Common_model->get_config('NO_STAFF_FREE_RATE')->value; - return $rate * $price; - } - } else { - //显示正常价格 + if ($user_type->free == 0) { + return 0; + } else if ($user_type->free == 1) { + $rate = $this->Common_model->get_config('NO_STAFF_FREE_RATE')->value; + return $rate * $price; + } + } else { + //显示正常价格 // if ($this->user->type_id == USERTYPE_OFFICIAL) { // return 0; // } - return $price; - } - } + return $price; + } + } - private function get_fee_deal_price($price,$fee_deal) - { - //工作账号正价 - if ($this->user->type_id == USERTYPE_OFFICIAL) { - return $price; - } + private function get_fee_deal_price($price,$fee_deal) + { + //工作账号正价 + if ($this->user->type_id == USERTYPE_OFFICIAL) { + return $price; + } - if($fee_deal == 1){ - $user_type = $this->User_model->get_user_type($this->user->type_id); + if($fee_deal == 1){ + $user_type = $this->User_model->get_user_type($this->user->type_id); - if ($user_type->id == USERTYPE_STAFF) { - return 0; - } else { - return $price; - } + if ($user_type->id == USERTYPE_STAFF) { + return 0; + } else { + return $price; + } - } else { - return $price; - } + } else { + return $price; + } - } + } - private - function get_meal_type_name($id) - { - $meal_types = $this->Common_model->get_meal_type(); - foreach ($meal_types as $meal_type) { - if ($meal_type->id == $id) { - return $meal_type->name; - } - } - return null; - } + private + function get_meal_type_name($id) + { + $meal_types = $this->Common_model->get_meal_type(); + foreach ($meal_types as $meal_type) { + if ($meal_type->id == $id) { + return $meal_type->name; + } + } + return null; + } - function get_book_title($dates, $date) - { - foreach ($dates as $d) { - if ($date == $d['id']) { - return $d['jcname']; - } - } - } + function get_book_title($dates, $date) + { + foreach ($dates as $d) { + if ($date == $d['id']) { + return $d['jcname']; + } + } + } - function check_dish_type($dish, $dish_types) - { - foreach ($dish_types as $dt) { - if ($dt->cpid == $dish->dish_type) { - return true; - } - } - return false; - } + function check_dish_type($dish, $dish_types) + { + foreach ($dish_types as $dt) { + if ($dt->cpid == $dish->dish_type) { + return true; + } + } + return false; + } - // 获取饭堂 pos 机 + // 获取饭堂 pos 机 public function get_hall_channel_list_get(){ $user = $this->user; $company_id = $user->company_id; diff --git a/backstage/application/api/controllers/api/Order.php b/backstage/application/api/controllers/api/Order.php index ea13e58..2d4954e 100644 --- a/backstage/application/api/controllers/api/Order.php +++ b/backstage/application/api/controllers/api/Order.php @@ -57,7 +57,13 @@ class Order extends REST_Controller $total_price = $this->input->post('total_price'); $notes = $this->input->post('notes'); - + if(empty($notes)){ + $this->response(array( + 'status' => 0, + 'message' => '请先填写备注', + 'data' => $data + ), REST_Controller::HTTP_OK); + } if ($this->user->type_id != USERTYPE_OFFICIAL) { if (floatval($total_price) >= 0) { } else { @@ -520,7 +526,13 @@ class Order extends REST_Controller $total_price = $this->input->post('total_price'); $notes = $this->input->post('notes'); - + if(empty($notes)){ + $this->response(array( + 'status' => 0, + 'message' => '请先填写备注', + 'data' => $data + ), REST_Controller::HTTP_OK); + } if ($this->user->type_id != USERTYPE_OFFICIAL) { if (floatval($total_price) >= 0) { } else { diff --git a/m/css/main.css b/m/css/main.css index 81f01a1..4214af2 100644 --- a/m/css/main.css +++ b/m/css/main.css @@ -2860,6 +2860,240 @@ textarea::-webkit-input-placeholder { } +#page-index6 .bar { + padding: 0; +} +#page-index6 header .icon { + font-size: 1.4rem; +} +#page-index6 header .icon.icon-scan { + font-size: 1.3rem; +} +#page-index6 header .icon.icon-unfold { + font-size: 0.8rem; + padding-bottom: 0.1rem; +} +#page-index6 .title { + position: relative; + margin-right: 0; + margin-left: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + line-height: inherit; +} +#page-index6 .list-block ul.cp { + border-top: none; + border-bottom: none; + background: inherit; + white-space: inherit; +} +#page-index6 .cp-list, +#page-index6 .cs-list { + overflow-x: hidden; + overflow-y: auto; + position: relative; +} +#page-index6 .cp-list { + background: #fffffc url(../img/menu-bg.png) repeat-y right top; +} +#page-index6 .cp-list .list-block { + height: inherit; + display: -webkit-box; + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; +} +#page-index6 .cp-list .ftpic { + background-size: contain; + margin-bottom: 0; + background-position: center center; + background-repeat: no-repeat; + display: -webkit-flex; + -webkit-flex: 1; + -moz-box-flex: 1; + -ms-flex: 1; +} +#page-index6 .list-block ul.cp:before { + background-color: inherit; +} +#page-index6 .list-block ul.cp .active .item-inner { + border-left: #f66b22 0.1rem solid !important; + background-color: #fff !important; +} +#page-index6 .list-block ul.cp .active .item-title { + color: #674f4d !important; + font-size: 0.6rem; +} +#page-index6 .list-block ul.cp .item-inner { + padding-right: 0; + padding-left: 0; + min-height: 2.4rem; + border-bottom: none; + border-left: 0.15rem solid #fffffc; +} +#page-index6 .list-block ul.cp .item-title { + width: 100%; + color: #afafb0; + text-align: center; + font-weight: bolder; + font-size: 0.6rem; + white-space: initial; +} +#page-index6 .list-block ul.cp .item-content { + padding-left: 0; + border-bottom: 1px solid #e7e7e7; +} +#page-index6 .list-block ul.cp .item-after { + position: absolute; + right: 0; +} +#page-index6 .list-block ul.cp .badge { + padding: 0 0.25rem; + border-radius: 0.4rem; + background-color: #f66b22; + color: #fff; + line-height: 0.8rem; + opacity: 0.7; +} +#page-index6 .cs-list .cs { + border-top: none; +} +#page-index6 .cs-list .list-block ul:before { + height: 0; +} +#page-index6 .cs-list .list-block .item-content { + padding-left: 0.3rem; + margin-top: 0.3rem; +} +#page-index6 .cs-list .list-block .item-text { + height: 1.25rem; + color: red; + font-size: 0.75rem; + line-height: 1.25rem; +} +#page-index6 .cs-list .list-block .item-text.kc { + height: 0.9rem; + color: #5e6060; + line-height: 0.9rem; + font-size: 0.6rem; +} +#page-index6 .cs-list .list-block .item-operator { + position: absolute; + right: 0.25rem; + bottom: 0.2rem; +} +#page-index6 .cs-list .list-block .item-media + .item-inner { + margin-left: 0.3rem; + padding-top: 0rem; + max-width: inherit; +} +#page-index6 .cs-list .list-block li.media-item .item-media, +.list-block.media-list .item-media { + padding-top: 0; +} +#page-index6 .cs-list .list-block.media-list .item-title { + color: #5e6060; + font-weight: 800; + font-size: 0.7rem; + max-width: inherit; + word-wrap: break-word; + white-space: inherit; +} +#page-index6 .cs-list .list-block.media-list img { + width: 4.2rem; + height: 3.2rem; +} +#page-index6 .cs-list .list-block.media-list .item-operator p { + margin: 0 0 0.5rem 0; +} +#page-index6 .cs-list .list-block.media-list .item-operator p .button { + padding: 0.2rem 0; + width: 1.5rem; + height: 1.85rem; + max-width: 1.5rem; + border: none; + color: #d7a98c; + font-size: 1.1rem; + opacity: 1; +} +#page-index6 .cs-list .list-block.media-list .item-operator p .num { + width: 1rem; + max-width: 1rem; + color: #ac9688; + font-size: 0.9rem; + line-height: 1.35rem; +} +#page-index6 .cs-list .list-block.media-list .item-operator p .add:active, +#page-index6.cs-list .list-block.media-list .item-operator p .minus:active { + color: #f7680d; +} +#page-index6 .cs-list .list-block > p { + font-size: 0.65rem; +} +#page-index6 .cs-list .cs-evaluate { + color: #f66b22; + border-bottom: 1px solid; +} +#page-index6 .title-text span { + display: block; + position: relative; + text-align: center; + color: #b5b5b5; + font-size: 0.7rem; +} +#page-index6 .title-text span:before, +.title-text span:after { + content: ''; + position: absolute; + top: 50%; + background: #8c8c8c; + width: 25%; + height: 1px; +} +#page-index6 .title-text span:before { + left: 2%; +} +#page-index6 .title-text span:after { + right: 2%; +} +#page-index6 .card { + margin: 0.3rem 0.2rem 0.3rem 0.2rem; +} +#page-index6 .list-block .card .card-header { + font-size: 0.7rem; +} +#page-index6 .text-orange { + color: #39b8ff !important; +} +#page-index6 .notice-view { + width: 100%; + position: relative; + color: #aaaaaa; + bottom: 10%; + text-align: center; +} +#page-index6 .notice-view p { + position: absolute; + top: -40%; + background: #ff6600; + bottom: 0; + margin: 0; + left: 65%; + z-index: 998; + height: 1rem; + width: 1rem; + border-radius: 100%; + color: #fff; + font-size: 0.6rem; +} +#page-index6 .bar-tab .tab-item .total-price { + padding: 0rem; +} + + /* #cs-evaluate */ /* #page-index3 .meal-footer{height: 4.5rem;} */ diff --git a/m/index6.html b/m/index6.html new file mode 100644 index 0000000..88143c7 --- /dev/null +++ b/m/index6.html @@ -0,0 +1,162 @@ + + + + + + + + 选择菜式 + + + + + + + + + + +
+
+
+
+
+
+
+
+

加载中

+
+ +
+ +
+
+
+ +
+
+
+ +
+
+
    +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
+ 0 +
+
+
+ +
+
+
+ + +
+ +
+
+
+
+
+
+

+ 个人信息 + +

+
+
+
+
+
+
余额
+
+
+
+
+
积分
+
+
+ +
+
+
生日
+
-
+
+
+ +
+
+
+ +
+
+
+
+ + +
+ + + + + + + + + diff --git a/m/js/main.js b/m/js/main.js index 3e9603c..b7c02a5 100644 --- a/m/js/main.js +++ b/m/js/main.js @@ -306,8 +306,8 @@ $(function () { $('.upload-imgInfo-dialog .imgList img').remove(); $('.upload-imgInfo-dialog .imgList').append( '' + ret.data.list[nowIndex].img_resize + + '">' ); } }); @@ -319,8 +319,8 @@ $(function () { $('.upload-imgInfo-dialog .imgList img').remove(); $('.upload-imgInfo-dialog .imgList').append( '' + ret.data.list[nowIndex].img_resize + + '">' ); } }); @@ -368,7 +368,7 @@ $(function () { // 获取notice数据 function showNotice() { - // return false; + // return false; var _this = this; var token = user.token; @@ -470,12 +470,12 @@ $(function () { $('.pop-content-notice .imgList h4').remove(); $('.pop-content-notice .imgList').append( '

' + - list[nowIndex].title + - '

类型:' + - list[nowIndex].type + - '
' + - list[nowIndex].content + - '
' + list[nowIndex].title + + '
类型:' + + list[nowIndex].type + + '
' + + list[nowIndex].content + + '' ); $.each($('.pop-content-notice .imgList'), function (i, listEl) { $.each($(listEl).find('img'), function (m, img) { @@ -510,12 +510,12 @@ $(function () { $('.pop-content-notice .imgList h4').remove(); $('.pop-content-notice .imgList').append( '

' + - list[nowIndex].title + - '

类型:' + - list[nowIndex].type + - '
' + - list[nowIndex].content + - '
' + list[nowIndex].title + + '
类型:' + + list[nowIndex].type + + '
' + + list[nowIndex].content + + '' ); $.each($('.pop-content-notice .imgList'), function (i, listEl) { $.each($(listEl).find('img'), function (m, img) { @@ -596,13 +596,13 @@ $(function () { function setHeight() { $('.main .cp-list').height( $(window).height() - - $('.bar-tab').innerHeight() - - $('header').innerHeight() + $('.bar-tab').innerHeight() - + $('header').innerHeight() ); $('.main .cs-list').height( $(window).height() - - $('.bar-tab').innerHeight() - - $('header').innerHeight() + $('.bar-tab').innerHeight() - + $('header').innerHeight() ); } @@ -676,10 +676,10 @@ $(function () { .find('.title') .after( '' + dining_hall_id + + '-' + + date_id + + '" readonly="">' ); } @@ -809,8 +809,8 @@ $(function () { parseInt(cs.total_max_num) == -1 ? '0' : parseInt(cs.total_max_num) > 0 - ? cs.total_max_num - : '999+'; + ? cs.total_max_num + : '999+'; var kc = '剩' + cs.rest_num + '/' + cs.total_max_num; cs.csnum = cs.csnum ? cs.csnum : ''; @@ -1020,7 +1020,7 @@ $(function () { var token = user.token; $.ajax({ type: 'POST', - url: '../show/jtj.php?act=gdj_findDininghallByNow', + url: '../show/jtj.php?act=gdj_findDininghallByNow', dataType: 'json', headers: { 'Content-Type': 'application/json;', @@ -1311,7 +1311,7 @@ $(function () { setTimeout(function () { $.router.replacePage( 'thisOrder3.html?oid=' + - encodeURIComponent(JSON.stringify(oids)) + encodeURIComponent(JSON.stringify(oids)) ); }, 900); } else { @@ -1685,7 +1685,7 @@ $(function () { $(page) .find('input[name=' + type + ']') .val() !== - dining_hall_id + '-' + date_id + dining_hall_id + '-' + date_id ) { var meal = $(page) .find('input[name=' + type + ']') @@ -1811,8 +1811,1621 @@ $(function () { $('.popup .content-list').height( $(window).height() - - $('.popup footer').height() - - $('.popup .content-list').position().top + $('.popup footer').height() - + $('.popup .content-list').position().top + ); + } + } else { + $.closeModal($('.popover')); + $.alert('页面已过期,将刷新', function () { + getData(); + }); + } + }); + $(document) + .off('click', '.open-pay-tips') + .on('click', '.open-pay-tips', function () { + if (user === null) { + $.closePanel(); + setTimeout(function () { + location.href = 'login.php'; + }, 200); + return false; + } + + setTimeout(function () { + $.showIndicator(); + }, 0); + drawFKM(true, ''); + }); + + // 扫一扫 + $(document) + .off('click', '.open-scan') + .on('click', '.open-scan', function () { + if (user === null) { + setTimeout(function () { + location.href = 'login.php'; + }, 200); + return false; + } + $.closeModal($('.popover')); + + // getScanValue('{"channelid": 176}') + // return false; + + // if (typeof iosJs !== 'undefined') { + // try { + // // ios + // QRScannerOpen(); + // } catch (e) {} + // } else + if (typeof androidJs !== 'undefined') { + try { + // 安卓 + // window.androidJs.startScan(); + var camera_scan = localStorage.getItem('camera_scan'); + + if(camera_scan === null){ + window.androidJs.startScan(); + return false; + } + + var auth_list = androidJs.getHasSelfPermissionsJS(); + if (auth_list.indexOf("CAMERA") === -1) { + window.androidJs.startScan(); + }else{ + // var camera_photo = localStorage.getItem('camera_photo'); + if(camera_scan == 'true'){ + window.androidJs.startScan(); + return false; + } + // if(camera_photo === null){ + // localStorage.setItem('camera_photo', true); + // } + // 系统有权限,则弹出下面窗口 + $.modal({ + title:'

该服务需要申请使用以下权限:

', + text: '

相机权限:用于扫码时使用。

仅用于饭堂扫码用,如您不同意请不要进行后续操作。

', + buttons: [{ + text: '拒绝', + onClick: function (){ + // localStorage.setItem('camera_scan', false); + // localStorage.setItem('camera_photo', false); + // localStorage.setItem('write_storage_photo', false); + // localStorage.setItem('write_storage_data', false); + // localStorage.setItem('photo_data', false); + } + },{ + text: '同意', + onClick: function (){ + localStorage.setItem('camera_scan', true); + window.androidJs.startScan(); + // localStorage.setItem('camera_photo', true); + // localStorage.setItem('write_storage_photo', true); + // localStorage.setItem('write_storage_data', true); + // localStorage.setItem('photo_data', true); + } + }] + }); + } + } catch (e) {} + } else if (typeof window.webkit !== 'undefined') { + try { + // ios + QRScannerOpen(); + } catch (e) {} + } else { + // $.alert('请使用App操作'); + } + }); + } + } else { + $.alert('页面已过期,将刷新', function () { + getData(); + }); + } + }); + + $(page).on('click', '.order-open-btn', function () { + var get_date_id = $(this).next().data('id'); + var el = $(this).next().hasClass('card-look') + ? '.card-look-' + get_date_id + : '.card-order-' + get_date_id; + var _this = this; + if (!$(page).find(el).is(':animated')) { + $(page).find(el).slideToggle('slow'); + $(_this).find('.icon').hasClass('icon-prev') + ? $(_this).find('.icon').removeClass('icon-prev') + : $(_this).find('.icon').addClass('icon-prev'); + } + }); + }); + // 针对珠海电信定制 + $(document).on('pageInit', '#page-index6', function (e, pageId, page) { + var beginTime = 0; + var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); + var rise_tips = false; + var dining_hall_id; + var date_id; + var totalNum = 0; + var totalPrice = 0; + var dining_halls = ''; + var user_birthMsg = ''; + + var indexNotice = { + list: [], + count: 0, + showNotice: showNotice, + openNotice: openNoticeHtml, + renderIndex: renderNoticeIndex, + handleNoticeStatus: handleNoticeStatus, + }; + + if (user && $('.noticeNum').find('a').hasClass('noticeList')) { + $('.noticeNum').find('a').removeClass('noticeList'); + $('.noticeNum').find('a').addClass('noticeList2'); + } + if ( + user && + user.hasOwnProperty('theme') && + user.theme && + user.theme != '6' + ) { + $.router.replacePage(initTheme(user.theme)); + // $.router.replacePage(initTheme(user.theme)); + return; + } + if (user && (user.company_id == '42' || user.company_id == '58')) { + $('.changeFt').parent('p').hide(); + } + + // 获取notice数据 + function showNotice() { + // return false; + + var _this = this; + var token = user.token; + $.ajax({ + type: 'POST', + url: '../show/jtj.php?act=gdj_findNoticeByUser', + dataType: 'json', + headers: { + 'Content-Type': 'application/json;', + }, + data: JSON.stringify({ + token: token, // 假数据 + }), + success: function success(ret) { + if (typeof ret.code !== 'undefined') { + $.closePanel(); + if (ret.code === -1) { + $.closePanel(); + return; + } else if (ret.code === 0) { + _this.list = ret.content.notice; + _this.count = ret.content.unreadCount; + var sessionStorage = window.sessionStorage; + var open_notice_count = sessionStorage.getItem( + 'open_notice_count' + ); + // 默认第一次进入APP都打开 + if (!open_notice_count) { + setTimeout(function () { + indexNotice.openNotice(); + open_notice_count++; + sessionStorage.setItem( + 'open_notice_count', + open_notice_count + ); + }, 400); + } + $('.noticeNum') + .find('.noticeList2') + .find('.num') + .html(ret.content.unreadCount ? ret.content.unreadCount : '0'); + /* 渲染未阅读数据 */ + _this.renderIndex(); + /* ------------- */ + } + } + }, + error: function error() { + $.hideIndicator(); + // $.alert("请检查网络!"); + }, + }); + return; + } + // 打开公告弹出渲染 + function openNoticeHtml() { + var _this = this; + var list = this.list; + var point_html = ''; + for (var index = list.length - 1; index >= 0; index--) { + if (index || index === 0) { + var popupHTML = + '', + }); + }); + $('.logout') + .off('click') + .on('click', function () { + var token = user.token; + $.ajax({ + type: 'POST', + url: '../api/user/logout/', + dataType: 'json', + data: { + token: token, + }, + success: function (ret) { + if (typeof ret.status !== 'undefined') { + if (ret.status === 1 || ret.status === -1) { + $.closePanel(); + setTimeout(function () { + location.href = 'login.php'; + }, 200); + return; + } else { + $.alert(ret.message); + } + } + }, + error: function () { + $.alert('请检查网络!'); + }, + }); + }); + $(page).on('click', '.xhl', function () { + if (!$(this).hasClass('btnDisabled')) { + $.closePanel(); + $.router.replacePage('confirmOrder.html'); + } + }); + $(page).on('click', '.minus,.add', function () { + var self = $(this); + var num = parseInt( + self.parent('p').children('.num').html() + ? self.parent('p').children('.num').html() + : 0 + ); + var price = parseFloat(self.parent('p').data('price')); + var limit = parseInt(self.parent('p').data('limit')); + var cid = parseInt(self.parent('p').data('id')); + var type = self.data('type'); + if (type === 'add') { + if (num >= limit) { + return; + } + var offset = $('#page-index6 .total-num').offset(); + var url = $(this).parent('p').data('img'); + $('#page-index6 .cart .icon-cart').addClass('active'); + setTimeout(function () { + $('#page-index6 .cart .icon-cart').removeClass('active'); + }, 200); + var flyer = $(''); + flyer.fly({ + start: { + left: $(this).offset().left, //开始位置(必填)#fly元素会被设置成position: fixed + top: $(this).offset().top, //开始位置(必填) + }, + end: { + left: offset.left + 10, //结束位置(必填) + top: offset.top + 10, //结束位置(必填) + width: 0, //结束时宽度 + height: 0, //结束时高度 + }, + onEnd: function () { + //结束回调 + this.destroy(); + }, + }); + } else { + if (num <= 0) { + return; + } + } + num = printReload(self, num, limit, price, type); + //cookie不存在 + var token = user.token; + + $.ajax({ + type: 'POST', + url: '../api/dishes/add/', + dataType: 'json', + data: { + token: token, + date_dish_id: cid, + num: num, + }, + success: function (ret) { + if (typeof ret.status !== 'undefined') { + if (ret.status === 1) { + if ( + parseFloat(totalPrice) !== parseFloat(ret.data.cart.price) || + parseInt(totalNum) !== parseInt(ret.data.cart.orderNum) + ) { + totalNum = parseInt(ret.data.cart.orderNum); + totalPrice = parseFloat(ret.data.cart.price); + printReload(self, ret.data.cart.csnum, limit, price, 'none'); + } + if (!rise_tips && ret.data.cart.rise_info.rise_status) { + if (type === 'add') { + $.alert(ret.data.cart.rise_info.rise_tip); + rise_tips = true; + } + } + return; + } else if (ret.status === -1) { + $.closePanel(); + location.href = 'login.php'; + return; + } else { + $.alert(ret.message, function () { + var dish_type = $('.cp .item-content.active').data('pid'); + getData(dining_hall_id, date_id, dish_type); + }); + } + } + //回退 + printReload( + self, + num, + limit, + price, + type === 'add' ? 'minus' : 'add' + ); + }, + error: function () { + $.alert('请检查网络!'); + //回退 + printReload( + self, + num, + limit, + price, + type === 'add' ? 'minus' : 'add' + ); + }, + }); + }); + + $(page).on('click', '.cs-evaluate', function () { + var self = $(this); + var cid = self.parent('.buttons-row').data('id'); + var url = self.parent('.buttons-row').data('img'); + var name = self + .parent() + .parent() + .prev('.item-inner') + .children() + .children() + .text(); + + var popupHTML = + ''; + $.popup(popupHTML); + + $('.popup .star') + .off('click') + .on('click', function () { + $(this).addClass('active'); + $(this).prevAll().addClass('active'); + $(this).nextAll().removeClass('active'); + }); + }); + + $(page).on('click', '.cp li.item-content', function () { + // 判断当前点击内部商城 + if ($(this).hasClass('shop-index')) { + var tar = 'shop-index.html'; + setTimeout(function () { + $.router.loadPage(tar); + return; + }, 450); + return; + } else if ($(this).hasClass('added-server')) { + var tar = 'added-server.html'; + setTimeout(function () { + $.router.loadPage(tar); + return; + }, 450); + } else if ($(this).hasClass('transferOrderList')) { + var tar = 'transferOrderList.html'; + setTimeout(function () { + $.router.loadPage(tar); + return; + }, 450); + } + else if ($(this).hasClass('lfyy')) { + // var tar = 'https://yzms.fsecity.com/lfyy/'; + // setTimeout(function () { + // $.router.loadPage(tar); + // return; + // }, 450); + + // var url = '/lfyy/'; + var url = 'https://yzms.fsecity.com/lfyy/'; + if(url){ + if(url.indexOf('?') == -1){ + url = url + "?token="+user.token; + }else{ + url = url + "&token="+user.token; + } + var wxuser = /micromessenger/.test(navigator.userAgent.toLowerCase()) + ? true + : false; + if (wxuser) { + //微信端发起 + location.href = url; + + return true; + //end of wx + } else if (typeof iosJs !== 'undefined') { + try { + //alert(decodeURIComponent(ret.data.mweb_url)); + iosJs.openInSafari(url); + } catch (e) {} + } else if (typeof androidJs !== 'undefined') { + try { + //alert(decodeURIComponent(ret.data.mweb_url)); + androidJs.openAndroidWebview(url); + } catch (e) {} + } else if (typeof window.webkit !== 'undefined') { + // 2019-11-06 yw + try { + promptOpenInSafari(url); + } catch (e) {} + } else { + location.href = url; + return true; + } + return; + } + } + if ($(this).hasClass('active')) { + return; + } + getData(dining_hall_id, $(this).data('date')); + }); + $(page).on('click', '.notice-view', function () { + indexNotice.openNotice(); + }); + $(page).on('click', '.title', function () { + openPicker($(this)); + }); + + $(document) + .off('click', '.changeButton') + .on('click', '.changeButton', function () { + $.closeModal(); + var type = $(this).attr('data-type'); + + if ( + $(page) + .find('input[name=' + type + ']') + .val() && + $(page) + .find('input[name=' + type + ']') + .val() !== + dining_hall_id + '-' + date_id + ) { + var meal = $(page) + .find('input[name=' + type + ']') + .val() + .split('-'); + getData(meal[0], meal[1]); + } + }); + $(page).on('click', '.open-this-panel', function () { + if ($('body').hasClass('with-panel-left-reveal')) { + $.closePanel(); + } else { + $.openPanel('#panel-left'); + } + }); + $(page).on('click', '.open-mypopover', function () { + // 判断是否显示扫一扫 + var scan_display = ''; + if ( + typeof androidJs !== 'undefined' || + typeof window.webkit !== 'undefined' + ) { + scan_display = "style='display:block'"; + } else { + scan_display = "style='display:none'"; + } + //fix app页面常驻不更新的bug + var thisTime = new Date().getTime(); + if (thisTime - beginTime < 3 * 60 * 60 * 1000) { + var pHTML = + '
' + + '
' + + '' + + '
' + + '
'; + if ($.popover(pHTML, $(this))) { + $(document) + .off('click', '.open-smart-tips') + .on('click', '.open-smart-tips', function () { + //fix app页面常驻不更新的bug + var thisTime = new Date().getTime(); + if (thisTime - beginTime < 3 * 60 * 60 * 1000) { + var url = $(page).find('.open-mypopover').data('url'); + var name = $(page).find('.open-mypopover').data('name'); + var num = $(page).find('.open-mypopover').data('num'); + var thislist = $(page) + .find('.open-mypopover') + .data('order_detail'); + if (typeof window.webkit !== 'undefined') { + // 2019-11-06 yw + // 调亮 + try { + screenBrightnessUp(); + } catch (e) {} + } + + //12小时内不过期 + //没内容则为空 + if (url === ' ') { + $.closeModal($('.popover')); + $.toast('暂无符合当前就餐时间的二维码'); + } else { + thislist = $.parseJSON(thislist); + + var detail = '
'; + $.each(thislist, function (i, dish) { + detail += + '
' + + '' + + '
'; + }); + + detail += '
'; + //指定detial高度 + + var popupHTML = + ''; + popupHTML += detail; + $.popup(popupHTML); + + $('.popup .content-list').height( + $(window).height() - + $('.popup footer').height() - + $('.popup .content-list').position().top ); } } else {