| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- <?php
- /**
- * Created by PhpStorm.
- * User: ring
- * Date: 2019/7/23
- * Time: 下午6:30
- */
- namespace App\Admin\Controllers;
- use App\Api\Util\IM;
- use App\Models\Users;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Layout\Content;
- use Encore\Admin\Show;
- use Illuminate\Support\Facades\Cache;
- class UsersController extends AdminController
- {
- use IM;
- protected $title = '用户管理';
- protected function grid()
- {
- $grid = new Grid(new Users());
- $grid->fixColumns(9,-3);
- $grid->lid('ID')->sortable();
- $grid->column('name', '名')->editable();
- $grid->column('tel', '电话');
- $grid->column('sex', '性别')->display(function ($x) {
- return $x == 1 ? '男':'女';
- });
- $grid->column('type', '类型')->display(function ($type) {
- $msg=$this->trump?'王牌':'';
- $s='普通';
- if($type==1){
- $s= $this->sex==2?$msg.'红娘':$msg.'月老';
- }
- return $s;
- })->sortable();
- // $grid->column('avatar', '头像')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
- $grid->column('vip', 'VIP')->display(function ($v) {
- return $v == 1 ? '是':'否';
- });
- $grid->column('rose', '余玫瑰');
- $grid->column('status', '状态')->display(function ($s) {
- return $s == 1 ? '在线':'离线';
- });
- $grid->column('openid', '微信绑定')->display(function ($o) {
- return $o ? '绑定':'未绑定';
- });
- $grid->column('realname', '姓名');
- $grid->column('age', '年龄');
- $grid->column('height', '身高');
- $grid->column('income', '收入');
- $grid->column('city', '城市');
- $grid->column('requirement', '交友条件');
- $grid->column('marriage', '婚姻')->display(function ($m) {
- return $m==1 ? '离遗':$m?'未婚':'丧偶';
- });
- $grid->column('think', '心声');
- $grid->column('wechat', '微信号');
- $grid->column('occupation', '职业');
- $grid->column('school', '毕业学校');
- $grid->column('km', '距离');
- $grid->column('wechat', '微信号');
- $grid->column('opt', '在')->display(function ($opt) {
- $s='浏览中';
- if($opt==1){
- $s='视频相亲';
- }
- if($opt==2){
- $s='专属相亲';
- }
- if($opt==4){
- $s='语音亲中';
- }
- if($opt==5){
- $s='交友';
- }
- return $s;
- });
- $grid->column('ban', '是否违规')->display(function ($b) {
- return $b>1 ? '有违规':'正常';
- });
- $grid->created_at('注册时间');
- $grid->updated_at('修改时间');
- $grid->disableExport();
- $grid->disableRowSelector();
- $grid->disableColumnSelector();
- $grid->disableCreateButton();
- $grid->expandFilter();
- $grid->model()->orderBy('id','desc');
- $grid->actions(function ($actions) {
- $actions->disableDelete();
- });
- $grid->filter(function ($filter) {
- $filter->disableIdFilter();
- $filter->equal('lid','用户ID')->placeholder('请输入用户ID');
- $filter->equal('realname','用户姓名')->placeholder('请输入用户姓名');
- $filter->equal('tel','用户电话')->placeholder('请输入用户电话');
- $filter->equal('type','类型')->select([0=> '普通',1=>'红娘/月老']);
- $filter->equal('vip','VIP')->select([1=> '是',0=>'否']);
- $filter->like('city','城市')->placeholder('请输入城市名');
- $filter->like('tuid','推荐人ID')->placeholder('查询某个用户推荐了几个人');
- });
- return $grid;
- }
- protected function form()
- {
- $form = new Form(new Users);
- $form->tab('基本信息', function ($form) {
- $form->display('lid', 'ID');
- $form->display('name', '名称');
- // $form->display('tel', '电话');
- $form->display('sex', '性别')->with(function ($value) {
- return $value==1?'男':'女';
- });
- $form->display('age', '年龄');
- $form->image('avatar', '头像');
- $form->display('realname', '姓名');
- $form->display('idcard', '身份证号');
- $form->display('opt', '在')->with(function ($x) {
- return $x==0 ? '浏览中':$x==1?'视频相亲':$x==2?'专属相亲':$x==4?'语音亲中':'交友';
- });
- $form->display('trump', '是否王牌')->with(function ($x) {
- return $x==1?'王牌':'非王牌';
- });
- $form->display('status', '状态')->with(function ($x) {
- return $x==1?'在线':'离线';
- });
- })->tab('编辑信息', function ($form) {
- $form->number('rose', '玫瑰')->rules('required|min:1');
- $form->select('vip', 'VIP')->options([0=>'不是VIP',1=>'是VIP']);
- $form->display('vip_time', 'VIP结束时间');//->format('YYYY-MM-DD HH:mm:ss');
- $form->select('type', '用户类型')->options([0=>'普通用户',1=>'月老/红娘']);
- $form->select('trump', '是否王牌')->options([0=>'普通用户',1=>'王牌']);
- $form->select('ban','禁止')->options([0=>'无',8=>'禁止登录',4=>'禁止开播',2=>'禁止发言',1=>'异常用户']);
- });
- $form->footer(function ($footer) {
- $footer->disableReset();
- $footer->disableViewCheck();
- $footer->disableEditingCheck();
- $footer->disableCreatingCheck();
- });
- $form->tools(function (Form\Tools $tools) {
- $tools->disableView();
- $tools->disableDelete();
- });
- $form->saved(function (Form $form) {
- if($form->vip!=$form->model()->vip){
- $this->portrait_set($form->model()->uid, ['Tag'=>'Tag_Profile_IM_Level','Value'=>1]);
- }
- if($form->trump!=$form->model()->trump){
- $this->portrait_set($form->model()->uid, ['Tag'=>'Tag_Profile_IM_Language','Value'=>$form->trump]);
- }
- if($form->type!=$form->model()->type){
- $this->portrait_set($form->model()->uid,['Tag'=>'Tag_Profile_IM_Role','Value'=>$form->type]);
- if($form->type){
- $this->imsendmassage('admin',$form->model()->uid,'你已经被开通为红娘/月老!');
- }
- }
- if($form->avatar!=$form->model()->avatar){
- $this->portrait_set($form->model()->uid,['Tag'=>'Tag_Profile_IM_Image','Value'=>$form->avatar]);
- }
- //$str=join(',', $form->ban);
- if($form->model()->ban>0){
- if($form->model()->ban==8){
- $str= $this->getUserSig($form->model()->uid);
- }
- $this->imsendmassage('admin',$form->model()->uid,'你有违规操作!');
- }
- });
- return $form;
- }
- public function detail($id){
- $d=Users::findOrFail($id);
- $show = new Show($d);
- $show->field('lid', '用户ID');
- // $show->field('tel', '用户电话');
- $show->field('sex', '性别')->as(function ($q)use($d){return $d->sex==1?'男-'.$d->age:'女-'.$d->age ;});
- $show->field('rose', '玫瑰数');
- $show->field('vip', '是否VIP')->as(function ($q)use($d){return $d->vip?'是'.date('Y-m-d',$d->vip_time):'否';});
- $show->field('type', '用户类型')->as(function ($q)use($d){return $q==0?'用户':$q==1&&$d->sex==1?'月老':'红娘';});
- // $show->field('ban', '是否违规');
- $show->field('created_at', '注册时间');
- $show->panel()->tools(function ($tools) {
- $tools->disableEdit();
- $tools->disableDelete();
- });
- $show->gifts('收的礼物', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('user.lid', '送礼者ID');
- $comments->column('user.name', '送礼者名');
- $comments->column('user.avatar', '送礼者头像')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
- $comments->column('gift.name', '送礼名');
- $comments->column('gift.file', '送礼图')->image(config('love.QINIU_MY_DOMAINS'), 50, 50);
- $comments->column('rose', '送礼物时价')->help('单位玫瑰!');
- $comments->column('gift.rose', '礼物现价')->help('单位玫瑰!');
- $comments->created_at('送礼时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- $comments->filter(function ($filter) {
- $filter->disableIdFilter();
- $filter->equal('user.lid', '客户ID')->placeholder('请输入送礼人ID');
- });
- });
- $show->userpays('消费明细', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('rose', '玫瑰数');
- $comments->column('description', '描述');
- $comments->created_at('消费时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- });
- $show->incomes('收入明细', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('rose', '玫瑰数');
- $comments->column('money', '钱数');
- $comments->column('description', '描述');
- $comments->created_at('收入时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- });
- $show->wallet('钱包明细', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('money', '钱数');
- $comments->column('description', '描述');
- $comments->column('status', '状态')->display(function ($x) {
- $msg='';
- if($x==0){
- $msg='待进钱包';
- }
- if($x==1){
- $msg='到钱包';
- }
- if($x==5){
- $msg='申请提现';
- }
- if($x==6){
- $msg='异常';
- }
- return $msg;
- });
- $comments->created_at('收入时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- });
- $show->reports('收到的举报', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('answers', '回复内容');
- $comments->column('questions', '问题描述');
- $comments->created_at('举报时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- });
- // $show->joinGroups('加了哪些群', function ($comments) {
- // // print_r($comments);
- // $comments->id('ID')->sortable();
- // $comments->created_at('加入时间');
- // $comments->disableExport();
- // $comments->disableRowSelector();
- // $comments->disableColumnSelector();
- // $comments->disableCreateButton();
- // $comments->disableactions();
- // });
- if($d->type){ //红娘有的功能
- $show->cashouts('提现明细', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('rose', '玫瑰数');
- $comments->column('money', '钱数');
- $comments->column('description', '描述');
- $comments->created_at('收入时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- });
- $show->gards('评价', function ($comments) {
- $comments->id('ID')->sortable();
- $comments->column('rose', '玫瑰数');
- $comments->column('start', '评价分数')->help('多多5分!');
- $comments->column('description', '描述');
- $comments->created_at('收入时间');
- $comments->disableExport();
- $comments->disableRowSelector();
- $comments->disableColumnSelector();
- $comments->disableCreateButton();
- $comments->disableactions();
- });
- }
- return $show;
- }
- public function update($id)
- {
- Cache::forget('user'.$id);
- Cache::forget('My'.$id);
- return $this->form()->update($id);
- }
- }
|