DBTool->queryBySql($sql); $data['code'] = $rowset['code']; $data['info'] = $rowset['info']; $data['data'] = $rowset['rowset']; $sql = "select a.id as comment_id, a.order_id, a.comment_type, case a.comment_type when 0 then '内部备注' when 1 then '公共备注' end as comment_type_desc, a.comment_txt, a.create_user_id as user_id, ifnull((select true_name from base_user where id = a.create_user_id),'') as user_true_name, a.create_user_id, a.create_time from order_comment as a where a.order_id = $order_id and a.comment_type in (0,1) and a.cancel_flag = 0"; writeLog(__FUNCTION__.'sql='.$sql); $rowset = $this->DBTool->queryBySql($sql); $data['order_comment'] = $rowset['rowset']; $sql = "select order_id,order_status,create_time,(select type_name from dict_type where a.ORDER_STATUS = id ) as order_status_name from order_ht_status_log a where order_id = $order_id and cancel_flag = 0"; $rowset = $this->DBTool->queryBySql($sql); $data['order_status'] = $rowset['rowset']; $sql = "select count(*) as total,stock_type,order_id,order_description,run_date,parent_order_id,prod_id,count(*)*order_price as all_price,prod_name,order_price,base_price,(order_price - base_price)*count(*) as benefit,run_time as checkin_time,order_confirm_code,outside_sale_org_id from order_main where parent_order_id=$order_id and cancel_flag = 0 and order_prod_type in (25,26) group by run_date "; $rowset = $this->DBTool->queryBySql($sql); if($rowset['code']!="0")return array("code"=>"20","info"=>"查询错误"); $data['hotel_child_order_detail'] = $rowset['rowset']; $sql = "select order_status,order_description,outside_order_no,parent_prod_name as hotel_name,order_confirm_code,refuse_flag, prod_name as product_name,prod_start_station_date as start_date,prod_end_station_date as end_date, run_date,run_time as checkin_time,customer_memo,customer_name,customer_mobile,order_price,create_time,order_pay_time from order_main where order_prod_type in (25,26) and order_id = $order_id and cancel_flag = 0 and parent_order_id = 0 or outside_order_no = $order_id "; $rowset = $this->DBTool->queryBySql($sql); if($rowset['code']!="0")return array("code"=>"20","info"=>"查询错误"); $data['hotel_order_detail'][0] = array_change_key_case($rowset['rowset'][0], CASE_LOWER); return $data; } function getExportInfo($param) { $order_id = $param['order_id']; $sql = "select A.order_status,F.true_name,A.order_description,A.outside_order_no,A.parent_prod_name as hotel_name,A.order_confirm_code, A.prod_name as product_name,A.prod_start_station_date as start_date,A.prod_end_station_date as end_date, A.run_date,A.run_time as checkin_time,A.customer_memo,A.customer_name,A.customer_mobile,A.order_price,A.create_time,A.order_pay_time,B.CONFIRM_FROM as org_id,C.org_name, (SELECT type_name from dict_type WHERE ID=D.SETT_TYPE) as type_name, (SELECT type_name from dict_type WHERE ID=D.SETT_FREQUENCY) as type_time, A.order_level,case A.order_level when '0' then '确认单' when '1' then '修改单' when '2' then '取消单' end as order_level_desc from order_main A LEFT JOIN opera_hotel B ON A.PARENT_PROD_ID=B.hotel_id LEFT JOIN base_confirm_organization C on B.CONFIRM_FROM=C.ID LEFT JOIN base_supplier D ON B.SUPPLIER_ID=D.ID LEFT JOIN base_user F ON A.CREATE_USER_ID=F.ID where (A.order_id = '{$order_id}' or A.outside_order_no = '{$order_id}') and A.cancel_flag = 0 and A.parent_order_id = 0 and C.CANCEL_FLAG=0 AND D.CANCEL_FLAG=0 and A.order_prod_type in (25,26)"; $rowset = $this->DBTool->queryBySql($sql); $data['export_info'] = $rowset['rowset'][0]; $sql = "select a.id as comment_id, a.order_id, a.comment_type, case a.comment_type when 0 then '内部备注' when 1 then '公共备注' end as comment_type_desc, a.comment_txt, ifnull((select true_name from base_user where id = a.create_user_id),'') as create_true_name, a.create_user_id, a.create_time from order_comment as a where a.order_id = $order_id and a.comment_type=1 and a.cancel_flag = 0"; $rowset = $this->DBTool->queryBySql($sql); $data['order_comment']=$rowset['rowset']; return $data; } function getOrderLog($param){ $order_id = isset($param['order_id'])?$param['order_id']:""; $log_type = isset($param['log_type'])?$param['log_type']:"1,2,3"; if(""==$order_id){ $data['code']="16"; $data['info']="缺少订单号!"; return $data; } $sql = "SELECT DISTINCT u.id,IFNULL(u.user_name,'') AS user_name,IFNULL(u.true_name,'') AS true_name FROM opera_hotel_log l INNER JOIN base_user u on l.create_user_id = u.id where LOG_TYPE in ($log_type) and order_id = $order_id"; writeLog('sql= ' . $sql); $rowset = $this->DBTool->queryBySql($sql); $data = array(); $data['code'] = $rowset['code']; $data['info'] = $rowset['info']; $data['all_updater'] = $rowset['rowset']; return $data; } function getOrderOrgList() { $sql = "select a.id as org_id ,a.supplier_name as org_name from base_supplier a inner join base_supplier_sale b on a.id = b.supplier_id where a.cancel_flag = 0 and a.supplier_type = 301 and a.is_disabled = 0 and b.parent_type = 25 and b.cancel_flag=0"; writeLog('sql= ' . $sql); $org_list = $this->DBTool->queryBySql($sql); $data['code'] = $org_list['code']; $data['info'] = $org_list['info']; $data['org_list'] = $org_list['rowset']; return $data; } function getTrueName($user_id=0) { $user_id=$user_id==0?1:$user_id; $sql = "select ifnull(true_name,'') as true_name from base_user where ID=$user_id AND CANCEL_FLAG=0 LIMIT 1"; $rowset = $this->DBTool->queryBySql($sql); return isset($rowset['rowset'][0]['true_name'])?$rowset['rowset'][0]['true_name']:""; } function getPrice($order_id) { $sql="select count(*) as num ,prod_start_station_date,A.base_price*count(*) as base_price from order_main as A LEFT JOIN run_hotel as B on A.run_id=B.id WHERE A.cancel_flag = 0 and A.parent_order_id='$order_id' GROUP BY PROD_START_STATION_DATE"; $rowset = $this->DBTool->queryBySql($sql); return $rowset['rowset']; } }