$rs=$db->get_one("select * from tb_config where class='IDCARD_ONLINE_TIMEOUT'");
if($rs)$interval=$rs['value'];
$data['ic_interval']=$interval;
echoRs(1,"ok",array('data'=>$data));
break;
case"syncorder":
$channel_id=intval($_POST['channel_id']);
$dining_hall_id=intval($_POST['dining_hall_id']);
$min=intval($_POST['min']);
$max=intval($_POST['max']);
//print_r($_POST);
//查询合符时间的菜谱类型
$time=date("H:i:s");
$date_ids=array();
$rs=$db->get_all("select a.* from tb_meal_type a,tb_meal_type_dining_hall b where a.id = b.meal_type_id and b.dining_hall_id = ".$dining_hall_id);
foreach($rsas$k=>$v){
$hour=substr($v['end_time'],0,2);
$minute=substr($v['end_time'],2,6);
if($hour>23){
$dateadd=1;
$v['end_time']=($hour-24).$minute;
}else{
$dateadd=0;
}
$date_ids[$v['id']]=array(
'dc_type'=>$v['id'],
'dateadd'=>$dateadd,
'start_time'=>$v['start_time'],
'end_time'=>$v['end_time'],
);;
}
$dc_date=date("Y-m-d",time()-86400);
$where="";
if($min>=0&&$max>0&&$min!=$max){
$where=" and a.id between ".$min." and ".$max;
}
if($min==$max){
$where=" and a.id > ".$max;
}
$rs=$db->get_all("select a.*,d.dc_date,b.name,d.dc_type,c.username,f.name type_name from tb_order a ,tb_date d,tb_meal_type b,tb_user c,tb_user_type f where a.uid = c.id and a.date_id = d.id and d.dc_type = b.id and c.type_id = f.id and d.dining_hall_id = ".$dining_hall_id.$where." and d.dc_date > '".$dc_date."' and a.state_id in (6) order by a.id asc limit 50");
//echo "select a.*,d.dc_date,b.name,d.dc_type,c.username,c.deptname,c.cellphone,cardno,f.name type_name from tb_order a ,tb_date d,tb_meal_type b,tb_user c,tb_user_type f where a.uid = c.id and a.date_id = d.id and d.dc_type = b.id and c.type_id = f.id and d.dining_hall_id = ".$dining_hall_id.$where." and d.dc_date > '".$dc_date."' and a.state_id in (6) order by a.id asc limit 50";
$rs=$db->get_all("select user_id,group_concat(cardno) cardno from tb_user_idcard where user_id in (".implode(",",$user_ids).") and state = 1");
foreach($rsas$k=>$v){
$idcards[$v['user_id']]=$v['cardno'];
}
$faces=array();
$rs=$db->get_all("select user_id,card from tb_user_face where user_id in (".implode(",",$user_ids).")");
foreach($rsas$k=>$v){
$faces[$v['user_id']]=$v['card'];
}
$details=array();
$rs=$db->get_all("select a.dish_id,a.order_id,b.dish_name,a.dish_price,a.dish_amount,c.type_name from tb_order_detail a, tb_dish b,tb_dish_type c where a.dish_id = b.id and b.dish_type = c.id and a.order_id in (".implode(",",$ids).")");
//echo "select a.order_id,b.dish_name,a.dish_price,a.dish_amount,c.type_name from tb_order_detail a, tb_dish b,tb_dish_type c where a.dish_id = b.id and b.type_id = c.id and a.order_id in (".implode(",",$ids).")";exit;
foreach($rsas$k=>$v){
$details[$v['order_id']][]=array(
'dish_id'=>$v['dish_id'],
'dish_name'=>$v['dish_name'],
'dish_price'=>$v['dish_price'],
'dish_amount'=>$v['dish_amount'],
'type_name'=>$v['type_name'],
);
}
foreach($dataas$k=>$v){
$data[$k]['order_detail']=$details[$v['id']];
$data[$k]['cardno']=$idcards[$v['user_id']];
$data[$k]['face']=$faces[$v['user_id']];
}
echoRs(1,"ok",array('data'=>$data));
break;
case"income";
$dining_hall_id=intval($_POST['dining_hall_id']);
$channel_id=intval($_POST['channel_id']);
$channel_name="";
$rs=$db->get_all("select sum(recharge_amount) recharge_amount,channel_id,b.name dining_hall_name,c.channel_name from tb_recharge a,tb_dining_hall b,tb_pos_channel c
$uInfo=$db->get_one("select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_idcard b where b.user_id=a.id and cardno='{$cardno}' and a.enabled in (1,-1) and b.state=1");
//echo "select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_idcard b where b.user_id=a.id and cardno='{$cardno}' and a.enabled not in (0, -99) and b.state=1";
$chk_server_log_table=$db->get_one("show tables like 'tb_chk_server_log'");
if($chk_server_log_table){
// 同一个机器,不能连续请求
$timestamp=time()-60;
$before_one_min=date('Y-m-d H:i:s',$timestamp);
$checkRequest=$db->get_one("select * from tb_chk_server_log where act='getConsumeList' and record_datetime>='{$before_one_min}' and channel_id='{$channel_id}'");
$sql="insert into tb_chk_server_log(act,ip,request,record_datetime,channel_id) values('".$act."','".$ip."','".$request."','".$now."', '".$channel_id."')";
$db->query($sql);
}
}
$all_consume_price=0;
// 获取今天总的消费额(人脸和刷卡消费)
// $data = $db->get_one("select sum(recharge_amount) all_consume_price from tb_recharge
// where
// channel_id='{$channel_id}' and
// DATE_FORMAT(record_datetime,'%Y-%m-%d')=CURRENT_DATE and
// user_id>0 and
// type in (12,15)");
// DATE_FORMAT(record_datetime,'%Y-%m-%d')=CURRENT_DATE and
$info=$db->get_one("select * from tb_period_amount where company_id='{$company_id}' and dining_hall_id='{$dining_hall_id}' and channel_id like '%,{$channel_id},%' and (CURTIME() BETWEEN start_time and end_time) and status='1' order by id desc");
if(empty($info)){
echoRs(0,'暂没有可用的固定消费金额',array());
}
$res['status']=1;
$res['msg']="获取成功";
$res['data']=array(
'price'=>$info['price'],
);
echojson_encode($res);
break;
case"icUserInfo":
$cardno=htmlentities($_POST['cardno']);
$uInfo=$db->get_one("select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_idcard b where b.user_id=a.id and cardno='{$cardno}' and a.enabled in (1,-1) and b.state=1");
//echo "select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_idcard b where b.user_id=a.id and cardno='{$cardno}' and a.enabled != 0 and b.state=1";
if(!$uInfo){
echoRs(0,'无效ic卡');
exit;
}
$info=array();
// 实验中学,增加用户信息(学生卡号,姓名,余额)
// if($UNIQUE_NAME == 'dlsyzx'){
// $ye = $db->get_one("select sum(account) total_account from tb_account where user_id='{$uInfo['id']}' group by user_id");
// $info['user'] = array(
// 'cardNo' => $cardno,
// 'username' => $uInfo['username'],
// 'ye' => $ye['total_account']
// );
// }
echoRs(1,'ok',array('data'=>$info));
break;
case"faceUserInfo":
$facecard=htmlentities($_POST['facecard']);
// $uInfo = $db->get_one("select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_idcard b where b.user_id=a.id and cardno='{$cardno}' and a.enabled in (1,-1) and b.state=1");
$uInfo=$db->get_one("select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_face b where b.user_id=a.id and b.card='{$facecard}' and a.enabled in (1,-1)");
//echo "select a.id,a.username,a.cellphone,a.deptname,a.area_id from tb_user a,tb_user_idcard b where b.user_id=a.id and cardno='{$cardno}' and a.enabled != 0 and b.state=1";
if(!$uInfo){
echoRs(0,'无效人脸');
exit;
}
$info=array();
// 实验中学,增加用户信息(学生卡号,姓名,余额)
// if($UNIQUE_NAME == 'dlsyzx'){
// $ye = $db->get_one("select sum(account) total_account from tb_account where user_id='{$uInfo['id']}' group by user_id");
$checkRequest=$db->get_one("select * from tb_chk_server_log where act='getLastMeal' and record_datetime>='{$before_one_min}' and channel_id='{$channel_id}'");
$sql="insert into tb_chk_server_log(act,ip,request,record_datetime,channel_id) values('".$act."','".$ip."','".$request."','".$now."', '".$channel_id."')";
$db->query($sql);
}
}
$GLOBALS['current_date_id']=0;
get_take_info($dining_hall_id,$userid);
$date_id=$GLOBALS['current_date_id'];
$sql="select c.id, c.dish_name, IFNULL(sum(b.dish_amount), 0) rest_num from (select c.id, c.dish_name from tb_dish c, tb_date_dish e where c.id = e.dish_id and e.date_id={$date_id} and c.dish_type not in (".USER_DISHES_TYPE_OFFICIAL1.",".USER_DISHES_TYPE_OFFICIAL2.")) c