Data.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\service\statistics;
  13. use app\common\service\BaseService;
  14. use app\store\service\statistics\data\Survey;
  15. use app\store\service\statistics\data\Trade7days;
  16. use app\store\service\statistics\data\GoodsRanking;
  17. use app\store\service\statistics\data\UserExpendRanking;
  18. /**
  19. * 数据概况服务类
  20. * Class Data
  21. * @package app\store\service\statistics
  22. */
  23. class Data extends BaseService
  24. {
  25. /**
  26. * 获取数据概况
  27. * @param null $startDate
  28. * @param null $endDate
  29. * @return array
  30. */
  31. public function getSurveyData($startDate = null, $endDate = null): array
  32. {
  33. return (new Survey)->getSurveyData($startDate, $endDate);
  34. }
  35. /**
  36. * 近7日走势
  37. * @return array
  38. */
  39. public function getTransactionTrend(): array
  40. {
  41. return (new Trade7days)->getTransactionTrend();
  42. }
  43. /**
  44. * 商品销售榜
  45. * @return mixed
  46. */
  47. public function getGoodsRanking()
  48. {
  49. return (new GoodsRanking)->getGoodsRanking();
  50. }
  51. /**
  52. * 用户消费榜
  53. * @return \think\Collection
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\DbException
  56. * @throws \think\db\exception\ModelNotFoundException
  57. */
  58. public function geUserExpendRanking(): \think\Collection
  59. {
  60. return (new UserExpendRanking)->getUserExpendRanking();
  61. }
  62. }