Commit ecd809dc authored by Jalin's avatar Jalin

增加未支付订单检测 #75 移除语音重复通知

parent 26063f5b
...@@ -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):
......
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