RechargeOrderController.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. namespace App\Admin\Controllers\OrdersManagement;
  3. use App\Admin\Actions\backstage\Orders\Evaluate;
  4. use App\Models\Order;
  5. use App\Admin\Actions\backstage\Orders\OrderDetails;
  6. use Encore\Admin\Controllers\AdminController;
  7. use Encore\Admin\Form;
  8. use Encore\Admin\Grid;
  9. use Encore\Admin\Show;
  10. class RechargeOrderController extends AdminController
  11. {
  12. /**
  13. * Title for current resource.
  14. *
  15. * @var string
  16. */
  17. protected $title = '充值订单';
  18. /**
  19. * Make a grid builder.
  20. *
  21. * @return Grid
  22. */
  23. protected function grid()
  24. {
  25. $grid = new Grid(new Order());
  26. $grid->disableCreateButton();
  27. $grid->model()->wherein('product_type',[7]);
  28. //筛选
  29. $grid->filter(function ($filter){
  30. $filter->disableIdFilter();
  31. $filter->like('user.nickname','用户姓名');
  32. $filter->equal('user_id', '用户id');
  33. $filter->equal('order_status','订单状态')->radio(
  34. [
  35. ''=>'不限',
  36. 1=>'未支付',
  37. 2=>'待接单',
  38. 3=>'进行中',
  39. 4=>'已完成',
  40. 5=>'已取消'
  41. ]
  42. );
  43. });
  44. $grid->actions(function ($actions) {
  45. // 去掉删除
  46. $actions->disableDelete();
  47. // 去掉编辑
  48. $actions->disableEdit();
  49. $actions->add(new Evaluate());
  50. });
  51. $grid->column('id', __('Id'))->sortable();
  52. $grid->column('user_id', __('用户id'));
  53. $grid->column('user.nickname', __('用户姓名'));
  54. $grid->column('product_type', __('产品类型'))->using([7=>'充值订单']);
  55. $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
  56. $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
  57. $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
  58. $grid->column('total_amount', __('订单总金额'))->display(function ($money){
  59. return $money/100;
  60. });
  61. $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
  62. return $money/100;
  63. });
  64. $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
  65. return $money/100;
  66. });
  67. $grid->column('payment_time', __('支付时间'))->display(function ($time){
  68. return date('Y-m-d H:i:s',$time);
  69. });
  70. $grid->column('receiving_time', __('接单时间'))->display(function ($time){
  71. return date('Y-m-d H:i:s',$time);
  72. });
  73. $grid->column('end_time', __('订单完成时间'))->display(function ($time){
  74. return date('Y-m-d H:i:s',$time);
  75. });
  76. return $grid;
  77. }
  78. /**
  79. * Make a show builder.
  80. *
  81. * @param mixed $id
  82. * @return Show
  83. */
  84. protected function detail($id)
  85. {
  86. $show = new Show(Order::findOrFail($id)); $show->field('id', __('Id'));
  87. $show->field('id', __('Id'));
  88. $show->field('user_id', __('用户id'));
  89. $show->field('user.nickname', __('用户姓名'));
  90. $show->field('docter_id', __('医生id'));
  91. $show->field('docter.name', __('医生姓名'));
  92. $show->field('patient_id', __('患者id'));
  93. $show->field('orderPatient.name', __('患者姓名'));
  94. $show->field('organization_id', __('机构id'));
  95. $show->field('organization.name', __('机构名'));
  96. $show->field('order_sn', __('订单号'));
  97. $show->field('product_type', __('产品类型'))->using([7=>'充值订单']);
  98. $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
  99. $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
  100. $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
  101. $show->field('total_amount', __(' 订单总金额'))->as(function ($money){
  102. return $money/100;
  103. });
  104. $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
  105. return $money/100;
  106. });
  107. $show->field('discount_amount', __('折扣金额'))->as(function ($money){
  108. return $money/100;
  109. });
  110. $show->field('payment_time', __('支付时间'))->as(function ($time){
  111. if($time == 0)
  112. {
  113. return '';
  114. }
  115. else
  116. {
  117. return date('Y-m-d H:i:s',$time);
  118. }
  119. });
  120. $show->field('receiving_time', __('接单时间'))->as(function ($time){
  121. if($time == 0)
  122. {
  123. return '';
  124. }
  125. else
  126. {
  127. return date('Y-m-d H:i:s',$time);
  128. }
  129. });
  130. $show->field('end_time', __('订单完成时间'))->as(function ($time){
  131. if($time == 0)
  132. {
  133. return '';
  134. }
  135. else
  136. {
  137. return date('Y-m-d H:i:s',$time);
  138. }
  139. });
  140. $show->field('created_at', __('创建时间'));
  141. $show->field('updated_at', __('更新时间'));
  142. return $show;
  143. }
  144. /**
  145. * Make a form builder.
  146. *
  147. * @return Form
  148. */
  149. protected function form()
  150. {
  151. $form = new Form(new Order());
  152. $form->number('user_id', __('User id'));
  153. $form->number('docter_id', __('Docter id'));
  154. $form->number('patient_id', __('Patient id'));
  155. $form->number('organization_id', __('Organization id'));
  156. $form->text('order_sn', __('Order sn'));
  157. $form->switch('payment_type', __('Payment type'))->default(1);
  158. $form->switch('product_type', __('Product type'))->default(1);
  159. $form->switch('order_status', __('Order status'))->default(1);
  160. $form->switch('payment_status', __('Payment status'))->default(1);
  161. $form->number('total_amount', __('Total amount'));
  162. $form->number('payment_amount', __('Payment amount'));
  163. $form->number('discount_amount', __('Discount amount'));
  164. $form->number('payment_time', __('Payment time'));
  165. $form->number('outtime', __('Outtime'));
  166. $form->number('receiving_time', __('Receiving time'));
  167. return $form;
  168. }
  169. }