Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

246 linhas
9.3 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. require_once '../php_include/zizai_api.inc';
  6. date_default_timezone_set('PRC');
  7. $current_date = date("Y-m-d");
  8. if( $current_date >= "2016-09-01" ) {
  9. header("Location:http://sfx.zhizhuchuxing.com/");
  10. exit();
  11. }
  12. //DB
  13. $objDbh = new Db;
  14. $objDbh->setAccount(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
  15. $objDisney = new DbDisney($objDbh);
  16. if( !isset($_POST["gid"])) {
  17. header("Location:list.php?cc=".$_COOKIE["companycode"]);exit();
  18. }
  19. $base_org_info = $objDisney->getBaseOrgInfoFromCode( $_COOKIE["companycode"] );
  20. $base_org_name = false == $base_org_info ? "酒店" : $base_org_info["org_name"];
  21. $good_info=$objDisney->getGoodInfoFromId($_POST["gid"]);
  22. $order_serial_no = date("ymdHis").sprintf("%06d",rand( 1, 999999));
  23. $org_id = $base_org_info["org_id"];
  24. if( $good_info["good_type"] == 1 ) {
  25. $good_info["good_name"] = $_POST["gid"] == 15 ? $good_info["good_name"]."(回{$base_org_name})" : $base_org_name.$good_info["good_name"];
  26. if( isset($_ary_ticket_price1[$base_org_info["org_id"]]) && $good_id != 2 ) {
  27. $good_info["good_price"] = $good_id == 1 ? $_ary_ticket_price2[$base_org_info["org_id"]] : $_ary_ticket_price1[$base_org_info["org_id"]];
  28. }
  29. } else if( $good_info["good_type"] == 2 ) {
  30. $good_info["good_name"] = $_POST["gid"] == 3 ? "上海迪士尼乐园一日票" : "上海迪士尼乐园两日票";
  31. $good_price_array = $_POST["gid"] == 3 ? $_ary_disney_price1 : $_ary_disney_price2;
  32. }
  33. $order_user_id = 0;//need modify here
  34. if( isset($_COOKIE["opera_user_id"]) ) {
  35. $order_user_id = $_COOKIE["opera_user_id"];
  36. }
  37. $_POST["star_time"] = str_replace("年",".",$_POST["star_time"]);
  38. $_POST["star_time"] = str_replace("月",".",$_POST["star_time"]);
  39. $_POST["star_time"] = str_replace("日",".",$_POST["star_time"]);
  40. if( isset($_POST["end_time"]) && mb_strlen($_POST["end_time"]) > 0) {
  41. $_POST["end_time"] = str_replace("年",".",$_POST["end_time"]);
  42. $_POST["end_time"] = str_replace("月",".",$_POST["end_time"]);
  43. $_POST["end_time"] = str_replace("日",".",$_POST["end_time"]);
  44. }
  45. $start_day = "";
  46. $start_time = "";
  47. $end_day = "";
  48. $end_time = "";
  49. $start_day2 = "";
  50. $start_time2 = "";
  51. $end_day2 = "";
  52. $end_time2 = "";
  53. if( $good_info["good_type"] == 2 ) {
  54. //need modify here
  55. $start_day = sprintf( "%04d-%02d-%02d",substr($_POST["star_time"],0,4), substr($_POST["star_time"],5,2), substr($_POST["star_time"],8,2));
  56. $start_time = "";
  57. $end_day = "";
  58. $end_time = "";
  59. $order_price = $good_price_array[0] * $_POST["number2"] + $good_price_array[1] * $_POST["number3"] + $good_price_array[2] * $_POST["number4"];
  60. $prod_name = $good_info["good_name"].":";
  61. if( $_POST["number2"] > 0 ) { $prod_name .= $_ary_tickets_type[0]."×".$_POST["number2"]." "; }
  62. if( $_POST["number3"] > 0 ) { $prod_name .= $_ary_tickets_type[1]."×".$_POST["number3"]." "; }
  63. if( $_POST["number4"] > 0 ) { $prod_name .= $_ary_tickets_type[2]."×".$_POST["number4"]." "; }
  64. } else {
  65. $prod_name = $good_info["good_name"]."×".$_POST["number1"];
  66. $order_price = $good_info["good_price"] * $_POST["number1"];
  67. if( $good_info["good_type"] == 1 ) {
  68. $time_array1 = explode("-", $_POST["star_time"]);
  69. $start_time1_array = explode(".", $time_array1[0]);
  70. $start_day = sprintf( "%04d-%02d-%02d", $start_time1_array[0], $start_time1_array[1], $start_time1_array[2]);
  71. $start_time = $start_time1_array[3];
  72. if( isset($time_array1[1]) ) {
  73. $end_time1_array = explode(".", $time_array1[1]);
  74. $end_day = sprintf("%04d-%02d-%02d", $end_time1_array[0], $end_time1_array[1], $end_time1_array[2]);
  75. $end_time = $end_time1_array[3];
  76. }
  77. if( isset($_POST["end_time"]) ) {
  78. if( isset($time_array1[1]) ) {
  79. $time_array2 = explode("-", $_POST["end_time"]);
  80. $start_time2_array = explode(".", $time_array2[0]);
  81. $end_time2_array = explode(".", $time_array2[1]);
  82. $start_day2 = sprintf("%04d-%02d-%02d", $start_time2_array[0], $start_time2_array[1], $start_time2_array[2]);
  83. $end_day2 = sprintf("%04d-%02d-%02d", $end_time2_array[0], $end_time2_array[1], $end_time2_array[2]);
  84. $start_time2 = $start_time2_array[3];
  85. $end_time2 = $end_time2_array[3];
  86. } else {
  87. $end_time1_array = explode(".", $_POST["end_time"]);
  88. $end_day = sprintf("%04d-%02d-%02d", $end_time1_array[0], $end_time1_array[1], $end_time1_array[2]);
  89. $end_time = $end_time1_array[3];
  90. }
  91. }
  92. } else {
  93. $start_time_array = explode(".", $_POST["star_time"]);
  94. $start_day = sprintf( "%04d-%02d-%02d", $start_time_array[0], $start_time_array[1], $start_time_array[2]);
  95. $start_time = $start_time_array[3];
  96. }
  97. }
  98. $trade_no = "";
  99. $order_comment = "";
  100. //zizai check
  101. if( ($good_info["good_type"] == 2 || $good_info["good_type"] == 3) ) {
  102. if ($_POST["gid"] == 3) {
  103. $ticket_array = get_disney_info($start_day);
  104. } else if ($_POST["gid"] == 6) {
  105. $ticket_array = get_disney_info2($start_day);
  106. } else if ($_POST["gid"] >= 9 && $_POST["gid"] <= 14) {
  107. $start_week_day = date("w", strtotime($start_day));
  108. if ($start_week_day == 6 || $start_week_day == 0) {
  109. $ticket_array = get_disney_info3($start_day, $start_time);
  110. } else {
  111. $ticket_array = get_disney_info3($start_day);
  112. }
  113. }
  114. if ($ticket_array == false) {
  115. header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
  116. exit();
  117. }
  118. $customer_txt = '{|' . $_POST["name"] . '|' . $_POST["phone"] . '|' . $_POST["idcard"] . '||}';
  119. $buy_prod_txt = "";
  120. if ($good_info["good_type"] == 2) {
  121. $base_prod_index = $_POST["gid"] == 3 ? 1 : 4;
  122. for ($number_index = 2; $number_index <= 4; $number_index++) {
  123. $post_index = "number" . $number_index;
  124. $ticket_index = $_ary_goods_zizai_index[$base_prod_index + $number_index];
  125. $buy_prod_info = $ticket_array[$ticket_index];
  126. if ($buy_prod_info["ticketcount"] < $_POST[$post_index]) {
  127. header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
  128. exit();
  129. }
  130. $buy_prod_txt .= $buy_prod_info["ticketid"] . "P" . $_POST[$post_index] . "|";
  131. }
  132. } else {
  133. $ticket_index = $_ary_goods_zizai_index[$_POST["gid"]];
  134. $buy_prod_info = $ticket_array[$ticket_index];
  135. if ($buy_prod_info["ticketcount"] < $_POST["number1"]) {
  136. header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
  137. exit();
  138. }
  139. $buy_prod_txt .= $buy_prod_info["ticketid"] . "P" . $_POST["number1"] . "|";
  140. }
  141. $result_info = lock(API_USER, API_PASSWORD, 15, $buy_prod_txt, $customer_txt, "", "", "");
  142. if ($result_info["code"] == 0) {
  143. $trade_no = $result_info["tradeno"];
  144. } else {
  145. header("Location:sold_out.php?cc=" . $_COOKIE["companycode"]);
  146. exit();
  147. }
  148. if ($trade_no != "" && $is_smartphone == false) {
  149. $result_info = eticket(API_USER, API_PASSWORD, $trade_no);
  150. if ($result_info["code"] == 0) {
  151. $order_comment = "已在自在自动下单,订单号:" . $trade_no;
  152. } else {
  153. $order_comment = "自在自动下单失败,失败原因:" . $result_info["info"];
  154. }
  155. }
  156. }
  157. $insert_order_array = array(
  158. "order_serial_no" => $order_serial_no,//test
  159. "org_id" => $org_id,//test
  160. "status" => 0,
  161. "is_payed" => 0,
  162. "pay_type" => 0,
  163. "pay_no" => "",
  164. "prod_id" =>$_POST["gid"],
  165. "prod_name" => $prod_name,
  166. "order_user_id" => $order_user_id,
  167. "create_time" => date('Y-m-d H:i:s'),
  168. "order_price" => $order_price,
  169. "afli_price" => 0,
  170. "comment" => $order_comment,
  171. "start_day" => $start_day,
  172. "start_time" => $start_time,
  173. "end_day" => $end_day,
  174. "end_time" => $end_time,
  175. "start_day2" => $start_day2,
  176. "start_time2" => $start_time2,
  177. "end_day2" => $end_day2,
  178. "end_time2" => $end_time2,
  179. "cus_name" => $_POST["name"],
  180. "cus_mobile" => $_POST["phone"],
  181. "cus_iden" => $_POST["idcard"],
  182. "outside_order_no" => $trade_no
  183. );
  184. $insert_result = $objDisney->insertNewOrder($insert_order_array);
  185. if( false == $insert_result ) {
  186. echo "预定失败";exit();
  187. }
  188. $last_order_info = $objDisney->getOrderInfoFromSN($order_serial_no);
  189. $insert_order_id = $last_order_info['id'];
  190. $insert_order_goods_array = array();
  191. $base_order_good_info = array(
  192. "order_id" => $insert_order_id,
  193. "good_id" => $_POST["gid"],
  194. "good_name" => $good_info["good_name"],
  195. "subtype" => 0,
  196. "good_per_price" => $good_info["good_price"],
  197. "good_num" => $_POST["number1"],
  198. "all_price" => $good_info["good_price"] * $_POST["number1"],
  199. "afli_price" => 0,
  200. "start_day" => $start_day,
  201. "start_time" => $start_time,
  202. "end_day" => $end_day,
  203. "end_time" => $end_time,
  204. "start_day2" => $start_day2,
  205. "start_time2" => $start_time2,
  206. "end_day2" => $end_day2,
  207. "end_time2" => $end_time2,
  208. );
  209. if( $good_info["good_type"] == 2 ) {
  210. for( $index_temp = 0; $index_temp < 3; $index_temp++ ) {
  211. $num_index = "number".($index_temp+2);
  212. if( $_POST[$num_index] <= 0) {
  213. continue;
  214. }
  215. $insert_array_temp = $base_order_good_info;
  216. $insert_array_temp["good_id"] =$_POST["gid"]+$index_temp;
  217. $insert_array_temp["good_name"] = $good_info["good_name"].$_ary_tickets_type[$index_temp];
  218. $insert_array_temp["good_per_price"] = $good_price_array[$index_temp];
  219. $insert_array_temp["good_num"] = $_POST[$num_index];
  220. $insert_array_temp["all_price"] = $insert_array_temp["good_per_price"] * $_POST[$num_index];
  221. $insert_array_temp["subtype"] = $index_temp;
  222. $insert_order_goods_array[] = $insert_array_temp;
  223. }
  224. } else {
  225. $insert_order_goods_array[] = $base_order_good_info;
  226. }
  227. $objDisney->insertOrderGoods($insert_order_goods_array);
  228. if( $is_smartphone == true ) {
  229. header("Location: pay.php?orderno=" . $order_serial_no);
  230. exit();
  231. } else {
  232. header("Location: paysuccess.php?orderno=" . $order_serial_no);
  233. exit();
  234. }
  235. ?>