Staff.php 5.1 KB
<?php

namespace app\admin\controller\verification;

use app\common\controller\Backend;

/**
 * 员工管理
 *
 * @icon fa fa-circle-o
 */
class Staff extends Backend
{


    /**
     * Staff模型对象
     * @var \app\admin\model\verification\Staff
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\verification\Staff;
        $this->view->assign("typeList", $this->model->getTypeList());
    }



    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */


    /**
     * 查看
     */
    public function index()
    {
        //当前是否为关联查询
        $this->relationSearch = true;
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage,则转发到Selectpage
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $list = $this->model
                    ->with(['store','user'])
                    ->where($where)
                    ->order($sort, $order)
                    ->paginate($limit);

            foreach ($list as $row) {
                $row->visible(['id','name','phone','user_id','verification_store_id','type']);
                $row->visible(['store']);
				$row->getRelation('store')->visible(['name']);
				$row->visible(['user']);
				$row->getRelation('user')->visible(['nickname']);
            }

            $result = array("total" => $list->total(), "rows" => $list->items());

            return json($result);
        }
        return $this->view->fetch();
    }


    /**
     * 查看
     */
    public function brokerage()
    {
        $verification_store_id = request()->param('verification_store_id');
        $send_user_id = request()->param('send_user_id');
        $params = request()->param('params');
        //当前是否为关联查询
        $offset = request()->param('offset');
        $this->relationSearch = true;
        //设置过滤方法

        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            list($where1, $sort, $order, $offset, $limit) = $this->buildparams();
            if(!empty($params)){
                $ids = request()->param('ids');
                $paramsA = explode('=',$params);
                $r = \think\Db::name('verification_brokerage_record')->where(['id'=>$ids])->update(['send_result'=>$paramsA[1]]);
                return json(['code'=>$r]);
            }
            //如果发送的来源是Selectpage,则转发到Selectpage
            $where['a.send_user_id'] = $send_user_id;
            $where['a.verification_store_id'] = $verification_store_id;
            $field = "a.id,a.commission,a.send_user_id,a.send_createtime,a.send_result,a.send_reason,a.order_id,
            b.price";
            $list = \think\Db::name('verification_brokerage_record')
                    ->alias('a')
                    ->field($field)
                    ->join('cv_verification_order b','a.order_id=b.id','left')
                    ->where($where)
                    ->order('a.id desc')
                    ->paginate($limit);

            $row = $list->items();

            foreach($row as $k=>$v){
                $row[$k]['send_createtime'] = date('Y-m-d H:i:s',$v['send_createtime']);
                $row[$k]['send_result_text'] = $v['send_result']==1?'成功':'失败';
                $row[$k]['send_result_view'] = $v['send_result']==1?'normal':'hidden';
            }

            $result = array("total" => $list->total(), "rows" => $row);
            return json($result);
        }
        return $this->view->fetch();
    }


    /**
     * 查看
     */
    public function share_list()
    {
        $verification_store_id = request()->param('verification_store_id');
        $send_user_id = request()->param('send_user_id');

        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {

            $where['a.pid'] = $send_user_id;
            $where['a.verification_store_id'] = $verification_store_id;
            $field = "a.*";

            $list = \think\Db::name('user')
                    ->alias('a')
                    ->field($field)

                    ->where($where)
                    ->order('a.id desc')
                    ->paginate();

            $row = $list->items();

            foreach($row as $k=>$v){
                $row[$k]['updatetime'] = date('Y-m-d H:i:s',$v['updatetime']);
            }

            $result = array("total" => $list->total(), "rows" => $row);
            return json($result);
        }
        return $this->view->fetch();
    }

}