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