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
49 lines
1.4 KiB
<?php
|
|
|
|
namespace App\Admin\Repositories;
|
|
|
|
use App\Models\storeUserReport as Model;
|
|
use Dcat\Admin\Grid\Model as GridModel;
|
|
use Dcat\Admin\Repositories\EloquentRepository;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class StoreUserReport extends EloquentRepository
|
|
{
|
|
/**
|
|
* Model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $eloquentClass = Model::class;
|
|
|
|
/**
|
|
* 获取统计列表数据
|
|
*/
|
|
public function get(GridModel $model)
|
|
{
|
|
$where = ['2020-06-01','2020-07-01'];
|
|
|
|
$list = DB::select(" SELECT
|
|
store.id
|
|
,store.market_id
|
|
,store.`name`
|
|
,store.mm_user_id
|
|
,count(distinct orders.user_id) new_user_total
|
|
FROM
|
|
ims_cjdc_order orders
|
|
INNER JOIN ims_cjdc_store store ON orders.store_id = store.id
|
|
INNER JOIN ims_cjdc_user users ON orders.user_id = users.id
|
|
WHERE
|
|
users.join_time BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)
|
|
AND UNIX_TIMESTAMP(orders.pay_time) BETWEEN UNIX_TIMESTAMP(?) AND UNIX_TIMESTAMP(?)
|
|
GROUP BY store.id
|
|
ORDER BY store.id ASC ",
|
|
array_merge($where,$where)
|
|
);
|
|
$total = count($list);
|
|
return $model->makePaginator(
|
|
$total,
|
|
$list
|
|
);
|
|
}
|
|
}
|