海南旅游SAAS
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.

142 lines
4.6 KiB

4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\AdminSupplier\Controllers;
  3. use App\AdminSupplier\Extensions\Grid\IndustryOrderAudit;
  4. use App\AdminSupplier\Extensions\Grid\IndustryOrderStatus;
  5. use App\AdminSupplier\Repositories\IndustryOrder;
  6. use App\Common\OrderStatus;
  7. use App\Common\PayType;
  8. use Dcat\Admin\Admin;
  9. use Dcat\Admin\Form;
  10. use Dcat\Admin\Grid;
  11. use Dcat\Admin\Show;
  12. use Dcat\Admin\Http\Controllers\AdminController;
  13. use Dcat\Admin\Widgets\Table;
  14. class IndustryOrderController extends AdminController
  15. {
  16. /**
  17. * Make a grid builder.
  18. *
  19. * @return Grid
  20. */
  21. protected function grid()
  22. {
  23. return Grid::make(new IndustryOrder(['agent:id,company_name']), function (Grid $grid) {
  24. $grid->disableCreateButton();
  25. $grid->disableRowSelector();
  26. $grid->disableActions();
  27. $grid->model()->where('supplier_id', Admin::user()->id);
  28. $grid->column('id')->sortable();
  29. $grid->column('agent.company_name', '代理商名称')->limit(10);
  30. $grid->column('order_no')->limit(10);
  31. $grid->column('num');
  32. $grid->column('price');
  33. $grid->column('name');
  34. $grid->column('mobile');
  35. $grid->column('info', '信息收集')
  36. ->display('查看')
  37. ->modal('信息收集', function ($modal) {
  38. $info = $this->info ?? [];
  39. $info = array_map(function($v) {
  40. if (isset($v['value'], $v['type'])) {
  41. if ($v['type'] == 'image') {
  42. if (is_array($v['value'])) {
  43. return array_reduce($v['value'], fn($v2, $v3) => $v2 . '<img data-action="preview-img" src="' . $v3 . '" style="max-width:120px;max-height:200px;cursor:pointer" class="img img-thumbnail"> &nbsp;');
  44. } else {
  45. return '<img data-action="preview-img" src="' . $v['value'] . '" style="max-width:120px;max-height:200px;cursor:pointer" class="img img-thumbnail">';
  46. }
  47. } else {
  48. return is_string($v['value']) ? $v['value'] : join(',', $v['value']);
  49. }
  50. }
  51. return is_string($v) ? $v : json_encode($v);
  52. }, $info);
  53. return Table::make([], $info);
  54. })->xl();
  55. $grid->column('industry_product_id', '产品ID');
  56. $grid->column('title')->limit(15);
  57. $grid->column('picture')->image('', 60, 60);
  58. $grid->column('pay_type')->using(PayType::array());
  59. $grid->column('订单状态')
  60. //待审核
  61. ->if(fn() => $this->audit_status == 0)
  62. ->then(function ($column) {
  63. $column->append((new IndustryOrderAudit(null, 1))->setKey($this->id))->append('&nbsp;');
  64. $column->append((new IndustryOrderAudit(null, 2))->setKey($this->id));
  65. })
  66. //审核拒绝
  67. ->if(fn() => $this->audit_status == -1)
  68. ->then(function ($column) {
  69. $column->append('已拒绝')->label();
  70. })
  71. //审核通过
  72. ->if(fn() => $this->audit_status == 1)
  73. ->then(function ($column) {
  74. if ($this->status == OrderStatus::OFFLINE_UNPAID) {
  75. $column->action(new IndustryOrderStatus);
  76. } else {
  77. $column->append(OrderStatus::array()[$this->status]);
  78. }
  79. });
  80. $grid->column('paid_at');
  81. // $grid->column('timeout');
  82. $grid->column('created_at');
  83. $grid->filter(function (Grid\Filter $filter) {
  84. $filter->equal('id')->width(2);
  85. $filter->equal('order_no')->width(3);
  86. });
  87. });
  88. }
  89. /**
  90. * Make a show builder.
  91. *
  92. * @param mixed $id
  93. *
  94. * @return Show
  95. */
  96. protected function detail($id)
  97. {
  98. /*return Show::make($id, new IndustryOrder(), function (Show $show) {
  99. $show->field('id');
  100. $show->field('agent_id');
  101. $show->field('supplier_id');
  102. $show->field('order_no');
  103. $show->field('industry_product_id');
  104. $show->field('num');
  105. $show->field('price');
  106. $show->field('name');
  107. $show->field('mobile');
  108. $show->field('title');
  109. $show->field('picture');
  110. $show->field('status');
  111. $show->field('paid_at');
  112. $show->field('verify_code');
  113. $show->field('timeout');
  114. $show->field('created_at');
  115. $show->field('updated_at');
  116. });*/
  117. }
  118. /**
  119. * Make a form builder.
  120. *
  121. * @return Form
  122. */
  123. protected function form()
  124. {
  125. return Form::make(new IndustryOrder(), function (Form $form) {
  126. $form->display('id');
  127. // $form->select('status')->options([OrderStatus::OFFLINE_PAID => '已付款']);
  128. })->saving(function(Form $form) {
  129. return $form->response()->error('操作禁止');
  130. })->deleting(function(Form $form) {
  131. return $form->response()->error('操作禁止');
  132. });
  133. }
  134. }