protected function _doCharge() { $arrDescription = array($this->_array_card[$this->card_type], $this->transaction, $this->user["ch_public_id"]); $strXml = '<?xml version="1.0" encoding="utf-16"?>'; $strXml .= '<CardRequest>'; $strXml .= '<Function>UseCard</Function>'; $strXml .= '<CardID>' . $this->seri . '</CardID>'; $strXml .= '<CardCode>' . $this->pin . '</CardCode>'; $strXml .= '<Description>' . implode('|', $arrDescription) . '</Description>'; $strXml .= '</CardRequest>'; $soap_client = new \SoapClient($this->url, ['trace' => 1, 'exception' => 0]); $response = $soap_client->Request(array("PartnerID" => $this->username, "RequestData" => (string) $this->encryptLocalPrivateKey($strXml))); $content = $this->decryptLocalPrivateKey($response->RequestResult); $content = simplexml_load_string(preg_replace('/(<\\?xml[^?]+?)utf-16/i', '$1utf-8', $content)); if (!empty($content)) { $content = json_encode($content); $content = json_decode($content, true); $description = explode("|", $content["Description"]); if ($content["ResponseStatus"] >= 10000) { $this->info_card = $content["ResponseStatus"]; $this->msg = "Success"; } else { $this->info_card = 0; $this->msg = $this->_error_card[$content["ResponseStatus"]]; } } else { $this->msg = "Hệ Thống Đang Bận Vui Lòng thử lại sau vài giây bạn nhé !!!"; $this->info_card = 0; } if (intval($this->info_card) >= 10000) { $response = array("status" => 1, "message" => "Bạn đã nạp : " . $this->info_card . " VNĐ. Vào tài khoản : " . $this->user["ch_nickname"], "partner_transaction" => $this->transaction, "value" => $this->info_card, "promotion" => $this->_promotion[$this->card_type]); } else { $response = array("status" => 0, "message" => $this->msg, "partner_transaction" => $this->transaction, "value" => 0, "promotion" => 0); } return $response; }
public static function GetHotelPlan($hotelList) { if(!is_array($hotelList) || count($hotelList) == 0) return; $now = time(); $ws = "http://openapi.ctrip.com/Hotel/OTA_HotelRatePlan.asmx?wsdl"; $xml = '<?xml version="1.0" encoding="utf-8"?><Request><Header AllianceID="' . self :: $aid . '" SID="' . self :: $sid . '" TimeStamp="' . $now . '" Signature="' . self :: GetSign($now, "OTA_HotelRatePlan") . '" RequestType="OTA_HotelRatePlan" /><HotelRequest><RequestBody xmlns:ns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ns:OTA_HotelRatePlanRQ TimeStamp="2013-06-01T00:00:00.000+08:00" Version="1.0"><ns:RatePlans>'; for($i = 0; $i < count($hotelList); $i++) { $xml .= '<ns:RatePlan><ns:DateRange Start="' . date('Y-m-d') . '" End="' . date('Y-m-d', time() + (7 * 24 * 60 * 60)) . '"/><ns:RatePlanCandidates><ns:RatePlanCandidate AvailRatesOnlyInd="true" ><ns:HotelRefs><ns:HotelRef HotelCode="' . $hotelList[$i] . '"/></ns:HotelRefs></ns:RatePlanCandidate></ns:RatePlanCandidates></ns:RatePlan>'; } $xml .= '</ns:RatePlans></ns:OTA_HotelRatePlanRQ></RequestBody></HotelRequest></Request>'; $logger = \Logger :: GetLogger("ctrip"); $logger->debug("查询酒店价格:请求xml\n" . $xml, __FUNCTION__); $client = new \SoapClient($ws); $result = $client->Request(array('requestXML' => $xml)); $xml = simplexml_load_string($result->RequestResult); $xml->asXML(__DIR__ . "/hotelpricedata/hotel" . $hotelList[0] . ".xml"); return; }
public function getAirlineDetail() { $retcode = "200"; $arr_message = array("result" => "fail", "message" => "操作出现异常,请稍后再试!"); $arr_body = $this->arr_body; $departCityCode = trim($arr_body['departCityCode']); $arriveCityCode = trim($arr_body['arriveCityCode']); $departTime = trim($arr_body['departTime']); $returnTime = trim($arr_body['returnTime']); $departDate = substr($departTime, 0, 10); $returnDate = substr($returnTime, 0, 10); $flight = trim($arr_body['flight']); $returnFlight = trim($arr_body['returnFlight']); $ws = "http://openapi.ctrip.com/Flight/DomesticFlight/OTA_FlightSearch.asmx?wsdl"; $now = time(); $xml = '<?xml version="1.0" encoding="utf-8"?><Request><Header AllianceID="' . $this->aid . '" SID="' . $this->sid . '" TimeStamp="' . $now . '" RequestType="OTA_FlightSearch" Signature="' . $this->GetSign($now, "OTA_FlightSearch") . '" /><FlightSearchRequest><SearchType>S</SearchType><Routes><FlightRoute><DepartCity>' . $departCityCode . '</DepartCity><ArriveCity>' . $arriveCityCode . '</ArriveCity><DepartDate>' . $departDate . '</DepartDate><EarliestDepartTime>' . $departTime . '</EarliestDepartTime><LatestDepartTime>' . $departTime . '</LatestDepartTime></FlightRoute>' . (($returnDate != "" && $returnTime != "" && $returnFlight != "") ? '<FlightRoute><DepartCity>' . $arriveCityCode . '</DepartCity><ArriveCity>' . $departCityCode . '</ArriveCity><DepartDate>' . $returnDate . '</DepartDate><EarliestDepartTime>' . $returnTime . '</EarliestDepartTime><LatestDepartTime>' . $returnTime . '</LatestDepartTime></FlightRoute>' : '') . '</Routes></FlightSearchRequest></Request>'; file_put_contents("/dx/mobilepay/log/debug.log", $xml . "\r\n", FILE_APPEND | LOCK_EX); $client = new SoapClient($ws); $result = $client->Request(array('requestXML' => $xml)); $flightList = array(); if(property_exists($result, "RequestResult")) { $xml = $result->RequestResult; } $xml = simplexml_load_string($xml); $flightCount = 0; if(isset($xml->FlightSearchResponse->FlightRoutes)) { $flightRoutesNode = $xml->FlightSearchResponse->FlightRoutes; $db = new DB_test(); foreach($flightRoutesNode->children() as $domesticFlightRouteNode) { $flightsListNode = $domesticFlightRouteNode->FlightsList; foreach ($flightsListNode->children() as $flightNode) { $sql = "INSERT INTO ctrip_airticket_flight_list (depart_city_code, depart_port_code, arrive_city_code, arrive_port_code, depart_time, arrive_time, flight, craft_code, airline_iata_code, seat_class, sub_seat_class, display_sub_seat_class, rate, price, standard_price, tax, oil_fee, standard_price_for_child, tax_for_child, oil_fee_for_child, standard_price_for_baby, tax_for_baby, oil_fee_for_baby, meal_type, stop_count, rer_code, end_code, ref_code, rer_note, end_note, ref_note, remark, quantity, punctuality_rate, ticket_type, price_type, product_type, product_source, inventory_type, before_fly_date, route_index, need_apply, recommend, refund_fee_formula_id, can_up_grade, can_separate_sale, can_no_defer, can_post, is_fly_man, only_own_city, is_lowest_cz_special_price, allow_cp_type, policy_id, is_rebate, rebate_amount) VALUES ('" . $flightNode->DepartCityCode . "', '" . strval($flightNode->DPortCode) . "', '" . strval($flightNode->ArriveCityCode) . "', '" . strval($flightNode->APortCode) . "', '" . strval($flightNode->TakeOffTime) . "', '" . strval($flightNode->ArriveTime) . "', '" . strval($flightNode->Flight) . "', '" . strval($flightNode->CraftType) . "', '" . strval($flightNode->AirlineCode) . "', '" . strval($flightNode->Class) . "', '" . strval($flightNode->SubClass) . "', '" . strval($flightNode->DisplaySubclass) . "', " . doubleval($flightNode->Rate) . ", " . doubleval($flightNode->Price) . ", " . doubleval($flightNode->StandardPrice) . ", " . doubleval($flightNode->AdultTax) . ", " . doubleval($flightNode->AdultOilFee) . ", " . doubleval($flightNode->ChildStandardPrice) . ", " . doubleval($flightNode->ChildTax) . ", " . doubleval($flightNode->ChildOilFee) . ", " . doubleval($flightNode->BabyStandardPrice) . ", " . doubleval($flightNode->BabyTax) . ", " . doubleval($flightNode->BabyOilFee) . ", '" . strval($flightNode->MealType) . "', " . intval($flightNode->StopTimes) . ", '" . strval($flightNode->Nonrer) . "', '" . strval($flightNode->Nonend) . "', '" . strval($flightNode->Nonref) . "', '" . strval($flightNode->Rernote) . "', '" . strval($flightNode->Endnote) . "', '" . strval($flightNode->Nonref) . "', '" . strval($flightNode->Remarks) . "', " . intval($flightNode->Quantity) . ", " . doubleval($flightNode->PunctualityRate) . ", " . intval($flightNode->TicketType) . ", '" . strval($flightNode->PriceType) . "', '" . strval($flightNode->ProductType) . "', " . intval($flightNode->ProductSource) . ", '" . strval($flightNode->InventoryType) . "', " . intval($flightNode->BeforeFlyDate) . ", " . intval($flightNode->RouteIndex) . ", '" . strval($flightNode->NeedApplyString) . "', " . intval($flightNode->Recommend) . ", " . intval($flightNode->RefundFeeFormulaID) . ", " . ((strval($flightNode->CanUpGrade) == "true") ? 1 : 0) . ", " . ((strval($flightNode->CanSeparateSale) == "true") ? 1 : 0) . ", " . ((strval($flightNode->CanNoDefer) == "true") ? 1 : 0) . ", " . ((strval($flightNode->CanPost) == "true") ? 1 : 0) . ", " . ((strval($flightNode->IsFlyMan) == "true") ? 1 : 0) . ", " . ((strval($flightNode->OnlyOwnCity) == "true") ? 1 : 0) . ", " . ((strval($flightNode->IsLowestCZSpecialPrice) == "true") ? 1 : 0) . ", " . intval($flightNode->AllowCPType) . ", " . intval($flightNode->PolicyID) . ", " . ((strval($flightNode->IsRebate) == "true") ? 1 : 0) . ", " . intval($flightNode->PolicyID) . ");"; $sql = auto_charset($sql, 'utf-8', 'gbk'); $db->query($sql); $flightCount++; } } $lastInsertId = $db->get_insert_id(); $sql = "SELECT id, flight, price, standard_price AS standardPrice, oil_fee AS oilFee, tax, standard_price_for_child AS standardPriceForChild, oil_fee_for_child AS oilFeeForChild, tax_for_child AS taxForChild, standard_price_for_baby AS standardPriceForBaby, oil_fee_for_baby AS oilFeeForBaby, tax_for_baby AS taxForBaby, quantity, display_sub_seat_class AS class, rer_note AS rerNote, end_note AS endNote, ref_note AS refNote FROM ctrip_airticket_flight_list WHERE depart_city_code = '" . $departCityCode . "' AND arrive_city_code = '" . $arriveCityCode . "' AND flight = '" . $flight . "' AND id > " . ($lastInsertId - $flightCount); if($returnDate != "" && $returnTime != "" && $returnFlight != "") { $sql .= " UNION SELECT id, flight, price, standard_price AS standardPrice, oil_fee AS oilFee, tax, standard_price_for_child AS standardPriceForChild, oil_fee_for_child AS oilFeeForChild, tax_for_child AS taxForChild, standard_price_for_baby AS standardPriceForBaby, oil_fee_for_baby AS oilFeeForBaby, tax_for_baby AS taxForBaby, quantity, display_sub_seat_class AS class, rer_note AS rerNote, end_note AS endNote, ref_note AS refNote FROM ctrip_airticket_flight_list WHERE depart_city_code = '" . $arriveCityCode . "' AND arrive_city_code = '" . $departCityCode . "' AND flight = '" . $returnFlight . "' AND id > " . ($lastInsertId - $flightCount); } $db->query($sql); $arr_msg = auto_charset($db->getData('', 'msgbody'), 'gbk', 'utf-8'); $arr_message = array("result" => "success", "message" => "查询航班成功"); } else { $arr_message = array("result" => "success", "message" => "航班信息有误"); } $retcode = "0"; $arr_msg['msgbody']['result'] = $arr_message['result']; $arr_msg['msgbody']['message'] = $arr_message['message']; $returnvalue = array ("msgbody" => $arr_msg['msgbody']); $returnval = TfbxmlResponse :: ResponsetoApp($retcode, $returnvalue); return $returnval; }