|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
-
- /**
- * Created by PhpStorm.
- * User: fuhc
- * Date: 2017/4/13
- * Time: 11:19
- */
- require_once __DIR__.'/../HotelLib.php';
-
-
- class HTOrderDetailLevelLib extends HotelLib
- {
-
- function getOrderDetail($param){
-
- $order_id = $param['order_id']?$param['order_id']:"";
- if(""==$order_id){
- $data['code']="16";
- $data['info']="缺少订单号!";
- return $data;
- }
- // order_level 对酒店订单:订单操作状态(0:确认单 1:修改单 2:取消单)
- $sql = "select a.outside_sale_org_id,(select supplier_name from base_supplier where id = outside_sale_org_id ) as outside_sale_org_name,parent_order_id,order_price,base_price,
- outside_order_no,ifnull(order_description,''),order_status,(select type_name from dict_type where id = order_status) as order_status_name,parent_prod_name as hotel_name,prod_name as room_name,
- run_time,prod_start_station_date as start_date,prod_end_station_date as end_date,customer_name,customer_mobile,customer_memo,order_confirm_code,stock_type,profit_value,total_commission,
- a.docking_type,(select type_name from dict_type where id=a.docking_type) as docking_type_desc,
- a.run_date as check_in_date,
- a.create_time as create_order_time,
- a.parent_prod_id as hotel_id,
- a.prod_id as room_type,
- ifnull((select distinct b.base_room_type from order_main as a inner join run_hotel_sub_room as b on b.hotel_id = a.parent_prod_id and b.room_type=a.prod_id and b.run_date = a.run_date
- where parent_order_id = '{$order_id}'),'') as base_room_type,
- a.channel_order_status,ifnull((select type_name from dict_type where id = a.channel_order_status),'') as channel_order_status_desc,
- 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
- where (order_id = $order_id or parent_order_id in ($order_id)) and a.order_prod_type in (25,26) and cancel_flag = 0";
- writeLog('sql='.$sql);
- $rowset = $this->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'];
- }
-
- }
|