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.
 
 
 
 
 

193 regels
7.6 KiB

  1. <?php
  2. require_once '../php_include/Config.php';
  3. require_once '../php_include/class.db.inc';
  4. require_once '../php_include/disney.inc';
  5. date_default_timezone_set('PRC');
  6. $current_date = date("Y-m-d");
  7. if( $current_date >= "2016-09-01" ) {
  8. header("Location:http://sfx.zhizhuchuxing.com/");
  9. exit();
  10. }
  11. //DB
  12. $objDbh = new Db;
  13. $objDbh->setAccount(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
  14. $objDisney = new DbDisney($objDbh);
  15. if( !isset($_POST["gid"])) {
  16. header("Location:list.php?cc=".$_COOKIE["companycode"]);exit();
  17. }
  18. $base_org_info = $objDisney->getBaseOrgInfoFromCode( $_COOKIE["companycode"] );
  19. $base_org_name = false == $base_org_info ? "酒店" : $base_org_info["org_name"];
  20. $good_info=$objDisney->getGoodInfoFromId($_POST["gid"]);
  21. $order_serial_no = date("ymdHis").sprintf("%06d",rand( 1, 999999));
  22. $org_id = $base_org_info["org_id"];
  23. if( $good_info["good_type"] == 1 ) {
  24. $good_info["good_name"] = $_POST["gid"] == 15 ? $good_info["good_name"]."(回{$base_org_name})" : $base_org_name.$good_info["good_name"];
  25. if( isset($_ary_ticket_price1[$base_org_info["org_id"]]) && $good_id != 2 ) {
  26. $good_info["good_price"] = $good_id == 1 ? $_ary_ticket_price2[$base_org_info["org_id"]] : $_ary_ticket_price1[$base_org_info["org_id"]];
  27. }
  28. } else if( $good_info["good_type"] == 2 ) {
  29. $good_info["good_name"] = $_POST["gid"] == 3 ? "上海迪士尼乐园一日票" : "上海迪士尼乐园两日票";
  30. $good_price_array = $_POST["gid"] == 3 ? $_ary_disney_price1 : $_ary_disney_price2;
  31. }
  32. $order_user_id = 0;//need modify here
  33. if( isset($_COOKIE["opera_user_id"]) ) {
  34. $order_user_id = $_COOKIE["opera_user_id"];
  35. }
  36. $_POST["star_time"] = str_replace("年",".",$_POST["star_time"]);
  37. $_POST["star_time"] = str_replace("月",".",$_POST["star_time"]);
  38. $_POST["star_time"] = str_replace("日",".",$_POST["star_time"]);
  39. if( isset($_POST["end_time"]) && mb_strlen($_POST["end_time"]) > 0) {
  40. $_POST["end_time"] = str_replace("年",".",$_POST["end_time"]);
  41. $_POST["end_time"] = str_replace("月",".",$_POST["end_time"]);
  42. $_POST["end_time"] = str_replace("日",".",$_POST["end_time"]);
  43. }
  44. $start_day = "";
  45. $start_time = "";
  46. $end_day = "";
  47. $end_time = "";
  48. $start_day2 = "";
  49. $start_time2 = "";
  50. $end_day2 = "";
  51. $end_time2 = "";
  52. if( $good_info["good_type"] == 2 ) {
  53. //need modify here
  54. $start_day = sprintf( "%04d-%02d-%02d",substr($_POST["star_time"],0,4), substr($_POST["star_time"],5,2), substr($_POST["star_time"],8,2));
  55. $start_time = "";
  56. $end_day = "";
  57. $end_time = "";
  58. $order_price = $good_price_array[0] * $_POST["number2"] + $good_price_array[1] * $_POST["number3"] + $good_price_array[2] * $_POST["number4"];
  59. $prod_name = $good_info["good_name"].":";
  60. if( $_POST["number2"] > 0 ) { $prod_name .= $_ary_tickets_type[0]."×".$_POST["number2"]." "; }
  61. if( $_POST["number3"] > 0 ) { $prod_name .= $_ary_tickets_type[1]."×".$_POST["number3"]." "; }
  62. if( $_POST["number4"] > 0 ) { $prod_name .= $_ary_tickets_type[2]."×".$_POST["number4"]." "; }
  63. } if( $good_info["good_type"] == 4 || $good_info["good_type"] == 5 ) {
  64. $start_day = sprintf( "%04d-%02d-%02d",substr($_POST["star_time"],0,4), substr($_POST["star_time"],5,2), substr($_POST["star_time"],8,2));
  65. $end_day = sprintf( "%04d-%02d-%02d",substr($_POST["star_time"],0,4), substr($_POST["star_time"],5,2), substr($_POST["star_time"],8,2));
  66. $start_station = substr($_POST["up_car"], 6);
  67. $end_station = substr($_POST["down_car"], 6);
  68. $start_time = substr($_POST["up_car"],0,5);
  69. $end_time = substr($_POST["down_car"],0,5);
  70. $prod_name = $good_info["good_name"].":(".$start_station."到".$end_station.")";
  71. $order_price = $good_info["good_price"] * $_POST["number1"];
  72. } else {
  73. $prod_name = $good_info["good_name"]."×".$_POST["number1"];
  74. $order_price = $good_info["good_price"] * $_POST["number1"];
  75. if( $good_info["good_type"] == 1 ) {
  76. $time_array1 = explode("-", $_POST["star_time"]);
  77. $start_time1_array = explode(".", $time_array1[0]);
  78. $start_day = sprintf( "%04d-%02d-%02d", $start_time1_array[0], $start_time1_array[1], $start_time1_array[2]);
  79. $start_time = $start_time1_array[3];
  80. if( isset($time_array1[1]) ) {
  81. $end_time1_array = explode(".", $time_array1[1]);
  82. $end_day = sprintf("%04d-%02d-%02d", $end_time1_array[0], $end_time1_array[1], $end_time1_array[2]);
  83. $end_time = $end_time1_array[3];
  84. }
  85. if( isset($_POST["end_time"]) ) {
  86. if( isset($time_array1[1]) ) {
  87. $time_array2 = explode("-", $_POST["end_time"]);
  88. $start_time2_array = explode(".", $time_array2[0]);
  89. $end_time2_array = explode(".", $time_array2[1]);
  90. $start_day2 = sprintf("%04d-%02d-%02d", $start_time2_array[0], $start_time2_array[1], $start_time2_array[2]);
  91. $end_day2 = sprintf("%04d-%02d-%02d", $end_time2_array[0], $end_time2_array[1], $end_time2_array[2]);
  92. $start_time2 = $start_time2_array[3];
  93. $end_time2 = $end_time2_array[3];
  94. } else {
  95. $end_time1_array = explode(".", $_POST["end_time"]);
  96. $end_day = sprintf("%04d-%02d-%02d", $end_time1_array[0], $end_time1_array[1], $end_time1_array[2]);
  97. $end_time = $end_time1_array[3];
  98. }
  99. }
  100. } else {
  101. $start_time_array = explode(".", $_POST["star_time"]);
  102. $start_day = sprintf( "%04d-%02d-%02d", $start_time_array[0], $start_time_array[1], $start_time_array[2]);
  103. $start_time = $start_time_array[3];
  104. }
  105. }
  106. $insert_order_array = array(
  107. "order_serial_no" => $order_serial_no,//test
  108. "org_id" => $org_id,//test
  109. "status" => 0,
  110. "is_payed" => 0,
  111. "pay_type" => 0,
  112. "pay_no" => "",
  113. "prod_id" =>$_POST["gid"],
  114. "prod_name" => $prod_name,
  115. "order_user_id" => $order_user_id,
  116. "create_time" => date('Y-m-d H:i:s'),
  117. "order_price" => $order_price,
  118. "afli_price" => 0,
  119. "comment" => "" ,
  120. "start_day" => $start_day,
  121. "start_time" => $start_time,
  122. "end_day" => $end_day,
  123. "end_time" => $end_time,
  124. "start_day2" => $start_day2,
  125. "start_time2" => $start_time2,
  126. "end_day2" => $end_day2,
  127. "end_time2" => $end_time2,
  128. "cus_name" => $_POST["name"],
  129. "cus_mobile" => $_POST["phone"],
  130. "cus_iden" => $_POST["idcard"]
  131. );
  132. $insert_result = $objDisney->insertNewOrder($insert_order_array);
  133. if( false == $insert_result ) {
  134. echo "预定失败";exit();
  135. }
  136. $last_order_info = $objDisney->getOrderInfoFromSN($order_serial_no);
  137. $insert_order_id = $last_order_info['id'];
  138. $insert_order_goods_array = array();
  139. $base_order_good_info = array(
  140. "order_id" => $insert_order_id,
  141. "good_id" => $_POST["gid"],
  142. "good_name" => $good_info["good_name"],
  143. "subtype" => 0,
  144. "good_per_price" => $good_info["good_price"],
  145. "good_num" => $_POST["number1"],
  146. "all_price" => $good_info["good_price"] * $_POST["number1"],
  147. "afli_price" => 0,
  148. "start_day" => $start_day,
  149. "start_time" => $start_time,
  150. "end_day" => $end_day,
  151. "end_time" => $end_time,
  152. "start_day2" => $start_day2,
  153. "start_time2" => $start_time2,
  154. "end_day2" => $end_day2,
  155. "end_time2" => $end_time2,
  156. );
  157. if( $good_info["good_type"] == 2 ) {
  158. for( $index_temp = 0; $index_temp < 3; $index_temp++ ) {
  159. $num_index = "number".($index_temp+2);
  160. if( $_POST[$num_index] <= 0) {
  161. continue;
  162. }
  163. $insert_array_temp = $base_order_good_info;
  164. $insert_array_temp["good_id"] =$_POST["gid"]+$index_temp;
  165. $insert_array_temp["good_name"] = $good_info["good_name"].$_ary_tickets_type[$index_temp];
  166. $insert_array_temp["good_per_price"] = $good_price_array[$index_temp];
  167. $insert_array_temp["good_num"] = $_POST[$num_index];
  168. $insert_array_temp["all_price"] = $insert_array_temp["good_per_price"] * $_POST[$num_index];
  169. $insert_array_temp["subtype"] = $index_temp;
  170. $insert_order_goods_array[] = $insert_array_temp;
  171. }
  172. } else {
  173. $insert_order_goods_array[] = $base_order_good_info;
  174. }
  175. $objDisney->insertOrderGoods($insert_order_goods_array);
  176. if( $is_smartphone == true ) {
  177. header("Location: pay.php?orderno=" . $order_serial_no);
  178. exit();
  179. } else {
  180. header("Location: paysuccess.php?orderno=" . $order_serial_no);
  181. exit();
  182. }
  183. ?>