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

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