Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
py12306
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
python
py12306
Commits
ecd809dc
Commit
ecd809dc
authored
Jan 18, 2019
by
Jalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加未支付订单检测 #75 移除语音重复通知
parent
26063f5b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
20 deletions
+24
-20
order.py
py12306/order/order.py
+24
-20
No files found.
py12306/order/order.py
View file @
ecd809dc
...
@@ -77,8 +77,8 @@ class Order:
...
@@ -77,8 +77,8 @@ class Order:
self
.
send_notification
()
self
.
send_notification
()
def
send_notification
(
self
):
def
send_notification
(
self
):
num
=
0
# 通知次数
#
num = 0 # 通知次数
sustain_time
=
self
.
notification_sustain_time
#
sustain_time = self.notification_sustain_time
if
Config
()
.
EMAIL_ENABLED
:
# 邮件通知
if
Config
()
.
EMAIL_ENABLED
:
# 邮件通知
Notification
.
send_email
(
Config
()
.
EMAIL_RECEIVER
,
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE
,
Notification
.
send_email
(
Config
()
.
EMAIL_RECEIVER
,
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE
,
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT
.
format
(
self
.
order_id
))
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT
.
format
(
self
.
order_id
))
...
@@ -94,17 +94,19 @@ class Order:
...
@@ -94,17 +94,19 @@ class Order:
if
Config
()
.
PUSHBEAR_ENABLED
:
# PushBear通知
if
Config
()
.
PUSHBEAR_ENABLED
:
# PushBear通知
Notification
.
push_bear
(
Config
()
.
PUSHBEAR_KEY
,
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE
,
Notification
.
push_bear
(
Config
()
.
PUSHBEAR_KEY
,
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE
,
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT
.
format
(
self
.
order_id
))
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT
.
format
(
self
.
order_id
))
while
sustain_time
:
# TODO 后面直接查询有没有待支付的订单就可以
num
+=
1
if
Config
()
.
NOTIFICATION_BY_VOICE_CODE
:
# 语音通知
if
Config
()
.
NOTIFICATION_BY_VOICE_CODE
:
# 语音通知
OrderLog
.
add_quick_log
(
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_START_SEND
.
format
(
num
))
OrderLog
.
add_quick_log
(
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_START_SEND
.
format
(
num
))
Notification
.
voice_code
(
Config
()
.
NOTIFICATION_VOICE_CODE_PHONE
,
self
.
user_ins
.
get_name
(),
Notification
.
voice_code
(
Config
()
.
NOTIFICATION_VOICE_CODE_PHONE
,
self
.
user_ins
.
get_name
(),
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT
.
format
(
OrderLog
.
MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT
.
format
(
self
.
query_ins
.
left_station
,
self
.
query_ins
.
arrive_station
))
self
.
query_ins
.
left_station
,
self
.
query_ins
.
arrive_station
))
else
:
# 取消循环发送通知
break
# while sustain_time: # TODO 后面直接查询有没有待支付的订单就可以
sustain_time
-=
self
.
notification_interval
# num += 1
sleep
(
self
.
notification_interval
)
# else:
# break
# sustain_time -= self.notification_interval
# sleep(self.notification_interval)
OrderLog
.
add_quick_log
(
OrderLog
.
MESSAGE_JOB_CLOSED
)
.
flush
()
OrderLog
.
add_quick_log
(
OrderLog
.
MESSAGE_JOB_CLOSED
)
.
flush
()
...
@@ -125,9 +127,11 @@ class Order:
...
@@ -125,9 +127,11 @@ class Order:
return
True
return
True
else
:
else
:
if
(
str
(
result
.
get
(
'messages'
,
''
))
.
find
(
'未处理'
)
>=
0
):
# 未处理订单
if
(
str
(
result
.
get
(
'messages'
,
''
))
.
find
(
'未处理'
)
>=
0
):
# 未处理订单
stay_second
(
self
.
retry_time
)
self
.
order_id
=
0
# 需要拿到订单号 TODO
return
self
.
order_did_success
()
OrderLog
.
add_quick_log
(
OrderLog
.
add_quick_log
(
OrderLog
.
MESSAGE_SUBMIT_ORDER_REQUEST_FAIL
.
format
(
result
.
get
(
'messages'
,
CommonLog
.
MESSAGE_RESPONSE_EMPTY_ERROR
)))
.
flush
()
OrderLog
.
MESSAGE_SUBMIT_ORDER_REQUEST_FAIL
.
format
(
result
.
get
(
'messages'
,
CommonLog
.
MESSAGE_RESPONSE_EMPTY_ERROR
)))
.
flush
()
return
False
return
False
def
check_order_info
(
self
):
def
check_order_info
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment