增加 乐福米业 自动订餐接口,限制127.0.0.1才能调用

Change-Id: I6a765f5a4d265b109e061687395e1ff390ba8d9b
This commit is contained in:
vguanyiwgd 2024-04-22 11:02:49 +08:00
parent 7cf6f3a24d
commit 486568e33b
1 changed files with 40 additions and 19 deletions

View File

@ -26,7 +26,7 @@ class User extends REST_Controller
$this->load->model('User_model', '', TRUE); $this->load->model('User_model', '', TRUE);
$this->load->model('Session_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 { } else {
@ -2174,12 +2174,30 @@ class User extends REST_Controller
), REST_Controller::HTTP_OK); ), 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"); $now_time = date("Y-m-d H:i:s");
@ -2195,7 +2213,7 @@ class User extends REST_Controller
if(empty($userInfo)){ if(empty($userInfo)){
return array( return array(
'status' => 0, 'status' => 0,
'message' => '未能找到敏卓的用户,用户不存在', 'message' => '未能找到用户,用户不存在',
); );
} }
$cutUsername = cutName($userInfo['username']); $cutUsername = cutName($userInfo['username']);
@ -2236,21 +2254,24 @@ class User extends REST_Controller
// 读取tb_order_rule看哪些菜谱早午晚还可以订 // 读取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(); $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();
/** if($company_id == '4146'){
* 硬写订餐时间,当天 // 敏桌
* 午餐 6.00-8:30 /**
* 晚餐 11.00-13.30 * 硬写订餐时间,当天
*/ * 午餐 6.00-8:30
$current_time = date("H:i:s"); * 晚餐 11.00-13.30
if($dateInfo['dc_type'] == '506'){ */
if($current_time < "06:00:00" || $current_time > "08:30:00"){ $current_time = date("H:i:s");
$message .= "<p><span style='color: red'>预定信息:</span> ".$tomorrow_format."{$dateInfo['dc_type_name']}不在菜谱预定时间内</p>"; if($dateInfo['dc_type'] == '506'){
continue; if($current_time < "06:00:00" || $current_time > "08:30:00"){
} $message .= "<p><span style='color: red'>预定信息:</span> ".$tomorrow_format."{$dateInfo['dc_type_name']}不在菜谱预定时间内</p>";
}elseif($dateInfo['dc_type'] == '507'){ continue;
if($current_time < "11:00:00" || $current_time > "13:30:00"){ }
$message .= "<p><span style='color: red'>预定信息:</span> ".$tomorrow_format."{$dateInfo['dc_type_name']}不在菜谱预定时间内</p>"; }elseif($dateInfo['dc_type'] == '507'){
continue; if($current_time < "11:00:00" || $current_time > "13:30:00"){
$message .= "<p><span style='color: red'>预定信息:</span> ".$tomorrow_format."{$dateInfo['dc_type_name']}不在菜谱预定时间内</p>";
continue;
}
} }
} }