Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

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