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.

ftp_check_hotel_travel_remind.php 7.3 KiB

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