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

77 lines
2.6 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. use App\Models\v3\Market as MarketModel;
  8. class OrderDeliveryById extends LazyRenderable
  9. {
  10. protected $title = '配送记录';
  11. public function grid(): Grid
  12. {
  13. // 获取外部传递的参数
  14. $horsemanId = $this->horseman_id ?? 0;
  15. $model = new OrderMainModel();
  16. if($horsemanId > 0){
  17. $model->where('horseman_id',$horsemanId)->where('type',1)->where('shipping_type',1);
  18. }
  19. // dd($model->where('horseman_id',$horsemanId));
  20. return Grid::make($model, function (Grid $grid) {
  21. $marketList = MarketModel::getMarketArray();
  22. $grid->column('horseman_id','配送员ID');
  23. // $grid->column('user_id','配送员姓名');
  24. $grid->column('global_order_id','订单编号');
  25. $grid->column('market_id','下单市场')->display(function($marketId) use($marketList){
  26. return $marketList[$marketId] ?? '';
  27. });
  28. $grid->column('state','状态')
  29. ->using(
  30. OrderMainModel::STATE_LIST
  31. );
  32. $grid->column('created_at','下单时间')->display(function($createdAt){
  33. return date('Y-m-d H:i:s',$createdAt);
  34. });
  35. // 搜索
  36. $grid->filter(function (Grid\Filter $filter) use($marketList){
  37. $filter->equal('user_id','下单用户懒ID')->width(3);
  38. $filter->equal('global_order_id','订单编号')->width(3);
  39. $filter->equal('market_id','下单市场')->select($marketList)->width(4);
  40. $filter->whereBetween('created_at',function($q){
  41. $start = $this->input['start'] ?? null;
  42. $end = $this->input['end'] ?? null;
  43. if($start !== null){
  44. $q->where('created_at','>=',strtotime($start));
  45. }
  46. if($end !== null){
  47. $q->where('created_at','<=',strtotime($end));
  48. }
  49. })->datetime()->width(7);
  50. });
  51. $grid->model()->orderBy('id','desc');
  52. // 每页10条
  53. $grid->paginate(10);
  54. $grid->disableActions();
  55. $grid->disableRowSelector();
  56. });
  57. }
  58. public function default()
  59. {
  60. // 获取外部传递的参数
  61. $horsemanId = $this->payload['horseman_id'] ?? 0;
  62. return [
  63. 'horseman_id' => $horsemanId,
  64. ];
  65. }
  66. }