2 changed files with 90 additions and 1 deletions
@ -0,0 +1,76 @@ |
|||
<?php |
|||
namespace App\Admin\Renderable; |
|||
|
|||
use App\Admin\Common\Type; |
|||
use Dcat\Admin\Support\LazyRenderable; |
|||
use Dcat\Admin\Widgets\Table; |
|||
use App\Models\FinancialRecord; |
|||
use Dcat\Admin\Grid; |
|||
|
|||
class StoreBalance extends LazyRenderable |
|||
{ |
|||
protected $title = '商户余额'; |
|||
protected $titles = ['ID','账户类型','账户余额','金额','流水类型','描述','系统描述','状态','时间']; |
|||
|
|||
public function render() |
|||
{ |
|||
// 获取外部传递的参数
|
|||
$userId = $this->user_id ?? 0; |
|||
|
|||
// $data = FinancialRecord::getFinancialRecordModel($userId)
|
|||
// ::select('user_id','user_type','current_balance','money','money_type','desc','comment','status','created_at')
|
|||
// ->whereRaw('user_type ='.Type::USER_TYPE_STORE)
|
|||
// ->where('source_type',Type::SOURCE_TYPE_ORDER)
|
|||
// ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
|
|||
// ->orderBy('id','desc')
|
|||
// ->get()->toArray();
|
|||
|
|||
// return Table::make($this->titles, $data);
|
|||
return $this->grid(); |
|||
} |
|||
|
|||
public function grid(): Grid |
|||
{ |
|||
// 获取外部传递的参数
|
|||
$userId = $this->payload['user_id'] ?? 0; |
|||
$model = FinancialRecord::getFinancialRecordModel($userId); |
|||
return Grid::make($model, function (Grid $grid) { |
|||
$grid->user_type; |
|||
$grid->current_balance; |
|||
$grid->money; |
|||
$grid->money_type; |
|||
$grid->comment; |
|||
$grid->status; |
|||
$grid->created_at->display(function($createdAt){ |
|||
return date('Y-m-d H:i:s',$createdAt); |
|||
}); |
|||
// 搜索
|
|||
$grid->filter(function (Grid\Filter $filter){ |
|||
$filter->panel(); |
|||
$filter->equal('money_type'); |
|||
$filter->equal('user_type'); |
|||
}); |
|||
$grid->model()->orderBy('id','desc'); |
|||
// 每页10条
|
|||
$grid->paginate(10); |
|||
|
|||
$grid->disableCreateButton(); |
|||
$grid->disableDeleteButton(); |
|||
$grid->disableEditButton(); |
|||
$grid->disableQuickEditButton(); |
|||
$grid->disableViewButton(); |
|||
$grid->disableActions(); |
|||
$grid->disableRowSelector(); |
|||
}); |
|||
} |
|||
|
|||
public function default() |
|||
{ |
|||
// 获取外部传递的参数
|
|||
$userId = $this->payload['user_id'] ?? 0; |
|||
|
|||
return [ |
|||
'user_id' => $userId, |
|||
]; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue