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

162 lines
5.9 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. $grid->disableCreateButton();
  77. });
  78. }
  79. /**
  80. * Make a show builder.
  81. *
  82. * @param mixed $id
  83. *
  84. * @return Show
  85. */
  86. protected function detail($id)
  87. {
  88. return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) {
  89. $show->id;
  90. $show->user_id;
  91. $show->order_num;
  92. $show->state;
  93. $show->time;
  94. $show->pay_time;
  95. $show->money;
  96. $show->tools(function (Show\Tools $tools) {
  97. $tools->append(new \App\Admin\Actions\Show\OrderDetail());
  98. });
  99. });
  100. }
  101. /**
  102. * Make a form builder.
  103. *
  104. * @return Form
  105. */
  106. protected function form()
  107. {
  108. return Form::make(new ImsCjdcOrderMain(), function (Form $form) {
  109. $form->display('id');
  110. $form->text('user_id');
  111. $form->text('order_num');
  112. $form->text('state');
  113. $form->text('time');
  114. $form->text('pay_time');
  115. $form->text('money');
  116. });
  117. }
  118. /**
  119. * 订单详情
  120. * @param Content $content
  121. * @return Content
  122. */
  123. public function orderDetail(Content $content)
  124. {
  125. $oid = request()->get('order_id');
  126. $page = request()->get('page');
  127. // 实例化表单类并传递自定义参数
  128. $detail = MyDetailPage::make(['order_id' => $oid]);
  129. return $content->header('订单详情')
  130. ->breadcrumb(
  131. ['text' => '列表', 'url' => "order?page={$page}"],
  132. ['text' => '详情', 'url' => 'detail'],
  133. )
  134. ->body(Lazy::make($detail));
  135. }
  136. public function orderGoodsRefund()
  137. {
  138. $uid = request()->get('user_id');
  139. $note = request()->get('note');
  140. $global_order_id = request()->get('global_order_id');
  141. $order_child_id = request()->get('order_child_id');
  142. $order_goods_id = request()->get('order_goods_id');
  143. $result = Rpc::onlineSingleRefund($uid, $note, $global_order_id, $order_child_id, $order_goods_id);
  144. return json_encode($result['result']);
  145. }
  146. }