TradeStatistic.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\statistic;
  12. use app\controller\admin\AuthController;
  13. use app\services\statistic\TradeStatisticServices;
  14. use think\facade\App;
  15. /**
  16. * Class TradeStatistic
  17. * @package app\controller\admin\v1\statistic
  18. */
  19. class TradeStatistic extends AuthController
  20. {
  21. /**
  22. * TradeStatistic constructor.
  23. * @param App $app
  24. * @param TradeStatisticServices $services
  25. */
  26. public function __construct(App $app, TradeStatisticServices $services)
  27. {
  28. parent::__construct($app);
  29. $this->services = $services;
  30. }
  31. /**
  32. * 顶部数据
  33. * @return mixed
  34. */
  35. public function topTrade()
  36. {
  37. $leftToday = $this->services->getTopLeftTrade(['time' => 'today']);
  38. $leftyestoday = $this->services->getTopLeftTrade(['time' => 'yestoday']);
  39. $rightOne = $this->services->getTopRightOneTrade();
  40. $rightTwo = $this->services->getTopRightTwoTrade();
  41. $right = ['today' => $rightOne, 'month' => $rightTwo];
  42. $totalleft = [$leftToday, $leftyestoday];
  43. $left = [];
  44. foreach ($totalleft as $k => $v) {
  45. $left['name'] = "当日订单金额";
  46. $left['x'] = $v['curve']['x'];
  47. $left['series'][$k]['money'] = round($v['total_money'], 2);
  48. $left['series'][$k]['value'] = array_values($v['curve']['y']);
  49. }
  50. $data['left'] = $left;
  51. $data['right'] = $right;
  52. return $this->success($data);
  53. }
  54. /**
  55. * 底部数据
  56. * @return mixed
  57. */
  58. public function bottomTrade()
  59. {
  60. $day = $this->request->getMore([
  61. ['data', ""],
  62. ]);
  63. $bottom = $this->services->getBottomTrade($day);
  64. return $this->success($bottom);
  65. }
  66. }