dw_pitcher_daily.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """
  2. @desc 投手维度全量表
  3. @auth ck
  4. """
  5. from model.sql_models import DB
  6. from config import using_config
  7. import logging
  8. def dw_pitcher_trend():
  9. logging.info('投手趋势数据处理,开始')
  10. logging.info('run> dw_pitcher_trend')
  11. sql = """
  12. truncate table dw_pitcher_trend;
  13. insert into dw_pitcher_trend
  14. select a.dt,pitcher,
  15. sum(cost),
  16. sum(order_amount),
  17. sum(reg_order_amount),
  18. sum(first_order_amount),
  19. sum(first_order_amount*100/node-cost) inva_cost,
  20. sum(first_order_user),
  21. sum(reg_order_user),
  22. sum(view_count),
  23. sum(click_count),
  24. sum(follow_user),
  25. sum(da1) d1,sum(da2) d2,sum(da3) d3,sum(da4) d4,sum(da5) d5,sum(da6) d6,sum(da7) d7,sum(da8) d8,sum(da9) d9,
  26. sum(da10) d10,sum(da11) d11,sum(da12) d12,
  27. sum(da13) d13,sum(da14) d14,sum(da15) d15,sum(da16) d16,sum(da17) d17,sum(da18) d18,sum(da19) d19,
  28. sum(da20) d20,sum(da21) d21,sum(da22) d22,sum(da23) d23,sum(da24) d24,sum(da25) d25,
  29. sum(da26) d26,sum(da27) d27,sum(da28) d28,sum(da29) d29,sum(da30) d30,
  30. sum(ba1),sum(ba2),sum(ba3),sum(ba4),sum(ba5),sum(ba6),sum(ba7),
  31. sum(first_order_amount*annual_mult-cost) annual_expect_profit
  32. from dw_channel a
  33. left join dw_channel_amount_daily b on a.dt=b.dt and a.channel=b.channel
  34. left join src_book_info c on a.book=c.book and a.platform=c.platform and a.type=c.type and a.dt=c.dt
  35. left join dw_channel_amount_daily_reverse d on a.dt=d.dt and a.channel=d.channel
  36. group by pitcher,a.dt"""
  37. dm_db = DB(config=using_config.dm)
  38. dm_db.session.execute(sql)
  39. dm_db.session.commit()
  40. logging.info('投手趋势数据处理,结束')
  41. if __name__ == '__main__':
  42. dw_pitcher_trend()