Commit 179f825d by Peng

新增捕获点击立即付款 弹窗 提示 系统繁忙 消息。判断该订单异常。写入redis 后端推送给采购

parent cce73649
......@@ -287,8 +287,18 @@ class get_1688_order_data():
chrom_page_tab.ele('xpath://div[contains(text(),"网银或柜台转账")]', timeout=3).click()
print('开始付款')
time.sleep(random.randint(1, 3))
self.click_pay(chrom_page_tab)
self.online_banking(chrom_page_tab, order_num)
if self.click_pay(chrom_page_tab, order_num):
items_err = {
"account": self.account,
"order_id": order_num,
"type": "异常",
"json": {
"value": '系统繁忙,请重试'
}
}
self.alipay_data_list.append(items_err)
else:
self.online_banking(chrom_page_tab, order_num)
else:
print('专属账号余额 有, 使用专属账号支付')
try:
......@@ -325,21 +335,32 @@ class get_1688_order_data():
else:
print('开始付款')
time.sleep(random.randint(1, 3))
self.click_pay(chrom_page_tab)
if '支付成功' in chrom_page_tab.html:
print('专属账号余额 支付成功 :', order_num)
else:
items = {
if self.click_pay(chrom_page_tab, order_num):
items_err = {
"account": self.account,
"order_id": order_num,
"type": "异常",
"json": {
"value": '需要手动确认,专属账号余额是否足够支付'
"value": '系统繁忙,请重试'
}
}
print('专属账号余额支付 items:::', items)
json_data = json.dumps(items, ensure_ascii=False)
json_data = json.dumps(items_err, ensure_ascii=False)
self.redis_db22.rpush('alipay_zszh:response', json_data)
else:
if '支付成功' in chrom_page_tab.html:
print('专属账号余额 支付成功 :', order_num)
else:
items = {
"account": self.account,
"order_id": order_num,
"type": "异常",
"json": {
"value": '需要手动确认,专属账号余额是否足够支付'
}
}
print('专属账号余额支付 items:::', items)
json_data = json.dumps(items, ensure_ascii=False)
self.redis_db22.rpush('alipay_zszh:response', json_data)
try:
print(f'从alipay_zszh:{self.account} redis删除订单号:', order_num)
self.redis_db22.lrem(f'alipay_zszh:{self.account}', 1, order_num)
......@@ -352,8 +373,18 @@ class get_1688_order_data():
zfb = chrom_page_tab.ele('xpath://span[contains(text(),"支付宝")]', timeout=3).click()
if zfb:
print('找到支付宝。开始选择支付宝')
self.click_pay(chrom_page_tab)
self.online_zfb(chrom_page_tab, order_num)
if self.click_pay(chrom_page_tab, order_num):
items_err = {
"account": self.account,
"order_id": order_num,
"type": "异常",
"json": {
"value": '系统繁忙,请重试'
}
}
self.alipay_data_list.append(items_err)
else:
self.online_zfb(chrom_page_tab, order_num)
else:
print('没有找到可以支付方式。退出 订单号。', order_num)
items = {
......@@ -432,7 +463,8 @@ class get_1688_order_data():
}
self.alipay_data_list.append(items)
time.sleep(random.randint(1, 3))
def click_pay(self, chrom_page_tab):
def click_pay(self, chrom_page_tab, order_num):
time.sleep(random.randint(1, 2))
print('点击立即付款')
js_click_cashier = '''
......@@ -442,7 +474,17 @@ class get_1688_order_data():
'''
# 获取
chrom_page_tab.run_js(js_click_cashier)
time.sleep(random.randint(6, 15))
time_num = 0
while True:
if '系统繁忙' in chrom_page_tab.html:
print('该订单 点击支付 提示 系统繁忙: ', order_num)
time.sleep(2)
return True
else:
time.sleep(0.3)
time_num += 1
if time_num > 30:
return False
def online_banking(self, chrom_page_tab, order_num):
print('解析网银支付账户信息')
......@@ -476,6 +518,7 @@ class get_1688_order_data():
print('检查订单号:', self.err_orders_list)
self.time_num += 1
time.sleep(random.randint(1, 3))
def get_account(self):
self.redis_db22 = self.redis_db()
start_index = 0 # 起始索引
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment