25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

208 satır
9.8 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. $base_price_total = 35 * $ticket;
  95. $outside_no = isset($_POST['outside_no'])?$_POST['outside_no']:'';
  96. $outside_sale_org_id = isset($_POST['outside_org_id'])?$_POST['outside_org_id']:'0';
  97. $order_customer_memo = "周庄门票订单号({$return_no})";
  98. $sql_in=" insert into order_main
  99. (`id`,
  100. `order_id`,`customer_memo`,
  101. `create_time`,`update_time`,`base_price`,
  102. `order_pay_status`,`order_description`,
  103. `order_price`,`order_prod_type`,`prod_name`,`order_status`,
  104. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  105. `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`)
  106. values ('".$id_p."','"
  107. .$order_id_p."','{$order_customer_memo}',
  108. '".$create_time."','".$update_time."',{$base_price_total},'0','".$order_description."','"
  109. .$price."','282','".$info['448027']['prod_name']."','".$pay_status."','
  110. ".$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."')";
  111. for_insert($sql_in);
  112. //插入支付方式等信息
  113. $sql_pay="insert INTO"
  114. . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
  115. . "VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$price.");"
  116. . "insert INTO `order_pay_detail`
  117. (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
  118. VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$pay_main_id.",".$pay_type.",".$price.");";
  119. for_insert($sql_pay);
  120. for($i=1;$i<=$ticket;$i++){
  121. $id =$order_id =getUniqeId();
  122. $sql = " insert into order_main
  123. (`id`,
  124. `order_id`,`customer_memo`,
  125. `create_time`,`update_time`,`base_price`,
  126. `order_pay_status`,
  127. `order_prod_type`,`order_status`,
  128. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  129. `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`)
  130. values ('".$id."','"
  131. .$order_id."','{$order_customer_memo}',
  132. '".$create_time."','".$update_time."',35,
  133. '0','282','".$pay_status."','
  134. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  135. '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."')";
  136. for_insert($sql);
  137. }
  138. function for_insert($sql){
  139. writeLog($sql);
  140. $pdo = conn();
  141. $re = $pdo->exec($sql);
  142. if($re==0){
  143. echo json_encode(array("code" => 1, "info" => '下单成功,插入数据库失败,请联系管理员'));
  144. exit ;
  145. }
  146. }
  147. $list =array();
  148. $list['type'] = $info['448027']['prod_name'];
  149. $list['date'] = $date;
  150. $list['desc'] = $return_info;
  151. $list['price'] = $price;
  152. $list['name'] = $cust_name;
  153. $list['phone'] = $cust_phone;
  154. //下单成功发送短信
  155. $massage ="{$cust_name}您好,您成功预订周庄古镇,周庄成人票(上海迪士尼直通车专用),票数{$ticket}张,游玩日期{$date},取票方式:凭本人有效二代身份证原件在周庄古牌楼网络门票服务处自动取票机刷卡取票。中国第一水乡欢迎您!祝您出游愉快!客服电话021-52218088 【自在旅行】【蜘蛛出行】";
  156. $massage1 =array($cust_name,$cust_phone,$massage);
  157. send_msg($id_p,$massage1);
  158. echo json_encode(array("code" => 0, "info" => date('H:i:s', time()),"list"=>$list));
  159. exit ;
  160. //发短信
  161. function send_msg($ORDER_ID,$massage) {
  162. $send_pdo=conn();
  163. $order_id = $ORDER_ID;
  164. $res_content = $massage;
  165. $name = $res_content[0];
  166. $tel = $res_content[1];
  167. $content = $res_content[2];
  168. writeLog("短信模板内容:【" . $content . "】");
  169. //..发短信先取消
  170. $response = sendTelMessage($tel, $name, $content, $order_id);
  171. writeLog(json_encode($response));
  172. $comment_type = 0;
  173. $comment_text = "";
  174. $send_success = (int)$response;
  175. $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})";
  176. $result1 = $send_pdo -> query($sql1);
  177. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  178. $result1 -> closeCursor();
  179. writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1);
  180. //insert order extra
  181. $hotelPrice = isset($_GET['hotelPrice']) ? $_GET['hotelPrice'] : "";
  182. $doorPrice = isset($_GET["doorPrice"]) ? $_GET["doorPrice"] : "";
  183. if ($hotelPrice != "" || $doorPrice != "") {
  184. $sqlInsert = " INSERT INTO order_extra_info (order_id,hotel_price,gate_price) VALUE(" . $ORDER_ID . ",'" . $hotelPrice . "','" . $doorPrice . "') ";
  185. writeLog("insert extra info: " . $sqlInsert);
  186. $result = $send_pdo -> exec($sqlInsert);
  187. }
  188. }