Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

175 rindas
6.6 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. //酒店订单 取消 和申请退单
  7. require_once __DIR__.'/../Common/Mysql.php';
  8. if (ALLOW_ORIGIN)
  9. header("Access-Control-Allow-Origin:*");
  10. $order_id=isset($_GET['order_id'])?$_GET['order_id']:'';
  11. $method=isset($_GET['method'])?$_GET['method']:'';
  12. $apply=isset($_GET['apply'])?$_GET['apply']:'';
  13. $comment_text=isset($_GET['comment_text'])?$_GET['comment_text']:'';
  14. if($order_id =='' || $method==''){
  15. echo json_encode(array("errcode"=>2,"errinfo"=>"参数不能为空"));
  16. exit;
  17. }
  18. if ($method=='apply' && $apply==''){
  19. echo json_encode(array("errcode"=>2,"errinfo"=>"参数不能为空"));
  20. exit;
  21. }else if($method=='check' && $comment_text==''){
  22. echo json_encode(array("errcode"=>2,"errinfo"=>"参数不能为空"));
  23. exit;
  24. }
  25. $userid=getUserId();
  26. if ($userid ===false){
  27. echo json_encode(array("errcode"=>1,"errinfo"=>"用户未登录"));
  28. exit;
  29. }
  30. $pdo=conn();
  31. if(is_object($pdo)){
  32. $sql="CALL HT_ORDER_CANCEL_CHARGEBACK(".$userid.",'".$method."',".$order_id.",'".$apply."','".$comment_text."')";
  33. $result=$pdo->query($sql);
  34. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  35. $result->closeCursor();
  36. writeLog(json_encode($rowset));
  37. if (is_array($rowset[0]) && $rowset[0]['code']==0 && SEND_MESSAGE==true){
  38. $name =$rowset[0]['CUSTOMER_NAME'];
  39. $tel =$rowset[0]['CUSTOMER_MOBILE'];
  40. $order_status=$rowset[0]['ORDER_STATUS'];
  41. // $content="单号:".$order_id.',订单状态变更为'.$order_status."随机数".rand(1,10000);
  42. $content=get_msg_info($order_id);
  43. $response=sendTelMessage($tel, $name, $content, $order_id);
  44. writeLog(json_encode($response));
  45. $send_success = (int)$response;
  46. $sql1="CALL HT_ADD_MSG_COMMENT(".$userid.",'addmsg',".$order_id.",0,'','".$tel."','".$content."','".date("Y-m-d H:i:s")."',{$send_success})";
  47. $result1=$pdo->query($sql1);
  48. $rowset1=$result1->fetchAll(PDO::FETCH_ASSOC);
  49. $result1->closeCursor();
  50. writeLog("hotel_order_cancel_changeback.php HT_ADD_MSG_COMMENT()::".$sql1);
  51. }
  52. //unset($rowset[0]['CUSTOMER_NAME']);
  53. //unset($rowset[0]['CUSTOMER_MOBILE']);
  54. writeLog("hotel_order_status.php HT_ORDER_CANCEL_CHARGEBACK()::".$sql);
  55. }
  56. /*得到短信模板*/
  57. function get_msg_info($order_id) {
  58. $msg_sql = "CALL HT_GET_MESSAGE_TEMPLATE(" . $order_id . ");";
  59. $msg_pdo = conn();
  60. $msg_result = $msg_pdo -> query($msg_sql);
  61. $msg_re_da = array();
  62. do {
  63. $msg_rowset = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  64. if ($msg_rowset) {
  65. $msg_re_da[] = $msg_rowset;
  66. }
  67. } while($msg_result->nextRowset());
  68. $data['code'] = "0";
  69. $data['info'] = "";
  70. if (!$msg_re_da) {
  71. $data['code'] = "-1";
  72. $data['info'] = "没有查询到结果";
  73. if (is_array($data)) {
  74. echo json_encode($data);
  75. exit();
  76. }
  77. }
  78. $data['message_info'] = isset($msg_re_da[1]) ? $msg_re_da[1] : array();
  79. if (!isset($msg_re_da[1])) {
  80. $data['code'] = "-1";
  81. $data['info'] = "失败";
  82. if (is_array($data)) {
  83. echo json_encode($data);
  84. exit();
  85. }
  86. }
  87. $data['days'] = $msg_re_da[0][0]['days'];
  88. $data['all_price'] = $msg_re_da[0][0]['all_price'];
  89. $data['message_info'] = $msg_re_da[1];
  90. $json_obj = json_decode(json_encode($data), TRUE);
  91. $message_info = $json_obj['message_info'];
  92. //$msg_customer_name=$message_info[0]['customer_name'];//用户姓名
  93. $name = $message_info[0]['customer_name'];
  94. $tel = $message_info[0]['customer_mobile'];
  95. $order_status = $message_info[0]['order_status'];
  96. //入住日期-主订单的入住日期=子订单第一个的日期
  97. $check_in_date = $message_info[0]['check_in_date'];
  98. //产品名称-所有日期的产品名称相同
  99. $prod_name = $message_info[0]['prod_name'];
  100. $ht_rooms = $message_info[0]['ht_rooms'];
  101. //酒店间数 -1表示没有
  102. for ($i = 0, $m = count($message_info); $i < $m; $i++) {
  103. $tm_day = $message_info[$i]['ht_rooms'];
  104. if ($ht_rooms == $tm_day) {
  105. continue;
  106. } else {
  107. $ht_rooms = "-1";
  108. break;
  109. }
  110. }
  111. $days = $json_obj['days'];
  112. //预订天数
  113. $all_price = $json_obj['all_price'];
  114. //总价格
  115. $breakfast = $message_info[0]['breakfast'];
  116. //早餐
  117. for ($i = 0, $m = count($message_info); $i < $m; $i++) {
  118. $tm_breakfast = $message_info[$i]['breakfast'];
  119. if ($breakfast == $tm_breakfast) {
  120. continue;
  121. } else {
  122. $breakfast = "-1";
  123. break;
  124. }
  125. }
  126. $content = "";
  127. //判断order_status的值
  128. if ($order_status == "145") {//待支付
  129. $content = "{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),订单已生成,请尽快支付以免影响您的出行。";
  130. } else if ($order_status == "198") {//待确定
  131. $content = "已支付,待确认:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),房间将在2小时内确认,请耐心等待确认信息。";
  132. } else if ($order_status == "199") {//待通知
  133. $content = "已确认:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),已安排房间。";
  134. } else if ($order_status == "201") {//退改中
  135. $content = "{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),酒店方确认当日无房,正在安排退款,请耐心等待。联系客服:021-33280578。";
  136. } else if ($order_status == "238") {//已退单
  137. $content = "退款成功:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),酒店方确认当日无房,已成功退款,请留意银行相关退款信息。联系客服:021-33280578。";
  138. } else if ($order_status == "148") {
  139. $content = "已取消:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),已取消。联系客服:021-33280578。";
  140. } else {
  141. $content = "短信模板错误---严重错误:500当前状态".$order_status;
  142. writeLog($content);
  143. exit();
  144. }
  145. $content = str_replace("{customer_name}", $name, $content);
  146. $content = str_replace("{check_in_date}", $check_in_date, $content);
  147. $content = str_replace("{prod_name}", $prod_name, $content);
  148. //判断房间数是否该显示
  149. if ($ht_rooms != "-1") {
  150. $content = str_replace("{ht_rooms}", $ht_rooms, $content);
  151. } else {
  152. $content = str_replace("{ht_rooms}间", "", $content);
  153. }
  154. $content = str_replace("{days}", $days, $content);
  155. $content = str_replace("{order_price}", $all_price, $content);
  156. //判断早餐是否该显示
  157. if ($breakfast != "-1") {
  158. $content = str_replace("{breakfast}", $breakfast, $content);
  159. } else {
  160. $content = str_replace("({breakfast})", "", $content);
  161. }
  162. return $content;
  163. }
  164. if (is_array($rowset[0])){
  165. writeLog("hotel_order_status.php HT_ORDER_CANCEL_CHARGEBACK()::".json_encode($rowset[0]));
  166. echo json_encode($rowset[0]);
  167. }
  168. exit;