@chuxingpay/licheng
Version:
### 安装
254 lines (238 loc) • 5.97 kB
JavaScript
const Request = require('./request')
const debug = require('debug')('LiChengSDK')
class lichengSDK {
constructor({ url, sid, key }) {
this.sid = sid
this.url = url
this.key = key
this.request = new Request(url, sid, key)
}
/**
* 酒店城市列表
* @returns Response
*/
async getHotelCityList(groupId) {
const uri = '/default/hotel/citylist'
const query = {
groupId: groupId
}
return this.request.post(uri, query)
}
/**
* 酒店列表
* @returns Response
*/
async getHotelList(groupId, cityCode, hotelIds) {
const uri = '/default/hotel/hotelShowList'
const query = {
groupId: groupId,
cityCode: cityCode || '',
hotelIds: hotelIds || []
}
return this.request.post(uri, query)
}
/**
* 酒店详情
* @param {Array} hotelCodes 酒店编号列表,每次最多 20 个
*/
async getHotelDetail(groupId, hotelId) {
const uri = '/default/hotel/hotelDetails'
const query = {
groupId: groupId,
hotelId: hotelId
}
return this.request.post(uri, query)
}
/**
* 酒店状态
* @param {Array} hotelCodes 酒店编号列表,每次最多 20 个
*/
async getHotelStatusList(groupId) {
const uri = '/default/hotel/hotelsStatus'
const query = {
groupId: groupId
}
return this.request.post(uri, query)
}
/**
* 房型详情
* @param {Array} hotelCodes 房型详情
*/
async getRoomTypeList(groupId, hotelId) {
const uri = '/distribution/product/productBriefList'
const query = {
groupId: groupId,
hotelId: hotelId
}
return this.request.post(uri, query)
}
/**
* 房价房态全量(正价)
* @param {String} StartDate 起始时间
* @param {String} EndDate 结束时间
*/
async getPriceStateList(groupId, hotelId, StartDate, EndDate) {
const uri = '/distribution/product/productList'
const query = {
groupId: groupId,
hotelId: hotelId,
checkInDate: StartDate,
checkOutDate: EndDate
}
return this.request.post(uri, query)
}
/**
*【分销模式-三方托管协议】查询公司列表
* @param {String} groupId
*/
async getCompanyList(groupId) {
const uri = '/distribution/product/getCompanyList'
const query = {
groupId: groupId
}
return this.request.post(uri, query)
}
/**
*【分销模式-三方托管协议】根据协议公司ID获取酒店的房型、产品
* @param {Array} companyIdList 公司idßßß
*/
async getProductBriefListByCompanyId(groupId, hotelId, companyIdList) {
const uri = '/distribution/product/productBriefListByCompanyId'
const query = {
groupId: groupId,
hotelId: hotelId,
companyIdList: companyIdList
}
return this.request.post(uri, query)
}
/**
*【分销模式-三方托管协议】根据协议公司ID获取酒店的房型、产品、每日价格、每日库存
* @param {String} checkInDate 起始时间
* @param {String} checkOutDate 结束时间
* */
async getProductListByCompanyId(
groupId,
hotelId,
companyIdList,
checkInDate,
checkOutDate
) {
const uri = '/distribution/product/productListByCompanyId'
const query = {
groupId: groupId,
hotelId: hotelId,
companyIdList: companyIdList,
checkInDate: checkInDate,
checkOutDate: checkOutDate
}
return this.request.post(uri, query)
}
/**
* 可订检查
* @returns Response
*/
async checkOrder(
companyId,
groupId,
hotelId,
StartDate,
EndDate,
productId,
dailyRateList,
numberOfPerson,
roomQuantity
) {
const uri = '/distribution/product/checkPriceAndCount'
const query = {
companyId: companyId,
groupId: groupId,
hotelId: hotelId,
checkInDate: StartDate,
checkOutDate: EndDate,
productId: productId,
dailyRateList: dailyRateList,
numberOfPerson: numberOfPerson,
roomQuantity: roomQuantity
}
return this.request.post(uri, query)
}
/**
* 下订单
*/
async createOrder(
companyId,
groupId,
hotelId,
StartDate,
EndDate,
dailyRateList,
productId,
rateId,
roomtypId,
comments,
contactPerson,
distributorResId,
inHotel,
roomQuantity,
totalAmount,
paymentType
) {
const uri = '/distribution/order/reserveOrder'
let roomRate = {
dailyRateList: dailyRateList,
paymentType: paymentType,
productId: productId,
rateId: rateId,
roomtypId: roomtypId
}
const query = {
companyId: companyId,
groupId: groupId,
hotelId: hotelId,
checkInDate: StartDate,
checkOutDate: EndDate,
comments: comments,
contactPerson: contactPerson,
distributorResId: distributorResId,
inHotel: inHotel,
roomQuantity: roomQuantity,
roomRate: roomRate,
totalAmount: totalAmount
}
// HTTP请求重试次数设置为1
query.maxAttempts = 1
return this.request.post(uri, query)
}
/**
* 取消订单
* @param {String} orderNo 酒店code
* @returns Response
*/
async cancelOrder(groupId, hotelId, crsOrderNo, distributorResId) {
const uri = '/distribution/order/cancelOrder'
const query = {
groupId: groupId,
hotelId: hotelId,
reservationIds: {
crsOrderNo: crsOrderNo,
distributorResId: distributorResId
}
}
return this.request.post(uri, query)
}
/**
* 订单详情
* @param {Array} orderNos 订单号
* @returns Response
*/
async getOrderInfo(groupId, distributorResIds, requestId) {
const uri = '/distribution/order/pullOrderStatus'
const query = {
groupId: groupId,
distributorResIds: distributorResIds || [],
requestId: requestId || ''
}
return this.request.post(uri, query)
}
}
module.exports = lichengSDK