Stat.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\wechat\shop\controller;
  11. use addon\wechat\model\Stat as StatModel;
  12. /**
  13. * 微信公众号基础功能
  14. */
  15. class Stat extends BaseWechat
  16. {
  17. /**
  18. * 访问统计
  19. */
  20. public function stat()
  21. {
  22. $stat_model = new StatModel();
  23. $yesterday = date('Y-m-d', strtotime('-1 day'));
  24. //昨天的用户分析数据
  25. $wechat_fans_result = $stat_model->fans($yesterday, $yesterday);
  26. $this->assign('yesterday_user_data', $wechat_fans_result['data'][0] ?? []);
  27. //昨天的接口分析数据
  28. $wechat_interface_result = $stat_model->interfaceSummary($yesterday, $yesterday);
  29. $this->assign('yesterday_interface_data', $wechat_interface_result['data'][0] ?? []);
  30. return $this->fetch('stat/stat', [], $this->replace);
  31. }
  32. /**
  33. * 接口调用统计
  34. * @return array
  35. */
  36. public function interfaceSummaryStatistics()
  37. {
  38. $date_type = input("date_type", "week");
  39. $stat_model = new StatModel();
  40. $result = $stat_model->interfaceSummaryStatistics($date_type);
  41. return $result;
  42. }
  43. /**
  44. * 用户访问统计
  45. * @return array
  46. */
  47. public function userSummaryStatistics()
  48. {
  49. $date_type = input("date_type", "week");
  50. $stat_model = new StatModel();
  51. $result = $stat_model->userSummaryStatistics($date_type);
  52. return $result;
  53. }
  54. }