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

168 lines
5.2 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
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\CouponTieEdit;
  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\Forms\CouponTieForm;
  12. use App\Admin\Renderable\PostChart;
  13. use App\Admin\Repositories\ImsCjdcOrderMain;
  14. use Dcat\Admin\Admin;
  15. use Dcat\Admin\Form;
  16. use Dcat\Admin\Grid;
  17. use Dcat\Admin\Layout\Content;
  18. use Dcat\Admin\Show;
  19. use Dcat\Admin\Controllers\AdminController;
  20. use Dcat\Admin\Widgets\Lazy;
  21. use Dcat\Admin\Widgets\Modal;
  22. ;
  23. class ImsCjdcOrderMainController extends AdminController
  24. {
  25. /**
  26. * Make a grid builder.
  27. *
  28. * @return Grid
  29. */
  30. protected function grid()
  31. {
  32. return Grid::make(new ImsCjdcOrderMain(), function (Grid $grid) {
  33. //>>1.只展示线上订单打√
  34. //>>2.不同服务站只能看到自己的市场订单
  35. //>>3.订单不允许有添加,编辑,删除
  36. //>>4.订单状态变更√
  37. //>>5.打印功能
  38. //>6.退款
  39. $grid->paginate(10);//每页展示数据10条
  40. //$grid->id;
  41. //$grid->user_id('用户信息');
  42. $grid->column('nick_name', '用户信息');
  43. $grid->order_num;
  44. $grid->state('订单状态')
  45. ->using(config('order.state'))
  46. ->label([1 => 'dark', 2 => 'danger', 3 => 'indigo', 4 => 'success']);
  47. $grid->money;
  48. $grid->column('market.name', '所属市场');
  49. $grid->pay_time('支付时间')->display(function () {
  50. return date('Y-m-d H:i:s');
  51. });
  52. $grid->created_at('下单时间')->display(function () {
  53. return date('Y-m-d H:i:s');
  54. });
  55. $grid->actions(function (Grid\Displayers\Actions $actions) use ($grid) {
  56. $state = $actions->row->state;
  57. if ($state == 2) {
  58. $actions->append(new OrderStateHandle('接单', 3));
  59. } elseif ($state == 311) {
  60. $actions->append(new OrderStateHandle('完成', 4));
  61. $actions->append(new OrderPrint('打印'));
  62. } elseif ($state == 3) {
  63. $actions->append(new OrderPrint('打印'));
  64. $actions->append(new CheckRow($actions->row->id, $grid->model()->getCurrentPage(), '自送'));
  65. } elseif ($state == 8) {
  66. $actions->append(new OrderStateHandle('同意退款', 9));
  67. $actions->append(new OrderRefund($actions->row->id, $grid->model()->getCurrentPage(), '拒绝退款'));
  68. }
  69. $actions->append(new OrderDetail($actions->row->id, $grid->model()->getCurrentPage(), '详情'));
  70. });
  71. $grid->filter(function (Grid\Filter $filter) {
  72. $filter->equal('id');
  73. });
  74. $grid->disableViewButton();
  75. $grid->disableEditButton();
  76. $grid->disableDeleteButton();
  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. return 0;
  139. $uid = request()->get('user_id');
  140. $note = request()->get('note');
  141. $global_order_id = request()->get('global_order_id');
  142. $order_child_id = request()->get('order_child_id');
  143. $order_goods_id = request()->get('order_goods_id');
  144. $result = Rpc::onlineSingleRefund($uid, $note, $global_order_id, $order_child_id, $order_goods_id);
  145. dd($result);
  146. return json_encode($result['result']);
  147. }
  148. }