|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- //酒店房型 添加和修改的接口
- require_once __DIR__.'/../Common/Mysql.php';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- $method=isset($_POST['method'])?$_POST['method']:'';
- $prod_id=isset($_POST['prod_id'])?$_POST['prod_id']:0;
- $info=isset($_POST['info'])?$_POST['info']:'';
- $dateTime=isset($_POST['dateTime'])?$_POST['dateTime']:'';
- $run_id=isset($_POST['run_id'])?$_POST['run_id']:'';
- if ($method == ''){
- echo json_encode(array("errcode"=>2,"errinfo"=>"参数不能为空"));
- exit;
- }
- if ($method=='add' && ($prod_id==0 || $info=='' || $dateTime=='')){
- echo json_encode(array("errcode"=>3,"errinfo"=>"参数不能为空"));
- exit;
- }else if($method=='del' && ($prod_id=='' || $dateTime=='' )){
- echo json_encode(array("errcode"=>4,"errinfo"=>"参数不能为空"));
- exit;
- }
- $userid=getUserId();
- if ($userid ===false){
- echo json_encode(array("errcode"=>1,"errinfo"=>"用户未登录"));
- exit;
- }
-
- $pdo=conn();
- if ($method=='add'){
-
- if(is_object($pdo)){
- $sql="CALL HT_STOCK_MANAGE(".$userid.",'".$method."','".$info."','".$dateTime."',".$prod_id.")";
- writeLog('HT_STOCK_MANAGE::add::'.$sql);
- $result=$pdo->query($sql);
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- writeLog("hotel_stock.php method=add".$sql."::".json_encode($rowset));
- if (is_array($rowset[0])){
- echo json_encode($rowset[0]);
- }
- }
- exit;
- }else if ($method =='del'){
- $sql="CALL HT_STOCK_MANAGE(".$userid.",'".$method."','".$info."','".$dateTime."',".$prod_id.")";
- writeLog('HT_STOCK_MANAGE::del::'.$sql);
- $result=$pdo->query($sql);
- $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
- $result->closeCursor();
- writeLog("hotel_stock.php method=del".$sql."::".json_encode($rowset));
- if (is_array($rowset[0])){
- echo json_encode($rowset[0]);
- }
- exit;
- }
|