|
@@ -4,6 +4,7 @@ import urllib3
|
|
|
import requests
|
|
|
import time
|
|
|
import datetime
|
|
|
+import threading
|
|
|
import re
|
|
|
from lxml import etree
|
|
|
from pyquery import PyQuery as pq
|
|
@@ -11,7 +12,6 @@ from entity.OrderInfo import OrderInfo,Contact,Passengers,Segments
|
|
|
from utils.CallbackOrderUtils import CallbackOrderUtils as call
|
|
|
from query.AkWebQuery import AkWebQuery
|
|
|
from query.AkBigQuery import AkBigQuery
|
|
|
-from imghdr import test_webp
|
|
|
urllib3.disable_warnings()
|
|
|
import logging
|
|
|
|
|
@@ -50,6 +50,12 @@ class OrderServer():
|
|
|
self.passengers_infant = []#婴儿乘客
|
|
|
#行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
|
|
|
self.luggageDict = {20:'PBAB',25:'PBAC',30:'PBAD',40:'PBAF'}
|
|
|
+
|
|
|
+ self._web_value_lock = threading.Lock() #实例化 Web查询
|
|
|
+ self._big_value_lock = threading.Lock() #实例化 Big查询
|
|
|
+
|
|
|
+ self.sign = False #是否刷单标记
|
|
|
+ self.passengerIds = [] #乘机人ID List
|
|
|
#获取订单信息
|
|
|
def LoadPrarm(self):
|
|
|
self.salt = self.json_str['cid']+'|'
|
|
@@ -64,6 +70,12 @@ class OrderServer():
|
|
|
self.oinfo.adultNum =self.json_str['adultNum'] #成人乘客数
|
|
|
self.oinfo.childNum =self.json_str['childNum'] #儿童乘客数
|
|
|
|
|
|
+ if 'data' in self.json_str.keys():
|
|
|
+ if 'sign' in self.json_str['data'].keys():
|
|
|
+ self.sign = self.json_str['data']['sign']
|
|
|
+ self.passengerIds = self.json_str['data']['passengerIds']
|
|
|
+ logging.info(self.salt+'特哥的,这里是刷单。谢林杰')
|
|
|
+
|
|
|
#获取联系人信息
|
|
|
contact = Contact()
|
|
|
contact.firstname = self.json_str['contactEntity']['firstName'] #名
|
|
@@ -179,29 +191,33 @@ class OrderServer():
|
|
|
def WebQuery(self):
|
|
|
akwebQuer = AkWebQuery(self.queryInputJson,self.oinfo.tripType,self.oinfo.fromFlight,self.oinfo.retFlight,self.oinfo.fxRate)
|
|
|
akQueryWebFrom,akQueryWebRet,isOk = akwebQuer.StartQuery()
|
|
|
- if self.oinfo.webIsOk:
|
|
|
- return
|
|
|
+# self._web_value_lock.acquire()#web结果锁 开始
|
|
|
+# if self.oinfo.webIsOk:
|
|
|
+# return
|
|
|
logging.info(self.salt+'WebQuer:'+str(isOk))
|
|
|
logging.info(self.salt+'Web去程:'+json.dumps(akQueryWebFrom))
|
|
|
logging.info(self.salt+'Web返程:'+json.dumps(akQueryWebRet))
|
|
|
+ self.oinfo.webIsOk = isOk
|
|
|
+ self.oinfo.webFromJson = akQueryWebFrom
|
|
|
+ self.oinfo.webRetJson = akQueryWebRet
|
|
|
#判断对象是否为空
|
|
|
- if self.oinfo.webIsOk == False:
|
|
|
- self.oinfo.webIsOk = isOk
|
|
|
- self.oinfo.webFromJson = akQueryWebFrom
|
|
|
- self.oinfo.webRetJson = akQueryWebRet
|
|
|
+# if self.oinfo.webIsOk == False:
|
|
|
+# self._web_value_lock.release() #web结果锁 开始
|
|
|
#发起Big查询
|
|
|
def BigQuery(self):
|
|
|
akbigQuer = AkBigQuery(self.queryInputJson,self.oinfo.tripType,self.oinfo.fromFlight,self.oinfo.retFlight,self.oinfo.fxRate)
|
|
|
akQueryBigFrom,akQueryBigRet,isOk = akbigQuer.StartQuery()
|
|
|
- if self.oinfo.bigIsOk:
|
|
|
- return
|
|
|
+# self._big_value_lock.acquire()#web结果锁 开始
|
|
|
+# if self.oinfo.bigIsOk:
|
|
|
+# return
|
|
|
+ self.oinfo.bigIsOk = isOk
|
|
|
+ self.oinfo.bigFromJson = akQueryBigFrom
|
|
|
+ self.oinfo.bigRetJson = akQueryBigRet
|
|
|
logging.info(self.salt+'BigQuer:'+str(isOk))
|
|
|
logging.info(self.salt+'Big去程:'+json.dumps(akQueryBigFrom))
|
|
|
logging.info(self.salt+'Big返程:'+json.dumps(akQueryBigRet))
|
|
|
- if self.oinfo.bigIsOk == False:
|
|
|
- self.oinfo.bigIsOk = isOk
|
|
|
- self.oinfo.bigFromJson = akQueryBigFrom
|
|
|
- self.oinfo.bigRetJson = akQueryBigRet
|
|
|
+# if self.oinfo.bigIsOk == False:
|
|
|
+# self._big_value_lock.release() #web结果锁 开始
|
|
|
def checkQuery(self):
|
|
|
if self.oinfo.bigIsOk and self.oinfo.webIsOk:
|
|
|
return True
|
|
@@ -212,7 +228,7 @@ class OrderServer():
|
|
|
|
|
|
#添加代理IP
|
|
|
cl = call()
|
|
|
- proxyurl = cl.getProxyFixedIP()
|
|
|
+ proxyurl = cl.getProxyIP()
|
|
|
proxy_handler = {
|
|
|
'http': 'http://'+proxyurl,
|
|
|
'https': 'https://'+proxyurl,
|
|
@@ -432,7 +448,7 @@ class OrderServer():
|
|
|
def Parity(self):
|
|
|
#先回调价格,其次比价EC EP
|
|
|
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))
|
|
|
+ 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)
|
|
|
|
|
|
agfPrice = 0.0 #代理人价格
|
|
|
agrPrice = 0.0 #代理人价格
|
|
@@ -495,10 +511,10 @@ class OrderServer():
|
|
|
|
|
|
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
|
|
|
+ bigp = bigfPrice + bigrPrice+55
|
|
|
webp = webfPrice + webrPrice
|
|
|
agp = agfPrice + agrPrice
|
|
|
if webp != 0.0:
|
|
@@ -671,6 +687,9 @@ class OrderServer():
|
|
|
#舒适套件
|
|
|
for row in page.xpath("//div[starts-with(@class,'uccomfortkitpanel-item-selection-form')]/input/@name"):
|
|
|
passengerData[row] = '0'
|
|
|
+
|
|
|
+ #行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
|
|
|
+ #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:
|
|
@@ -804,7 +823,6 @@ class OrderServer():
|
|
|
'HiddenFieldPageBookingData':page.xpath('//input[@id="HiddenFieldPageBookingDataId"]/@value')[0],
|
|
|
'__VIEWSTATEGENERATOR':'05F9A2B0'
|
|
|
}
|
|
|
- logging.info(self.salt+str(PaymentData))
|
|
|
res = self.session.post('https://booking2.airasia.com/Payment.aspx', data=PaymentData, verify=False,timeout = 60)
|
|
|
logging.info(self.salt+'支付选择提交成,进入下一步!')
|
|
|
logging.info(self.salt+str(res.status_code))
|