sync_get_order_data.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import warnings
  2. warnings.filterwarnings('ignore')
  3. from apscheduler.schedulers.blocking import BlockingScheduler
  4. from sync_amz_data.settings import MYSQL_AUTH_CONF, MYSQL_DATA_CONF
  5. from sync_amz_data.public import sp_api_client
  6. def func_run():
  7. try:
  8. for days in (-2,-3):
  9. sp_api_client.SpApiRequest.get_allShops("GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",days=days,**{})
  10. except Exception as e:
  11. print(e)
  12. try:
  13. for days in (-2,-3): #range(-29,-2):#
  14. sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"SKU"})
  15. sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"PARENT"})
  16. sp_api_client.SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=days,**{"level":"CHILD"})
  17. except Exception as e:
  18. print(e)
  19. # func_run()
  20. if __name__ == '__main__':
  21. sched = BlockingScheduler()
  22. sched.add_job(func_run, 'cron', hour=0, minute=0,
  23. second=30)
  24. sched.start()