123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- namespace App\Admin\Controllers\OrdersManagement;
- use App\Admin\Actions\backstage\Orders\Evaluate;
- use App\Models\Order;
- use App\Admin\Actions\backstage\Orders\OrderDetails;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- class RechargeOrderController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '充值订单';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new Order());
- $grid->disableCreateButton();
- $grid->model()->wherein('product_type',[7]);
- //筛选
- $grid->disableActions();
- $grid->filter(function ($filter){
- $filter->disableIdFilter();
- $filter->like('user.nickname','用户姓名');
- $filter->equal('user.phone','用户电话');
- $filter->equal('order_status','订单状态')->radio(
- [
- ''=>'不限',
- 1=>'未支付',
- 2=>'待接单',
- 3=>'进行中',
- 4=>'已完成',
- 5=>'已取消'
- ]
- );
- $filter->timestampBetween('payment_time', "支付时间")->datetime();
- });
- $grid->export(function ($export) {
- $export->filename('充值订单');
- });
- $grid->actions(function ($actions) {
- // 去掉删除
- $actions->disableDelete();
- // 去掉编辑
- $actions->disableEdit();
- });
- $status_arr = Order::getStatus();
- $grid->model()->orderBy('id','desc');
- $grid->column('id', __('Id'))->sortable();
- $grid->column('user_id', __('用户id'));
- $grid->column('user.nickname', __('用户姓名'));
- $grid->column('user.phone', __('用户电话'));
- $grid->column('product_type', __('产品类型'))->using([7=>'充值订单']);
- $grid->column('payment_type', __('支付方式'))->using([1=>'微信支付',2=>'余额支付']);
- $grid->column('order_status', __('订单状态'))->display(function ($w) use ($status_arr) {
- $info = $status_arr[intval($w)];
- if($w == 1 || $w == 2){
- return '<span class="label label-warning">'.$info.'</span>';
- } else if( $w == 4 ){
- return '<span class="label label-success">'.$info.'</span>';
- } else if($w == 7 || $w == 3 ){
- return '<span class="label label-info">'.$info.'</span>';
- } else if($w == 6){
- return '<span class="label label-danger">'.$info.'</span>';
- } else {
- return '<span class="label label-default">'.$info.'</span>';
- }
- });
- $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款'])->label([1=>'warning',2=>'success',3=>'info',4=>'danger']);;
- $grid->column('total_amount', __('订单总金额'))->display(function ($money){
- return $money/100;
- });
- $grid->column('payment_amount', __('用户实际支付的金额'))->display(function ($money){
- return $money/100;
- });
- $grid->column('discount_amount', __('折扣金额'))->display(function ($money){
- return $money/100;
- });
- $grid->column('order_notes', __('订单备注'));
- $grid->column('payment_time', __('支付时间'))->display(function ($time){
- if ($time == 0 )
- {
- return '';
- }
- else
- {
- return date('Y-m-d H:i:s',$time);
- }
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(Order::findOrFail($id)); $show->field('id', __('Id'));
- $show->field('id', __('Id'));
- $show->field('user_id', __('用户id'));
- $show->field('user.nickname', __('用户姓名'));
- $show->field('docter_id', __('医生id'));
- $show->field('docter.name', __('医生姓名'));
- $show->field('patient_id', __('患者id'));
- $show->field('orderPatient.name', __('患者姓名'));
- $show->field('organization_id', __('机构id'));
- $show->field('organization.name', __('机构名'));
- $show->field('order_sn', __('订单号'));
- $show->field('product_type', __('产品类型'))->using([7=>'充值订单']);
- $show->field('payment_type', __('支付类型'))->using([1=>'微信支付',2=>'余额支付']);
- $show->field('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
- $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
- $show->field('total_amount', __(' 订单总金额'))->as(function ($money){
- return $money/100;
- });
- $show->field('payment_amount', __('用户实际支付的金额'))->as(function ($money){
- return $money/100;
- });
- $show->field('discount_amount', __('折扣金额'))->as(function ($money){
- return $money/100;
- });
- $show->field('payment_time', __('支付时间'))->as(function ($time){
- if($time == 0)
- {
- return '';
- }
- else
- {
- return date('Y-m-d H:i:s',$time);
- }
- });
- $show->field('receiving_time', __('接单时间'))->as(function ($time){
- if($time == 0)
- {
- return '';
- }
- else
- {
- return date('Y-m-d H:i:s',$time);
- }
- });
- $show->field('end_time', __('订单完成时间'))->as(function ($time){
- if($time == 0)
- {
- return '';
- }
- else
- {
- return date('Y-m-d H:i:s',$time);
- }
- });
- $show->field('created_at', __('创建时间'));
- $show->field('updated_at', __('更新时间'));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new Order());
- $form->number('user_id', __('User id'));
- $form->number('docter_id', __('Docter id'));
- $form->number('patient_id', __('Patient id'));
- $form->number('organization_id', __('Organization id'));
- $form->text('order_sn', __('Order sn'));
- $form->switch('payment_type', __('Payment type'))->default(1);
- $form->switch('product_type', __('Product type'))->default(1);
- $form->switch('order_status', __('Order status'))->default(1);
- $form->switch('payment_status', __('Payment status'))->default(1);
- $form->number('total_amount', __('Total amount'));
- $form->number('payment_amount', __('Payment amount'));
- $form->number('discount_amount', __('Discount amount'));
- $form->number('payment_time', __('Payment time'));
- $form->number('outtime', __('Outtime'));
- $form->number('receiving_time', __('Receiving time'));
- return $form;
- }
- }
|