OrdersDetailsController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Order;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class OrdersDetailsController extends AdminController
  9. {
  10. /**
  11. * Title for current resource.
  12. *
  13. * @var string
  14. */
  15. protected $title = '订单详情';
  16. /**
  17. * Make a grid builder.
  18. *
  19. * @return Grid
  20. */
  21. protected function grid()
  22. {
  23. $grid = new Grid(new Order());
  24. $grid->disableActions();
  25. $grid->column('id', __('Id'));
  26. $grid->column('product_type', __('产品类型'))->using([
  27. 1=>'电话咨询',
  28. 2=>'图文咨询',
  29. 3=>'门诊预约',
  30. 4=>'疫苗接种预约',
  31. 5=>'儿保预约',
  32. 6=>'服务包',
  33. 7=>'充值订单'
  34. ]);
  35. $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
  36. $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
  37. $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
  38. $grid->column('payment_time', __('支付时间'))->display(function ($time){
  39. return date('Y-m-d H:i:s',$time);
  40. });
  41. $grid->column('receiving_time', __('接单时间'))->display(function ($time){
  42. return date('Y-m-d H:i:s',$time);
  43. });
  44. $grid->column('end_time', __('订单完成时间'))->display(function ($time){
  45. return date('Y-m-d H:i:s',$time);
  46. });
  47. $grid->column('total_amount', __('订单总金额'))->display(function ($money){
  48. return $money/100;
  49. });
  50. $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
  51. return $money/100;
  52. });
  53. $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
  54. return $money/100;
  55. });
  56. return $grid;
  57. }
  58. /**
  59. * Make a show builder.
  60. *
  61. * @param mixed $id
  62. * @return Show
  63. */
  64. protected function detail($id)
  65. {
  66. $show = new Show(Order::findOrFail($id));
  67. $show->field('id', __('Id'));
  68. $show->field('user_id', __('User id'));
  69. $show->field('docter_id', __('Docter id'));
  70. $show->field('patient_id', __('Patient id'));
  71. $show->field('organization_id', __('Organization id'));
  72. $show->field('order_sn', __('Order sn'));
  73. $show->field('payment_type', __('Payment type'));
  74. $show->field('product_type', __('Product type'));
  75. $show->field('order_status', __('Order status'));
  76. $show->field('payment_status', __('Payment status'));
  77. $show->field('total_amount', __('Total amount'));
  78. $show->field('payment_amount', __('Payment amount'));
  79. $show->field('discount_amount', __('Discount amount'));
  80. $show->field('payment_time', __('Payment time'));
  81. $show->field('created_at', __('Created at'));
  82. $show->field('updated_at', __('Updated at'));
  83. $show->field('outtime', __('Outtime'));
  84. $show->field('receiving_time', __('Receiving time'));
  85. return $show;
  86. }
  87. /**
  88. * Make a form builder.
  89. *
  90. * @return Form
  91. */
  92. protected function form()
  93. {
  94. $form = new Form(new Order());
  95. $form->number('user_id', __('User id'));
  96. $form->number('docter_id', __('Docter id'));
  97. $form->number('patient_id', __('Patient id'));
  98. $form->number('organization_id', __('Organization id'));
  99. $form->text('order_sn', __('Order sn'));
  100. $form->switch('payment_type', __('Payment type'))->default(1);
  101. $form->switch('product_type', __('Product type'))->default(1);
  102. $form->switch('order_status', __('Order status'))->default(1);
  103. $form->switch('payment_status', __('Payment status'))->default(1);
  104. $form->number('total_amount', __('Total amount'));
  105. $form->number('payment_amount', __('Payment amount'));
  106. $form->number('discount_amount', __('Discount amount'));
  107. $form->number('payment_time', __('Payment time'));
  108. $form->number('outtime', __('Outtime'));
  109. $form->number('receiving_time', __('Receiving time'));
  110. return $form;
  111. }
  112. }