getSaleRule($para_hotel_id, $para_base_room_type, $para_room_type, $para_distrib_name, $para_start_date, $current, $page_size); //$data_temp=$saleRule->getSaleRule('235', '10608', '1', '', '2016-11-10', '1', '5'); $data = array(); $data['code'] = "0"; $data['info'] = ""; $data['currpage'] = $data_temp['rowset'][0][0]['currpage']; $data['total_page'] = $data_temp['rowset'][0][0]['total_page']; $data['total'] = $data_temp['rowset'][0][0]['total']; $data['page_size'] = $data_temp['rowset'][0][0]['page_size']; $data['result'] = $data_temp['rowset'][1]; return $data; } //authorize_status=" + 1 + "&hotel_id=" + hotel_id + "&parent_room_type=" + parent_room_type + "&room_type=" + room_type_id + "&op=updateAuthorizeStatus&distrib_id_string=" + distrib_id; function updateAuthorizeStatus() { // writeLog('执行到这里了!'); $authorize_status = isset($_POST['authorize_status']) ? $_POST['authorize_status'] : (isset($_GET['authorize_status']) ? $_GET['authorize_status'] : ""); // 不为空 $hotel_id = isset($_POST['hotel_id']) ? $_POST['hotel_id'] : (isset($_GET['hotel_id']) ? $_GET['hotel_id'] : ""); // 不为空 默认给今天 $parent_room_type = isset($_POST['parent_room_type']) ? $_POST['parent_room_type'] : (isset($_GET['parent_room_type']) ? $_GET['parent_room_type'] : ""); // 可为空 $room_type = isset($_POST['room_type']) ? $_POST['room_type'] : (isset($_GET['room_type']) ? $_GET['room_type'] : ""); // 可为空 $para_start_date = isset($_POST['para_start_date']) ? $_POST['para_start_date'] : (isset($_GET['para_start_date']) ? $_GET['para_start_date'] : ""); // 可为空 $distrib_id_string = isset($_POST['distrib_id_string']) ? $_POST['distrib_id_string'] : (isset($_GET['distrib_id_string']) ? $_GET['distrib_id_string'] : ""); $saleRule = new SaleRule(); $data_temp = $saleRule->updateAuthorizeStatus($authorize_status, $hotel_id, $parent_room_type, $room_type, $para_start_date, $distrib_id_string); // $data_temp=$saleRule->getSaleRule(3,274,1,"",'2016-09-15'); $data = array(); $data['code'] = "0"; $data['info'] = ""; return $data; } function updateAuthorizeInfo() { $para_user_id = isset($_POST['para_user_id']) ? $_POST['para_user_id'] : (isset($_GET['para_user_id']) ? $_GET['para_user_id'] : ""); // 不为空 $para_hotel_id = isset($_POST['para_hotel_id']) ? $_POST['para_hotel_id'] : (isset($_GET['para_hotel_id']) ? $_GET['para_hotel_id'] : ""); // 不为空 $para_base_room_type = isset($_POST['para_base_room_type']) ? $_POST['para_base_room_type'] : (isset($_GET['para_base_room_type']) ? $_GET['para_base_room_type'] : ""); // 不为空 $para_room_type = isset($_POST['para_room_type']) ? $_POST['para_room_type'] : (isset($_GET['para_room_type']) ? $_GET['para_room_type'] : ""); // 不为空 $para_distrib_list = isset($_POST['para_distrib_list']) ? $_POST['para_distrib_list'] : (isset($_GET['para_distrib_list']) ? $_GET['para_distrib_list'] : ""); // 不为空 $para_start_date = isset($_POST['para_start_date']) ? $_POST['para_start_date'] : (isset($_GET['para_start_date']) ? $_GET['para_start_date'] : ""); // 不为空 $para_end_date = isset($_POST['para_end_date']) ? $_POST['para_end_date'] : (isset($_GET['para_end_date']) ? $_GET['para_end_date'] : ""); // 不为空 $para_week_day = isset($_POST['para_week_day']) ? $_POST['para_week_day'] : (isset($_GET['para_week_day']) ? $_GET['para_week_day'] : ""); // 不为空 $para_stock_type = isset($_POST['para_stock_type']) ? $_POST['para_stock_type'] : (isset($_GET['para_stock_type']) ? $_GET['para_stock_type'] : ""); // 不为空 $para_stock_num = isset($_POST['para_stock_num']) ? $_POST['para_stock_num'] : (isset($_GET['para_stock_num']) ? $_GET['para_stock_num'] : ""); // 不为空 $para_prod_price = isset($_POST['para_prod_price']) ? $_POST['para_prod_price'] : (isset($_GET['para_prod_price']) ? $_GET['para_prod_price'] : ""); // 不为空 $para_cus_price = isset($_POST['para_cus_price']) ? $_POST['para_cus_price'] : (isset($_GET['para_cus_price']) ? $_GET['para_cus_price'] : ""); // 不为空 $para_over_sale = isset($_POST['para_over_sale']) ? $_POST['para_over_sale'] : (isset($_GET['para_over_sale']) ? $_GET['para_over_sale'] : ""); // 超卖 if (empty($para_user_id) || empty($para_hotel_id) || empty($para_base_room_type) || empty($para_room_type) || empty($para_distrib_list) || empty($para_start_date) || empty($para_end_date) || empty($para_week_day) || empty($para_stock_type) ) { $data['code'] = "16"; $data['info'] = "错误的请求参数"; return $data; } // elseif (($para_prod_price==0 && $para_cus_price==0)||($para_prod_price>0 && $para_cus_price>0)){ // $data['code'] = "16"; // $data['info'] = "请正确输入价格"; // return $data; // } elseif ($para_stock_num === '' || $para_stock_num < 0) { $data['code'] = "17"; $data['info'] = "请正确输入库存数量"; return $data; } //$para_stock_num 数量判断,不能少于已售库存 $hotelOrder = new MakeHotelOrder(); //现在 修改数量是修改剩余数量,不需要限制最小数量 if($para_over_sale == 0){ if ($para_stock_type == 329) { $para_stock_num = 0; } else { $tmp = $hotelOrder->getSaled($para_start_date, $para_end_date, $para_hotel_id, $para_room_type, $para_distrib_list, $para_stock_num); if (!empty($tmp['order_list'])) { $data['code'] = "18"; $data['info'] = "库存数量不能少于已售数量"; return $data; } } } //固定数值,数量不能大于 // if($para_over_sale == 0){ $max = $hotelOrder->getMaxCount($para_start_date, $para_end_date, $para_hotel_id, $para_stock_num); if ($max['code'] != 0) { return $max; } // } //其他渠道商已经占用的库存数量 $used = $hotelOrder->getUsedCount($para_start_date, $para_end_date, $para_hotel_id, $para_base_room_type, $para_stock_num, $para_distrib_list, $max['rowset'][0]['tot']); if ($used['code'] != 0) { return $used; } $authorize_info = array(); $authorize_info['para_user_id'] = $para_user_id; $authorize_info['para_hotel_id'] = $para_hotel_id; $authorize_info['para_base_room_type'] = $para_base_room_type; $authorize_info['para_room_type'] = $para_room_type; $authorize_info['para_distrib_list'] = $para_distrib_list; $authorize_info['para_start_date'] = $para_start_date; $authorize_info['para_end_date'] = $para_end_date; $authorize_info['para_week_day'] = $para_week_day; $authorize_info['para_stock_type'] = $para_stock_type; $authorize_info['para_stock_num'] = $para_stock_num; $authorize_info['para_prod_price'] = $para_prod_price; $authorize_info['para_cus_price'] = $para_cus_price; $authorize_info['para_over_sale'] = $para_over_sale; $saleRule = new SaleRule; $data = $saleRule->updateAuthorizeInfo($authorize_info); return $data; } function getMaxStockNumber() { $para_hotel_id = isset($_POST['para_hotel_id']) ? $_POST['para_hotel_id'] : (isset($_GET['para_hotel_id']) ? $_GET['para_hotel_id'] : ""); // 不为空 $para_distrib_list = isset($_POST['para_distrib_list']) ? $_POST['para_distrib_list'] : (isset($_GET['para_distrib_list']) ? $_GET['para_distrib_list'] : ""); // 不为空 $para_start_date = isset($_POST['para_start_date']) ? $_POST['para_start_date'] : (isset($_GET['para_start_date']) ? $_GET['para_start_date'] : ""); // 不为空 $para_end_date = isset($_POST['para_end_date']) ? $_POST['para_end_date'] : (isset($_GET['para_end_date']) ? $_GET['para_end_date'] : ""); // 不为空 $para_room_type = isset($_POST['para_room_type']) ? $_POST['para_room_type'] : (isset($_GET['para_room_type']) ? $_GET['para_room_type'] : ""); // 不为空 $base_room_type = isset($_POST['para_base_room_type']) ? $_POST['para_base_room_type'] : (isset($_GET['para_base_room_type']) ? $_GET['para_base_room_type'] : ""); // 不为空 $hotelOrder = new MakeHotelOrder(); //9999不需要查看数字 $max = $hotelOrder->getMaxCount($para_start_date, $para_end_date, $para_hotel_id, 9999); if (isset($max['rowset']) && count($max['rowset']) > 0) { } else { return 0; } $used = $hotelOrder->getUsedCount($para_start_date, $para_end_date, $para_hotel_id, $base_room_type, 9999, $para_distrib_list, $max['rowset'][0]['tot']); if (isset($used['rowset']) && count($used['rowset']) > 0) { return $max['rowset'][0]['tot'] > $used['rowset'][0]['tot'] ? $max['rowset'][0]['tot'] - $used['rowset'][0]['tot'] : 0; } else { return $max['rowset'][0]['tot']; } } } $op = isset($_POST['op']) ? $_POST['op'] : (isset($_GET['op']) ? $_GET['op'] : ""); // 不为空 $saleRules = new SaleRuleInfo(); if ($op == 'getSaleRule') { $data = $saleRules->getSaleRule(); } else if ($op == 'updateAuthorizeStatus') { //更改授权状态 $data = $saleRules->updateAuthorizeStatus(); } else if ($op == 'updateAuthorizeInfo') { //批量修改 $data = $saleRules->updateAuthorizeInfo(); } else if ($op == 'getMaxStockNumber') { //批量修改 $data = $saleRules->getMaxStockNumber(); } echo json_encode($data); ?>