|
|
@ -1,64 +1,87 @@ |
|
|
<?php |
|
|
<?php |
|
|
namespace App\Admin\Renderable; |
|
|
namespace App\Admin\Renderable; |
|
|
|
|
|
|
|
|
|
|
|
use Dcat\Admin\Grid; |
|
|
use App\Admin\Common\Type; |
|
|
use App\Admin\Common\Type; |
|
|
use Dcat\Admin\Support\LazyRenderable; |
|
|
|
|
|
use Dcat\Admin\Widgets\Table; |
|
|
|
|
|
|
|
|
use App\Admin\Repositories\CommonEmpty; |
|
|
|
|
|
use Dcat\Admin\Grid\LazyRenderable; |
|
|
use App\Models\FinancialRecord; |
|
|
use App\Models\FinancialRecord; |
|
|
use Dcat\Admin\Grid; |
|
|
|
|
|
|
|
|
|
|
|
class StoreBalance extends LazyRenderable |
|
|
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(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected $title = '商户余额明细'; |
|
|
|
|
|
|
|
|
public function grid(): Grid |
|
|
public function grid(): Grid |
|
|
{ |
|
|
{ |
|
|
// 获取外部传递的参数
|
|
|
// 获取外部传递的参数
|
|
|
$userId = $this->payload['user_id'] ?? 0; |
|
|
|
|
|
|
|
|
$userId = $this->user_id ?? 0; |
|
|
$model = FinancialRecord::getFinancialRecordModel($userId); |
|
|
$model = FinancialRecord::getFinancialRecordModel($userId); |
|
|
|
|
|
if(!$model){ |
|
|
|
|
|
return Grid::make(new CommonEmpty(), function (Grid $grid) { |
|
|
|
|
|
$grid->column('id','商 户 未 绑 定 提 现 用 户 懒 ID !'); |
|
|
|
|
|
$grid->disableRowSelector(); |
|
|
|
|
|
$grid->disableActions(); |
|
|
|
|
|
$grid->disablePagination(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return Grid::make($model, function (Grid $grid) { |
|
|
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){ |
|
|
|
|
|
|
|
|
$grid->column('id','ID'); |
|
|
|
|
|
$grid->column('user_type','账户类型')->display(function($userType){ |
|
|
|
|
|
$item = Type::USER_TYPE_LIST[$userType] ?? ''; |
|
|
|
|
|
return $item; |
|
|
|
|
|
}); |
|
|
|
|
|
$grid->column('money_type','流水类型')->display(function($moneyType){ |
|
|
|
|
|
$item = Type::MONEY_TYPE_LIST[$moneyType] ?? ''; |
|
|
|
|
|
return $item; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$grid->column('money','金额'); |
|
|
|
|
|
$grid->column('current_balance','账户余额'); |
|
|
|
|
|
$grid->column('comment','描述'); |
|
|
|
|
|
$grid->column('status','状态') |
|
|
|
|
|
->using( |
|
|
|
|
|
FinancialRecord::$status |
|
|
|
|
|
) |
|
|
|
|
|
->label( |
|
|
|
|
|
config('label.status_label') |
|
|
|
|
|
); |
|
|
|
|
|
$grid->column('created_at')->display(function($createdAt){ |
|
|
return date('Y-m-d H:i:s',$createdAt); |
|
|
return date('Y-m-d H:i:s',$createdAt); |
|
|
}); |
|
|
}); |
|
|
// 搜索
|
|
|
// 搜索
|
|
|
$grid->filter(function (Grid\Filter $filter){ |
|
|
$grid->filter(function (Grid\Filter $filter){ |
|
|
$filter->panel(); |
|
|
|
|
|
$filter->equal('money_type'); |
|
|
|
|
|
$filter->equal('user_type'); |
|
|
|
|
|
|
|
|
$userTypeList = Type::USER_TYPE_LIST; |
|
|
|
|
|
$moneyTypeList = Type::MONEY_TYPE_LIST; |
|
|
|
|
|
$sourceTYpeList = Type::SOURCE_TYPE_LIST; |
|
|
|
|
|
unset($userTypeList[0],$moneyTypeList[0]); |
|
|
|
|
|
|
|
|
|
|
|
$filter->equal('id','流水表ID')->width(3); |
|
|
|
|
|
$filter->equal('user_id','账户ID')->width(3); |
|
|
|
|
|
$filter->equal('current_balance','账户余额')->width(3); |
|
|
|
|
|
|
|
|
|
|
|
$filter->equal('money','流水金额')->width(3); |
|
|
|
|
|
$filter->equal('source_id','关联流水ID')->width(3); |
|
|
|
|
|
|
|
|
|
|
|
$filter->equal('money_type','流水类型')->select($userTypeList)->width(4); |
|
|
|
|
|
$filter->equal('user_type','账户类型')->select($moneyTypeList)->width(4); |
|
|
|
|
|
$filter->equal('source_type','关联类型')->select($sourceTYpeList)->width(4); |
|
|
|
|
|
|
|
|
|
|
|
$filter->whereBetween('created_at',function($q){ |
|
|
|
|
|
$start = $this->input['start'] ?? null; |
|
|
|
|
|
$end = $this->input['end'] ?? null; |
|
|
|
|
|
if($start !== null){ |
|
|
|
|
|
$q->where('created_at','>=',strtotime($start)); |
|
|
|
|
|
} |
|
|
|
|
|
if($end !== null){ |
|
|
|
|
|
$q->where('created_at','<=',strtotime($end)); |
|
|
|
|
|
} |
|
|
|
|
|
})->datetime()->width(7); |
|
|
}); |
|
|
}); |
|
|
$grid->model()->orderBy('id','desc'); |
|
|
$grid->model()->orderBy('id','desc'); |
|
|
// 每页10条
|
|
|
// 每页10条
|
|
|
$grid->paginate(10); |
|
|
$grid->paginate(10); |
|
|
|
|
|
|
|
|
$grid->disableCreateButton(); |
|
|
|
|
|
$grid->disableDeleteButton(); |
|
|
|
|
|
$grid->disableEditButton(); |
|
|
|
|
|
$grid->disableQuickEditButton(); |
|
|
|
|
|
$grid->disableViewButton(); |
|
|
|
|
|
$grid->disableActions(); |
|
|
$grid->disableActions(); |
|
|
$grid->disableRowSelector(); |
|
|
$grid->disableRowSelector(); |
|
|
}); |
|
|
}); |
|
|
|