链街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.

75 lines
2.4 KiB

  1. <?php
  2. namespace App\Admin\Renderable;
  3. use App\Admin\Common\Type;
  4. use Dcat\Admin\Support\LazyRenderable;
  5. use Dcat\Admin\Widgets\Table;
  6. use App\Models\FinancialRecord;
  7. use Dcat\Admin\Grid;
  8. class StoreBalance extends LazyRenderable
  9. {
  10. protected $title = '商户余额';
  11. protected $titles = ['ID','账户类型','账户余额','金额','流水类型','描述','系统描述','状态','时间'];
  12. public function render()
  13. {
  14. // 获取外部传递的参数
  15. $userId = $this->user_id ?? 0;
  16. // $data = FinancialRecord::getFinancialRecordModel($userId)
  17. // ::select('user_id','user_type','current_balance','money','money_type','desc','comment','status','created_at')
  18. // ->whereRaw('user_type ='.Type::USER_TYPE_STORE)
  19. // ->where('source_type',Type::SOURCE_TYPE_ORDER)
  20. // ->where('money_type',Type::MONEY_TYPE_STORE_PLAT_NEW_USER)
  21. // ->orderBy('id','desc')
  22. // ->get()->toArray();
  23. // return Table::make($this->titles, $data);
  24. return $this->grid();
  25. }
  26. public function grid(): Grid
  27. {
  28. // 获取外部传递的参数
  29. $userId = $this->payload['user_id'] ?? 0;
  30. $model = FinancialRecord::getFinancialRecordModel($userId);
  31. return Grid::make($model, function (Grid $grid) {
  32. $grid->user_type;
  33. $grid->current_balance;
  34. $grid->money;
  35. $grid->money_type;
  36. $grid->comment;
  37. $grid->status;
  38. $grid->created_at->display(function($createdAt){
  39. return date('Y-m-d H:i:s',$createdAt);
  40. });
  41. // 搜索
  42. $grid->filter(function (Grid\Filter $filter){
  43. $filter->panel();
  44. $filter->equal('money_type');
  45. $filter->equal('user_type');
  46. });
  47. $grid->model()->orderBy('id','desc');
  48. // 每页10条
  49. $grid->paginate(10);
  50. $grid->disableCreateButton();
  51. $grid->disableDeleteButton();
  52. $grid->disableEditButton();
  53. $grid->disableQuickEditButton();
  54. $grid->disableViewButton();
  55. $grid->disableActions();
  56. $grid->disableRowSelector();
  57. });
  58. }
  59. public function default()
  60. {
  61. // 获取外部传递的参数
  62. $userId = $this->payload['user_id'] ?? 0;
  63. return [
  64. 'user_id' => $userId,
  65. ];
  66. }
  67. }