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.
 
 
 
 

431 lines
19 KiB

  1. <?php
  2. //require_once '../../Common/Mysql.php';
  3. //echo '<PRE>';
  4. if (ALLOW_ORIGIN)
  5. header("Access-Control-Allow-Origin:*");
  6. //require_once '../../Common/Mysql.php';
  7. $user_id = $_COOKIE['user_id'];
  8. $order_from_org_id = isset($_COOKIE['org_id']) ? $_COOKIE['org_id'] : 0;
  9. $top_org_id = $_COOKIE['top_org_id'];
  10. if (!$user_id) {
  11. echo json_encode(array("code" => 1, "iflogin" => 1, "info" => "用户未登录"));
  12. exit;
  13. }
  14. $mem_theater_array = get_memcache('lion_threater_info');
  15. if( $mem_theater_array == false ) {
  16. echo json_encode(array("code" => 1, "info" => "系统维护中,当前不接受预订,请稍后再试"));
  17. exit;
  18. }
  19. $tic_info = false;
  20. if (isset($_POST)) {
  21. $date = isset($_POST['date_time']) ? $_POST['date_time'] : '0';
  22. /*
  23. if ($date <= '2016-10-23') {
  24. echo json_encode(array("code" => 1, "info" => "系统维护暂停售票"));
  25. exit;
  26. }
  27. */
  28. if (isset($_POST['get_tic'])) {
  29. $date = $_POST['get_tic'];
  30. $time = $_POST['time'];
  31. if( isset($mem_theater_array[$date][$time]) ) {
  32. $tic_info = $mem_theater_array[$date][$time];
  33. } else {
  34. echo json_encode(array("code" => 1, "info" => "该时间段无演出"));
  35. exit;
  36. }
  37. echo json_encode(array("code" => 0, "info" => $tic_info['tic_info'], 'price' => $tic_info['price']));
  38. exit;
  39. }
  40. if( $mem_theater_array[$date] == false ) {
  41. $date_get = isset($_POST['date_get']) ? $_POST['date_get'] : '999';
  42. if ($date_get == 0) {
  43. echo json_encode(array("code" => 0, "info" => "","list"=>array('15:00')));
  44. exit;
  45. } elseif ($date_get == 1) {
  46. echo json_encode(array("code" => 1, "info" => "周一没有演出", "list" => array()));
  47. exit;
  48. } elseif ($date_get <= 5) {
  49. echo json_encode(array("code" => 0, "info" => "", "list" => array('19:00')));
  50. exit;
  51. } elseif ($date_get == 6) {
  52. echo json_encode(array("code" => 0, "info" => "", "list" => array('13:30', '19:00')));
  53. exit;
  54. }
  55. } else {
  56. $time_list = array();
  57. $list_tic_day = $mem_theater_array[$date];
  58. foreach( $list_tic_day as $time_key => $tic_array_tmp ) {
  59. $time_list[] = $time_key;
  60. }
  61. echo json_encode(array("code" => 0, "info" => "","list"=>$time_list));
  62. exit;
  63. }
  64. $date = $_POST['date_time'];
  65. $time = $_POST['time'];
  66. $cust_name = $_POST['customer_name'];
  67. $cust_phone = $_POST['customer_phone'];
  68. $id_type = 150; // 150身份证 153 护照
  69. $customer_id = '';
  70. if (!isset($_POST['date_time']) || !isset($_POST['time'])) {
  71. $code = 1;
  72. $info = '';
  73. $massge = 'fail';
  74. $list = "";
  75. $json['code'] = $code;
  76. $json['info'] = $info;
  77. $json['massge'] = $massge;
  78. $json['list'] = $list;
  79. echo json_encode($json);
  80. die;
  81. }
  82. //票种和数量价格 prod_id=>票的数量
  83. $ticket = array(
  84. 'AA' => isset($_POST['AA']) ? $_POST['AA'] : 0,
  85. 'AB' => isset($_POST['AB']) ? $_POST['AB'] : 0,
  86. 'BB' => isset($_POST['BB']) ? $_POST['BB'] : 0,
  87. 'BA' => isset($_POST['BA']) ? $_POST['BA'] : 0,
  88. 'CA' => isset($_POST['CA']) ? $_POST['CA'] : 0,
  89. 'CB' => isset($_POST['CB']) ? $_POST['CB'] : 0,
  90. );
  91. $buy_array = array(
  92. '0' => isset($_POST['AA']) ? $_POST['AA'] : 0,
  93. '1' => isset($_POST['AB']) ? $_POST['AB'] : 0,
  94. '3' => isset($_POST['BB']) ? $_POST['BB'] : 0,
  95. '2' => isset($_POST['BA']) ? $_POST['BA'] : 0,
  96. '4' => isset($_POST['CA']) ? $_POST['CA'] : 0,
  97. '5' => isset($_POST['CB']) ? $_POST['CB'] : 0
  98. );
  99. $ticket_no_b = serialize($buy_array);
  100. }
  101. if( !isset($date) || $date == false || $date == "" ) {
  102. echo json_encode(array("code" => 1, "info" => '请选择演出时间'));
  103. exit ;
  104. }
  105. if( !isset($time) || $time == false || $time == "" ) {
  106. echo json_encode(array("code" => 1, "info" => '请选择演出时间'));
  107. exit ;
  108. }
  109. if(!isset($mem_theater_array[$date][$time])) {
  110. echo json_encode(array("code" => 1, "info" => "该时间段无演出"));
  111. exit;
  112. }
  113. if( $tic_info == false ) {
  114. $tic_info = $mem_theater_array[$date][$time];
  115. }
  116. //check ticket num
  117. foreach( $buy_array as $buy_key => $buy_count ) {
  118. $ticket_remain_count = $tic_info['tic_info'][$buy_key];
  119. if( $ticket_remain_count < $buy_count ) {
  120. echo json_encode(array("code" => 1, "info" => '预订票数超出余票数量' ));
  121. exit ;
  122. }
  123. }
  124. //$tic_buy = buy_lionking_ticket('魏意锡','18663582623','371521199011034631',$buy_array,'2016-8-13','13:30');
  125. $tic_buy = buy_lionking_ticket($cust_name, $cust_phone, $customer_id, $buy_array, $date, $time, $tic_info["ticket_array"]);
  126. if ($tic_buy == '-1' || $tic_buy == '0') {
  127. echo json_encode(array("code" => 1, "info" => '出票失败'));
  128. exit;
  129. }
  130. $pdo = conn();
  131. $sql = "select a.prod_id,a.prod_name,b.prod_price,b.prod_type_id "
  132. . "from opera_product a inner join opera_product_price b on a.prod_id = b.prod_id "
  133. . "where a.parent_id = 387544";
  134. $result = $pdo->query($sql);
  135. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  136. $info = array();
  137. foreach ($rowset as $v) {
  138. $info[$v['prod_id']] = $v;
  139. }
  140. $sql_p = "select prod_id,prod_name "
  141. . " from opera_product "
  142. . " where prod_id = 387544";
  143. $result_p = $pdo->query($sql_p);
  144. $rowset_p = $result_p->fetchAll(PDO::FETCH_ASSOC);
  145. $info_p = $rowset_p[0];
  146. /**
  147. * 迪士尼票种信息
  148. * 152990 =>
  149. * array
  150. * 'prod_id' => string '152990' (length=6)
  151. * 'prod_name' => string '迪士尼门票(成人票)' (length=30)
  152. * 'prod_price' => string '20.00' (length=5)
  153. * 'prod_type_id' => string '262' (length=3)
  154. */
  155. $num = 0;
  156. $order_description = "";
  157. $price = 0;
  158. $return_info = '';
  159. //var_dump($info);die;
  160. foreach ($ticket as $k => $v) {
  161. $num += $v;
  162. if ($v) {
  163. switch ($k) {
  164. case 'AA':
  165. $price += $tic_info['price']['0'] * $v;
  166. $return_info .= ' AA区 × ' . $v;
  167. $order_description .= "迪士尼剧场AA区," . date('Y-m-d', time()) . "," . $v . "|";
  168. break;
  169. case 'AB':
  170. $price += $tic_info['price']['1'] * $v;
  171. $return_info .= ' AB区 × ' . $v;
  172. $order_description .= "迪士尼剧场AB区," . date('Y-m-d', time()) . "," . $v . "|";
  173. break;
  174. case 'BB':
  175. $price += $tic_info['price']['3'] * $v;
  176. $return_info .= ' BB区 × ' . $v;
  177. $order_description .= "迪士尼剧场BB区," . date('Y-m-d', time()) . "," . $v . "|";
  178. break;
  179. case 'BA':
  180. $price += $tic_info['price']['2'] * $v;
  181. $return_info .= ' BA区 × ' . $v;
  182. $order_description .= "迪士尼剧场BA区," . date('Y-m-d', time()) . "," . $v . "|";
  183. break;
  184. case 'CA':
  185. $price += $tic_info['price']['4'] * $v;
  186. $return_info .= ' CA区 × ' . $v;
  187. $order_description .= "迪士尼剧场CA区," . date('Y-m-d', time()) . "," . $v . "|";
  188. break;
  189. case 'CB':
  190. $price += $tic_info['price']['5'] * $v;
  191. $return_info .= ' CB区 × ' . $v;
  192. $order_description .= "迪士尼剧场CB区," . date('Y-m-d', time()) . "," . $v . "|";
  193. break;
  194. }
  195. }
  196. }
  197. if ($num <= 0) {
  198. $code = 1;
  199. $info = '';
  200. $massge = 'fail';
  201. $list = "";
  202. $json['code'] = $code;
  203. $json['info'] = $info;
  204. $json['massge'] = $massge;
  205. $json['list'] = $list;
  206. echo json_encode($json);
  207. die;
  208. }
  209. //支付方式
  210. if (isset($_COOKIE['login_type']) || $top_org_id == 0) {
  211. $pay_status = 145;
  212. $pay_type_id_1 = 278;
  213. } else {
  214. $pay_status = 146;
  215. $pay_type_id_1 = 275;
  216. }
  217. //订单插入需要的字段 id = order_id create_time update_time order_pay_satatus 0 未支付 order_description order_price order_prod_type
  218. // prod_name order_status customer_name customer_mobile customer_id_type customer_id _no
  219. // 至订单需要的之短 parent_order_id prod_id parent_prod_id prod_name parent_prod_name order_price
  220. $id_p = $order_id_p = getUniqeId1();
  221. $pay_main_id = getUniqeId1();
  222. $create_time = $update_time = date('Y-m-d H:i:s', time());
  223. $order_pay_status = 0;
  224. //查找数据库中关于迪士尼的信息
  225. $sql_in = " insert into order_main
  226. (`id`,
  227. `order_id`,
  228. `create_time`,`update_time`,
  229. `order_pay_status`,`order_description`,
  230. `order_price`,`order_prod_type`,`prod_name`,`order_status`,
  231. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  232. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`prod_id`,`run_date`,`run_time`,`main_create_user_id`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`)
  233. values ('" . $id_p . "','". $order_id_p . "','" . $create_time . "','" . $update_time . "','0','" . $order_description . "','"
  234. . $price . "','259','" . $info_p['prod_name'] . "','" . $pay_status . "','"
  235. . $cust_name . "','" . $cust_phone . "','" . $id_type . "','" . $customer_id . "','1','0','" . $info_p['prod_id'] . "','" . $date . "','" . $time . "','" . $user_id . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "')";
  236. for_insert($sql_in);
  237. $sql_pay = "insert INTO"
  238. . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
  239. . "VALUES(" . $pay_main_id . "," . $user_id . ",'" . date('Y-m-d H-i-s', time()) . "'," . $user_id . "," . $price . ");"
  240. . "insert INTO `order_pay_detail`
  241. (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
  242. VALUES(" . $pay_main_id . "," . $user_id . ",'" . date('Y-m-d H-i-s', time()) . "'," . $user_id . "," . $pay_main_id . "," . $pay_type_id_1 . "," . $price . ");";
  243. for_insert($sql_pay);
  244. foreach ($ticket as $k => $v) {
  245. if ($v) {
  246. switch ($k) {
  247. case 'AA':
  248. for ($i = 1; $i <= $v; $i++) {
  249. $id = $order_id = getUniqeId1();
  250. $sql = " insert into order_main
  251. (`id`,
  252. `order_id`,
  253. `create_time`,`update_time`,
  254. `order_pay_status`,
  255. `order_prod_type`,`order_status`,
  256. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  257. `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`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  258. values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
  259. . $customer_id . "','0','0','" . $id_p . "','" . $info['387545']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387545']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['0'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
  260. for_insert($sql);
  261. }
  262. break;
  263. case 'AB':
  264. for ($i = 1; $i <= $v; $i++) {
  265. $id = $order_id = getUniqeId1();
  266. $sql = " insert into order_main
  267. (`id`,
  268. `order_id`,
  269. `create_time`,`update_time`,
  270. `order_pay_status`,
  271. `order_prod_type`,`order_status`,
  272. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  273. `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`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  274. values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
  275. . $customer_id . "','0','0','" . $id_p . "','" . $info['387546']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387546']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['1'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
  276. for_insert($sql);
  277. }
  278. break;
  279. case 'BB':
  280. for ($i = 1; $i <= $v; $i++) {
  281. $id = $order_id = getUniqeId1();
  282. $sql = " insert into order_main
  283. (`id`,
  284. `order_id`,
  285. `create_time`,`update_time`,
  286. `order_pay_status`,
  287. `order_prod_type`,`order_status`,
  288. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  289. `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`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  290. values ('" . $id . "','"
  291. . $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','"
  292. . $id_type . "','" . $customer_id . "','0','0','" . $id_p . "','" . $info['387547']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387547']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['3'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
  293. for_insert($sql);
  294. }
  295. break;
  296. case 'BA':
  297. for ($i = 1; $i <= $v; $i++) {
  298. $id = $order_id = getUniqeId1();
  299. $sql = " insert into order_main
  300. (`id`,
  301. `order_id`,
  302. `create_time`,`update_time`,
  303. `order_pay_status`,
  304. `order_prod_type`,`order_status`,
  305. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  306. `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`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  307. values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
  308. . $customer_id . "','0','0','" . $id_p . "','" . $info['387548']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387548']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['2'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
  309. for_insert($sql);
  310. }
  311. break;
  312. case 'CA':
  313. for ($i = 1; $i <= $v; $i++) {
  314. $id = $order_id = getUniqeId1();
  315. $sql = " insert into order_main
  316. (`id`,
  317. `order_id`,
  318. `create_time`,`update_time`,
  319. `order_pay_status`,
  320. `order_prod_type`,`order_status`,
  321. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  322. `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`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  323. values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
  324. . $customer_id . "','0','0','" . $id_p . "','" . $info['387549']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387549']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['4'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
  325. for_insert($sql);
  326. }
  327. break;
  328. case 'CB':
  329. for ($i = 1; $i <= $v; $i++) {
  330. $id = $order_id = getUniqeId1();
  331. $sql = " insert into order_main
  332. (`id`,
  333. `order_id`,
  334. `create_time`,`update_time`,
  335. `order_pay_status`,
  336. `order_prod_type`,`order_status`,
  337. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  338. `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`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  339. values ('" . $id . "','". $order_id . "','" . $create_time . "','" . $update_time . "','0','259','" . $pay_status . "','" . $cust_name . "','" . $cust_phone . "','" . $id_type . "','"
  340. . $customer_id . "','0','0','" . $id_p . "','" . $info['387550']['prod_id'] . "','" . $info_p['prod_id'] . "','" . $info['387550']['prod_name'] . "','" . $info_p['prod_name'] . "','" . $tic_info['price']['5'] . "','" . $date . "','" . $time . "','" . $pay_main_id . "','" . $order_from_org_id . "','" . $tic_buy . "','" . $user_id . "')";
  341. for_insert($sql);
  342. }
  343. break;
  344. }
  345. }
  346. }
  347. function for_insert($sql)
  348. {
  349. // echo $sql;
  350. $pdo = conn();
  351. $re = $pdo->exec($sql);
  352. if ($re == 0) {
  353. echo json_encode(array("code" => 1, "info" => "error_sql=" . "$sql"));
  354. exit;
  355. }
  356. }
  357. if ($_COOKIE['top_org_id']) {
  358. true_buy_disney($tic_buy);
  359. } else {
  360. $sql = "INSERT into `disney_order`(order_id,yet,cust_name,cust_phone,customer_id,ticket_no,date,create_time,dis_the,time) VALUES(" . $id_p . ",1,'" . $cust_name . "','" . $cust_phone . "','" . $customer_id . "','" . $ticket_no_b . "','" . $date . "',null,1,'" . $time . "');";
  361. $result = $pdo->query($sql);
  362. //$rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  363. if (!$result) {
  364. echo json_encode(array("code" => 1, "info" => '下单失败'));
  365. exit;
  366. }
  367. }
  368. $list = array();
  369. $list['type'] = $info_p['prod_name'];
  370. $list['date'] = $date;
  371. $list['desc'] = $return_info;
  372. $list['price'] = $price;
  373. $list['name'] = $cust_name;
  374. $list['phone'] = $cust_phone;
  375. $list['order_id'] = $id_p;
  376. $code = 0;
  377. $info = '0';
  378. $massge = 'success';
  379. $json['code'] = $code;
  380. $json['info'] = $info;
  381. $json['order_id'] = $id_p;
  382. $json['massge'] = $massge;
  383. $json['list'] = $list;
  384. $json['ifdisney'] = 1;
  385. echo json_encode($json);
  386. die;
  387. function getUniqeId1()
  388. {
  389. $pdo = conn();
  390. $result = $pdo->query("select FUNC_GET_UNIQUE_ID('1','1') id");
  391. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  392. return $rowset[0]['id'];
  393. }