Browse Source

添加服务商角色

master
Mike 6 years ago
parent
commit
b2d1d204a1
  1. 94
      app/Admin/Controllers/LanzuMpWithdrawController.php
  2. 2
      app/Models/LanzuMmWithdraw.php
  3. 9
      app/Models/LanzuMpWithdraw.php

94
app/Admin/Controllers/LanzuMpWithdrawController.php

@ -18,18 +18,24 @@ class LanzuMpWithdrawController extends AdminController
*/ */
protected function grid() protected function grid()
{ {
return Grid::make(new LanzuMpWithdraw(), function (Grid $grid) {
return Grid::make(new LanzuMpWithdraw(['mpInfo']), function (Grid $grid) {
$grid->id->sortable(); $grid->id->sortable();
$grid->mp_id;
$grid->column('mpInfo.name','服务商名字');
$grid->money; $grid->money;
$grid->status;
$grid->status('提现状态')->using([-1=>'拒绝',0=>'审核中',1=>'通过'])
->label([-1=>'danger',0=>'default',1=>'success']);
$grid->created_at; $grid->created_at;
$grid->updated_at->sortable();
$grid->filter(function (Grid\Filter $filter) { $grid->filter(function (Grid\Filter $filter) {
$filter->equal('id'); $filter->equal('id');
}); });
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableDelete();
// $actions->disableEdit();
$actions->disableQuickEdit();
$actions->disableView();
});
}); });
} }
@ -42,9 +48,10 @@ class LanzuMpWithdrawController extends AdminController
*/ */
protected function detail($id) protected function detail($id)
{ {
return Show::make($id, new LanzuMpWithdraw(), function (Show $show) {
return Show::make($id, new LanzuMpWithdraw(['mpInfo']), function (Show $show) {
$show->id; $show->id;
$show->mp_id; $show->mp_id;
$show->column('服务商名称','mpInfo.name');
$show->money; $show->money;
$show->status; $show->status;
$show->created_at; $show->created_at;
@ -58,21 +65,74 @@ class LanzuMpWithdrawController extends AdminController
* @return Form * @return Form
*/ */
public function mpForm(){
protected function lanzu_bis_form(){
//管理员或者lanzu_bis操作
return Form::make(new LanzuMpWithdraw(['mpInfo']), function (Form $form) {
$form->footer(function ($footer) {
// 去掉`查看`checkbox
$footer->disableViewCheck();
// 去掉`继续编辑`checkbox
$footer->disableEditingCheck();
// 去掉`继续创建`checkbox
$footer->disableCreatingCheck();
});
$form->tools(function (Form\Tools $tools) {
// 去掉跳转详情页按钮
$tools->disableView();
// 去掉删除按钮
$tools->disableDelete();
$tools->disableList();
});
// dd($form->model()->mp_info['name']);
$mpName = $form->model()->mp_info['name'];
//dd( $mpName);
$form->display('id');
$form->text('mp_id','服务商ID')->disable();
$form->display('','服务商名')->value($mpName);
$form->text('money','提现金额')->disable()->required();
$form->hidden('is_operated');
$form->saving(function (Form $form) {
$form->is_operated = 1;
});
if($form->model()->is_operated){
$status = '';
if($form->model()->status==1){
$status = '审核通过';
}
if($form->model()->status==-1){
$status = '拒绝';
}
$form->display('','审核状态')->value($status);
$form->disableSubmitButton();
$form->disableResetButton();
}else{
$form->radio('status')->options([1 => '通过审核', -1=> '拒绝'])->default(-1);;
}
});
}
protected function form()
{
$current_user = Admin::user(); $current_user = Admin::user();
if(!$current_user->isRole('lanzu_mp')){
return $this->lanzu_bis_form();
}
//如果是服务商角色
$mp = MpBalance::where('user_id',$current_user->id) $mp = MpBalance::where('user_id',$current_user->id)
->where('user_type',1)->first(); ->where('user_type',1)->first();
$balance = 0; $balance = 0;
if($mp){ if($mp){
$balance = $mp->balance; $balance = $mp->balance;
} }
return Form::make(new LanzuMpWithdraw(), function (Form $form) use($current_user,$balance) { return Form::make(new LanzuMpWithdraw(), function (Form $form) use($current_user,$balance) {
$form->footer(function ($footer) { $form->footer(function ($footer) {
@ -101,16 +161,4 @@ class LanzuMpWithdrawController extends AdminController
//$form->text('status'); //$form->text('status');
}); });
} }
protected function form()
{
return Form::make(new LanzuMpWithdraw(), function (Form $form) {
$form->display('id');
$form->text('mp_id');
$form->text('money');
$form->text('status');
$form->display('created_at');
$form->display('updated_at');
});
}
} }

2
app/Models/LanzuMmWithdraw.php

@ -15,7 +15,7 @@ class LanzuMmWithdraw extends Model
public function mmInfo() public function mmInfo()
{ {
return $this->hasOne('\App\Models\LanzuMpInfo','id','mm_id');
return $this->hasOne('\App\Models\LanzuMmInfo','id','mm_id');
} }
} }

9
app/Models/LanzuMpWithdraw.php

@ -2,16 +2,19 @@
namespace App\Models; namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class LanzuMpWithdraw extends Model class LanzuMpWithdraw extends Model
{ {
use HasDateTimeFormatter;
use SoftDeletes;
use SoftDeletes;
protected $dateFormat = 'U';
protected $table = 'lanzu_mp_withdraw'; protected $table = 'lanzu_mp_withdraw';
public function mpInfo()
{
return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id');
}
} }
Loading…
Cancel
Save