"; $c_price = $_POST['c_price']; $p_price = $_POST['p_price']; $ticket_type = $_POST['ticket_type']; $line_id = $_POST['line_id']; // $c_price = 100; // $p_price = 99; // $ticket_type = 1; // $line_id = 153097; $product_time = date("Y-m-d H:i:s",time() ); if($ticket_type == 1){ $prod_name = "普通座票"; $ticket_mark = 1; }else{ $prod_name = "普通座票(往返)"; $ticket_mark = 2; } $sql = "select order_id,res_id,area_id,inout_type from opera_product_station where prod_id = " . $line_id . " order by order_id"; $result = $pdo->query($sql); $station = $result->fetchAll(PDO::FETCH_ASSOC); $station_array = array(); foreach($station as $station_info){ //$station_array[$station_info['order_id']] = $station_info; if($station_info['inout_type'] == 108){ $start_array[$station_info['order_id']] = $station_info; }else{ $end_array = $station_info; } } $sql = "select id from opera_product order by id desc limit 1"; $result = $pdo->query($sql); $pro_id = $result->fetchAll(PDO::FETCH_ASSOC); $pro_id = $pro_id[0]['id'] + 1; //添加产品表信息 $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"; //添加产品属性表信息 $property_sql = "insert into opera_product_property(create_time,prod_id,type_id,property) values"; $price_sql = "insert into opera_product_price(prod_id,prod_type_id,prod_price,cus_price,create_time) values"; //print_r($start_array);print_r($end_array);die; foreach($start_array as $k => $v){ $product_str[] = "(" . $pro_id . "," . $pro_id . ",'" . $prod_name . "',82," . $line_id . ",1,1,'" . $product_time . "'," . $ticket_mark . ")"; $property_str[] = "('" . $product_time . "'," . $pro_id . ",112," . $v['res_id'] . ")"; $property_str[] = "('" . $product_time . "'," . $pro_id . ",113," . $end_array['res_id'] . ")"; $property_str[] = "('" . $product_time . "'," . $pro_id . ",125," . $v['area_id'] . ")"; $property_str[] = "('" . $product_time . "'," . $pro_id . ",126," . $end_array['area_id'] . ")"; $property_str[] = "('" . $product_time . "'," . $pro_id . ",71,72)"; $property_str[] = "('" . $product_time . "'," . $pro_id . ",158,159)"; $price_str[] = "(" . $pro_id . ",82,'" . $p_price . "','" . $c_price . "','" . $product_time . "')"; $pro_id ++ ; } $product_str = implode(",",$product_str); $property_str = implode(",",$property_str); $price_str = implode(",",$price_str); $product_sql .= $product_str; $property_sql .= $property_str; $price_sql .= $price_str; $product_result = $pdo->exec($product_sql); $property_result = $pdo->exec($property_sql); $price_result = $pdo->exec($price_sql); if($product_result && $property_result && $price_result){ $data['code'] = 0; $data['info'] = "票种添加成功"; }else{ $data['code'] = 1; $data['info'] = "代码错误,请联系系统管理员"; } //print_r($data);die; echo json_encode($data); ?>