="'.$today.'"'; }elseif ($type==147){ $today='<"'.$today.'"'; } $sql=''."SELECT v.PARENT_ORDER_ID AS order_id, max(v.RUN_DATE) 'rundate', v.order_prod_type AS type, min( CONCAT(v.RUN_DATE, ' ', v.RUN_TIME) ) 'mt' FROM order_main v, ( SELECT order_id FROM order_main WHERE member_id = $userId AND parent_order_id = 0 UNION ALL SELECT order_id FROM order_weixin_bond WHERE weixin_open_id = $userId ) v1 WHERE v.PARENT_ORDER_ID = v1.order_id AND v.order_status in (146,147) GROUP BY v.PARENT_ORDER_ID HAVING rundate $today ORDER BY mt DESC LIMIT $page,$limit"; $result=$this->fetchAll($sql); return $result; } /** * Function Description:获取普通订单数据 * Function Name: normalDate * @param $normalOrderId * * @return array * * @author 娄梦宁 */ public function normalDate($normalOrderId){ $sql=""."SELECT order_prod_type type, run_date, parent_order_id as order_id, prod_start_station_time as run_time, prod_start_station_res_name AS start_res_name, prod_end_station_res_name AS end_res_name, ( prod_end_station_time_minutes - prod_start_station_time_minutes ) minutes, prod_start_station_area_name AS start_area_name, prod_end_station_area_name AS end_area_name FROM order_main WHERE parent_order_id IN ($normalOrderId) GROUP BY parent_order_id ORDER BY run_date DESC, run_time DESC"; $result=$this->fetchAll($sql); return $result; } /** * Function Description:获取周边游订单数据 * Function Name: aroundDate * @param $aroundOrderId * * @return array * * @author 娄梦宁 */ public function aroundDate($aroundOrderId){ $sql=''."SELECT a.order_id, ifnull(d.PROPERTY, '') AS line_add, a.PROD_START_STATION_DATE AS run_date, a.PROD_START_STATION_TIME AS run_time, a.order_prod_type AS type, a.parent_prod_name as line_name FROM order_main a LEFT JOIN opera_line_group b ON a.parent_prod_id = b.line_id LEFT JOIN base_resource_property d ON b.end_res_id = d.res_id WHERE a.CANCEL_FLAG = 0 AND b.CANCEL_FLAG = 0 AND b.day_num = 1 AND b.seq_id = 1 AND d.CANCEL_FLAG = 0 AND d.TYPE_ID = 279 AND a.order_id IN ($aroundOrderId) GROUP BY a.order_id"; $result=$this->fetchAll($sql); return $result; } /** * Function Description:电子票页面数据提取 * Function Name: getEticket * @param $arr * * @return array * * @author 娄梦宁 */ public function getEticket($arr){ $order_id=$arr['order_id']; $sql=''."SELECT c.run_date AS date, a.order_id, c.PROD_START_STATION_res_NAME AS start_res_name, c.PROD_end_STATION_res_NAME AS end_res_name, c.prod_start_station_time AS time, c.PROD_START_STATION_AREA_NAME AS start_area_name, c.PROD_END_STATION_AREA_NAME AS end_area_name, substring_index(substring_index(a.ORDER_DESCRIPTION, ',' ,- 1),'|',1) AS count, c.prod_name, a.customer_name, a.customer_mobile FROM order_main a LEFT JOIN order_main c ON c.PARENT_ORDER_ID = a.order_id WHERE a.cancel_flag = 0 AND c.CANCEL_FLAG = 0 AND a.PARENT_ORDER_ID = 0 and a.order_id=$order_id GROUP BY a.order_id LIMIT 1 "; $result=$this->fetchRow($sql); return $result; } /** * Function Description:查询是否检票 * Function Name: isCheck * @param $order_id * * @return array * * @author 娄梦宁 */ public function isCheck($order_id){ $sql=''."select id from order_check_tickets where order_id=$order_id"; $result=$this->fetchRow($sql); return $result; } /** * Function Description:获取手机号下的所有订单 * Function Name: getAllOrder * @param $tel * * @return array * * @author 娄梦宁 */ public function getAllOrder($tel){ $sql=''."select order_id from order_main where CUSTOMER_MOBILE=$tel and cancel_flag=0 and parent_order_id=0 and order_status in(146,147)"; $result=$this->fetchAll($sql); return $result; } /** * Function Description:绑定订单 * Function Name: tripBind * @param $arr * * @return int * * @author 娄梦宁 */ public function tripBind($arr){ $tel=$arr['tel'] ; $userId=$arr['userId']; $nowtime=date('Y-m-d h:i:s',time()); $sql=''."INSERT INTO `order_weixin_bond` ( `order_id`, `tel`, `weixin_open_id`, `bond_time` ) SELECT ORDER_ID, '$tel', '$userId', '$nowtime' FROM order_main a WHERE CUSTOMER_MOBILE = '$tel' AND order_id NOT IN ( SELECT order_id FROM order_weixin_bond WHERE weixin_open_id = '$userId' ) AND cancel_flag = 0 AND parent_order_id = 0 and order_status in (146,147) "; $result=$this->execSql($sql); return $result; } /** * Function Description:更新订单表menber_id为当前id * Function Name: uptOrder * @param $orderStr * @param $userId * * @return array * * @author 娄梦宁 */ public function uptOrder($orderStr,$userId){ $data = array( 'MEMBER_ID' => $userId ); $result=$this->update($data,"MEMBER_ID=0 and (order_id in($orderStr) or parent_order_id in ($orderStr))"); return $result; } }