StoreDailySalesSt.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 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\model;
  13. use app\common\model\StoreDailySalesSt as StoreStModel;
  14. /**
  15. * 门店销售数据每日统计模型
  16. * Class ShopsDailySalesSt
  17. * @package app\common\model
  18. */
  19. class StoreDailySalesSt extends StoreStModel
  20. {
  21. /**
  22. * 商城销售额按天统计
  23. * @param $from
  24. * @param $to
  25. * @return StoreDailySalesSt[]|array|\think\Collection
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. */
  30. public function listAMonthSt($from,$to){
  31. return self::where('st_time','between',[$from,$to])
  32. ->field('sale_volume,order_count,st_time,st_month,right(st_month,2) as int_month,right(st_time,2) as st_day')
  33. ->order('st_time asc')->select();
  34. }
  35. /**
  36. * 商城销售额按月统计
  37. * @param $from
  38. * @param $to
  39. * @return mixed
  40. */
  41. public function listTwoMonthSt($from,$to){
  42. return self::where('st_time','between',[$from,$to])
  43. ->field('sum(sale_volume) as sale_volume,right(st_month,2) as int_month,left(st_month,4) as st_year')
  44. ->group('st_month')
  45. ->order('st_month asc')->select();
  46. }
  47. }