ServicePackOrderController.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. namespace App\Admin\Controllers\OrdersManagement;
  3. use App\Admin\Actions\backstage\Docters\Team;
  4. use App\Admin\Actions\backstage\Orders\Evaluate;
  5. use App\Admin\Actions\backstage\Orders\ServicePack;
  6. use App\Admin\Actions\backstage\Orders\ServicePackOrderList;
  7. use App\Models\Order;
  8. use App\Admin\Actions\backstage\Orders\OrderDetails;
  9. use Encore\Admin\Controllers\AdminController;
  10. use App\Admin\Actions\backstage\User\MapDepot;
  11. use App\Admin\Actions\backstage\User\Suggests;
  12. use Encore\Admin\Form;
  13. use Encore\Admin\Grid;
  14. use Encore\Admin\Show;
  15. class ServicePackOrderController extends AdminController
  16. {
  17. /**
  18. * Title for current resource.
  19. *
  20. * @var string
  21. */
  22. protected $title = '服务包开通订单';
  23. /**
  24. * Make a grid builder.
  25. *
  26. * @return Grid
  27. */
  28. protected function grid()
  29. {
  30. $grid = new Grid(new Order());
  31. $grid->disableCreateButton();
  32. $grid->model()->wherein('product_type',[6]);
  33. //筛选
  34. $grid->filter(function ($filter){
  35. $filter->disableIdFilter();
  36. $filter->like('user.nickname','用户姓名');
  37. $filter->equal('user.phone','用户电话');
  38. $filter->like('orderPack.pack_name','服务包名称');
  39. $filter->like('patient.name','患者姓名');
  40. $filter->equal('order_status','订单状态')->radio(
  41. [
  42. ''=>'不限',
  43. 1=>'未支付',
  44. 2=>'待接单',
  45. 3=>'进行中',
  46. 4=>'已完成',
  47. 5=>'已取消'
  48. ]
  49. );
  50. $filter->where(function ($query){
  51. $query->whereHas('orderPack',function ($query){
  52. $query->where('team_id','like',"%{$this->input}%");
  53. });
  54. },'医生团队')->select(\App\Models\Team::where('status',1)->pluck('name','id'));
  55. $filter->timestampBetween('payment_time', "支付时间")->datetime();
  56. });
  57. //操作
  58. $grid->actions(function ($actions) {
  59. $actions->disableView();
  60. // 去掉删除
  61. $actions->disableDelete();
  62. // 去掉编辑
  63. $actions->disableEdit();
  64. $actions->add(new ServicePack());
  65. $actions->add(new ServicePackOrderList());
  66. });
  67. $grid->export(function ($export) {
  68. $export->filename('服务包开通订单');
  69. });
  70. $status_arr = Order::getStatus();
  71. $grid->model()->orderBy('id','desc');
  72. $grid->column('id', __('Id'))->sortable();
  73. $grid->column('order_sn', __('订单编号'));
  74. $grid->column('user.nickname', __('用户姓名'));
  75. $grid->column('patient.name', __('患者姓名'));
  76. $grid->column('patient_id', __('患者id'))->hide();
  77. $grid->column('user.phone', __('用户电话'));
  78. $grid->column('orderPack.service_pack_id', __('服务包id'));
  79. $grid->column('orderPack.pack_name', __('服务包名称'));
  80. $grid->column('orderPack.pack_price', __('服务包价格'))->display(function ($money){
  81. return $money/100;
  82. });
  83. $grid->column('orderPack.team_id', __('医生团队'))->display(function ($team){
  84. if (empty($team))
  85. {
  86. return '无';
  87. }else
  88. {
  89. $res = \App\Models\Team::whereIn('id',$team)->pluck('name')->toArray();
  90. return $res;
  91. }
  92. })->label('info');
  93. $grid->column('product_type', __('产品类型'))->using([6=>'服务包订单']);
  94. $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
  95. $grid->column('order_status', __('订单状态'))->display(function ($w) use ($status_arr) {
  96. $info = $status_arr[intval($w)];
  97. if($w == 1 || $w == 2){
  98. return '<span class="label label-warning">'.$info.'</span>';
  99. } else if( $w == 4 ){
  100. return '<span class="label label-success">'.$info.'</span>';
  101. } else if($w == 7 || $w == 3 ){
  102. return '<span class="label label-info">'.$info.'</span>';
  103. } else if($w == 6){
  104. return '<span class="label label-danger">'.$info.'</span>';
  105. } else {
  106. return '<span class="label label-default">'.$info.'</span>';
  107. }
  108. });
  109. $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款'])->label([1=>'warring',2=>'success',3=>'info',4=>'danger']);;
  110. $grid->column('total_amount', __('订单总金额'))->display(function ($money){
  111. return $money/100;
  112. });
  113. $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
  114. return $money/100;
  115. });
  116. $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
  117. return $money/100;
  118. });
  119. $grid->column('order_notes', __('订单备注'));
  120. $grid->column('payment_time', __('支付时间'))->display(function ($time){
  121. return date('Y-m-d H:i:s',$time);
  122. });
  123. return $grid;
  124. }
  125. /**
  126. * Make a show builder.
  127. *
  128. * @param mixed $id
  129. * @return Show
  130. */
  131. protected function detail($id)
  132. {
  133. $show = new Show(Order::findOrFail($id));
  134. $show->field('id', __('Id'));
  135. $show->field('user_id', __('用户id'));
  136. $show->field('user.nickname', __('用户姓名'));
  137. $show->field('docter_id', __('医生id'));
  138. $show->field('docter.name', __('医生姓名'));
  139. $show->field('patient_id', __('患者id'));
  140. $show->field('orderPatient.name', __('患者姓名'));
  141. $show->field('organization_id', __('机构id'));
  142. $show->field('organization.name', __('机构名'));
  143. $show->field('order_sn', __('订单号'));
  144. $show->field('product_type', __('产品类型'))->using([6=>'服务包订单']);
  145. $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
  146. $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
  147. $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
  148. $show->field('total_amount', __(' 订单总金额'))->as(function ($money){
  149. return $money/100;
  150. });
  151. $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
  152. return $money/100;
  153. });
  154. $show->field('discount_amount', __('折扣金额'))->as(function ($money){
  155. return $money/100;
  156. });
  157. $show->field('payment_time', __('支付时间'))->as(function ($time){
  158. if($time == 0)
  159. {
  160. return '';
  161. }
  162. else
  163. {
  164. return date('Y-m-d H:i:s',$time);
  165. }
  166. });
  167. $show->field('receiving_time', __('接单时间'))->as(function ($time){
  168. if($time == 0)
  169. {
  170. return '';
  171. }
  172. else
  173. {
  174. return date('Y-m-d H:i:s',$time);
  175. }
  176. });
  177. $show->field('end_time', __('订单完成时间'))->as(function ($time){
  178. if($time == 0)
  179. {
  180. return '';
  181. }
  182. else
  183. {
  184. return date('Y-m-d H:i:s',$time);
  185. }
  186. });
  187. $show->field('created_at', __('创建时间'));
  188. $show->field('updated_at', __('更新时间'));
  189. return $show;
  190. }
  191. }