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

159 lines
5.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Common\Rpc;
  4. use App\Admin\Extensions\CheckRow;
  5. use App\Admin\Extensions\MyDetailPage;
  6. use App\Admin\Extensions\OrderDetail;
  7. use App\Admin\Extensions\OrderPrint;
  8. use App\Admin\Extensions\OrderRefund;
  9. use App\Admin\Extensions\OrderStateHandle;
  10. use App\Admin\Repositories\ImsCjdcOrderMain;
  11. use Dcat\Admin\Form;
  12. use Dcat\Admin\Grid;
  13. use Dcat\Admin\Layout\Content;
  14. use Dcat\Admin\Show;
  15. use Dcat\Admin\Controllers\AdminController;
  16. use Dcat\Admin\Widgets\Lazy;
  17. class ImsCjdcOrderMainController extends AdminController
  18. {
  19. /**
  20. * Make a grid builder.
  21. *
  22. * @return Grid
  23. */
  24. protected function grid()
  25. {
  26. return Grid::make(new ImsCjdcOrderMain(), function (Grid $grid) {
  27. //>>1.只展示线上订单打√
  28. //>>2.不同服务站只能看到自己的市场订单
  29. //>>3.订单不允许有添加,编辑,删除
  30. //>>4.订单状态变更√
  31. //>>5.打印功能
  32. //>6.退款
  33. $grid->paginate(10);//每页展示数据10条
  34. //$grid->id;
  35. //$grid->user_id('用户信息');
  36. $grid->column('nick_name', '用户信息');
  37. $grid->order_num;
  38. $grid->state('订单状态')
  39. ->using(config('order.state'))
  40. ->label([1 => 'dark', 2 => 'danger', 3 => 'indigo', 4 => 'success',8=>'warning']);
  41. $grid->money;
  42. $grid->column('market.name', '所属市场');
  43. $grid->pay_time('支付时间')->display(function () {
  44. return date('Y-m-d H:i:s');
  45. });
  46. $grid->created_at('下单时间')->display(function () {
  47. return date('Y-m-d H:i:s');
  48. });
  49. $grid->actions(function (Grid\Displayers\Actions $actions) use ($grid) {
  50. $state = $actions->row->state;
  51. if ($state == 2) {
  52. $actions->append(new OrderStateHandle('接单', 3));
  53. } elseif ($state == 311) {
  54. $actions->append(new OrderStateHandle('完成', 4));
  55. $actions->append(new OrderPrint('打印'));
  56. } elseif ($state == 3) {
  57. $actions->append(new OrderPrint('打印'));
  58. $actions->append(new CheckRow($actions->row->id, $grid->model()->getCurrentPage(), '自送'));
  59. } elseif ($state == 8) {
  60. $actions->append(new OrderStateHandle('同意退款', 9));
  61. $actions->append(new OrderRefund($actions->row->id, $grid->model()->getCurrentPage(), '拒绝退款'));
  62. }
  63. $actions->append(new OrderDetail($actions->row->id, $grid->model()->getCurrentPage(), '详情'));
  64. });
  65. $grid->filter(function (Grid\Filter $filter) {
  66. $filter->equal('id');
  67. });
  68. $grid->disableViewButton();
  69. $grid->disableEditButton();
  70. $grid->disableDeleteButton();
  71. });
  72. }
  73. /**
  74. * Make a show builder.
  75. *
  76. * @param mixed $id
  77. *
  78. * @return Show
  79. */
  80. protected function detail($id)
  81. {
  82. return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) {
  83. $show->id;
  84. $show->user_id;
  85. $show->order_num;
  86. $show->state;
  87. $show->time;
  88. $show->pay_time;
  89. $show->money;
  90. $show->tools(function (Show\Tools $tools) {
  91. $tools->append(new \App\Admin\Actions\Show\OrderDetail());
  92. });
  93. });
  94. }
  95. /**
  96. * Make a form builder.
  97. *
  98. * @return Form
  99. */
  100. protected function form()
  101. {
  102. return Form::make(new ImsCjdcOrderMain(), function (Form $form) {
  103. $form->display('id');
  104. $form->text('user_id');
  105. $form->text('order_num');
  106. $form->text('state');
  107. $form->text('time');
  108. $form->text('pay_time');
  109. $form->text('money');
  110. });
  111. }
  112. /**
  113. * 订单详情
  114. * @param Content $content
  115. * @return Content
  116. */
  117. public function orderDetail(Content $content)
  118. {
  119. $oid = request()->get('order_id');
  120. $page = request()->get('page');
  121. // 实例化表单类并传递自定义参数
  122. $detail = MyDetailPage::make(['order_id' => $oid]);
  123. return $content->header('订单详情')
  124. ->breadcrumb(
  125. ['text' => '列表', 'url' => "order?page={$page}"],
  126. ['text' => '详情', 'url' => 'detail'],
  127. )
  128. ->body(Lazy::make($detail));
  129. }
  130. public function orderGoodsRefund()
  131. {
  132. $uid = request()->get('user_id');
  133. $note = request()->get('note');
  134. $global_order_id = request()->get('global_order_id');
  135. $order_child_id = request()->get('order_child_id');
  136. $order_goods_id = request()->get('order_goods_id');
  137. $result = Rpc::onlineSingleRefund($uid, $note, $global_order_id, $order_child_id, $order_goods_id);
  138. return json_encode($result['result']);
  139. }
  140. }