novel_order_daily_amount.py 803 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """"
  2. @desc 订单数据日统计
  3. @auth ck
  4. @date 20201119
  5. """
  6. from model.util.DateUtils import DateUtils
  7. from model.util.DataBaseUtils import MysqlUtils
  8. db = MysqlUtils()
  9. dt = DateUtils()
  10. def run(ymd):
  11. sql = """replace into novel_daily_order_amount
  12. select "{0}" as ymd,platform,channel_id,channel,stage,
  13. ROUND(SUM(amount),2) as amount,
  14. count(1) as order_num,
  15. count(DISTINCT user_id) as order_user
  16. from `order`
  17. where `date` = UNIX_TIMESTAMP("{0}") GROUP BY platform,stage,channel
  18. """.format(ymd)
  19. db.quchen_text.execute(sql)
  20. if __name__ == '__main__':
  21. ymd = dt.get_n_days(-1)
  22. run(ymd)
  23. # for i in dt.getDateLists("2020-10-01", "2020-11-01"):
  24. # run(i)