RechargeOrderController.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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->disableActions();
  30. $grid->filter(function ($filter){
  31. $filter->disableIdFilter();
  32. $filter->like('user.nickname','用户姓名');
  33. $filter->equal('order_status','订单状态')->radio(
  34. [
  35. ''=>'不限',
  36. 1=>'未支付',
  37. 2=>'待接单',
  38. 3=>'进行中',
  39. 4=>'已完成',
  40. 5=>'已取消'
  41. ]
  42. );
  43. $filter->timestampBetween('payment_time', "支付时间")->datetime();
  44. });
  45. $grid->export(function ($export) {
  46. $export->filename('充值订单');
  47. });
  48. $grid->actions(function ($actions) {
  49. // 去掉删除
  50. $actions->disableDelete();
  51. // 去掉编辑
  52. $actions->disableEdit();
  53. });
  54. $status_arr = Order::getStatus();
  55. $grid->model()->orderBy('id','desc');
  56. $grid->column('id', __('Id'))->sortable();
  57. $grid->column('user_id', __('用户id'));
  58. $grid->column('user.nickname', __('用户姓名'));
  59. $grid->column('user.phone', __('用户电话'));
  60. $grid->column('product_type', __('产品类型'))->using([7=>'充值订单']);
  61. $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
  62. $grid->column('order_status', __('订单状态'))->display(function ($w) use ($status_arr) {
  63. $info = $status_arr[intval($w)];
  64. if($w == 1 || $w == 2){
  65. return '<span class="label label-warning">'.$info.'</span>';
  66. } else if( $w == 4 ){
  67. return '<span class="label label-success">'.$info.'</span>';
  68. } else if($w == 7 || $w == 3 ){
  69. return '<span class="label label-info">'.$info.'</span>';
  70. } else if($w == 6){
  71. return '<span class="label label-danger">'.$info.'</span>';
  72. } else {
  73. return '<span class="label label-default">'.$info.'</span>';
  74. }
  75. });
  76. $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款'])->label([1=>'warring',2=>'success',3=>'info',4=>'danger']);;
  77. $grid->column('total_amount', __('订单总金额'))->display(function ($money){
  78. return $money/100;
  79. });
  80. $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
  81. return $money/100;
  82. });
  83. $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
  84. return $money/100;
  85. });
  86. $grid->column('order_notes', __('订单备注'));
  87. $grid->column('payment_time', __('支付时间'))->display(function ($time){
  88. if ($time == 0 )
  89. {
  90. return '';
  91. }
  92. else
  93. {
  94. return date('Y-m-d H:i:s',$time);
  95. }
  96. });
  97. return $grid;
  98. }
  99. /**
  100. * Make a show builder.
  101. *
  102. * @param mixed $id
  103. * @return Show
  104. */
  105. protected function detail($id)
  106. {
  107. $show = new Show(Order::findOrFail($id)); $show->field('id', __('Id'));
  108. $show->field('id', __('Id'));
  109. $show->field('user_id', __('用户id'));
  110. $show->field('user.nickname', __('用户姓名'));
  111. $show->field('docter_id', __('医生id'));
  112. $show->field('docter.name', __('医生姓名'));
  113. $show->field('patient_id', __('患者id'));
  114. $show->field('orderPatient.name', __('患者姓名'));
  115. $show->field('organization_id', __('机构id'));
  116. $show->field('organization.name', __('机构名'));
  117. $show->field('order_sn', __('订单号'));
  118. $show->field('product_type', __('产品类型'))->using([7=>'充值订单']);
  119. $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
  120. $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
  121. $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
  122. $show->field('total_amount', __(' 订单总金额'))->as(function ($money){
  123. return $money/100;
  124. });
  125. $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
  126. return $money/100;
  127. });
  128. $show->field('discount_amount', __('折扣金额'))->as(function ($money){
  129. return $money/100;
  130. });
  131. $show->field('payment_time', __('支付时间'))->as(function ($time){
  132. if($time == 0)
  133. {
  134. return '';
  135. }
  136. else
  137. {
  138. return date('Y-m-d H:i:s',$time);
  139. }
  140. });
  141. $show->field('receiving_time', __('接单时间'))->as(function ($time){
  142. if($time == 0)
  143. {
  144. return '';
  145. }
  146. else
  147. {
  148. return date('Y-m-d H:i:s',$time);
  149. }
  150. });
  151. $show->field('end_time', __('订单完成时间'))->as(function ($time){
  152. if($time == 0)
  153. {
  154. return '';
  155. }
  156. else
  157. {
  158. return date('Y-m-d H:i:s',$time);
  159. }
  160. });
  161. $show->field('created_at', __('创建时间'));
  162. $show->field('updated_at', __('更新时间'));
  163. return $show;
  164. }
  165. /**
  166. * Make a form builder.
  167. *
  168. * @return Form
  169. */
  170. protected function form()
  171. {
  172. $form = new Form(new Order());
  173. $form->number('user_id', __('User id'));
  174. $form->number('docter_id', __('Docter id'));
  175. $form->number('patient_id', __('Patient id'));
  176. $form->number('organization_id', __('Organization id'));
  177. $form->text('order_sn', __('Order sn'));
  178. $form->switch('payment_type', __('Payment type'))->default(1);
  179. $form->switch('product_type', __('Product type'))->default(1);
  180. $form->switch('order_status', __('Order status'))->default(1);
  181. $form->switch('payment_status', __('Payment status'))->default(1);
  182. $form->number('total_amount', __('Total amount'));
  183. $form->number('payment_amount', __('Payment amount'));
  184. $form->number('discount_amount', __('Discount amount'));
  185. $form->number('payment_time', __('Payment time'));
  186. $form->number('outtime', __('Outtime'));
  187. $form->number('receiving_time', __('Receiving time'));
  188. return $form;
  189. }
  190. }