2 changed files with 143 additions and 0 deletions
@ -0,0 +1,84 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Controllers\v3; |
||||
|
|
||||
|
use App\Admin\Repositories\v3\OrderReport; |
||||
|
use Dcat\Admin\Form; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Show; |
||||
|
use Dcat\Admin\Controllers\AdminController; |
||||
|
use Dcat\Admin\Layout\Content; |
||||
|
use Dcat\Admin\Form\Row; |
||||
|
use Dcat\Admin\Grid\Column; |
||||
|
use App\Models\v3\Market as marketModel; |
||||
|
|
||||
|
class OrderReportController extends AdminController |
||||
|
{ |
||||
|
/** |
||||
|
* Make a grid builder. |
||||
|
* |
||||
|
* @return Grid |
||||
|
*/ |
||||
|
protected function grid() |
||||
|
{ |
||||
|
$marketId = request()->get('market_id'); |
||||
|
return Grid::make(new OrderReport(), function (Grid $grid) { |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public function index(Content $content) |
||||
|
{ |
||||
|
return $content |
||||
|
->header('Dashboard') |
||||
|
->description('Description...') |
||||
|
->body(function (Row $row) { |
||||
|
$row->column(6, function (Column $column) { |
||||
|
$column->row(); |
||||
|
$column->row(); |
||||
|
}); |
||||
|
|
||||
|
$row->column(6, function (Column $column) { |
||||
|
$column->row(function (Row $row) { |
||||
|
$row->column(); |
||||
|
$row->column(); |
||||
|
}); |
||||
|
|
||||
|
$column->row(); |
||||
|
$column->row(); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Make a show builder. |
||||
|
* |
||||
|
* @param mixed $id |
||||
|
* |
||||
|
* @return Show |
||||
|
*/ |
||||
|
protected function detail($id) |
||||
|
{ |
||||
|
return Show::make($id, new StoreUserReport(), function (Show $show) { |
||||
|
$show->id; |
||||
|
$show->market_id; |
||||
|
$show->name; |
||||
|
$show->mm_user_id; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Make a form builder. |
||||
|
* |
||||
|
* @return Form |
||||
|
*/ |
||||
|
protected function form() |
||||
|
{ |
||||
|
return Form::make(new StoreUserReport(), function (Form $form) { |
||||
|
$form->display('id'); |
||||
|
$form->text('market_id'); |
||||
|
$form->text('name'); |
||||
|
$form->text('mm_user_id'); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,59 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Repositories\v3; |
||||
|
|
||||
|
use App\Models\v3\Store as Model; |
||||
|
use Dcat\Admin\Grid\Model as GridModel; |
||||
|
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
use App\Models\ImsCjdcOrder as OrderModel; |
||||
|
use Illuminate\Support\Facades\DB; |
||||
|
|
||||
|
class OrderReport extends EloquentRepository |
||||
|
{ |
||||
|
/** |
||||
|
* Model. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $eloquentClass = Model::class; |
||||
|
|
||||
|
/** |
||||
|
* 获取统计列表数据 |
||||
|
*/ |
||||
|
public function get(GridModel $model) |
||||
|
{ |
||||
|
$this->setSort($model); |
||||
|
$this->setPaginate($model); |
||||
|
|
||||
|
/** |
||||
|
* 订单 用户 |
||||
|
* 订单总金额 现存用户总数 |
||||
|
* 新用户补贴金额 新增用户总数 |
||||
|
* 商户首单补贴金额 |
||||
|
*/ |
||||
|
$orderModel = new OrderModel(); |
||||
|
$query = $orderModel::join('ims_cjdc_store as store','ims_cjdc_store_account.store_id','store.id') |
||||
|
->select('store_id','store.market_id','store.name as store_name',DB::raw("count(distinct ims_cjdc_store_account.id) as new_user_total")) |
||||
|
->whereRaw("note = '新用户下单成功,平台奖励'") |
||||
|
->groupBy('store_id') |
||||
|
->orderBy('store.market_id','desc') |
||||
|
->orderBY('new_user_total','desc') |
||||
|
->orderBY('store_id','desc'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
$model->getQueries()->unique()->each(function ($value) use (&$query) { |
||||
|
if ($value['method'] == 'paginate') { |
||||
|
$value['arguments'][1] = $this->getGridColumns(); |
||||
|
} elseif ($value['method'] == 'get') { |
||||
|
$value['arguments'] = [$this->getGridColumns()]; |
||||
|
} |
||||
|
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); |
||||
|
}); |
||||
|
|
||||
|
$query = $query->toArray(); |
||||
|
|
||||
|
$query = $model->makePaginator($query['total'],$query['data']); |
||||
|
return $query; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue