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

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