|
@@ -49,13 +49,17 @@ class OrderServer():
|
|
self.passengers_chd = [] #儿童乘客
|
|
self.passengers_chd = [] #儿童乘客
|
|
self.passengers_infant = []#婴儿乘客
|
|
self.passengers_infant = []#婴儿乘客
|
|
#行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
|
|
#行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
|
|
- self.luggageDict = {20:'PBAB',25:'PBAC',30:'PBAD',40:'PBAF'}
|
|
|
|
|
|
+ self.luggageDict = {20:'PBAB',25:'PBAC',30:'PBAD',40:'PBAF'}
|
|
|
|
|
|
self._web_value_lock = threading.Lock() #实例化 Web查询
|
|
self._web_value_lock = threading.Lock() #实例化 Web查询
|
|
self._big_value_lock = threading.Lock() #实例化 Big查询
|
|
self._big_value_lock = threading.Lock() #实例化 Big查询
|
|
|
|
|
|
self.sign = False #是否刷单标记
|
|
self.sign = False #是否刷单标记
|
|
self.passengerIds = [] #乘机人ID List
|
|
self.passengerIds = [] #乘机人ID List
|
|
|
|
+
|
|
|
|
+ self.luggage = '';#行李编码
|
|
|
|
+ self.ismeals = False;#是否占套餐
|
|
|
|
+ self.cabin = 'EC';#占舱类型
|
|
#获取订单信息
|
|
#获取订单信息
|
|
def LoadPrarm(self):
|
|
def LoadPrarm(self):
|
|
self.salt = self.json_str['cid']+'|'
|
|
self.salt = self.json_str['cid']+'|'
|
|
@@ -67,6 +71,7 @@ class OrderServer():
|
|
self.oinfo.toCity =self.json_str['toCity'] #到达三字码
|
|
self.oinfo.toCity =self.json_str['toCity'] #到达三字码
|
|
if self.oinfo.tripType == 2:
|
|
if self.oinfo.tripType == 2:
|
|
self.oinfo.retDate =self.json_str['retDate'] #返程日期 2018-04-29
|
|
self.oinfo.retDate =self.json_str['retDate'] #返程日期 2018-04-29
|
|
|
|
+ print('反程日期:'+self.json_str['retDate'])
|
|
self.oinfo.adultNum =self.json_str['adultNum'] #成人乘客数
|
|
self.oinfo.adultNum =self.json_str['adultNum'] #成人乘客数
|
|
self.oinfo.childNum =self.json_str['childNum'] #儿童乘客数
|
|
self.oinfo.childNum =self.json_str['childNum'] #儿童乘客数
|
|
|
|
|
|
@@ -122,7 +127,16 @@ class OrderServer():
|
|
seg.cabin = 'EC'
|
|
seg.cabin = 'EC'
|
|
if 'EC' != seg.cabin:
|
|
if 'EC' != seg.cabin:
|
|
self.isContinue = False
|
|
self.isContinue = False
|
|
- return
|
|
|
|
|
|
+ if 'EC' == seg.cabin or 'EP' == seg.cabin:
|
|
|
|
+ self.luggage = 'PBNO'
|
|
|
|
+ elif 'VF' == seg.cabin or 'HF' == seg.cabin:
|
|
|
|
+ self.luggage = 'PBAB'
|
|
|
|
+ self.ismeals = True
|
|
|
|
+ elif 'PM' == seg.cabin:
|
|
|
|
+ self.luggage = 'PBAF'
|
|
|
|
+ self.ismeals = True
|
|
|
|
+ self.cabin = seg.cabin
|
|
|
|
+
|
|
seg.depAirport = kfsa['depAirport'] #出发机场IATA三字码 KUL
|
|
seg.depAirport = kfsa['depAirport'] #出发机场IATA三字码 KUL
|
|
seg.arrAirport = kfsa['arrAirport'] #到达机场IATA三字码 DPS
|
|
seg.arrAirport = kfsa['arrAirport'] #到达机场IATA三字码 DPS
|
|
seg.arrTime = kfsa['arrTime'] #起飞时间20180428053
|
|
seg.arrTime = kfsa['arrTime'] #起飞时间20180428053
|
|
@@ -205,6 +219,7 @@ class OrderServer():
|
|
# self._web_value_lock.release() #web结果锁 开始
|
|
# self._web_value_lock.release() #web结果锁 开始
|
|
#发起Big查询
|
|
#发起Big查询
|
|
def BigQuery(self):
|
|
def BigQuery(self):
|
|
|
|
+ self.queryInputJson['airSource'] = 'AK_BIG_APP';
|
|
akbigQuer = AkBigQuery(self.queryInputJson,self.oinfo.tripType,self.oinfo.fromFlight,self.oinfo.retFlight,self.oinfo.fxRate)
|
|
akbigQuer = AkBigQuery(self.queryInputJson,self.oinfo.tripType,self.oinfo.fromFlight,self.oinfo.retFlight,self.oinfo.fxRate)
|
|
akQueryBigFrom,akQueryBigRet,isOk = akbigQuer.StartQuery()
|
|
akQueryBigFrom,akQueryBigRet,isOk = akbigQuer.StartQuery()
|
|
# self._big_value_lock.acquire()#web结果锁 开始
|
|
# self._big_value_lock.acquire()#web结果锁 开始
|
|
@@ -227,14 +242,14 @@ class OrderServer():
|
|
def AagenLogin(self):
|
|
def AagenLogin(self):
|
|
|
|
|
|
#添加代理IP
|
|
#添加代理IP
|
|
- cl = call()
|
|
|
|
- proxyurl = cl.getProxyIP()
|
|
|
|
- proxy_handler = {
|
|
|
|
- 'http': 'http://'+proxyurl,
|
|
|
|
- 'https': 'https://'+proxyurl,
|
|
|
|
- }
|
|
|
|
- self.session.proxies = proxy_handler
|
|
|
|
- logging.info(self.salt+'IP:'+proxyurl)
|
|
|
|
|
|
+# cl = call()
|
|
|
|
+# proxyurl = cl.getProxyIP()
|
|
|
|
+# proxy_handler = {
|
|
|
|
+# 'http': 'http://'+proxyurl,
|
|
|
|
+# 'https': 'https://'+proxyurl,
|
|
|
|
+# }
|
|
|
|
+# self.session.proxies = proxy_handler
|
|
|
|
+# logging.info(self.salt+'IP:'+proxyurl)
|
|
res = self.session.get("https://www.airasia.com/my/en/login/travel-agent.page")
|
|
res = self.session.get("https://www.airasia.com/my/en/login/travel-agent.page")
|
|
page = etree.HTML(res.text)
|
|
page = etree.HTML(res.text)
|
|
self.logindata['__VIEWSTATE'] = page.xpath("//input[@name='__VIEWSTATE']/@value")[0]
|
|
self.logindata['__VIEWSTATE'] = page.xpath("//input[@name='__VIEWSTATE']/@value")[0]
|
|
@@ -453,35 +468,44 @@ class OrderServer():
|
|
#先回调价格,其次比价EC EP
|
|
#先回调价格,其次比价EC EP
|
|
cl = call()
|
|
cl = call()
|
|
cl.BallbackPrice(self.oinfo.cid, str(self.oinfo.webFromJson),str(self.oinfo.webRetJson), str(self.oinfo.agentFromJson),str(self.oinfo.agentRetJson),str(self.oinfo.bigFromJson),str(self.oinfo.bigRetJson),self.sign)
|
|
cl.BallbackPrice(self.oinfo.cid, str(self.oinfo.webFromJson),str(self.oinfo.webRetJson), str(self.oinfo.agentFromJson),str(self.oinfo.agentRetJson),str(self.oinfo.bigFromJson),str(self.oinfo.bigRetJson),self.sign)
|
|
-
|
|
|
|
|
|
+ #EC.特惠 EP.低航费 VF.超值套餐 HF.常飞客 PM.豪华平躺
|
|
agfPrice = 0.0 #代理人价格
|
|
agfPrice = 0.0 #代理人价格
|
|
agrPrice = 0.0 #代理人价格
|
|
agrPrice = 0.0 #代理人价格
|
|
agfromVal = '' #代理人去程提交字符串
|
|
agfromVal = '' #代理人去程提交字符串
|
|
agretVal = '' #代理人返程提交字符串
|
|
agretVal = '' #代理人返程提交字符串
|
|
agfromPrice = self.oinfo.agentFromJson
|
|
agfromPrice = self.oinfo.agentFromJson
|
|
agretPrice = self.oinfo.agentRetJson
|
|
agretPrice = self.oinfo.agentRetJson
|
|
- if 'EC' in agfromPrice.keys():
|
|
|
|
- agfPrice = agfromPrice['EC']['priceTotal']
|
|
|
|
- agfromVal = agfromPrice['EC']['radioValue']
|
|
|
|
- if 'EP' in agfromPrice.keys():
|
|
|
|
- if agfPrice != 0.0 and agfPrice > agfromPrice['EP']['priceTotal']:
|
|
|
|
- agfPrice = agfromPrice['EP']['priceTotal']
|
|
|
|
- agfromVal = agfromPrice['EP']['radioValue']
|
|
|
|
- if agfPrice == 0.0:
|
|
|
|
- agfPrice = agfromPrice['EP']['priceTotal']
|
|
|
|
- agfromVal = agfromPrice['EP']['radioValue']
|
|
|
|
- if agretPrice != None:
|
|
|
|
- if 'EC' in agretPrice.keys():
|
|
|
|
- agrPrice = agretPrice['EC']['priceTotal']
|
|
|
|
- agretVal = agretPrice['EC']['radioValue']
|
|
|
|
- if 'EP' in agretPrice.keys():
|
|
|
|
- if agrPrice != 0.0 and agrPrice > agretPrice['EP']['priceTotal']:
|
|
|
|
- agrPrice = agretPrice['EP']['priceTotal']
|
|
|
|
- agretVal = agretPrice['EP']['radioValue']
|
|
|
|
- if agrPrice == 0.0:
|
|
|
|
- agrPrice = agretPrice['EP']['priceTotal']
|
|
|
|
- agretVal = agretPrice['EP']['radioValue']
|
|
|
|
-
|
|
|
|
|
|
+ if 'EC' in self.cabin:
|
|
|
|
+ if 'EC' in agfromPrice.keys():
|
|
|
|
+ agfPrice = agfromPrice['EC']['priceTotal']
|
|
|
|
+ agfromVal = agfromPrice['EC']['radioValue']
|
|
|
|
+ if 'EP' in agfromPrice.keys():
|
|
|
|
+ if agfPrice != 0.0 and agfPrice > agfromPrice['EP']['priceTotal']:
|
|
|
|
+ agfPrice = agfromPrice['EP']['priceTotal']
|
|
|
|
+ agfromVal = agfromPrice['EP']['radioValue']
|
|
|
|
+ if agfPrice == 0.0:
|
|
|
|
+ agfPrice = agfromPrice['EP']['priceTotal']
|
|
|
|
+ agfromVal = agfromPrice['EP']['radioValue']
|
|
|
|
+ if agretPrice != None:
|
|
|
|
+ if 'EC' in agretPrice.keys():
|
|
|
|
+ agrPrice = agretPrice['EC']['priceTotal']
|
|
|
|
+ agretVal = agretPrice['EC']['radioValue']
|
|
|
|
+ if 'EP' in agretPrice.keys():
|
|
|
|
+ if agrPrice != 0.0 and agrPrice > agretPrice['EP']['priceTotal']:
|
|
|
|
+ agrPrice = agretPrice['EP']['priceTotal']
|
|
|
|
+ agretVal = agretPrice['EP']['radioValue']
|
|
|
|
+ if agrPrice == 0.0:
|
|
|
|
+ agrPrice = agretPrice['EP']['priceTotal']
|
|
|
|
+ agretVal = agretPrice['EP']['radioValue']
|
|
|
|
+ else:
|
|
|
|
+ if self.cabin in agfromPrice.keys():
|
|
|
|
+ agfPrice = agfromPrice[self.cabin]['priceTotal']
|
|
|
|
+ agfromVal = agfromPrice[self.cabin]['radioValue']
|
|
|
|
+ if agretPrice != None:
|
|
|
|
+ if self.cabin in agretPrice.keys():
|
|
|
|
+ agrPrice = agretPrice[self.cabin]['priceTotal']
|
|
|
|
+ agretVal = agretPrice[self.cabin]['radioValue']
|
|
|
|
+
|
|
logging.info(self.salt+'代理人去程:'+str(agfPrice)+' __'+agfromVal)
|
|
logging.info(self.salt+'代理人去程:'+str(agfPrice)+' __'+agfromVal)
|
|
logging.info(self.salt+'代理人回程:'+str(agrPrice)+' __'+agretVal)
|
|
logging.info(self.salt+'代理人回程:'+str(agrPrice)+' __'+agretVal)
|
|
|
|
|
|
@@ -491,48 +515,48 @@ class OrderServer():
|
|
webretVal = '' #Web官网返程提交字符串
|
|
webretVal = '' #Web官网返程提交字符串
|
|
webfromPrice = self.oinfo.webFromJson
|
|
webfromPrice = self.oinfo.webFromJson
|
|
webretPrice = self.oinfo.webRetJson
|
|
webretPrice = self.oinfo.webRetJson
|
|
- if 'EC' in webfromPrice.keys():
|
|
|
|
- webfPrice = webfromPrice['EC']['priceTotal']
|
|
|
|
- webfromVal = webfromPrice['EC']['radioValue']
|
|
|
|
|
|
+ if self.cabin in webfromPrice.keys():
|
|
|
|
+ webfPrice = webfromPrice[self.cabin]['priceTotal']
|
|
|
|
+ webfromVal = webfromPrice[self.cabin]['radioValue']
|
|
if webretPrice != None:
|
|
if webretPrice != None:
|
|
- if 'EC' in webretPrice.keys():
|
|
|
|
- webrPrice = webretPrice['EC']['priceTotal']
|
|
|
|
- webretVal = webretPrice['EC']['radioValue']
|
|
|
|
|
|
+ if self.cabin in webretPrice.keys():
|
|
|
|
+ webrPrice = webretPrice[self.cabin]['priceTotal']
|
|
|
|
+ webretVal = webretPrice[self.cabin]['radioValue']
|
|
|
|
|
|
logging.info(self.salt+'Web官网去程:'+str(webfPrice) +' __'+webfromVal)
|
|
logging.info(self.salt+'Web官网去程:'+str(webfPrice) +' __'+webfromVal)
|
|
logging.info(self.salt+'Web官网回程:'+str(webrPrice) +' __'+webretVal)
|
|
logging.info(self.salt+'Web官网回程:'+str(webrPrice) +' __'+webretVal)
|
|
|
|
|
|
|
|
|
|
- bigfPrice = 0.0 #Big积分价格
|
|
|
|
- bigrPrice = 0.0 #Big积分价格
|
|
|
|
- bigfromPrice = self.oinfo.bigFromJson
|
|
|
|
- bigretPrice = self.oinfo.bigRetJson
|
|
|
|
- if 'EC' in bigfromPrice.keys():
|
|
|
|
- bigfPrice = bigfromPrice['EC']['priceTotal']
|
|
|
|
- if bigretPrice != None:
|
|
|
|
- if 'EC' in bigretPrice.keys():
|
|
|
|
- bigrPrice = bigretPrice['EC']['priceTotal']
|
|
|
|
-
|
|
|
|
- logging.info(self.salt+'Big积分去程价:'+str(bigfPrice))
|
|
|
|
- logging.info(self.salt+'Big积分回程价:'+str(bigrPrice))
|
|
|
|
- logging.info(self.salt+'Big积分加价55,然后再比价!')
|
|
|
|
- if bigfPrice != 0.0:
|
|
|
|
- #一决雌雄 使用那种方式生单 AGENT_ORDER WEB_ORDER BIG_ORDER
|
|
|
|
- bigp = bigfPrice + bigrPrice+55
|
|
|
|
- webp = webfPrice + webrPrice
|
|
|
|
- agp = agfPrice + agrPrice
|
|
|
|
- if webp != 0.0:
|
|
|
|
- if bigp < webp and bigp < webp:
|
|
|
|
- #Big价格优势
|
|
|
|
- self.oinfo.modeOrder = 'BIG_ORDER'
|
|
|
|
- logging.info(self.salt+'-----Big价格优势')
|
|
|
|
- return
|
|
|
|
- else:
|
|
|
|
- if bigp < agp:
|
|
|
|
- #Big价格优势
|
|
|
|
- self.oinfo.modeOrder = 'BIG_ORDER'
|
|
|
|
- logging.info(self.salt+'-----Big价格优势')
|
|
|
|
- return
|
|
|
|
|
|
+# bigfPrice = 0.0 #Big积分价格
|
|
|
|
+# bigrPrice = 0.0 #Big积分价格
|
|
|
|
+# bigfromPrice = self.oinfo.bigFromJson
|
|
|
|
+# bigretPrice = self.oinfo.bigRetJson
|
|
|
|
+# if 'EC' in bigfromPrice.keys():
|
|
|
|
+# bigfPrice = bigfromPrice['EC']['priceTotal']
|
|
|
|
+# if bigretPrice != None:
|
|
|
|
+# if 'EC' in bigretPrice.keys():
|
|
|
|
+# bigrPrice = bigretPrice['EC']['priceTotal']
|
|
|
|
+#
|
|
|
|
+# logging.info(self.salt+'Big积分去程价:'+str(bigfPrice))
|
|
|
|
+# logging.info(self.salt+'Big积分回程价:'+str(bigrPrice))
|
|
|
|
+# logging.info(self.salt+'Big积分加价55,然后再比价!')
|
|
|
|
+# if bigfPrice != 0.0:
|
|
|
|
+# #一决雌雄 使用那种方式生单 AGENT_ORDER WEB_ORDER BIG_ORDER
|
|
|
|
+# bigp = bigfPrice + bigrPrice+55
|
|
|
|
+# webp = webfPrice + webrPrice
|
|
|
|
+# agp = agfPrice + agrPrice
|
|
|
|
+# if webp != 0.0:
|
|
|
|
+# if bigp < webp and bigp < webp:
|
|
|
|
+# #Big价格优势
|
|
|
|
+# self.oinfo.modeOrder = 'BIG_ORDER'
|
|
|
|
+# logging.info(self.salt+'-----Big价格优势')
|
|
|
|
+# return
|
|
|
|
+# else:
|
|
|
|
+# if bigp < agp:
|
|
|
|
+# #Big价格优势
|
|
|
|
+# self.oinfo.modeOrder = 'BIG_ORDER'
|
|
|
|
+# logging.info(self.salt+'-----Big价格优势')
|
|
|
|
+# return
|
|
|
|
|
|
self.oinfo.modeOrder = 'AGENT_ORDER'
|
|
self.oinfo.modeOrder = 'AGENT_ORDER'
|
|
#接下来是官网与代理的对决
|
|
#接下来是官网与代理的对决
|
|
@@ -685,21 +709,50 @@ class OrderServer():
|
|
'CONTROLGROUP_OUTERTRAVELER$CONTROLGROUPTRAVELER$ButtonSubmit':'Continue',
|
|
'CONTROLGROUP_OUTERTRAVELER$CONTROLGROUPTRAVELER$ButtonSubmit':'Continue',
|
|
'__VIEWSTATEGENERATOR':'05F9A2B0'
|
|
'__VIEWSTATEGENERATOR':'05F9A2B0'
|
|
}
|
|
}
|
|
- #餐食选择
|
|
|
|
- for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
|
|
|
|
- passengerData[row] = '0'
|
|
|
|
#舒适套件
|
|
#舒适套件
|
|
for row in page.xpath("//div[starts-with(@class,'uccomfortkitpanel-item-selection-form')]/input/@name"):
|
|
for row in page.xpath("//div[starts-with(@class,'uccomfortkitpanel-item-selection-form')]/input/@name"):
|
|
passengerData[row] = '0'
|
|
passengerData[row] = '0'
|
|
|
|
|
|
|
|
+ #餐食选择
|
|
|
|
+ passListarts = []
|
|
|
|
+ for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
|
|
|
|
+ if '_group_AAXmealCat' in row:
|
|
|
|
+ AAXmealCa = row[105:107]+row[136:158]
|
|
|
|
+ if AAXmealCa not in passListarts:
|
|
|
|
+ passListarts.append(AAXmealCa)
|
|
|
|
+ passengerData[row] = '1'
|
|
|
|
+ else:
|
|
|
|
+ passengerData[row] = '0'
|
|
|
|
+
|
|
#行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
|
|
#行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
|
|
#self.luggageDict = {20:'PBAB',25:'PBAC',30:'PBAD',40:'PBAF'}
|
|
#self.luggageDict = {20:'PBAB',25:'PBAC',30:'PBAD',40:'PBAF'}
|
|
#行李选择
|
|
#行李选择
|
|
- for row in page.xpath("//div[starts-with(@class,'dropdown-styled')]/select/@name"):
|
|
|
|
- if '_previousSsr_' in row:
|
|
|
|
- passengerData[row] = 'BWQZ'
|
|
|
|
- else:
|
|
|
|
- passengerData[row] = ''
|
|
|
|
|
|
+ if self.luggage == 'PBNO':
|
|
|
|
+ for row in page.xpath("//div[starts-with(@class,'dropdown-styled')]/select/@name"):
|
|
|
|
+ if '_previousSsr_' in row:
|
|
|
|
+ passengerData[row] = 'BWQZ'
|
|
|
|
+ else:
|
|
|
|
+ passengerData[row] = ''
|
|
|
|
+ #40Kg
|
|
|
|
+ if self.luggage == 'PBAB':
|
|
|
|
+ for row in page.xpath("//div[starts-with(@class,'dropdown-styled')]/select/@name"):
|
|
|
|
+ if 'previousSsr' in row:
|
|
|
|
+ passengerData[row] = 'BWMX'
|
|
|
|
+ else:
|
|
|
|
+ vl = row[80:]
|
|
|
|
+ vl = vl.replace("journey_1", "ssrCode_PBAB_ssrNum_1");
|
|
|
|
+ vl = vl.replace("journey_2", "ssrCode_PBAB_ssrNum_1");
|
|
|
|
+ passengerData[row] = vl
|
|
|
|
+ #40Kg
|
|
|
|
+ if self.luggage == 'PBAF':
|
|
|
|
+ for row in page.xpath("//div[starts-with(@class,'dropdown-styled')]/select/@name"):
|
|
|
|
+ if 'previousSsr' in row:
|
|
|
|
+ passengerData[row] = 'BWMX'
|
|
|
|
+ else:
|
|
|
|
+ vl = row[80:]
|
|
|
|
+ vl = vl.replace("journey_1", "ssrCode_PBAF_ssrNum_1");
|
|
|
|
+ vl = vl.replace("journey_2", "ssrCode_PBAF_ssrNum_1");
|
|
|
|
+ passengerData[row] = vl
|
|
|
|
|
|
self.passengers_adt.extend(self.passengers_chd)
|
|
self.passengers_adt.extend(self.passengers_chd)
|
|
#成人与儿童
|
|
#成人与儿童
|
|
@@ -827,6 +880,8 @@ class OrderServer():
|
|
'HiddenFieldPageBookingData':page.xpath('//input[@id="HiddenFieldPageBookingDataId"]/@value')[0],
|
|
'HiddenFieldPageBookingData':page.xpath('//input[@id="HiddenFieldPageBookingDataId"]/@value')[0],
|
|
'__VIEWSTATEGENERATOR':'05F9A2B0'
|
|
'__VIEWSTATEGENERATOR':'05F9A2B0'
|
|
}
|
|
}
|
|
|
|
+ logging.info(self.salt+json.dumps(PaymentData))
|
|
|
|
+ logging.info(self.salt+str(self.session.headers))
|
|
res = self.session.post('https://booking2.airasia.com/Payment.aspx', data=PaymentData, verify=False,timeout = 60)
|
|
res = self.session.post('https://booking2.airasia.com/Payment.aspx', data=PaymentData, verify=False,timeout = 60)
|
|
logging.info(self.salt+'支付选择提交成,进入下一步!')
|
|
logging.info(self.salt+'支付选择提交成,进入下一步!')
|
|
logging.info(self.salt+str(res.status_code))
|
|
logging.info(self.salt+str(res.status_code))
|