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

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