diff --git a/backstage/application/api/controllers/api/User.php b/backstage/application/api/controllers/api/User.php index b3c5201..99ddf5e 100644 --- a/backstage/application/api/controllers/api/User.php +++ b/backstage/application/api/controllers/api/User.php @@ -26,7 +26,7 @@ class User extends REST_Controller $this->load->model('User_model', '', TRUE); $this->load->model('Session_model', '', TRUE); - if (in_array($this->uri->segment(3), ['login', 'get_token_by_openid'])) { + if (in_array($this->uri->segment(3), ['login', 'get_token_by_openid', 'lfmy_advance_dc'])) { } else { @@ -2174,12 +2174,30 @@ class User extends REST_Controller ), REST_Controller::HTTP_OK); } + // 乐福米业 刷卡自动明天的订餐 $company_id=4152 + public function lfmy_advance_dc_post(){ + // 限制ip=127.0.0.1 + $ip = $this->input->ip_address(); + if($ip != '127.0.0.1'){ + echo json_encode(array( + 'status' => 0, + 'message' => '非法请求' + )); + exit; + } + $user_id = $this->input->post("user_id",true); + $user_id = intval($user_id); + $company_id = "4152"; + $res = $this->tomorrow_dc($user_id, $company_id); + echo json_encode($res); + } + /** * 预定明天的菜谱 */ - private function tomorrow_dc($user_id){ + private function tomorrow_dc($user_id, $company_id = '4146'){ // 敏卓 - $company_id = '4146'; +// $company_id = '4146'; // 当前时间 $now_time = date("Y-m-d H:i:s"); @@ -2195,7 +2213,7 @@ class User extends REST_Controller if(empty($userInfo)){ return array( 'status' => 0, - 'message' => '未能找到敏卓的用户,用户不存在', + 'message' => '未能找到用户,用户不存在', ); } $cutUsername = cutName($userInfo['username']); @@ -2236,21 +2254,24 @@ class User extends REST_Controller // 读取tb_order_rule,看哪些菜谱(早午晚)还可以订 $dateInfo = $this->db->query("select a.*, b.name as dc_type_name from tb_date a, tb_meal_type b where a.dc_type=b.id and a.id='{$date_id}'")->row_array(); - /** - * 硬写订餐时间,当天 - * 午餐 6.00-8:30 - * 晚餐 11.00-13.30 - */ - $current_time = date("H:i:s"); - if($dateInfo['dc_type'] == '506'){ - if($current_time < "06:00:00" || $current_time > "08:30:00"){ - $message .= "

预定信息: ".$tomorrow_format."的{$dateInfo['dc_type_name']}不在菜谱预定时间内

"; - continue; - } - }elseif($dateInfo['dc_type'] == '507'){ - if($current_time < "11:00:00" || $current_time > "13:30:00"){ - $message .= "

预定信息: ".$tomorrow_format."的{$dateInfo['dc_type_name']}不在菜谱预定时间内

"; - continue; + if($company_id == '4146'){ + // 敏桌 + /** + * 硬写订餐时间,当天 + * 午餐 6.00-8:30 + * 晚餐 11.00-13.30 + */ + $current_time = date("H:i:s"); + if($dateInfo['dc_type'] == '506'){ + if($current_time < "06:00:00" || $current_time > "08:30:00"){ + $message .= "

预定信息: ".$tomorrow_format."的{$dateInfo['dc_type_name']}不在菜谱预定时间内

"; + continue; + } + }elseif($dateInfo['dc_type'] == '507'){ + if($current_time < "11:00:00" || $current_time > "13:30:00"){ + $message .= "

预定信息: ".$tomorrow_format."的{$dateInfo['dc_type_name']}不在菜谱预定时间内

"; + continue; + } } }