链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. <?php
  2. namespace App\Admin\Repositories;
  3. use App\Models\storeUserReport as Model;
  4. use Dcat\Admin\Grid\Model as GridModel;
  5. use Dcat\Admin\Repositories\EloquentRepository;
  6. use Illuminate\Support\Facades\DB;
  7. class StoreUserReport extends EloquentRepository
  8. {
  9. /**
  10. * Model.
  11. *
  12. * @var string
  13. */
  14. protected $eloquentClass = Model::class;
  15. /**
  16. * 获取统计列表数据
  17. */
  18. public function get(GridModel $model)
  19. {
  20. $where = ['2020-06-01','2020-07-01'];
  21. $list = DB::select(" SELECT
  22. store.id
  23. ,store.market_id
  24. ,store.`name`
  25. ,store.mm_user_id
  26. ,count(distinct orders.user_id) new_user_total
  27. FROM
  28. ims_cjdc_order orders
  29. INNER JOIN ims_cjdc_store store ON orders.store_id = store.id
  30. INNER JOIN ims_cjdc_user users ON orders.user_id = users.id
  31. WHERE
  32. users.join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)
  33. AND UNIX_TIMESTAMP(orders.pay_time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)
  34. GROUP BY store.id
  35. ORDER BY store.id ASC ",
  36. array_merge($where,$where)
  37. );
  38. $total = count($list);
  39. return $model->makePaginator(
  40. $total,
  41. $list
  42. );
  43. }
  44. }