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

188 lines
7.1 KiB

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