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

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