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.
 
 
 
 

99 lines
3.4 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. //载入配置文件和连接数据库
  4. // require_once 'Common/Mysql.php';
  5. // $pdo=conn();
  6. // echo "<pre>";
  7. $c_price = $_POST['c_price'];
  8. $p_price = $_POST['p_price'];
  9. $ticket_type = $_POST['ticket_type'];
  10. $line_id = $_POST['line_id'];
  11. // $c_price = 100;
  12. // $p_price = 99;
  13. // $ticket_type = 1;
  14. // $line_id = 153097;
  15. $product_time = date("Y-m-d H:i:s",time() );
  16. if($ticket_type == 1){
  17. $prod_name = "普通座票";
  18. $ticket_mark = 1;
  19. }else{
  20. $prod_name = "普通座票(往返)";
  21. $ticket_mark = 2;
  22. }
  23. $sql = "select order_id,res_id,area_id,inout_type from opera_product_station where prod_id = " . $line_id . " order by order_id";
  24. $result = $pdo->query($sql);
  25. $station = $result->fetchAll(PDO::FETCH_ASSOC);
  26. $station_array = array();
  27. foreach($station as $station_info){
  28. //$station_array[$station_info['order_id']] = $station_info;
  29. if($station_info['inout_type'] == 108){
  30. $start_array[$station_info['order_id']] = $station_info;
  31. }else{
  32. $end_array = $station_info;
  33. }
  34. }
  35. $sql = "select id from opera_product order by id desc limit 1";
  36. $result = $pdo->query($sql);
  37. $pro_id = $result->fetchAll(PDO::FETCH_ASSOC);
  38. $pro_id = $pro_id[0]['id'] + 1;
  39. //添加产品表信息
  40. $product_sql = "insert into opera_product(id,prod_id,prod_name,prod_type,parent_id,top_org_id,org_id,create_time,ticket_mark) values";
  41. //添加产品属性表信息
  42. $property_sql = "insert into opera_product_property(create_time,prod_id,type_id,property) values";
  43. $price_sql = "insert into opera_product_price(prod_id,prod_type_id,prod_price,cus_price,create_time) values";
  44. //print_r($start_array);print_r($end_array);die;
  45. foreach($start_array as $k => $v){
  46. $product_str[] = "(" . $pro_id . "," . $pro_id . ",'" . $prod_name . "',82," . $line_id . ",1,1,'" . $product_time . "'," . $ticket_mark . ")";
  47. $property_str[] = "('" . $product_time . "'," . $pro_id . ",112," . $v['res_id'] . ")";
  48. $property_str[] = "('" . $product_time . "'," . $pro_id . ",113," . $end_array['res_id'] . ")";
  49. $property_str[] = "('" . $product_time . "'," . $pro_id . ",125," . $v['area_id'] . ")";
  50. $property_str[] = "('" . $product_time . "'," . $pro_id . ",126," . $end_array['area_id'] . ")";
  51. $property_str[] = "('" . $product_time . "'," . $pro_id . ",71,72)";
  52. $property_str[] = "('" . $product_time . "'," . $pro_id . ",158,159)";
  53. $price_str[] = "(" . $pro_id . ",82,'" . $p_price . "','" . $c_price . "','" . $product_time . "')";
  54. $pro_id ++ ;
  55. }
  56. $product_str = implode(",",$product_str);
  57. $property_str = implode(",",$property_str);
  58. $price_str = implode(",",$price_str);
  59. $product_sql .= $product_str;
  60. $property_sql .= $property_str;
  61. $price_sql .= $price_str;
  62. $product_result = $pdo->exec($product_sql);
  63. $property_result = $pdo->exec($property_sql);
  64. $price_result = $pdo->exec($price_sql);
  65. if($product_result && $property_result && $price_result){
  66. $data['code'] = 0;
  67. $data['info'] = "票种添加成功";
  68. }else{
  69. $data['code'] = 1;
  70. $data['info'] = "代码错误,请联系系统管理员";
  71. }
  72. //print_r($data);die;
  73. echo json_encode($data);
  74. ?>