WxShopOrderGoodsController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  3. use App\Admin\Actions\Grid\OrderGoodsAction;
  4. use App\Admin\Repositories\Shop\WxShopOrderGoods;
  5. use App\Wen\Utils\Settings;
  6. use Dcat\Admin\Admin;
  7. use Dcat\Admin\Form;
  8. use Dcat\Admin\Grid;
  9. use Dcat\Admin\Show;
  10. use Dcat\Admin\Http\Controllers\AdminController;
  11. class WxShopOrderGoodsController extends AdminController
  12. {
  13. /**
  14. * Make a grid builder.
  15. *
  16. * @return Grid
  17. */
  18. protected function grid()
  19. {
  20. $admin_user = Admin::user();
  21. $app_coin_name = Settings::get('app_coin_name', '硬币');
  22. // todo: 拒绝退款
  23. return Grid::make(new WxShopOrderGoods(), function (Grid $grid) use ($app_coin_name, $admin_user){
  24. $grid->simplePaginate();
  25. if(!$admin_user->isAdministrator()){
  26. if(_empty_($admin_user->uid)){
  27. $grid->model()->where('id', '<', -1);
  28. }else{
  29. $grid->model()->where('seller_user_id', $admin_user->uid);
  30. }
  31. }
  32. $grid->quickSearch(['id', 'name'])->placeholder('搜索订单商品ID,名字...');
  33. $grid->model()->whereNotIn('goods_type', [6,7])->orderBy('id', 'desc');
  34. $grid->column('id')->sortable();
  35. $grid->column('order_id', '站内订单id')->display(function ($v){
  36. return '<a href="'.admin_url('/shop/order?id='.$v).'" target="_blank">订单'.$v.'</a>';
  37. });
  38. $grid->column('pic')->image('', 80);
  39. $grid->column('name');
  40. $grid->column('product')->limit(20);
  41. $grid->column('vip_price')->display(function ($v) use ($app_coin_name){
  42. if($this->credit_type == 1){
  43. return '¥'.$v;
  44. }else{
  45. return $v.$app_coin_name;
  46. }
  47. })->sortable();
  48. $grid->column('price')->display(function ($v) use ($app_coin_name){
  49. if($this->credit_type == 1){
  50. return '¥'.$v;
  51. }else{
  52. return $v.$app_coin_name;
  53. }
  54. })->sortable();
  55. $grid->column('recharge')->display(function ($v) use ($app_coin_name){
  56. // todo:
  57. if($this->credit_type == 1){
  58. return '¥'.$v;
  59. }else{
  60. return $v.$app_coin_name;
  61. }
  62. })->sortable();
  63. $grid->column('quantity');
  64. $grid->column('goods_id');
  65. $grid->column('product_id');
  66. // $grid->column('type')->using([0 => '正常购买', 1 => '补发', 2 => '赠送'])->label([
  67. // 0 => 'green',
  68. // 1 => 'blue',
  69. // 2 => 'orange2'
  70. // ]);
  71. $grid->column('state')->using([0 => '无售后申请', 1 => '② 退款中(待退款)', 2 => '① 退货退款中(协商退货)', 3 => '③ 已退款(售后完结)', 4 => '异常', 5=>'微信退款处理中', 6=>'支付宝退款处理中'])->label([
  72. 0 => 'silver',
  73. 1 => 'red',
  74. 2 => 'red',
  75. 3 => 'green',
  76. 4 => 'red',
  77. 5 => 'red',
  78. 6 => 'red',
  79. ]);
  80. $grid->column('created_at');
  81. // $grid->column('updated_at')->sortable();
  82. $grid->filter(function (Grid\Filter $filter) {
  83. $filter->equal('id');
  84. $filter->equal('order_id');
  85. });
  86. $grid->actions(function (Grid\Displayers\Actions $actions) {
  87. $actions->append((new OrderGoodsAction())->setKey($this->id));
  88. });
  89. $grid->disableCreateButton();
  90. // $grid->disableActions();
  91. $grid->disableViewButton();
  92. // 禁用编辑按钮
  93. $grid->disableEditButton();
  94. $grid->disableDeleteButton();
  95. });
  96. }
  97. /**
  98. * Make a show builder.
  99. *
  100. * @param mixed $id
  101. *
  102. * @return Show
  103. */
  104. protected function detail($id)
  105. {
  106. return Show::make($id, new WxShopOrderGoods(), function (Show $show) {
  107. $show->field('id');
  108. $show->field('pic');
  109. $show->field('name');
  110. $show->field('product');
  111. $show->field('vip_price');
  112. $show->field('price');
  113. $show->field('recharge');
  114. $show->field('quantity');
  115. $show->field('order_id');
  116. $show->field('goods_id');
  117. $show->field('product_id');
  118. $show->field('type');
  119. $show->field('state');
  120. $show->field('created_at');
  121. $show->field('updated_at');
  122. $show->disableEditButton();
  123. });
  124. }
  125. /**
  126. * Make a form builder.
  127. *
  128. * @return Form
  129. */
  130. protected function form()
  131. {
  132. return Form::make(new WxShopOrderGoods(), function (Form $form) {
  133. $form->display('id');
  134. $form->text('pic');
  135. $form->text('name');
  136. $form->text('product');
  137. $form->text('vip_price');
  138. $form->text('price');
  139. $form->text('recharge');
  140. $form->text('quantity');
  141. $form->text('order_id');
  142. $form->text('goods_id');
  143. $form->text('product_id');
  144. $form->text('type');
  145. $form->text('state');
  146. $form->deleting(function (Form $form){
  147. global $__MINI_GLOBAL_TENANT_ID__;
  148. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  149. return $form->response()->error('权限不足,不可以删除其他分站对象');
  150. }
  151. });
  152. });
  153. }
  154. }