query($sql); if (count($guide_info) == 1) { $json['code'] = '0'; $json['info'] = '手机号有效'; $json['driver_info'] = $guide_info[0]; $json['type'] = '导游'; return $json; } $sql = "SELECT driver_id AS id,driver_name AS name,org_id, (SELECT supplier_name FROM base_supplier WHERE id = org_id LIMIT 1) AS supplier_name FROM base_driver WHERE phone_no = " . $phone . " AND cancel_flag = 0 LIMIT 1"; $driver_info = $this->query($sql); if (count($driver_info) == 1) { $json['code'] = '0'; $json['info'] = '手机号有效'; $json['driver_info'] = $driver_info[0]; $json['type'] = '司机'; } else { $json['code'] = '1'; $json['info'] = '手机号无效'; } return $json; } /** * 获取验证码 * @param $param */ public function getCode($param) { $phone = isset($param['phone']) ? trim($param['phone']) : false; $div = isset($param['div']) ? trim($param['div']) : false; $user_id = $this->user_id; $time = date('Y-m-d :H:i:s', time()); if (!$phone || !$div) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $driver_info = $this->checkLogin($phone); if ($driver_info['code'] == '1') { return $driver_info; } $driver_id = $driver_info['driver_info']['id']; $is_exist_sql = "SELECT id FROM driver_login WHERE phone = '" . $phone . "' AND `div` = '" . $div . "' AND res_id = " . $driver_id . " AND cancel_flag = 0 LIMIT 1"; $is_exist = $this->query($is_exist_sql); $code = rand(1000, 9999); if (count($is_exist) == 1) { $sql = "UPDATE driver_login SET update_user_id = " . $user_id . ", update_time = '" . $time . "', `code` = " . $code . ", status = 179, code_deadline = '" . $time . "' WHERE id = " . $is_exist[0]['id']; } else { $sql = "INSERT INTO driver_login ( res_id, phone, `code`, `div`, code_deadline, status, cancel_flag, create_user_id, create_time, update_user_id, update_time, mark ) VALUE(" . $driver_id . ",'" . $phone . "','" . $code . "','" . $div . "','" . $time . "',179,0," . $user_id . ",'" . $time . "'," . $user_id . ",'" . $time . "',1)"; } $result = $this->exec($sql); if ($result) { $content = array('phone' => $phone, 'code' => $code); message::sendMessage(1, $content); $json['code'] = '0'; $json['info'] = '获取验证码成功'; $json['code_info'] = $code; $json['driver_id'] = $driver_id; } else { $json['code'] = '1'; $json['info'] = '数据库原因,获取验证码失败'; } return $json; } /** * 退出登录 * @param $param */ public function loginOut($param) { $driver_id = isset($param['driver_id']) ? trim($param['driver_id']) : false;//id if (!$driver_id) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $user_id = $this->user_id; $time = date('Y-m-d :H:i:s', time()); $sql = "UPDATE driver_login SET `status` = 179, update_user_id = " . $user_id . ", update_time = '" . $time . "', mark = 2 WHERE res_id = " . $driver_id . " AND cancel_flag = 0"; $login_out = $this->exec($sql); if ($login_out) { $json['code'] = '0'; $json['info'] = '退出成功'; } else { $json['code'] = '1'; $json['info'] = '数据库原因,退出失败'; } return $json; } /** * 登录 */ public function login($param) { $phone = isset($param['phone']) ? trim($param['phone']) : false; $div = isset($param['div']) ? trim($param['div']) : false; $code = isset($param['code']) ? trim($param['code']) : false; $user_id = $this->user_id; $time = date('Y-m-d :H:i:s', time()); if (!$phone || !$div || !$code) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $driver_info = $this->checkLogin($phone); if ($driver_info['code'] == '1') { return $driver_info; } $driver_type = $driver_info['type']; $driver_info = $driver_info['driver_info']; $check_sql = "SELECT id,code FROM driver_login WHERE phone = '" . $phone . "' AND `div` = '" . $div . "' AND res_id = " . $driver_info['id'] . " AND cancel_flag = 0 LIMIT 1"; $check_result = $this->query($check_sql); if (count($check_result) == 0) { $json['code'] = '1'; $json['info'] = '请获取验证码'; return $json; } if ($check_result[0]['code'] != $code) { $json['code'] = '1'; $json['info'] = '请输入正确的验证码'; return $json; } $update_sql = "UPDATE driver_login SET update_user_id = " . $user_id . ", update_time = '" . $time . "', status = 180, login_deadline = '" . $time . "' WHERE id = " . $check_result[0]['id']; $result = $this->exec($update_sql); if ($result) { $json['code'] = '0'; $json['info'] = '登陆成功'; $json['driver_info'] = $driver_info; $json['driver_type'] = $driver_type; } else { $json['code'] = '1'; $json['info'] = '数据库原因,登录失败'; } return $json; } /**获取行程 * @param $param */ public function getTravel($param) { zzcsUtils::validateParams(array('date_type,driver_id,driver_type' => 'empty'), $param); $date_type = isset($param['date_type']) ? trim($param['date_type']) : false;//行程类型 过去past 今日today 未来future $driver_id = isset($param['driver_id']) ? trim($param['driver_id']) : false;//id $driver_type = isset($param['driver_type']) ? trim($param['driver_type']) : false;//司机driver,导游guide $page_size = isset($param['page_size']) ? trim($param['page_size']) : false;//每页展示条数 $current_page = isset($param['current_page']) ? trim($param['current_page']) : false;//当前页 if (!$date_type || !$driver_id || !$driver_type || ($date_type == 'formerly' && (!$page_size || !$current_page))) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } //获取司机或导游的查询条件 if ($driver_type == 'driver') { $select_driver_type = ' b.send_bus_driver_res_id = ' . $driver_id; } else { $select_driver_type = ' b.send_tour_guide_res_id = ' . $driver_id; } //获取时间类型的查询条件 $today = date('Y-m-d', time()); if ($date_type == 'today') { $select_date_type = " m.run_date = '" . $today . "' "; $order_by = " ORDER BY m.run_date asc,m.run_time asc "; } elseif ($date_type == 'past') { $early_date = date('Y-m-d', strtotime("-1 month")); $last_date = date('Y-m-d', strtotime("-1 day")); $order_by = " ORDER BY m.run_date desc,m.run_time asc "; $select_date_type = " m.run_date BETWEEN '" . $early_date . "' AND '" . $last_date . "' "; } else { $order_by = " ORDER BY m.run_date asc,m.run_time asc "; $select_date_type = " m.run_date > '" . $today . "' "; } if ($date_type == 'past') {//往日行程获取分页 $start_row = ($current_page - 1) * $page_size; $limit = " limit " . $start_row . "," . $page_size; } else { $limit = ''; } $sql = "SELECT run_id,run_date,run_time,send_bus_no,people_num,bus_order_id, (SELECT area_id FROM run_station WHERE run_id = temp.run_id AND station_order_id = temp.start_order_id limit 1) AS start_area_id, (SELECT area_name FROM base_area WHERE id = (SELECT area_id FROM run_station WHERE run_id = temp.run_id AND station_order_id = temp.start_order_id limit 1)) AS start_area_name, (SELECT area_id FROM run_station WHERE run_id = temp.run_id AND station_order_id = temp.end_order_id limit 1) AS end_area_id, (SELECT area_name FROM base_area WHERE id = (SELECT area_id FROM run_station WHERE run_id = temp.run_id AND station_order_id = temp.end_order_id limit 1)) AS end_area_name FROM ( SELECT m.run_id,m.run_date,m.run_time,b.send_bus_no,b.bus_order_id, b.real_total_count AS people_num, min(s.station_order_id) AS start_order_id, max(s.station_order_id) AS end_order_id FROM run_main AS m, run_bus AS b, run_station AS s WHERE m.run_id = b.run_id AND m.run_id = s.run_id AND b.cancel_flag = 0 AND " . $select_date_type . " AND " . $select_driver_type . " GROUP BY m.run_id " . $order_by . " ) as temp" . $limit; $run_list = $this->query($sql); if ($date_type == 'past') {//往日行程获取分页 if (count($run_list) == 0) { $json['code'] = '0'; $json['info'] = '没有相关数据信息'; $json['run_list'] = array(); $json['page']['page_size'] = $page_size; $json['page']['current_page'] = $current_page; $json['page']['total_count'] = '0'; $json['page']['total_page'] = '0'; return $json; } $count_sql = "SELECT count(run_id) as total_count FROM ( SELECT m.run_id FROM run_main AS m, run_bus AS b, run_station AS s WHERE m.run_id = b.run_id AND m.run_id = s.run_id AND b.cancel_flag = 0 AND " . $select_date_type . " AND " . $select_driver_type . " GROUP BY m.run_id ) as temp"; $total_count = $this->query($count_sql); $total_count = $total_count[0]['total_count']; $total_page = ceil($total_count / $page_size); $json['code'] = '0'; $json['info'] = '返回列表信息成功'; $json['run_list'] = $run_list; $json['page']['page_size'] = $page_size; $json['page']['current_page'] = $current_page; $json['page']['total_count'] = $total_count; $json['page']['total_page'] = $total_page; return $json; } else { $json['code'] = '0'; $json['info'] = '返回数据成功'; $json['run_list'] = $run_list; return $json; } } /** * 获取车次的线路订单统计信息 * 温依莅 * @param $param */ public function getOrderCount($param) { $json['code'] = '2'; $json['info'] = "该接口暂停使用"; return $json; $run_id = isset($param['run_id']) ? trim($param['run_id']) : false;//班次id 448706 $bus_order_id = isset($param['bus_order_id']) ? trim($param['bus_order_id']) : false;//车号 1 if (!$run_id || !$bus_order_id) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } //首先做一个判断,是单一线路订单还是组合线路订单 $judge_sql = "SELECT c.line_type FROM order_main a INNER JOIN order_main b ON a.order_id = b.PARENT_ORDER_ID LEFT JOIN opera_line c ON a.parent_prod_id = c.line_id WHERE b.run_id = $run_id AND b.RUN_BUS_ORDER_ID = $bus_order_id GROUP BY a.order_id LIMIT 1;"; $res = $this->query($judge_sql); if (false == $res || count($res) == 0) { $json['code'] = '3'; $json['info'] = "参数有误"; return $json; } if ($res[0]['line_type'] != 316) { //如果是单一线路订单 $sql = "select sum(num) as people_num,GROUP_CONCAT(sin,'|') as order_description,tmp.* from (SELECT a.PARENT_ORDER_ID as main_order_id, a.customer_mobile as phone, a.customer_memo, a.sales_man, IFNULL(a.receive_value,0) as receive_value, a.prod_start_station_res_id as res_id, a.prod_start_station_res_name as res_name, a.prod_start_station_seq_id as seq_id, a.run_id, a.run_bus_order_id as bus_no, a.real_passenger_num as change_type, m.line_id, m.line_code AS line_name, count(a.order_id) AS num, CONCAT_WS(',',c.TYPE_NAME,count(a.order_id)) as sin, IFNULL((SELECT check_status from order_check_tickets WHERE order_id = a.order_id AND run_id = run_id AND bus_no = bus_no AND check_station = a.prod_start_station_res_id AND check_seq_id = seq_id LIMIT 1),0) as check_status FROM order_main a LEFT JOIN opera_tickets b ON a.prod_id = b.TICKET_ID LEFT JOIN dict_type c ON b.HUMAN_TYPE = c.id LEFT JOIN opera_line m ON a.PARENT_PROD_ID = m.line_id WHERE a.run_id = $run_id AND a.RUN_BUS_ORDER_ID = $bus_order_id AND a.order_valid_status=1 AND a.order_status<>148 AND m.cancel_flag=0 AND m.if_disabled=0 AND m.is_onsale=1 GROUP BY a.PARENT_ORDER_ID,a.PROD_ID) as tmp group by main_order_id;"; //如果该车次是单一线路订单,获取该车次各单一订单的订单人数 $sql2 = "SELECT b.line_code AS line_codes, count(a.order_id) as num FROM order_main a LEFT JOIN opera_line b ON a.PARENT_PROD_ID = b.line_id WHERE a.run_id = $run_id AND a.RUN_BUS_ORDER_ID = $bus_order_id AND a.order_valid_status=1 AND a.order_status<>148 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1;"; } else { //获取该车次的日期和线路信息,用以区分判断组合线路两日 行程 $get_date_sql = "select a.run_date,b.line_type from run_main a left join opera_line b on a.prod_id=b.line_id where a.run_id=$run_id limit 1"; $res_info = $this->query($get_date_sql); if (!$res_info) { $json['code'] = '3'; $json['info'] = "获取数据失败"; return $json; } //run_date表示该车次出发日期,line_type 接驳256,直通255 $run_date = $res_info[0]['run_date']; $line_type = $res_info[0]['line_type']; if (!$line_type) { $line_type = 255; } //如果是组合线路订单 $sql = "SELECT a.order_id as main_order_id, a.real_passenger_num as change_type, a.customer_mobile as phone, a.customer_memo, a.sales_man, $line_type as line_type, a.prod_start_station_res_name as ori_res_name, (SELECT s.send_bus_no FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id = h.line_id LEFT JOIN run_bus s ON g.run_id = s.RUN_ID AND g.RUN_BUS_ORDER_ID = s.BUS_ORDER_ID WHERE g.PARENT_ORDER_ID = a.order_id AND h.line_type = 255 and g.run_date='$run_date' limit 1) as send_bus_no, IF(a.receive_value=0.00,0,a.receive_value) as receive_value, IFNULL((SELECT g.prod_start_station_res_id FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS res_id, IFNULL((SELECT g.prod_start_station_res_name FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS res_name, IFNULL((SELECT g.prod_start_station_seq_id FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS seq_id, IFNULL((SELECT g.run_id FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS run_id, IFNULL((SELECT o.run_bus_order_id FROM order_main o LEFT JOIN opera_line v ON o.parent_prod_id=v.line_id WHERE o.PARENT_ORDER_ID=a.order_id and o.run_id=$run_id and o.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS bus_no, b.line_id, b.line_code AS line_name, IFNULL(SUBSTRING_INDEX(a.order_description,'|',-1),0) AS people_num, a.order_description, IFNULL((SELECT check_status from order_check_tickets WHERE order_id = a.order_id AND run_id = run_id AND bus_no = bus_no LIMIT 1),0) as check_status FROM order_main a LEFT JOIN opera_line b ON a.parent_prod_id = b.line_id WHERE CONCAT_WS('-',$run_id,$bus_order_id) in (SELECT CONCAT_WS('-',o.run_id,o.RUN_BUS_ORDER_ID) FROM order_main o LEFT JOIN opera_line v ON o.parent_prod_id=v.line_id WHERE o.PARENT_ORDER_ID=a.order_id) AND a.order_valid_status=1 AND a.order_status<>148 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1;"; //如果是该车次是组合订单,获取该车次各组合订单人数 $sql2 = " SELECT b.line_code AS line_codes, sum(IFNULL(SUBSTRING_INDEX(a.order_description,'|',-1),0)) AS num FROM order_main a LEFT JOIN opera_line b ON a.parent_prod_id = b.line_id WHERE CONCAT_WS('-',$run_id,$bus_order_id) in (SELECT CONCAT_WS('-',o.run_id,o.RUN_BUS_ORDER_ID) FROM order_main o LEFT JOIN opera_line v ON o.parent_prod_id=v.line_id WHERE o.PARENT_ORDER_ID=a.order_id) AND a.order_valid_status=1 AND a.order_status<>148 AND b.line_type=316 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1 group by line_codes;"; } zzcsUtils::writeLog($sql); $run_bus_info = $this->query($sql); if (false === $run_bus_info) { $json['code'] = '1'; $json['info'] = '获取车次信息失败'; return $json; } $bus_order_count = $this->query($sql2); if (false === $bus_order_count) { $json['code'] = '1'; $json['info'] = '获取车次订单信息失败'; return $json; } //--处理得到订单具体票种信息(成人,儿童) if ($res[0]['line_type'] != 316) { //单一订单 票种人数处理--原 /*foreach ($run_bus_info as $k => $v) { $tmp_id = $v['main_order_id']; $tmp_sql = "SELECT n.TYPE_NAME as human_type, count(l.order_id) AS num FROM order_main l LEFT JOIN opera_tickets m ON l.prod_id = m.TICKET_ID LEFT JOIN dict_type n ON m.HUMAN_TYPE = n.id WHERE l.PARENT_ORDER_ID = $tmp_id GROUP BY l.PROD_ID"; $tmp_res = $this->query($tmp_sql); if (false === $tmp_res || count($tmp_res) == 0) { $run_bus_info[$k]['ticket_info'] = array(); } else { $run_bus_info[$k]['ticket_info'] = $tmp_res; } }*/ //单一订单 票种人数处理--新 foreach ($run_bus_info as $k => $v) { $temp_str = $v['order_description']; $temp_arr = explode('|', $temp_str, -1); $ticket_list = array(); foreach ($temp_arr as $k1 => $v1) { $arr = explode(',', $v1); $len = count($arr); //$ticket_list[$k]['ticket_id'] = $arr[0]; $ticket_list[$k1]['human_type'] = $arr[$len - 2]; $ticket_list[$k1]['num'] = end($arr); } $run_bus_info[$k]['ticket_info'] = $ticket_list; } } else { //组合订单 票种人数处理 foreach ($run_bus_info as $k => $v) { $temp_str = $v['order_description']; $temp_arr = explode('|', $temp_str, -1); $ticket_list = array(); foreach ($temp_arr as $k1 => $v1) { $arr = explode(',', $v1); $len = count($arr); //$ticket_list[$k]['ticket_id'] = $arr[0]; $ticket_list[$k1]['human_type'] = $arr[$len - 2]; $ticket_list[$k1]['num'] = end($arr); } $run_bus_info[$k]['ticket_info'] = $ticket_list; } } if (false === $bus_order_count) { $json['code'] = '1'; $json['info'] = '获取车次订单信息失败'; return $json; } $json['code'] = '0'; $json['info'] = '返回统计信息成功'; $json['order_count'] = $bus_order_count; return $json; } /** * 获取班次详情 * @param $param */ public function getRunInfo($param) { $run_id = isset($param['run_id']) ? trim($param['run_id']) : false;//班次id 448706 $bus_order_id = isset($param['bus_order_id']) ? trim($param['bus_order_id']) : false;//车号 1 if (!$run_id || !$bus_order_id) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } /*原sql语句*/ /*$sql = "SELECT m.parent_order_id as main_order_id, count(m.order_id) as people_num, m.run_id, m.run_bus_order_id as bus_no, m.prod_start_station_seq_id as seq_id, m.prod_start_station_res_id as res_id, m.prod_start_station_res_name as res_name, m.customer_mobile as phone, m.parent_prod_id as line_id, (SELECT line_code FROM opera_line WHERE line_id = (SELECT parent_prod_id from order_main WHERE order_id = m.parent_order_id limit 1) LIMIT 1) as line_name, IFNULL((SELECT check_status from order_check_tickets WHERE order_id = m.parent_order_id AND run_id = m.run_id AND bus_no = m.run_bus_order_id AND check_station = m.prod_start_station_res_id AND check_seq_id = m.prod_start_station_seq_id LIMIT 1),0) as check_status FROM order_main AS m, run_station AS s WHERE m.run_id = s.run_id AND m.prod_start_station_seq_id = s.station_order_id AND m.cancel_flag = 0 AND m.parent_order_id != 0 AND m.run_id = " . $run_id . " AND m.run_bus_order_id = " . $bus_order_id . " GROUP BY m.prod_start_station_seq_id,m.parent_order_id ORDER BY m.prod_start_station_seq_id";*/ //新sql语句 ---温依莅 //首先做一个判断,是单一线路订单还是组合线路订单 $judge_sql = ''."SELECT c.line_type FROM order_main a INNER JOIN order_main b ON a.order_id = b.PARENT_ORDER_ID LEFT JOIN opera_line c ON a.parent_prod_id = c.line_id WHERE b.run_id = $run_id AND b.RUN_BUS_ORDER_ID = $bus_order_id GROUP BY a.order_id LIMIT 1;"; $res = $this->query($judge_sql); if (false == $res || count($res) == 0) { $json['code'] = '3'; $json['info'] = "参数有误"; return $json; } if ($res[0]['line_type'] != 316) { //如果是单一线路订单 /*$sql = "SELECT a.PARENT_ORDER_ID as main_order_id, a.customer_mobile as phone, a.customer_memo, IFNULL(a.receive_value,0) as receive_value, a.prod_start_station_res_id as res_id, a.prod_start_station_res_name as res_name, a.prod_start_station_seq_id as seq_id, a.run_id, a.run_bus_order_id as bus_no, a.real_passenger_num as change_type, b.line_id, b.line_code AS line_name, count(a.order_id) as people_num, IFNULL((SELECT check_status from order_check_tickets WHERE order_id = a.order_id AND run_id = run_id AND bus_no = bus_no AND check_station = a.prod_start_station_res_id AND check_seq_id = seq_id LIMIT 1),0) as check_status FROM order_main a LEFT JOIN opera_line b ON a.PARENT_PROD_ID = b.line_id WHERE a.run_id = $run_id AND a.RUN_BUS_ORDER_ID = $bus_order_id AND a.order_valid_status=1 AND a.order_status<>148 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1 GROUP BY a.PARENT_ORDER_ID;";*/ $sql = ''."select sum(num) as people_num,GROUP_CONCAT(sin,'|') as order_description,tmp.* from (SELECT a.PARENT_ORDER_ID as main_order_id, IFNULL((select tavern_stay from order_expand_xm where order_id = a.order_id),'') 'tavern_stay', IFNULL((SELECT special_state from order_unusual_process where order_id = a.order_id),'') 'special_state', a.customer_mobile as phone, 0 as group_line_flag, a.customer_memo, a.sales_man, IF(a.receive_value='0.00','0',ifnull(a.receive_value,0)) as receive_value, a.prod_start_station_res_id as res_id, a.prod_start_station_res_name as res_name, a.prod_start_station_seq_id as seq_id, a.run_id, a.run_bus_order_id as bus_no, a.real_passenger_num as change_type, m.line_id, m.line_code AS line_name, count(a.order_id) AS num, CONCAT_WS(',',c.TYPE_NAME,count(a.order_id)) as sin, IFNULL((SELECT check_status from order_check_tickets WHERE order_id = a.order_id AND run_id = run_id AND bus_no = bus_no AND check_station = a.prod_start_station_res_id AND check_seq_id = seq_id LIMIT 1),0) as check_status FROM order_main a LEFT JOIN opera_tickets b ON a.prod_id = b.TICKET_ID LEFT JOIN dict_type c ON b.HUMAN_TYPE = c.id LEFT JOIN opera_line m ON a.PARENT_PROD_ID = m.line_id WHERE a.run_id = $run_id AND a.RUN_BUS_ORDER_ID = $bus_order_id AND a.order_valid_status=1 AND a.order_status<>148 AND m.cancel_flag=0 AND m.if_disabled=0 AND m.is_onsale=1 GROUP BY a.PARENT_ORDER_ID,a.PROD_ID) as tmp group by main_order_id;"; //如果该车次是单一线路订单,获取该车次各单一订单的订单人数 $sql2 = ''."SELECT b.line_code AS line_codes, count(a.order_id) as num FROM order_main a LEFT JOIN opera_line b ON a.PARENT_PROD_ID = b.line_id WHERE a.run_id = $run_id AND a.RUN_BUS_ORDER_ID = $bus_order_id AND a.order_valid_status=1 AND a.order_status<>148 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1;"; } else { //如果是组合线路订单 //获取该车次的日期和线路信息,用以区分判断组合线路两日 行程 $get_date_sql = ''."select a.run_date,b.line_type from run_main a left join opera_line b on a.prod_id=b.line_id where a.run_id=$run_id limit 1"; $res_info = $this->query($get_date_sql); if (!$res_info) { $json['code'] = '3'; $json['info'] = "获取数据失败"; return $json; } //run_date表示该车次出发日期,line_type 接驳256,直通255 $run_date = $res_info[0]['run_date']; $line_type = $res_info[0]['line_type']; if (!$line_type) { //是0或者'' $line_type = 255; } $sql = ''."SELECT a.order_id as main_order_id, IFNULL((select tavern_stay from order_expand_xm where order_id = a.order_id),'') 'tavern_stay', IFNULL((SELECT special_state from order_unusual_process where order_id = a.order_id),'') 'special_state', 1 as group_line_flag, a.real_passenger_num as change_type, a.customer_mobile as phone, a.customer_memo, (DATEDIFF('$run_date',a.prod_start_station_date)+1) as day, a.sales_man, $line_type as line_type, a.prod_start_station_res_name as ori_res_name, (SELECT s.send_bus_no FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id = h.line_id LEFT JOIN run_bus s ON g.run_id = s.RUN_ID AND g.RUN_BUS_ORDER_ID = s.BUS_ORDER_ID WHERE g.PARENT_ORDER_ID = a.order_id AND h.line_type = 255 and g.run_date='$run_date' limit 1) as send_bus_no, IF(a.receive_value='0.00','0',ifnull(a.receive_value,0)) as receive_value, IFNULL((SELECT g.prod_start_station_res_id FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS res_id, IFNULL((SELECT g.prod_start_station_res_name FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS res_name, IFNULL((SELECT g.prod_start_station_seq_id FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS seq_id, IFNULL((SELECT g.run_id FROM order_main g LEFT JOIN opera_line h ON g.parent_prod_id=h.line_id WHERE g.PARENT_ORDER_ID=a.order_id and g.run_id=$run_id and g.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS run_id, IFNULL((SELECT o.run_bus_order_id FROM order_main o LEFT JOIN opera_line v ON o.parent_prod_id=v.line_id WHERE o.PARENT_ORDER_ID=a.order_id and o.run_id=$run_id and o.RUN_BUS_ORDER_ID=$bus_order_id limit 1),0) AS bus_no, b.line_id, b.line_code AS line_name, IFNULL(SUBSTRING_INDEX(a.order_description,'|',-1),0) AS people_num, a.order_description, IFNULL((SELECT check_status from order_check_tickets WHERE order_id = a.order_id AND run_id = run_id AND bus_no = bus_no LIMIT 1),0) as check_status FROM order_main a LEFT JOIN opera_line b ON a.parent_prod_id = b.line_id WHERE CONCAT_WS('-',$run_id,$bus_order_id) in (SELECT CONCAT_WS('-',o.run_id,o.RUN_BUS_ORDER_ID) FROM order_main o LEFT JOIN opera_line v ON o.parent_prod_id=v.line_id WHERE o.PARENT_ORDER_ID=a.order_id) AND a.order_valid_status=1 AND a.order_status<>148 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1;"; //如果是该车次是组合订单,获取该车次各组合订单人数 $sql2 = ''." SELECT b.line_code AS line_codes, sum(IFNULL(SUBSTRING_INDEX(a.order_description,'|',-1),0)) AS num FROM order_main a LEFT JOIN opera_line b ON a.parent_prod_id = b.line_id WHERE CONCAT_WS('-',$run_id,$bus_order_id) in (SELECT CONCAT_WS('-',o.run_id,o.RUN_BUS_ORDER_ID) FROM order_main o LEFT JOIN opera_line v ON o.parent_prod_id=v.line_id WHERE o.PARENT_ORDER_ID=a.order_id) AND a.order_valid_status=1 AND a.order_status<>148 AND b.line_type=316 AND b.cancel_flag=0 AND b.if_disabled=0 AND b.is_onsale=1 group by line_codes;"; } zzcsUtils::writeLog($sql); $run_bus_info = $this->query($sql); if (false === $run_bus_info) { $json['code'] = '1'; $json['info'] = '获取车次信息失败'; return $json; } $bus_order_count = $this->query($sql2); if (false === $bus_order_count) { $json['code'] = '1'; $json['info'] = '获取车次订单信息失败'; return $json; } //--处理得到订单具体票种信息(成人,儿童) if ($res[0]['line_type'] != 316) { //单一订单 票种人数处理--原 /*foreach ($run_bus_info as $k => $v) { $tmp_id = $v['main_order_id']; $tmp_sql = "SELECT n.TYPE_NAME as human_type, count(l.order_id) AS num FROM order_main l LEFT JOIN opera_tickets m ON l.prod_id = m.TICKET_ID LEFT JOIN dict_type n ON m.HUMAN_TYPE = n.id WHERE l.PARENT_ORDER_ID = $tmp_id GROUP BY l.PROD_ID"; $tmp_res = $this->query($tmp_sql); if (false === $tmp_res || count($tmp_res) == 0) { $run_bus_info[$k]['ticket_info'] = array(); } else { $run_bus_info[$k]['ticket_info'] = $tmp_res; } }*/ //单一订单 票种人数处理--新 foreach ($run_bus_info as $k => $v) { $temp_str = $v['order_description']; $temp_arr = explode('|', $temp_str, -1); $ticket_list = array(); foreach ($temp_arr as $k1 => $v1) { $arr = explode(',', $v1); $len = count($arr); //$ticket_list[$k]['ticket_id'] = $arr[0]; $ticket_list[$k1]['human_type'] = $arr[$len - 2]; $ticket_list[$k1]['num'] = end($arr); } $run_bus_info[$k]['ticket_info'] = $ticket_list; } } else { //组合订单 票种人数处理 foreach ($run_bus_info as $k => $v) { $temp_str = $v['order_description']; $temp_arr = explode('|', $temp_str, -1); $ticket_list = array(); foreach ($temp_arr as $k1 => $v1) { $arr = explode(',', $v1); $len = count($arr); //$ticket_list[$k]['ticket_id'] = $arr[0]; $ticket_list[$k1]['human_type'] = $arr[$len - 2]; $ticket_list[$k1]['num'] = end($arr); } $run_bus_info[$k]['ticket_info'] = $ticket_list; } } //按始发站重排数组// if (count($run_bus_info) > 0) { $run_bus_array = array(); foreach ($run_bus_info as $k => $v) { if (!isset($run_bus_array[$v['res_id']]['info'])) { $run_bus_array[$v['res_id']]['info']['res_id'] = $v['res_id']; $run_bus_array[$v['res_id']]['info']['res_name'] = $v['res_name']; } $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['tavern_stay'] = $v['tavern_stay']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['special_state'] = $v['special_state']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['change_type'] = $v['change_type']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['order_id'] = $v['main_order_id']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['run_id'] = $v['run_id']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['res_id'] = $v['res_id']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['bus_order_id'] = $v['bus_no']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['seq_id'] = $v['seq_id']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['phone'] = $v['phone']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['customer_memo'] = $v['customer_memo']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['day'] = $v['day']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['group_line_flag'] = $v['group_line_flag']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['sales_man'] = $v['sales_man']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['line_type'] = $v['line_type']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['ori_res_name'] = $v['ori_res_name']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['send_bus_no'] = $v['send_bus_no']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['receive_value'] = $v['receive_value']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['people_num'] = $v['people_num']; //如果是二日游,这里把line_name改为eg:z(a+e)(第二天) if ($v['day'] == 2) { $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['line_name'] = $v['line_name'] . '(第二日)'; } else { $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['line_name'] = $v['line_name']; } $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['check_status'] = $v['check_status']; $run_bus_array[$v['res_id']]['order_list'][$v['main_order_id']]['ticket_info'] = $v['ticket_info']; } $run_bus_array = array_merge($run_bus_array); foreach ($run_bus_array as $k => $v) { $run_bus_array[$k]['order_list'] = array_merge($run_bus_array[$k]['order_list']); } foreach ($run_bus_array as $res_k => $res_v) { $up_car = 0; $not_on = 0; $count_people = 0; foreach ($res_v['order_list'] as $order_k => $order_v) { if ($order_v['change_type'] == -1) { $count_people += $order_v['people_num']; } else { $count_people += $order_v['change_type']; } if ($order_v['check_status'] == 1) { if ($order_v['change_type'] == -1) { $up_car += $order_v['people_num']; } else { $up_car += $order_v['change_type']; } } else { $not_on += $order_v['people_num']; } } $run_bus_array[$res_k]['info']['up_car'] = $up_car; $run_bus_array[$res_k]['info']['not_on'] = $not_on; $run_bus_array[$res_k]['info']['count_people'] = $count_people; } } else { $run_bus_array = array(); $bus_order_count = array(); } //---按线路重排数组--// if (count($run_bus_info) > 0) { foreach ($run_bus_info as $k => $v) { if (!isset($bus_count_array[$v['line_name']]['info'])) { $bus_count_array[$v['line_name']]['info']['line_name'] = $v['line_name']; } $bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['change_type'] = $v['change_type']; $bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['order_id'] = $v['main_order_id']; $bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['day'] = $v['day']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['run_id'] = $v['run_id']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['res_id'] = $v['res_id']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['bus_order_id'] = $v['bus_no']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['seq_id'] = $v['seq_id']; $bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['phone'] = $v['phone']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['customer_memo'] = $v['customer_memo']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['sales_man'] = $v['sales_man']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['line_type'] = $v['line_type']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['ori_res_name'] = $v['ori_res_name']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['send_bus_no'] = $v['send_bus_no']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['receive_value'] = $v['receive_value']; $bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['people_num'] = $v['people_num']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['line_name'] = $v['line_name']; //$bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['check_status'] = $v['check_status']; $bus_count_array[$v['line_name']]['order_list'][$v['main_order_id']]['ticket_info'] = $v['ticket_info']; } $bus_count_array = array_merge($bus_count_array); foreach ($bus_count_array as $k => $v) { $bus_count_array[$k]['order_list'] = array_merge($bus_count_array[$k]['order_list']); } foreach ($bus_count_array as $res_k => $res_v) { $real_people = 0; $ori_people = 0; foreach ($res_v['order_list'] as $order_k => $order_v) { if ($order_v['change_type'] == -1) { $real_people += $order_v['people_num']; } else { $real_people += $order_v['change_type']; } $ori_people += $order_v['people_num']; } $bus_count_array[$res_k]['info']['real_people'] = $real_people; $bus_count_array[$res_k]['info']['ori_people'] = $ori_people; } } else { $bus_count_array = array(); $bus_order_count = array(); } $bus_count_array2 = array_values($bus_count_array); $json['code'] = '0'; $json['info'] = '返回详情成功'; $json['list'] = $run_bus_array; $json['order_count'] = $bus_count_array2; //$json['list_test'] = $run_bus_info; return $json; } /** * 检票 * @param $param */ public function checkTicket($param) { $run_id = isset($param['run_id']) ? trim($param['run_id']) : false;//班次id 448706 $bus_order_id = isset($param['bus_order_id']) ? trim($param['bus_order_id']) : false;//车号 1 $driver_id = isset($param['driver_id']) ? trim($param['driver_id']) : false;//司机id $check_order_str = isset($param['check_order_str']) ? trim($param['check_order_str']) : false;//检票字符串 $check_time = date('Y-m-d H:i:s', time()); if (!$run_id || !$bus_order_id || !$driver_id || !$check_order_str) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $check_order_str = substr($check_order_str, 1, -1); $check_order_array = explode('}{', $check_order_str); foreach ($check_order_array as $k => $v) { $v = explode(',', $v); $one = array(); $one['order_id'] = $v[0]; $one['seq_id'] = $v[1]; $one['res_id'] = $v[2]; $check_order_array[$k] = $one; } $sql = "INSERT INTO order_check_tickets ( order_id, run_id, bus_no, check_status, check_time, check_station, check_seq_id, check_user_id )values"; foreach ($check_order_array as $k => $v) { $value_array[] = "(" . $v['order_id'] . "," . $run_id . "," . $bus_order_id . ",1,'" . $check_time . "'," . $v['res_id'] . "," . $v['seq_id'] . "," . $driver_id . ")"; } $sql .= implode(',', $value_array); $result = $this->exec($sql); if ($result) { $json['code'] = '0'; $json['info'] = '检票成功'; } else { $json['code'] = '1'; $json['info'] = '数据库原因,检票失败'; } return $json; } /** * 提交版本 * @param $param */ public function submitVersion($param) { $driver_id = isset($param['driver_id']) ? trim($param['driver_id']) : false;//司机id $div = isset($param['div']) ? trim($param['div']) : false; $driver_name = isset($param['driver_name']) ? trim($param['driver_name']) : false;//司机名字 $version_code = isset($param['version_code']) ? trim($param['version_code']) : false;//版本号 if (!$driver_id || !$div || !$driver_name || !$version_code) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $update_time = date('Y-m-d H:i:s', time()); $sql = "SELECT id FROM driver_app_update_status_xiamen WHERE driver_res_id = " . $driver_id . " AND `div` = '" . $div . "' LIMIT 1"; $check_version = $this->query($sql); if (count($check_version) == 1) { $update_sql = "UPDATE driver_app_update_status_xiamen SET driver_update_time = '" . $update_time . "', version_code_now = '" . $version_code . "' WHERE id = " . $check_version[0]['id']; } else { $update_sql = "INSERT INTO driver_app_update_status_xiamen ( driver_res_id, `div`, driver_update_time, driver_name, version_code_now ) VALUE(" . $driver_id . ",'" . $div . "','" . $update_time . "','" . $driver_name . "','" . $version_code . "')"; } $result = $this->exec($update_sql); if ($result) { $json['code'] = '0'; $json['info'] = '版本提交成功'; } else { $json['code'] = '1'; $json['info'] = '数据库原因,版本提交失败'; } return $json; } /** * 更新版本 * @param $param */ public function updateVersion($param) { $download_address = isset($param['download_address']) ? trim($param['download_address']) : false;//更新地址 $version_code = isset($param['version_code']) ? trim($param['version_code']) : false;//最新版本号 if (!$download_address || !$version_code) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $update_time = date('Y-m-d H:i:s', time()); $sql = "UPDATE driver_app_update_status_xiamen SET publish_update_time = '" . $update_time . "', download_address = '" . $download_address . "', version_code = '" . $version_code . "'"; $result = $this->exec($sql); if ($result) { $json['code'] = '0'; $json['info'] = '版本更新成功'; } else { $json['code'] = '1'; $json['info'] = '数据库原因,版本更新失败'; } return $json; } /** * 获取版本 */ public function getVersion($param) { $driver_id = isset($param['driver_id']) ? trim($param['driver_id']) : false;//司机id $div = isset($param['div']) ? trim($param['div']) : false; if (!$driver_id || !$div) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $sql = "SELECT download_address, version_code FROM driver_app_update_status_xiamen WHERE driver_res_id = " . $driver_id . " AND `div` = " . $div . " LIMIT 1"; $info = $this->query($sql); if (count($info) == 0) { $json['code'] = '1'; $json['info'] = '请上传版本号'; } else { $json['code'] = '0'; $json['info'] = '获取最新版本号成功'; $json['download_address'] = $info[0]['download_address']; $json['version_code'] = $info[0]['version_code']; } return $json; } /** * 更新行程 * @param $param */ public function updateRoute($param) { $driver_id = isset($param['driver_id']) ? trim($param['driver_id']) : false;//司机id $div = isset($param['div']) ? trim($param['div']) : false;//司机id $pos_x = isset($param['pos_x']) ? trim($param['pos_x']) : false; $pos_y = isset($param['pos_y']) ? trim($param['pos_y']) : false; $update_time = date('Y-m-d H:i:s', time()); if (!$driver_id || !$pos_x || !$pos_y || !$div) { $json['code'] = '2'; $json['info'] = "缺少必要参数"; return $json; } $sql = "INSERT INTO run_bus_pos ( phone_serial_no, log_time, pos_x, pos_y, driver_id ) VALUE ('" . $div . "','" . $update_time . "','" . $pos_x . "','" . $pos_y . "'," . $driver_id . ") ON DUPLICATE KEY UPDATE log_time = '" . $update_time . "', pos_x = '" . $pos_x . "', pos_y = '" . $pos_y . "'"; $result = $this->query($sql); if ($result) { $json['code'] = '0'; $json['info'] = '更新行程成功'; } else { $json['code'] = '1'; $json['info'] = '数据库原因,更新行程失败'; } return $json; } /** * 更新乘客数 * @param $param */ public function updatePassenerNum($param) { $valid = zzcsUtils::validateParams( array( 'order_id,passener_num,run_id,bus_order_id,user_type,order_num,old_num,group_line_flag' => 'number' ), $param); //参数验证 if (!$valid['status']) { $result['code'] = (string)$valid['status']; $result['info'] = $valid['info']; return $result; } $order_id = $param['order_id'];//主订单id $passener_num = $param['passener_num'];//新真实上车人数 $run_id = $param['run_id'];//班次id $bus_order_id = $param['bus_order_id'];//车次号 $user_type = $param['user_type'];//用户类型 1司机,2导游 $order_num = $param['order_num'];//订单人数 $old_num = $param['old_num'];//原真实上车人数 $group_line_flag = $param['group_line_flag'];//1表示组合线路订单0表示单一线路订单 $phone = empty($param['phone']) ? '' : $param['phone'];//司机或导游手机号 $special_state = empty($param['special_state']) ? '' : $param['special_state'];//订单特殊变更备注 //获取其他需要插入driver_record 表的数据 $sql_info = '' . "select b.run_date,a.send_bus_res_id,a.send_bus_no,a.send_bus_driver_res_id,a.send_driver_name,send_driver_mobile,a.send_tour_guide_res_id,a.send_tour_guide_name,a.send_tour_guide_mobile from run_bus a left join run_main b on a.run_id=b.run_id where a.run_id=$run_id and a.bus_order_id=$bus_order_id;"; $tmp = $this->query($sql_info); if (!$tmp) { $json['code'] = '1'; $json['info'] = '获取车次信息失败'; return $json; } //修改run_bus人数 $sql_runbus = '' . " SELECT ORDER_ID,ORDER_DESCRIPTION,REAL_PASSENGER_NUM,RUN_ID,RUN_BUS_ORDER_ID FROM order_main where ORDER_ID = {$order_id} OR PARENT_ORDER_ID = {$order_id} ORDER BY ORDER_ID "; $result = $this->query($sql_runbus); if (!$result) { $json['code'] = '1'; $json['info'] = '实际上车人数更新失败'; return $json; } $orgin_num = 0; $run_bus_array = array(); foreach ($result as $sub_order_info) { if ($sub_order_info["RUN_ID"] == 0) { $order_des = $sub_order_info["ORDER_DESCRIPTION"]; $order_des_array = explode("|", $order_des); $order_num_index = count($order_des_array) - 1; if (strlen($order_des_array[$order_num_index]) > 0) { $orgin_num = $order_des_array[$order_num_index]; } else { $main_des_array = explode(",", $order_des_array[0]); $order_num_index = count($main_des_array) - 1; $orgin_num = $main_des_array[$order_num_index]; } //如果是第二次修改,则按主订单real_passenger_num来判断orgin_num----温依莅 if ($sub_order_info['REAL_PASSENGER_NUM'] != -1) { $orgin_num = $sub_order_info['REAL_PASSENGER_NUM']; } continue; } if (!isset($run_bus_array[$sub_order_info["RUN_ID"]])) { $run_bus_array[$sub_order_info["RUN_ID"]] = $sub_order_info["RUN_BUS_ORDER_ID"]; } } $update_sql = ''; $update_time = date('Y-m-d H:i:s', time()); if ($passener_num != $orgin_num) {//当人数变更时 if ($passener_num > $orgin_num) { $base_sql = '' . " UPDATE run_bus SET REAL_TOTAL_COUNT = REAL_TOTAL_COUNT +" . ($passener_num - $orgin_num) . " WHERE "; } else { $base_sql = '' . " UPDATE run_bus SET REAL_TOTAL_COUNT = REAL_TOTAL_COUNT -" . ($orgin_num - $passener_num) . " WHERE "; } $update_sql .= $base_sql . " RUN_ID=$run_id AND BUS_ORDER_ID=$bus_order_id;"; $update_sql .= '' . "UPDATE order_main SET real_passenger_num = " . $passener_num . " WHERE order_id = {$order_id} OR parent_order_id = {$order_id};"; //把相关数据插入driver_record记录表 $update_sql .= '' . "REPLACE INTO driver_record (CREATE_TIME, ORDER_ID, RUN_ID, RUN_DATE, BUS_ORDER_ID, USER_TYPE, SEND_BUS_RES_ID, SEND_BUS_NO, SEND_BUS_DRIVER_RES_ID, SEND_DRIVER_NAME, SEND_DRIVER_MOBILE, SEND_TOUR_GUIDE_RES_ID, SEND_TOUR_GUIDE_NAME, SEND_TOUR_GUIDE_MOBILE, GROUP_LINE_FLAG, ORDER_NUM, OLD_NUM, NEW_NUM) VALUES (NOW(),$order_id,$run_id,'" . $tmp[0]['run_date'] . "',$bus_order_id,$user_type" . "," . $tmp[0]['send_bus_res_id'] . ",'" . $tmp[0]['send_bus_no'] . "'," . $tmp[0]['send_bus_driver_res_id'] . ",'" . $tmp[0]['send_driver_name'] . "','" . $tmp[0]['send_driver_mobile'] . "'," . $tmp[0]['send_tour_guide_res_id'] . ",'" . $tmp[0]['send_tour_guide_name'] . "','" . $tmp[0]['send_tour_guide_mobile'] . "',$group_line_flag,$order_num,$old_num,$passener_num);"; } $update_sql .= '' . "replace into order_unusual_process(`order_id`, `special_state`,`submitter_phone`,`create_time`) VALUES({$order_id},'{$_POST['special_state']}','{$phone}','{$update_time}');"; zzcsUtils::writeLog($update_sql); if ($update_sql == '' || $this->exec($update_sql)) { $json['code'] = '0'; $json['info'] = '实际上车人数更新成功'; } else { $json['code'] = '1'; $json['info'] = '实际上车人数更新失败'; } return $json; } } ?>