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

88 lines
3.1 KiB

  1. <?php
  2. namespace App\Admin\Renderable;
  3. use Dcat\Admin\Grid;
  4. use App\Admin\Common\Type;
  5. use Dcat\Admin\Grid\LazyRenderable;
  6. use App\Models\ImsCjdcOrderMain as OrderMainModel;
  7. class OrderDeliveryById extends LazyRenderable
  8. {
  9. protected $title = '配送记录';
  10. public function grid(): Grid
  11. {
  12. // 获取外部传递的参数
  13. $horsemanId = $this->horseman_id ?? 0;
  14. $model = new OrderMainModel();
  15. if($horsemanId > 0){
  16. $model->where('horseman_id',$horsemanId);
  17. }
  18. return Grid::make($model, function (Grid $grid) {
  19. $grid->column('id','ID');
  20. $grid->column('user_id','配送员姓名');
  21. $grid->column('global_order_id','订单编号');
  22. $grid->column('market_id','下单市场');
  23. $grid->column('created_at','下单时间')->display(function($createdAt){
  24. return date('Y-m-d H:i:s',$createdAt);;
  25. });
  26. $grid->column('status','状态')
  27. ->using(
  28. []
  29. )
  30. ->label(
  31. config('label.status_label')
  32. );
  33. $grid->column('created_at')->display(function($createdAt){
  34. return date('Y-m-d H:i:s',$createdAt);
  35. });
  36. // 搜索
  37. $grid->filter(function (Grid\Filter $filter){
  38. $userTypeList = Type::USER_TYPE_LIST;
  39. $moneyTypeList = Type::MONEY_TYPE_LIST;
  40. $sourceTYpeList = Type::SOURCE_TYPE_LIST;
  41. unset($userTypeList[0],$moneyTypeList[0]);
  42. $filter->equal('id','流水表ID')->width(3);
  43. $filter->equal('user_id','账户ID')->width(3);
  44. $filter->equal('current_balance','账户余额')->width(3);
  45. $filter->equal('money','流水金额')->width(3);
  46. $filter->equal('source_id','关联流水ID')->width(3);
  47. $filter->equal('money_type','流水类型')->select($userTypeList)->width(4);
  48. $filter->equal('user_type','账户类型')->select($moneyTypeList)->width(4);
  49. $filter->equal('source_type','关联类型')->select($sourceTYpeList)->width(4);
  50. $filter->whereBetween('created_at',function($q){
  51. $start = $this->input['start'] ?? null;
  52. $end = $this->input['end'] ?? null;
  53. if($start !== null){
  54. $q->where('created_at','>=',strtotime($start));
  55. }
  56. if($end !== null){
  57. $q->where('created_at','<=',strtotime($end));
  58. }
  59. })->datetime()->width(7);
  60. });
  61. $grid->model()->orderBy('id','desc');
  62. // 每页10条
  63. $grid->paginate(10);
  64. $grid->disableActions();
  65. $grid->disableRowSelector();
  66. });
  67. }
  68. public function default()
  69. {
  70. // 获取外部传递的参数
  71. $horsemanId = $this->payload['horseman_id'] ?? 0;
  72. return [
  73. 'horseman_id' => $horsemanId,
  74. ];
  75. }
  76. }