소스 검색

feat(view): 分销订单

xiansin 4 년 전
부모
커밋
442bbca7e2
4개의 변경된 파일118개의 추가작업 그리고 0개의 파일을 삭제
  1. 108 0
      app/Admin/Controllers/UserVipController.php
  2. 1 0
      app/Admin/routes.php
  3. 2 0
      app/Http/Controllers/Api/UserController.php
  4. 7 0
      app/Models/UserVip.php

+ 108 - 0
app/Admin/Controllers/UserVipController.php

xqd
@@ -0,0 +1,108 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\UserVip;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+
+class UserVipController extends AdminController
+{
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new UserVip(), function (Grid $grid) {
+            $grid->model()->where('is_share',1)->where('status',1)
+                ->orderBy('id','desc');
+            $grid->column('id')->sortable()->width('80px');
+            $grid->column('order_id');
+            $grid->column('order_fee','订单金额');
+            $grid->column('user_id','用户昵称')->display(function () {
+                return $this->user->nickname;
+            });
+            $grid->column('user_id','用户电话')->display(function () {
+                return $this->user->phone_num;
+            });
+            $grid->column('parent_id','上级用户')->display(function () {
+                return $this->parent->nickname;
+            });
+            $grid->column('status','支付状态')
+                ->using([0 => '未支付', 1 => '已支付'])->dot([
+                0 => 'danger',
+                1 => 'success'
+            ]);
+            $grid->column('pay_at','支付时间');
+            $grid->column('created_at');
+
+            $grid->disableViewButton();
+            $grid->disableEditButton();
+            $grid->disableCreateButton();
+            $grid->disableRowSelector();
+            $grid->disableDeleteButton();
+            $grid->disableActions();
+
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('order','订单ID');
+                $filter->like('user.nickname','用户昵称');
+                $filter->equal('user.phone_num','用户手机');
+                $filter->like('parent.nickname','上级用户');
+
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new UserVip(), function (Show $show) {
+            $show->field('id');
+            $show->field('order_id');
+            $show->field('user_id');
+            $show->field('prepay_id');
+            $show->field('serial_number');
+            $show->field('order_fee');
+            $show->field('is_share');
+            $show->field('parent_id');
+            $show->field('status');
+            $show->field('pay_at');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new UserVip(), function (Form $form) {
+            $form->display('id');
+            $form->text('order_id');
+            $form->text('user_id');
+            $form->text('prepay_id');
+            $form->text('serial_number');
+            $form->text('order_fee');
+            $form->text('is_share');
+            $form->text('parent_id');
+            $form->text('status');
+            $form->text('pay_at');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}

+ 1 - 0
app/Admin/routes.php

xqd
@@ -19,6 +19,7 @@ Route::group([
     $router->resource('withdraw', 'UserWithdrawController');
     $router->resource('shareSetting', 'ShareConfigController');
     $router->post('shareSetting/save', 'ShareConfigController@save');
+    $router->resource('shareOrder', 'UserVipController');
 
     $router->resource('setting', 'SettingController');
     $router->put('setting', 'SettingController@setting');

+ 2 - 0
app/Http/Controllers/Api/UserController.php

xqd
@@ -89,6 +89,8 @@ class UserController extends Controller
                     $order = UserVip::create([
                         'order_id' => $orderId,
                         'user_id' => $user['id'],
+                        'is_share' => $user['parent_id'] ? 1 : 0,
+                        'parent_id' => $user['parent_id'],
                         'order_fee' => $shareConfig['member_price']
                     ]);
                 }else{

+ 7 - 0
app/Models/UserVip.php

xqd xqd
@@ -45,6 +45,8 @@ class UserVip extends Model
         'user_id',
         'order_fee',
         'prepay_id',
+        'is_share',
+        'parent_id',
         'serial_number',
         'status',
     ];
@@ -54,4 +56,9 @@ class UserVip extends Model
         return $this->belongsTo(User::class);
     }
 
+    public function parent()
+    {
+        return $this->belongsTo(User::class,'parent_id');
+    }
+
 }