You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

163 lines
9.2 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: fuhc
  5. * Date: 2017/4/13
  6. * Time: 11:19
  7. */
  8. require_once __DIR__.'/../HotelLib.php';
  9. class HTOrderDetailLevelLib extends HotelLib
  10. {
  11. function getOrderDetail($param){
  12. $order_id = $param['order_id']?$param['order_id']:"";
  13. if(""==$order_id){
  14. $data['code']="16";
  15. $data['info']="缺少订单号!";
  16. return $data;
  17. }
  18. // order_level 对酒店订单:订单操作状态(0:确认单 1:修改单 2:取消单)
  19. $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,
  20. 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,
  21. 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,
  22. a.docking_type,(select type_name from dict_type where id=a.docking_type) as docking_type_desc,
  23. a.run_date as check_in_date,
  24. a.create_time as create_order_time,
  25. a.parent_prod_id as hotel_id,
  26. a.prod_id as room_type,
  27. 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
  28. where parent_order_id = '{$order_id}'),'') as base_room_type,
  29. a.channel_order_status,ifnull((select type_name from dict_type where id = a.channel_order_status),'') as channel_order_status_desc,
  30. a.order_level,case a.order_level when '0' then '确认单'
  31. when '1' then '修改单'
  32. when '2' then '取消单' end as order_level_desc
  33. from order_main a
  34. where (order_id = $order_id or parent_order_id in ($order_id)) and a.order_prod_type in (25,26) and cancel_flag = 0";
  35. writeLog('sql='.$sql);
  36. $rowset = $this->DBTool->queryBySql($sql);
  37. $data['code'] = $rowset['code'];
  38. $data['info'] = $rowset['info'];
  39. $data['data'] = $rowset['rowset'];
  40. $sql = "select
  41. a.id as comment_id,
  42. a.order_id,
  43. a.comment_type,
  44. case a.comment_type when 0 then '内部备注'
  45. when 1 then '公共备注' end as comment_type_desc,
  46. a.comment_txt,
  47. a.create_user_id as user_id,
  48. ifnull((select true_name from base_user where id = a.create_user_id),'') as user_true_name,
  49. a.create_user_id,
  50. a.create_time
  51. from order_comment as a where a.order_id = $order_id and a.comment_type in (0,1) and a.cancel_flag = 0";
  52. writeLog(__FUNCTION__.'sql='.$sql);
  53. $rowset = $this->DBTool->queryBySql($sql);
  54. $data['order_comment'] = $rowset['rowset'];
  55. $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";
  56. $rowset = $this->DBTool->queryBySql($sql);
  57. $data['order_status'] = $rowset['rowset'];
  58. $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
  59. from order_main where parent_order_id=$order_id and cancel_flag = 0 and order_prod_type in (25,26) group by run_date ";
  60. $rowset = $this->DBTool->queryBySql($sql);
  61. if($rowset['code']!="0")return array("code"=>"20","info"=>"查询错误");
  62. $data['hotel_child_order_detail'] = $rowset['rowset'];
  63. $sql = "select order_status,order_description,outside_order_no,parent_prod_name as hotel_name,order_confirm_code,refuse_flag,
  64. prod_name as product_name,prod_start_station_date as start_date,prod_end_station_date as end_date,
  65. run_date,run_time as checkin_time,customer_memo,customer_name,customer_mobile,order_price,create_time,order_pay_time
  66. 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 ";
  67. $rowset = $this->DBTool->queryBySql($sql);
  68. if($rowset['code']!="0")return array("code"=>"20","info"=>"查询错误");
  69. $data['hotel_order_detail'][0] = array_change_key_case($rowset['rowset'][0], CASE_LOWER);
  70. return $data;
  71. }
  72. function getExportInfo($param)
  73. {
  74. $order_id = $param['order_id'];
  75. $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,
  76. A.prod_name as product_name,A.prod_start_station_date as start_date,A.prod_end_station_date as end_date,
  77. 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,
  78. (SELECT type_name from dict_type WHERE ID=D.SETT_TYPE) as type_name,
  79. (SELECT type_name from dict_type WHERE ID=D.SETT_FREQUENCY) as type_time,
  80. A.order_level,case A.order_level when '0' then '确认单'
  81. when '1' then '修改单'
  82. when '2' then '取消单' end as order_level_desc
  83. from order_main A LEFT JOIN opera_hotel B ON A.PARENT_PROD_ID=B.hotel_id LEFT JOIN base_confirm_organization C
  84. on B.CONFIRM_FROM=C.ID LEFT JOIN base_supplier D ON B.SUPPLIER_ID=D.ID
  85. LEFT JOIN base_user F ON A.CREATE_USER_ID=F.ID
  86. where (A.order_id = '{$order_id}' or A.outside_order_no = '{$order_id}') and A.cancel_flag = 0
  87. and A.parent_order_id = 0 and C.CANCEL_FLAG=0 AND D.CANCEL_FLAG=0 and A.order_prod_type in (25,26)";
  88. $rowset = $this->DBTool->queryBySql($sql);
  89. $data['export_info'] = $rowset['rowset'][0];
  90. $sql = "select
  91. a.id as comment_id,
  92. a.order_id,
  93. a.comment_type,
  94. case a.comment_type when 0 then '内部备注'
  95. when 1 then '公共备注' end as comment_type_desc,
  96. a.comment_txt,
  97. ifnull((select true_name from base_user where id = a.create_user_id),'') as create_true_name,
  98. a.create_user_id,
  99. a.create_time
  100. from order_comment as a where a.order_id = $order_id and a.comment_type=1 and a.cancel_flag = 0";
  101. $rowset = $this->DBTool->queryBySql($sql);
  102. $data['order_comment']=$rowset['rowset'];
  103. return $data;
  104. }
  105. function getOrderLog($param){
  106. $order_id = isset($param['order_id'])?$param['order_id']:"";
  107. $log_type = isset($param['log_type'])?$param['log_type']:"1,2,3";
  108. if(""==$order_id){
  109. $data['code']="16";
  110. $data['info']="缺少订单号!";
  111. return $data;
  112. }
  113. $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";
  114. writeLog('sql= ' . $sql);
  115. $rowset = $this->DBTool->queryBySql($sql);
  116. $data = array();
  117. $data['code'] = $rowset['code'];
  118. $data['info'] = $rowset['info'];
  119. $data['all_updater'] = $rowset['rowset'];
  120. return $data;
  121. }
  122. function getOrderOrgList()
  123. {
  124. $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";
  125. writeLog('sql= ' . $sql);
  126. $org_list = $this->DBTool->queryBySql($sql);
  127. $data['code'] = $org_list['code'];
  128. $data['info'] = $org_list['info'];
  129. $data['org_list'] = $org_list['rowset'];
  130. return $data;
  131. }
  132. function getTrueName($user_id=0)
  133. {
  134. $user_id=$user_id==0?1:$user_id;
  135. $sql = "select ifnull(true_name,'') as true_name from base_user where ID=$user_id AND CANCEL_FLAG=0 LIMIT 1";
  136. $rowset = $this->DBTool->queryBySql($sql);
  137. return isset($rowset['rowset'][0]['true_name'])?$rowset['rowset'][0]['true_name']:"";
  138. }
  139. function getPrice($order_id)
  140. {
  141. $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
  142. on A.run_id=B.id
  143. WHERE A.cancel_flag = 0 and A.parent_order_id='$order_id' GROUP BY PROD_START_STATION_DATE";
  144. $rowset = $this->DBTool->queryBySql($sql);
  145. return $rowset['rowset'];
  146. }
  147. }