|
- <?php
- header("Access-Control-Allow-Origin:*");
- date_default_timezone_set('PRC');
-
- require_once '../Common/Mysql.php';
- require_once '../Common/sinaAPI.php';
- require_once '../Api/OrderListServer.php';
- require_once '../Api/SyncOrder.php';
- $pdo=conn();
-
- $user_id =getUserId();
- //$order_from_org_id = $_COOKIE['org_id'];
- //$top_org_id=$_COOKIE['top_org_id'];
- //echo $order_from_org_id;die;
- //if (!$user_id) {
- // echo json_encode(array("code" => 1,"iflogin"=>1, "info" => "用户未登录"));
- // exit ;
- //}
-
- if(isset($_POST['price'])){
- echo json_encode(array("code" => 0, "info" => '','price'=>88));
- exit ;
- }
-
- $pay_status =146;
- $pay_type = 275;
- //获取提交信息 票的数量 和出发时间
- if(isset($_POST)){
- $date = isset($_POST['date_time'])?$_POST['date_time']:'2016-08-22';
- $cust_name = isset($_POST['customer_name'])?$_POST['customer_name']:'匿名者';
- $cust_phone = isset($_POST['customer_phone'])?$_POST['customer_phone']:'123456789';
- $id_type = isset($_POST['customer_id_type'])? $_POST['customer_id_type']:'150'; // 150身份证 153 护照
- $customer_id = isset($_POST['customer_id'])?$_POST['customer_id']:'371521199011034631';
- //票种和数量价格 prod_id=>票的数量
- $ticket=isset($_POST['tic'])?$_POST['tic']:'0';
- }
- if($date <= date('Y-m-d', time())){
- echo json_encode(array("code" => 1, "info" =>'不可预定当天的票' ,"list"=>''));
- exit ;
- }
-
-
-
- //获取本地订单编号
- $id_p = getUniqeId();
- $order_id_p = $id_p;
- $pay_main_id =getUniqeId();
- $create_time = date('Y-m-d H:i:s',time());
- $update_time = $create_time;
- $order_pay_status = 0;
- $outside_sale_org_id =0;
-
- $zzUtils=new zzUtils();
- /**
- * @param $operateType 操作类型 add:新增 update:更新
- * @param $serialId 分销平台订单流水号
- * @param string $confirmNumber 分销平台确认码,没有可不传
- * @param $sceneryId 景点ID
- * @param string $sceneryName 景区名称,如果不传则默认为智慧旅游系统对应的景区名称
- * @param $ticketTypeId 智慧旅游景区票型Id(各分销平台同步前需做相应的转换)
- * @param string $ticketTypeName 景区名称,如果不传则默认为智慧旅游系统对应的景区名称
- * @param $retailPrice 票面价
- * @param $webPrice 单价(单张网上售价)
- * @param $costPrice 成本价(即单张票的结算价)
- * @param $ticketCount 取票数量
- * @param $totalAmount 总金额(单张网上售价*预订数量)
- * @param $realPayAmount 实付金额
- * @param $payType 支付方式 景区现付:scenerycash或空字符串 在线支付:onlinepayment
- * @param $playDate 游玩时间(订单有效开始时间)
- * @param string $expiryDate 截止日期(订单有效截止日期,如不提供,则默认与playDate同) 可空
- * @param $orderStatus 订单状态 N: 新订单未支付,即景区收款 P: 已支付,即平台收款 C:已取消 T:已取票
- * @param $travelerName 取票人姓名
- * @param $travelerMobile 取票人手机
- * @param $orderDate 预订时间
- * @param string $identityCard 身份证
- * @param string $captcha 数字确认码
- * @param string $isParcelTicket 是否包票 0不是包票,1是包票
- * @return array|bool
- */
- $order_info = SyncOrder('add',$id_p, '',"1", '',"119", '', "100", "88", "35",$ticket, 88*$ticket, 35*$ticket,'onlinepayment',$date,'','P', $cust_name,$cust_phone,date('Y-m-d',time()),$customer_id,"","");
- //$SyncOrder = SyncOrder('add',"212121", '',1, '', 336, '', 99, 99, 99, 1, 198, 198, 'onlinepayment', '2016-08-22 00:00:00', '', 'P', 'Steven', '18663582623','2016-08-20 00:00:00', '371521199011034631',"","");
- //$order_info = SyncOrder('update','17999', '',"1", '', "336", '', "990", "99", "99", "2", "198", "198", 'onlinepayment', '2016-08-22 00:00:00', '', 'P', '魏意锡', '18663582623','2016-08-20 00:00:00', '371521199011034631',"","");
-
- if($order_info){
- $return_no = $order_info['captcha'];
-
- $pdo = conn();
- $sql = "select a.prod_id,a.prod_name,b.prod_price,b.prod_type_id "
- . "from opera_product a inner join opera_product_price b on a.prod_id = b.prod_id "
- . "where a.prod_id = 448027";
- $result=$pdo->query($sql);
- $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
- $info = array();
- foreach ($rowset as $v) {
- $info[$v['prod_id']] = $v;
- }
- $price=$info['448027']['prod_price']*$ticket;
- $return_info='周庄门票 × '.$ticket;
- $order_description=" 周庄门票,". date('Y-m-d',time()).",".$ticket."|";
- }else {
- echo json_encode(array("code" => 1, "info" =>'订单提交失败!'));
- exit ;
- }
- $outside_no = isset($_POST['outside_no'])?$_POST['outside_no']:'';
- $outside_sale_org_id = isset($_POST['outside_org_id'])?$_POST['outside_org_id']:'0';
- $order_customer_memo = "周庄门票订单号({$return_no})";
- $sql_in=" insert into order_main
- (`id`,
- `order_id`,`customer_memo`,
- `create_time`,`update_time`,
- `order_pay_status`,`order_description`,
- `order_price`,`order_prod_type`,`prod_name`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`prod_id`,`run_date`,`main_create_user_id`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`)
- values ('".$id_p."','"
- .$order_id_p."','{$order_customer_memo}',
- '".$create_time."','".$update_time."','0','".$order_description."','"
- .$price."','282','".$info['448027']['prod_name']."','".$pay_status."','
- ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."','0','0','".$info['448027']['prod_id']."','".$date."','".$user_id."','".$pay_main_id."','".$outside_sale_org_id."','".$outside_no."')";
- for_insert($sql_in);
- //插入支付方式等信息
- $sql_pay="insert INTO"
- . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
- . "VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$price.");"
- . "insert INTO `order_pay_detail`
- (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
- VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$pay_main_id.",".$pay_type.",".$price.");";
-
- for_insert($sql_pay);
- for($i=1;$i<=$ticket;$i++){
- $id =$order_id =getUniqeId();
- $sql = " insert into order_main
- (`id`,
- `order_id`,`customer_memo`,
- `create_time`,`update_time`,
- `order_pay_status`,
- `order_prod_type`,`order_status`,
- `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
- `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
- values ('".$id."','"
- .$order_id."','{$order_customer_memo}',
- '".$create_time."','".$update_time."',
- '0','282','".$pay_status."','
- ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
- '0','0','".$id_p."','0','".$info['448027']['prod_id']."','".$info['448027']['prod_name']."','".$info['448027']['prod_name']."','".$info['448027']['prod_price']."','".$date."','".$pay_main_id."','".$outside_sale_org_id."','".$outside_no."','".$user_id."')";
- for_insert($sql);
- }
-
- function for_insert($sql){
- writeLog($sql);
- $pdo = conn();
- $re = $pdo->exec($sql);
- if($re==0){
- echo json_encode(array("code" => 1, "info" => '下单成功,插入数据库失败,请联系管理员'));
- exit ;
- }
- }
- $list =array();
- $list['type'] = $info['448027']['prod_name'];
- $list['date'] = $date;
- $list['desc'] = $return_info;
- $list['price'] = $price;
- $list['name'] = $cust_name;
- $list['phone'] = $cust_phone;
- //下单成功发送短信
- $massage ="{$cust_name}您好,您成功预订周庄古镇,周庄成人票(上海迪士尼直通车专用),票数{$ticket}张,游玩日期{$date},取票方式:凭本人有效二代身份证原件在周庄古牌楼网络门票服务处自动取票机刷卡取票。中国第一水乡欢迎您!祝您出游愉快!客服电话021-52218088 【自在旅行】【蜘蛛出行】";
- $massage1 =array($cust_name,$cust_phone,$massage);
- send_msg($id_p,$massage1);
- echo json_encode(array("code" => 0, "info" => date('H:i:s', time()),"list"=>$list));
- exit ;
-
-
- //发短信
- function send_msg($ORDER_ID,$massage) {
- $send_pdo=conn();
- $order_id = $ORDER_ID;
- $res_content = $massage;
- $name = $res_content[0];
- $tel = $res_content[1];
- $content = $res_content[2];
- writeLog("短信模板内容:【" . $content . "】");
-
- //..发短信先取消
- $response = sendTelMessage($tel, $name, $content, $order_id);
- writeLog(json_encode($response));
-
- $comment_type = 0;
- $comment_text = "";
- $send_success = (int)$response;
- $sql1 = "CALL HT_ADD_MSG_COMMENT(2,'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
- $result1 = $send_pdo -> query($sql1);
- $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
- $result1 -> closeCursor();
- writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1);
- //insert order extra
- $hotelPrice = isset($_GET['hotelPrice']) ? $_GET['hotelPrice'] : "";
- $doorPrice = isset($_GET["doorPrice"]) ? $_GET["doorPrice"] : "";
- if ($hotelPrice != "" || $doorPrice != "") {
- $sqlInsert = " INSERT INTO order_extra_info (order_id,hotel_price,gate_price) VALUE(" . $ORDER_ID . ",'" . $hotelPrice . "','" . $doorPrice . "') ";
- writeLog("insert extra info: " . $sqlInsert);
- $result = $send_pdo -> exec($sqlInsert);
- }
- }
-
-
|