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

177 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
  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',311=>'#bd10e0']);
  53. $grid->money;
  54. $grid->column('market.name', '所属市场');
  55. $grid->pay_time('支付时间')->display(function ($time) {
  56. if ($time){
  57. return date('Y-m-d H:i:s',$time);
  58. }
  59. return '<span style="color: #ceccce">未支付</span>';
  60. });
  61. $grid->created_at('下单时间')->display(function ($time) {
  62. return date('Y-m-d H:i:s',$time);
  63. });
  64. $grid->actions(function (Grid\Displayers\Actions $actions) use ($grid) {
  65. $state = $actions->row->state;
  66. $actions->append(new OrderDetail($actions->row->id, $grid->model()->getCurrentPage(), '<div type="button" class="btn btn-outline-primary btn-sm">详情</div>'));
  67. if ($state == 2) {
  68. $actions->append(new OrderStateHandle('<div type="button" class="btn btn-outline-danger btn-sm">接单</div>', 3));
  69. } elseif ($state == 311) {
  70. $actions->append(new OrderStateHandle('<div type="button" class="btn btn-outline-warning btn-sm">完成</div>', 4));
  71. $actions->append(new OrderPrint('<div type="button" class="btn btn-outline-dark btn-sm">打印</div>'));
  72. } elseif ($state == 3) {
  73. $actions->append(new OrderPrint('<div type="button" class="btn btn-outline-dark btn-sm">打印</div>'));
  74. $actions->append(new CheckRow($actions->row->id, $grid->model()->getCurrentPage(), '<div type="button" class="btn btn-outline-info btn-sm">自送</div>'));
  75. } elseif ($state == 8) {
  76. $actions->append(new OrderStateHandle('<div type="button" class="btn btn-outline-secondary btn-sm">同意</div>', 9));
  77. $actions->append(new OrderRefund($actions->row->id, $grid->model()->getCurrentPage(), '<div type="button" class="btn btn-outline-secondary btn-sm">拒绝</div>'));
  78. }
  79. });
  80. $grid->filter(function (Grid\Filter $filter) {
  81. $filter->equal('order_num');
  82. if (!(Admin::user()->isRole('market_service'))){
  83. $filter->equal('market_id','所属市场')->select(ImsCjdcMarket::getMarket());
  84. }
  85. });
  86. $grid->disableViewButton();
  87. $grid->disableEditButton();
  88. $grid->disableDeleteButton();
  89. $grid->disableCreateButton();
  90. });
  91. }
  92. /**
  93. * Make a show builder.
  94. *
  95. * @param mixed $id
  96. *
  97. * @return Show
  98. */
  99. protected function detail($id)
  100. {
  101. return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) {
  102. $show->id;
  103. $show->user_id;
  104. $show->order_num;
  105. $show->state;
  106. $show->time;
  107. $show->pay_time;
  108. $show->money;
  109. $show->tools(function (Show\Tools $tools) {
  110. $tools->append(new \App\Admin\Actions\Show\OrderDetail());
  111. });
  112. });
  113. }
  114. /**
  115. * Make a form builder.
  116. *
  117. * @return Form
  118. */
  119. protected function form()
  120. {
  121. return Form::make(new ImsCjdcOrderMain(), function (Form $form) {
  122. $form->display('id');
  123. $form->text('user_id');
  124. $form->text('order_num');
  125. $form->text('state');
  126. $form->text('time');
  127. $form->text('pay_time');
  128. $form->text('money');
  129. });
  130. }
  131. /**
  132. * 订单详情
  133. * @param Content $content
  134. * @return Content
  135. */
  136. public function orderDetail(Content $content)
  137. {
  138. $oid = request()->get('order_id');
  139. $page = request()->get('page');
  140. // 实例化表单类并传递自定义参数
  141. $detail = MyDetailPage::make(['order_id' => $oid]);
  142. return $content->header('订单详情')
  143. ->breadcrumb(
  144. ['text' => '列表', 'url' => "order?page={$page}"],
  145. ['text' => '详情', 'url' => 'detail']
  146. )
  147. ->body(Lazy::make($detail));
  148. }
  149. public function orderGoodsRefund()
  150. {
  151. $uid = request()->get('user_id');
  152. $note = request()->get('note');
  153. $global_order_id = request()->get('global_order_id');
  154. $order_child_id = request()->get('order_child_id');
  155. $order_goods_id = request()->get('order_goods_id');
  156. $result = Rpc::onlineSingleRefund($uid, $note, $global_order_id, $order_child_id, $order_goods_id);
  157. return json_encode($result['result']);
  158. }
  159. }