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

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