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.
 
 
 
 

207 lines
9.7 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. date_default_timezone_set('PRC');
  4. require_once '../Common/Mysql.php';
  5. require_once '../Common/sinaAPI.php';
  6. require_once '../Api/OrderListServer.php';
  7. require_once '../Api/SyncOrder.php';
  8. $pdo=conn();
  9. $user_id =getUserId();
  10. //$order_from_org_id = $_COOKIE['org_id'];
  11. //$top_org_id=$_COOKIE['top_org_id'];
  12. //echo $order_from_org_id;die;
  13. //if (!$user_id) {
  14. // echo json_encode(array("code" => 1,"iflogin"=>1, "info" => "用户未登录"));
  15. // exit ;
  16. //}
  17. if(isset($_POST['price'])){
  18. echo json_encode(array("code" => 0, "info" => '','price'=>88));
  19. exit ;
  20. }
  21. $pay_status =146;
  22. $pay_type = 275;
  23. //获取提交信息 票的数量 和出发时间
  24. if(isset($_POST)){
  25. $date = isset($_POST['date_time'])?$_POST['date_time']:'2016-08-22';
  26. $cust_name = isset($_POST['customer_name'])?$_POST['customer_name']:'匿名者';
  27. $cust_phone = isset($_POST['customer_phone'])?$_POST['customer_phone']:'123456789';
  28. $id_type = isset($_POST['customer_id_type'])? $_POST['customer_id_type']:'150'; // 150身份证 153 护照
  29. $customer_id = isset($_POST['customer_id'])?$_POST['customer_id']:'371521199011034631';
  30. //票种和数量价格 prod_id=>票的数量
  31. $ticket=isset($_POST['tic'])?$_POST['tic']:'0';
  32. }
  33. if($date <= date('Y-m-d', time())){
  34. echo json_encode(array("code" => 1, "info" =>'不可预定当天的票' ,"list"=>''));
  35. exit ;
  36. }
  37. //获取本地订单编号
  38. $id_p = getUniqeId();
  39. $order_id_p = $id_p;
  40. $pay_main_id =getUniqeId();
  41. $create_time = date('Y-m-d H:i:s',time());
  42. $update_time = $create_time;
  43. $order_pay_status = 0;
  44. $outside_sale_org_id =0;
  45. $zzUtils=new zzUtils();
  46. /**
  47. * @param $operateType 操作类型 add:新增 update:更新
  48. * @param $serialId 分销平台订单流水号
  49. * @param string $confirmNumber 分销平台确认码,没有可不传
  50. * @param $sceneryId 景点ID
  51. * @param string $sceneryName 景区名称,如果不传则默认为智慧旅游系统对应的景区名称
  52. * @param $ticketTypeId 智慧旅游景区票型Id(各分销平台同步前需做相应的转换)
  53. * @param string $ticketTypeName 景区名称,如果不传则默认为智慧旅游系统对应的景区名称
  54. * @param $retailPrice 票面价
  55. * @param $webPrice 单价(单张网上售价)
  56. * @param $costPrice 成本价(即单张票的结算价)
  57. * @param $ticketCount 取票数量
  58. * @param $totalAmount 总金额(单张网上售价*预订数量)
  59. * @param $realPayAmount 实付金额
  60. * @param $payType 支付方式 景区现付:scenerycash或空字符串 在线支付:onlinepayment
  61. * @param $playDate 游玩时间(订单有效开始时间)
  62. * @param string $expiryDate 截止日期(订单有效截止日期,如不提供,则默认与playDate同) 可空
  63. * @param $orderStatus 订单状态 N: 新订单未支付,即景区收款 P: 已支付,即平台收款 C:已取消 T:已取票
  64. * @param $travelerName 取票人姓名
  65. * @param $travelerMobile 取票人手机
  66. * @param $orderDate 预订时间
  67. * @param string $identityCard 身份证
  68. * @param string $captcha 数字确认码
  69. * @param string $isParcelTicket 是否包票 0不是包票,1是包票
  70. * @return array|bool
  71. */
  72. $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,"","");
  73. //$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',"","");
  74. //$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',"","");
  75. if($order_info){
  76. $return_no = $order_info['captcha'];
  77. $pdo = conn();
  78. $sql = "select a.prod_id,a.prod_name,b.prod_price,b.prod_type_id "
  79. . "from opera_product a inner join opera_product_price b on a.prod_id = b.prod_id "
  80. . "where a.prod_id = 448027";
  81. $result=$pdo->query($sql);
  82. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  83. $info = array();
  84. foreach ($rowset as $v) {
  85. $info[$v['prod_id']] = $v;
  86. }
  87. $price=$info['448027']['prod_price']*$ticket;
  88. $return_info='周庄门票 × '.$ticket;
  89. $order_description=" 周庄门票,". date('Y-m-d',time()).",".$ticket."|";
  90. }else {
  91. echo json_encode(array("code" => 1, "info" =>'订单提交失败!'));
  92. exit ;
  93. }
  94. $outside_no = isset($_POST['outside_no'])?$_POST['outside_no']:'';
  95. $outside_sale_org_id = isset($_POST['outside_org_id'])?$_POST['outside_org_id']:'0';
  96. $order_customer_memo = "周庄门票订单号({$return_no})";
  97. $sql_in=" insert into order_main
  98. (`id`,
  99. `order_id`,`customer_memo`,
  100. `create_time`,`update_time`,
  101. `order_pay_status`,`order_description`,
  102. `order_price`,`order_prod_type`,`prod_name`,`order_status`,
  103. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  104. `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`)
  105. values ('".$id_p."','"
  106. .$order_id_p."','{$order_customer_memo}',
  107. '".$create_time."','".$update_time."','0','".$order_description."','"
  108. .$price."','282','".$info['448027']['prod_name']."','".$pay_status."','
  109. ".$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."')";
  110. for_insert($sql_in);
  111. //插入支付方式等信息
  112. $sql_pay="insert INTO"
  113. . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
  114. . "VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$price.");"
  115. . "insert INTO `order_pay_detail`
  116. (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
  117. VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$pay_main_id.",".$pay_type.",".$price.");";
  118. for_insert($sql_pay);
  119. for($i=1;$i<=$ticket;$i++){
  120. $id =$order_id =getUniqeId();
  121. $sql = " insert into order_main
  122. (`id`,
  123. `order_id`,`customer_memo`,
  124. `create_time`,`update_time`,
  125. `order_pay_status`,
  126. `order_prod_type`,`order_status`,
  127. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  128. `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`)
  129. values ('".$id."','"
  130. .$order_id."','{$order_customer_memo}',
  131. '".$create_time."','".$update_time."',
  132. '0','282','".$pay_status."','
  133. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  134. '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."')";
  135. for_insert($sql);
  136. }
  137. function for_insert($sql){
  138. writeLog($sql);
  139. $pdo = conn();
  140. $re = $pdo->exec($sql);
  141. if($re==0){
  142. echo json_encode(array("code" => 1, "info" => '下单成功,插入数据库失败,请联系管理员'));
  143. exit ;
  144. }
  145. }
  146. $list =array();
  147. $list['type'] = $info['448027']['prod_name'];
  148. $list['date'] = $date;
  149. $list['desc'] = $return_info;
  150. $list['price'] = $price;
  151. $list['name'] = $cust_name;
  152. $list['phone'] = $cust_phone;
  153. //下单成功发送短信
  154. $massage ="{$cust_name}您好,您成功预订周庄古镇,周庄成人票(上海迪士尼直通车专用),票数{$ticket}张,游玩日期{$date},取票方式:凭本人有效二代身份证原件在周庄古牌楼网络门票服务处自动取票机刷卡取票。中国第一水乡欢迎您!祝您出游愉快!客服电话021-52218088 【自在旅行】【蜘蛛出行】";
  155. $massage1 =array($cust_name,$cust_phone,$massage);
  156. send_msg($id_p,$massage1);
  157. echo json_encode(array("code" => 0, "info" => date('H:i:s', time()),"list"=>$list));
  158. exit ;
  159. //发短信
  160. function send_msg($ORDER_ID,$massage) {
  161. $send_pdo=conn();
  162. $order_id = $ORDER_ID;
  163. $res_content = $massage;
  164. $name = $res_content[0];
  165. $tel = $res_content[1];
  166. $content = $res_content[2];
  167. writeLog("短信模板内容:【" . $content . "】");
  168. //..发短信先取消
  169. $response = sendTelMessage($tel, $name, $content, $order_id);
  170. writeLog(json_encode($response));
  171. $comment_type = 0;
  172. $comment_text = "";
  173. $send_success = (int)$response;
  174. $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})";
  175. $result1 = $send_pdo -> query($sql1);
  176. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  177. $result1 -> closeCursor();
  178. writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1);
  179. //insert order extra
  180. $hotelPrice = isset($_GET['hotelPrice']) ? $_GET['hotelPrice'] : "";
  181. $doorPrice = isset($_GET["doorPrice"]) ? $_GET["doorPrice"] : "";
  182. if ($hotelPrice != "" || $doorPrice != "") {
  183. $sqlInsert = " INSERT INTO order_extra_info (order_id,hotel_price,gate_price) VALUE(" . $ORDER_ID . ",'" . $hotelPrice . "','" . $doorPrice . "') ";
  184. writeLog("insert extra info: " . $sqlInsert);
  185. $result = $send_pdo -> exec($sqlInsert);
  186. }
  187. }