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

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