2,"errinfo"=>"分销商或外部订单号参数不能为空")); exit; } if($maxcount>0){ $prod_list=''; $total_base_price=$total_mid_price=$total_order_price=$total_num= 0; $prod_description=''; $check_in_date_array=array(); for($i=0;$i<$maxcount;$i++){ $check_in_date=isset($_POST['check_in_date_'.$i])?$_POST['check_in_date_'.$i]:''; if ($check_in_date !=''){ $check_in_date_array[]=$check_in_date; } $run_id=isset($_POST['run_id_'.$i])?$_POST['run_id_'.$i]:0; $room_count=isset($_POST['room_count_'.$i])?$_POST['room_count_'.$i]:0; $base_price=isset($_POST['base_price_'.$i])?$_POST['base_price_'.$i]:0; $mid_price=isset($_POST['mid_price_'.$i])?$_POST['mid_price_'.$i]:0; $order_price=isset($_POST['order_price_'.$i])?$_POST['order_price_'.$i]:0; $t_base_price=$base_price*$room_count; $t_mid_price=$mid_price*$room_count; $t_order_price=$order_price*$room_count; $total_base_price+=$t_base_price; $total_mid_price+=$t_mid_price; $total_order_price+=$t_order_price; $total_num+=$room_count; $prod_description.=$prod_name.",".$check_in_date.",".$room_count."|"; $prod_list.=$check_in_date."^".$run_id."^".$room_count."^".$base_price."^".$mid_price."^".$order_price."*"; } $prod_list=rtrim($prod_list,"*"); $prod_description=rtrim($prod_description,"|"); }else{ echo json_encode(array("errcode"=>3,"errinfo"=>"没有预定入住日期")); exit; } if ($method =='' || $customer_name=='' || $customer_mobile==0){ echo json_encode(array("errcode"=>3,"errinfo"=>"客人信息或者method参数不能为空")); exit; } $para_org_list=$prod_id."^".$distributors."^".$out_order_id."^".($total_num+1)."^".$total_base_price."^".$total_mid_price."^".$total_order_price."^".$prod_description."^".$arrive_latest_time."^".min($check_in_date_array); $customer_list=$customer_name."^".$customer_mobile."^".$order_comment; $userid=getUserId(); if ($userid ===false){ echo json_encode(array("errcode"=>1,"errinfo"=>"用户未登录")); exit; } $pdo=conn(); if(is_object($pdo)){ if($method=='add'){ $sql="CALL HT_SUBMIT_ORDER(".$userid.",'".$method."','".$para_org_list."','".$prod_list."','".$customer_list."',".$order_id.")"; writeLog("hotel_submit_order.php HT_SUBMIT_ORDER()::sql".$sql); $result=$pdo->query($sql); $rowset=$result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); writeLog("hotel_submit_order.php HT_SUBMIT_ORDER()::rowset".json_encode($rowset)); if (is_array($rowset[0]) && $rowset[0]['code']==0){ if (SEND_MESSAGE == true) { $order_id=$rowset[0]['global_order_id']; $rowset_order_status=145; $res_content=get_msg_info($order_id); $name=$res_content[0]; $tel=$res_content[1]; $content=$res_content[2]; // $content = "单号:" . $order_id . ',订单状态变更为' . $order_status . "随机数" . rand(1, 10000); writeLog("短信模板内容:【" . $content . "】"); $response = sendTelMessage($tel, $name, $content, $order_id); writeLog(json_encode($response)); $send_success = (int)$response; $sql1 = "CALL HT_ADD_MSG_COMMENT(" . $userid . ",'addmsg'," . $order_id . ",0,'','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})"; $result1 = $pdo -> query($sql1); $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC); $result1 -> closeCursor(); writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1); } $url= "http://".$_SERVER['HTTP_HOST']."/hotelOrderList.html"; echo ""; //header("Location: $url"); exit; }else{ $url= "http://".$_SERVER['HTTP_HOST']."/hotelPlaceOrder.html?prod_id=".$prod_id; echo ""; exit; } }else if($method=='modify'){ $sql="CALL HT_SUBMIT_ORDER(".$userid.",'".$method."','".$para_org_list."','".$prod_list."','".$customer_list."',".$order_id.")"; writeLog("hotel_submit_order.php HT_SUBMIT_ORDER():: modify ::sql".$sql); $result=$pdo->query($sql); $rowset=$result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); writeLog("hotel_submit_order.php HT_SUBMIT_ORDER():: modify :: rowset".json_encode($rowset)); if (is_array($rowset[0]) && $rowset[0]['code']==0){ if (SEND_MESSAGE == true) { $rowset_order_status=145; $res_content=get_msg_info($order_id); $name=$res_content[0]; $tel=$res_content[1]; $content=$res_content[2]; // $content = "单号:" . $order_id . ',订单状态变更为' . $order_status . "随机数" . rand(1, 10000); writeLog("短信模板内容:【" . $content . "】"); $response = sendTelMessage($tel, $name, $content, $order_id); writeLog(json_encode($response)); } $url= "http://".$_SERVER['HTTP_HOST']."/hotelWaitConfirm.html?order_id=".$order_id; echo ""; //header("Location: $url"); exit; }else{ $url= "http://".$_SERVER['HTTP_HOST']."/hotelOrderList.html"; echo ""; exit; } } } function get_msg_info($order_id) { $msg_sql = "CALL HT_GET_MESSAGE_TEMPLATE(" . $order_id . ");"; writeLog($msg_sql); $msg_pdo = conn(); $msg_result = $msg_pdo -> query($msg_sql); $msg_re_da = array(); do { $msg_rowset = $msg_result -> fetchAll(PDO::FETCH_ASSOC); if ($msg_rowset) { $msg_re_da[] = $msg_rowset; } } while($msg_result->nextRowset()); $data['code'] = "0"; $data['info'] = ""; if (!$msg_re_da) { $data['code'] = "-1"; $data['info'] = "没有查询到结果"; if (is_array($data)) { echo json_encode($data); exit(); } } $data['message_info'] = isset($msg_re_da[1]) ? $msg_re_da[1] : array(); if (!isset($msg_re_da[1])) { $data['code'] = "-1"; $data['info'] = "失败"; if (is_array($data)) { echo json_encode($data); exit(); } } $data['days'] = $msg_re_da[0][0]['days']; $data['all_price'] = $msg_re_da[0][0]['all_price']; $data['message_info'] = $msg_re_da[1]; writeLog("get_msg_info:::".json_encode($data)); $json_obj = json_decode(json_encode($data), TRUE); $message_info = $json_obj['message_info']; //$msg_customer_name=$message_info[0]['customer_name'];//用户姓名 $name = $message_info[0]['customer_name']; $tel = $message_info[0]['customer_mobile']; $order_status = $message_info[0]['order_status']; //入住日期-主订单的入住日期=子订单第一个的日期 $check_in_date = $message_info[0]['check_in_date']; //产品名称-所有日期的产品名称相同 $prod_name = $message_info[0]['prod_name']; $ht_rooms = $message_info[0]['ht_rooms']; //酒店间数 -1表示没有 for ($i = 0, $m = count($message_info); $i < $m; $i++) { $tm_day = $message_info[$i]['ht_rooms']; if ($ht_rooms == $tm_day) { continue; } else { $ht_rooms = "-1"; break; } } $days = $json_obj['days']; //预订天数 $all_price = $json_obj['all_price']; //总价格 $breakfast = $message_info[0]['breakfast']; //早餐 for ($i = 0, $m = count($message_info); $i < $m; $i++) { $tm_breakfast = $message_info[$i]['breakfast']; if ($breakfast == $tm_breakfast) { continue; } else { $breakfast = "-1"; break; } } $content = ""; //判断order_status的值 if ($order_status == "145") {//待支付 //$content="【蜘蛛出行】{用户姓名}预订的{入住日期}{产品名称},{酒店间数}间{预订天数}晚,总价{订单总价}({早餐}),订单已生成,请尽快支付以免影响您的出行。"; $content = "{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),订单已生成,请尽快支付以免影响您的出行。"; } else if ($order_status == "198") {//待确定 //【蜘蛛出行】已支付,待确认:{用户姓名}预订的{入住日期}{产品名称},{酒店间数}间{预订天数}晚,总价{订单总价}({早餐}),房间将在2小时内确认,请耐心等待确认信息。 $content = "已支付,待确认:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),房间将在2小时内确认,请耐心等待确认信息。"; } else if ($order_status == "199") {//待通知 //【蜘蛛出行】已确认:{用户姓名}预订的{入住日期}{产品名称},{酒店间数}间{预订天数}晚,总价{订单总价}({早餐}),已安排房间。 $content = "已确认:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),已安排房间。"; } else if ($order_status == "201") {//退改中 //【蜘蛛出行】{用户姓名}预订的{入住日期}{产品名称},{酒店间数}间{预订天数}晚,总价{订单总价}({早餐}),酒店方确认当日无房,正在安排退款,请耐心等待。联系客服:021-33280578。 $content = "{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),酒店方确认当日无房,正在安排退款,请耐心等待。联系客服:021-33280578。"; } else if ($order_status == "238") {//已退单 //【蜘蛛出行】退款成功:{用户姓名}预订的{入住日期}{产品名称},{酒店间数}间{预订天数}晚,总价{订单总价}({早餐}),酒店方确认当日无房,已成功退款,请留意银行相关退款信息。联系客服:021-33280578。 $content = "退款成功:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),酒店方确认当日无房,已成功退款,请留意银行相关退款信息。联系客服:021-33280578。"; } else if ($order_status == "148") { //【蜘蛛出行】已取消:{用户姓名}预订的{入住日期}{产品名称},{酒店间数}间{预订天数}晚,总价{订单总价}({早餐}),已取消。联系客服:021-33280578。 $content = "已取消:{customer_name}预订的{check_in_date}{prod_name},{ht_rooms}间{days}晚,总价{order_price}({breakfast}),已取消。联系客服:021-33280578。"; } else { $content = "短信模板错误---严重错误:500当前状态".$order_status; writeLog($content); exit(); } $content = str_replace("{customer_name}", $name, $content); $content = str_replace("{check_in_date}", $check_in_date, $content); $content = str_replace("{prod_name}", $prod_name, $content); //判断房间数是否该显示 if ($ht_rooms != "-1") { $content = str_replace("{ht_rooms}", $ht_rooms, $content); } else { $content = str_replace("{ht_rooms}间", "", $content); } $content = str_replace("{days}", $days, $content); $content = str_replace("{order_price}", $all_price, $content); //判断早餐是否该显示 if ($breakfast != "-1") { $content = str_replace("{breakfast}", $breakfast, $content); } else { $content = str_replace("({breakfast})", "", $content); } return array($name,$tel,$content); } exit;