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.
 
 
 
 

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