get_order_hourly.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. __title__ = '每小时获取各平台的的订单数据'
  5. @Time : 2020/10/11 15:00
  6. @Author : Kenny-PC
  7. @Software: PyCharm
  8. # code is far away from bugs with the god animal protecting
  9. I love animals. They taste delicious.
  10. ┏┓ ┏┓
  11. ┏┛┻━━━┛┻┓
  12. ┃ ☃ ┃
  13. ┃ ┳┛ ┗┳ ┃
  14. ┃ ┻ ┃
  15. ┗━┓ ┏━┛
  16. ┃ ┗━━━┓
  17. ┃ 神兽保佑 ┣┓
  18. ┃ 永无BUG! ┏┛
  19. ┗┓┓┏━┳┓┏┛
  20. ┃┫┫ ┃┫┫
  21. ┗┻┛ ┗┻┛
  22. """
  23. from apscheduler.schedulers.blocking import BlockingScheduler
  24. from util import date_util
  25. from util import db_order_util
  26. from util import platform_order_api_util
  27. def start_order_job():
  28. start_exec_seconds = date_util.getCurrentSecondTime()
  29. st_unix, et_unix = date_util.getPreviousHourAndCurrentHourSecondTime(start_exec_seconds)
  30. # st_unix = 1602313200 # 2020/10/10 15:0:0
  31. # et_unix = 1602316800 # 2020/10/10 16:0:0
  32. print('查询开始时间:', st_unix, date_util.getSecondsToDatetime(st_unix))
  33. print('查询结束时间:', et_unix, date_util.getSecondsToDatetime(et_unix))
  34. ########################################## 测试开关 ##########################################
  35. # order_list = platform_order_api_util.get_zhangzhongyun_order(st_unix, et_unix)
  36. # # print(order_list)
  37. # db_order_util.batch_save_order(order_list)
  38. #
  39. # exit_flag = True
  40. # if exit_flag:
  41. # exit() #这里是为了测试,不让代码继续执行
  42. ########################################## 测试开关 ##########################################
  43. db_order_util.batch_save_order(platform_order_api_util.get_zhangzhongyun_order(st_unix, et_unix))
  44. db_order_util.batch_save_order(platform_order_api_util.get_yuewen_order(st_unix, et_unix))
  45. db_order_util.batch_save_order(platform_order_api_util.get_huasheng_order(st_unix, et_unix))
  46. db_order_util.batch_save_order(platform_order_api_util.get_youshuge_order(st_unix, et_unix))
  47. db_order_util.batch_save_order(platform_order_api_util.get_zhangdu_order(st_unix, et_unix))
  48. print('订单同步执行时间(秒):', date_util.getCurrentSecondTime() - start_exec_seconds)
  49. if __name__ == '__main__':
  50. # start_order_job()
  51. scheduler = BlockingScheduler()
  52. #每小时25分钟就执行一次
  53. scheduler.add_job(start_order_job, 'cron', max_instances=10, minute='25')
  54. scheduler.start()