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.
 
 
 
 

162 lines
7.4 KiB

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