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

191 lines
7.2 KiB

6 years ago
5 years ago
6 years ago
5 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 years ago
5 years ago
6 years ago
5 years ago
5 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 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
5 years ago
5 years ago
6 years ago
5 years ago
6 years ago
5 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\Actions\Tools\ShowOrderStateHandle;
  4. use App\Admin\Common\Auth;
  5. use App\Admin\Common\Rpc;
  6. use App\Admin\Extensions\CheckRow;
  7. use App\Admin\Extensions\MyDetailPage;
  8. use App\Admin\Extensions\OrderDetail;
  9. use App\Admin\Extensions\OrderDetailCopy;
  10. use App\Admin\Extensions\OrderPrint;
  11. use App\Admin\Extensions\OrderRefund;
  12. use App\Admin\Extensions\OrderStateHandle;
  13. use App\Admin\Repositories\ImsCjdcOrderMain;
  14. use App\Models\ImsCjdcMarket;
  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. use Dcat\Admin\Widgets\Modal;
  23. class ImsCjdcOrderMainController extends AdminController
  24. {
  25. /**
  26. * Make a grid builder.
  27. *
  28. * @return Grid
  29. */
  30. protected function grid()
  31. {
  32. return Grid::make(new ImsCjdcOrderMain(), function (Grid $grid) {
  33. //>>1.只展示线上订单打√
  34. //>>2.不同服务站只能看到自己的市场订单
  35. //>>3.订单不允许有添加,编辑,删除
  36. //>>4.订单状态变更√
  37. //>>5.打印功能
  38. //>6.退款
  39. $grid->tools(new ShowOrderStateHandle(2));
  40. $grid->tools(new ShowOrderStateHandle(8));
  41. $grid->paginate(10);//每页展示数据10条
  42. //$grid->id;
  43. //$grid->user_id('用户信息');
  44. if (!(Admin::user()->isRole('market_service'))){
  45. $marketId = \Request::get('market_id');
  46. if ($marketId){
  47. $grid->model()->where('market_id',$marketId);
  48. }
  49. }else{
  50. $marketId =Auth::getMarket();
  51. $grid->model()->where('market_id',$marketId);
  52. }
  53. $grid->column('nick_name', '用户信息');
  54. $grid->order_num;
  55. $grid->state('订单状态')
  56. ->using(config('order.state'))
  57. ->label([1 => 'dark', 2 => 'danger', 3 => 'indigo', 4 => 'success',8=>'warning',311=>'#bd10e0']);
  58. $grid->money;
  59. $grid->column('market.name', '所属市场');
  60. $grid->pay_time('支付时间')->display(function ($time) {
  61. if ($time){
  62. return date('Y-m-d H:i:s',$time);
  63. }
  64. return '<span style="color: #ceccce">未支付</span>';
  65. });
  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. $filter->equal('state','订单状态')->select(
  97. [1=>'待付款',2=>'待接单',4=>'已完成',6=>'已取消',8=>'退款中',9=>'已退款',10=>'退款拒绝']
  98. );
  99. });
  100. $grid->disableViewButton();
  101. $grid->disableEditButton();
  102. $grid->disableDeleteButton();
  103. $grid->disableCreateButton();
  104. });
  105. }
  106. /**
  107. * Make a show builder.
  108. *
  109. * @param mixed $id
  110. *
  111. * @return Show
  112. */
  113. protected function detail($id)
  114. {
  115. return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) {
  116. $show->id;
  117. $show->user_id;
  118. $show->order_num;
  119. $show->state;
  120. $show->time;
  121. $show->pay_time;
  122. $show->money;
  123. $show->tools(function (Show\Tools $tools) {
  124. $tools->append(new \App\Admin\Actions\Show\OrderDetail());
  125. });
  126. });
  127. }
  128. /**
  129. * Make a form builder.
  130. *
  131. * @return Form
  132. */
  133. protected function form()
  134. {
  135. return Form::make(new ImsCjdcOrderMain(), function (Form $form) {
  136. $form->display('id');
  137. $form->text('user_id');
  138. $form->text('order_num');
  139. $form->text('state');
  140. $form->text('time');
  141. $form->text('pay_time');
  142. $form->text('money');
  143. });
  144. }
  145. /**
  146. * 订单详情
  147. * @param Content $content
  148. * @return Content
  149. */
  150. public function orderDetail(Content $content)
  151. {
  152. $oid = request()->get('order_id');
  153. $page = request()->get('page');
  154. // 实例化表单类并传递自定义参数
  155. $detail = MyDetailPage::make(['order_id' => $oid,'page'=>$page]);
  156. return $content->header("<a href='order?page={$page}'><<返回</a>")
  157. ->breadcrumb(
  158. ['text' => '返回', 'url' => "order?page={$page}"],
  159. ['text' => '详情', 'url' => 'detail']
  160. )
  161. ->body(Lazy::make($detail));
  162. }
  163. public function orderGoodsRefund()
  164. {
  165. $uid = request()->get('user_id');
  166. $note = request()->get('note');
  167. $global_order_id = request()->get('global_order_id');
  168. $order_child_id = request()->get('order_child_id');
  169. $order_goods_id = request()->get('order_goods_id');
  170. $result = Rpc::onlineSingleRefund($uid, $note, $global_order_id, $order_child_id, $order_goods_id);
  171. return json_encode($result['result']);
  172. }
  173. }