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.
 
 
 
 

145 lines
3.8 KiB

  1. <?php
  2. //Author:fuhc
  3. //Date:20160908
  4. //基础房型
  5. require_once __DIR__.'/../HotelLib.php';
  6. class HTBaseRoom extends HotelLib{
  7. // 添加基础房型
  8. function addBaseRoom($user_id,$room_type_sale,$hotel_id){
  9. $sql="update opera_hotel set update_user_id=".$user_id.",
  10. update_time=now(),
  11. room_type_sale='".$room_type_sale."'
  12. where hotel_id=".$hotel_id." and cancel_flag=0";
  13. writeLog(__FUNCTION__." sql= ".$sql);
  14. $result=$this->DBTool->execSql($sql);
  15. if($result['code']=="0"){
  16. $model=array(
  17. "user_id"=>$user_id,
  18. "log_type"=>1,
  19. "hotel_id"=>$hotel_id,
  20. "room_type"=>0,
  21. "log_desc"=>"添加基础房型".$room_type_sale
  22. );
  23. $this->DBLog->insertLog($model,'添加基础房型');
  24. }
  25. $data['code']=$result['code'];
  26. $data['info']=$result['info'];
  27. return $data;
  28. }
  29. //得到酒店列表
  30. function getHotelList($user_id,$current,$page_size,$area_id,$hotel_name,$hotel_status){
  31. $sql="CALL ht_hotel_product_list({$user_id},".$area_id.",".$hotel_status.",'".$hotel_name."',".$current.",".$page_size.")";
  32. writeLog(__FUNCTION__." sql=".$sql);
  33. $data=array();
  34. $rowset=$this->DBTool->execProcedure($sql);
  35. $data['code']=$rowset['code'];
  36. $data['info']=$rowset['info'];
  37. $data['hotel_list']=isset($rowset['rowset'][0])?$rowset['rowset'][0]:array();
  38. return $data;
  39. }
  40. // 修改基础房型
  41. function updateBaseRoom($Model){
  42. $user_id=$Model['user_id'];
  43. $stock_type=$Model['stock_type'];
  44. $base_price=$Model['base_price'];
  45. $total_count=$Model['total_count'];
  46. $run_date=$Model['run_date'];
  47. $room_type=$Model['room_type'];
  48. $hotel_id=$Model['hotel_id'];
  49. foreach ($Model as $k => $v) {
  50. if(empty($v)){
  51. $data['code']="16";
  52. $data['info']="参数错误";
  53. return $data;
  54. break;
  55. }
  56. }
  57. $sqlArr=array();
  58. $sql="update run_hotel set update_user_id={$user_id},stock_type={$stock_type},base_price={$base_price},total_count={$total_count}
  59. where run_date='".$run_date."' and room_type={$room_type} and hotel_id={$hotel_id} and saled_count<={$total_count};";
  60. writeLog(__FUNCTION__." sql1= ".$sql);
  61. $sqlArr[]=$sql;
  62. $sql="update run_hotel set update_user_id={$user_id},stock_type={$stock_type},total_count={$total_count}
  63. where run_date='".$run_date."' and parent_room_type={$room_type} and hotel_id={$hotel_id} and saled_count<={$total_count};";
  64. writeLog(__FUNCTION__." sql2= ".$sql);
  65. $sqlArr[]=$sql;
  66. $rowset=$this->DBTool->execSqlArr($sqlArr);
  67. if($rowset['code']=="0"){
  68. $model=array(
  69. "user_id"=>$user_id,
  70. "log_type"=>2,
  71. "hotel_id"=>$hotel_id,
  72. "room_type"=>$room_type,
  73. "log_desc"=>"修改基础房型"
  74. );
  75. $this->DBLog->insertLog($model,'修改基础房型');
  76. }
  77. $data['code']=$rowset['code'];
  78. $data['info']=$rowset['info'];
  79. return $data;
  80. }
  81. // 修改价格库存
  82. function updateStockPrice($user_id,$hotel_id,$room_info){
  83. $sql="call ht_run_room_save({$user_id},{$hotel_id},'{$room_info}')";
  84. writeLog(__FUNCTION__." sql= ".$sql);
  85. $rowset=$this->DBTool->execProcedure($sql);
  86. $data=array();
  87. $data_r=array();
  88. $data_r['code']=$rowset['code'];
  89. $data_r['info']=$rowset['info'];
  90. $data_r['rowset']=isset($rowset['rowset'][0])?$rowset['rowset'][0]:array();
  91. if($data_r['code']!="0"){
  92. $data['code']=$data_r['code'];
  93. $data['info']=$data_r['info'];
  94. return $data;
  95. }
  96. if($data_r['rowset'][0]['errcode']=="0"){
  97. $room_arr=explode(',',$room_info);
  98. $room_str=str_replace('{','',$room_arr);
  99. $model=array(
  100. "user_id"=>$user_id,
  101. "log_type"=>2,
  102. "hotel_id"=>$hotel_id,
  103. "room_type"=>(int)$room_str,
  104. "log_desc"=>"修改价格库存"
  105. );
  106. $this->DBLog->insertLog($model,'修改价格库存');
  107. }
  108. $data['code']=$data_r['rowset'][0]['errcode'];
  109. $data['info']=$data_r['rowset'][0]['errinfo'];
  110. return $data;
  111. }
  112. }
  113. ?>