| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 | <?phpnamespace App\Admin\Controllers\Company;use App\Http\Controllers\Controller;use App\Models\Order;use App\Models\Subsite;use Encore\Admin\Auth\Permission;use Encore\Admin\Controllers\HasResourceActions;use Encore\Admin\Form;use Encore\Admin\Grid;use Encore\Admin\Layout\Content;use Encore\Admin\Show;class BusienssIncrementController extends Controller{    use HasResourceActions;    /**     * Index interface.     *     * @param Content $content     * @return Content     */    public function index(Content $content)    {        return $content            ->header('增值服务')            ->description('列表')            ->body($this->grid());    }    /**     * Show interface.     *     * @param mixed $id     * @param Content $content     * @return Content     */    public function show($id, Content $content)    {        return $content            ->header('增值服务')            ->description('详情')            ->body($this->detail($id));    }    /**     * Edit interface.     *     * @param mixed $id     * @param Content $content     * @return Content     */    public function edit($id, Content $content)    {        return $content            ->header('增值服务')            ->description('修改')            ->body($this->form()->edit($id));    }    /**     * Create interface.     *     * @param Content $content     * @return Content     */    public function create(Content $content)    {        return $content            ->header('增值服务')            ->description('新增')            ->body($this->form());    }    /**     * Make a grid builder.     *     * @return Grid     */    protected function grid()    {        Permission::check('increment_manager_index');        $grid = new Grid(new Order);        $grid->model()->where('utype', 1)->whereNotIn( 'order_type', [1,2])->when(get_subsite_id()>0, function ($querys) {            $querys->whereHas('companys', function ($query) {                $query->where('subsite_id', get_subsite_id());            });        });        $grid->service_name('服务内容');        $grid->column('companys.companyname', '企业名称');        $grid->column('companys.username', '申请会员');        $grid->amount('金额');        $grid->created_at('申请时间');        $grid->filter(function ($filter) {                //在这里添加字段过滤器                $filter->equal('uid', '企业ID');                $filter->like('companys.username', '会员名称');            $subsite = Subsite::where('effective', 1)->select('id', 'sitename')->get();            $subsiteArr=[];            if ($subsite) {                $subsiteArr = $subsite->toArray();                $subsiteArr = array_column($subsiteArr, 'sitename', 'id');            }            $subsiteArr[0] = "总站";            ksort($subsiteArr);            if (get_subsite_id()== 0) {                $filter->equal('companys.subsite_id', '所属分站')->select($subsiteArr);            }                //$filter->like('companys.companyname','企业名称');                 $filter->equal('order_type', '订单类型')->select(                     [                                1=>'套餐升级',                                2=>'充值积分',                                3=>'简历置顶',                                4=>'醒目标签',                                5=>'简历模板',                                6=>'简历包',                                7=>'短信包',                                8=>'职位置顶',                                9=>'职位紧急',                                10=>'企业模板',                                11=>'职位刷新',                                12=>'简历下载'                     ]                 );                $filter->between('created_at', '注册时间')->datetime();        });        return $grid;    }    /**     * Make a show builder.     *     * @param mixed $id     * @return Show     */    protected function detail($id)    {        $show = new Show(Order::findOrFail($id));        $show->oid('订单ID');        $show->companys()->companyname('企业名称')->as(function ($companys) {            return $companys->companyname;        });        $show->is_pay()->as(function ($is_pay) {            switch ($is_pay) {                case 1:                    return "待付款";                    break;                case 2:                    return "已付款";                    break;                case 3:                    return "已取消";                    break;            }        });        $show->amount('订单金额');        $show->pay_amount('现金支付金额');        $show->pay_points('积分支付');        $show->service_name('订单描述');        $show->pay_type('订单金额')->as(function ($pay_type) {            switch ($pay_type) {                case 1:                    return '现金';                    break;                case 2:                    return '积分';                    break;                case 3:                    return '现金+积分';                    break;            }        });        $show->payment_time('支付时间')->as(function ($payment_time) {            if ($payment_time) {                return date('Y-m-d H:i:s', $payment_time);            }            return '';        });        $show->notes('备注');        return $show;    }    /**     * Make a form builder.     *     * @return Form     */    protected function form()    {        $form = new Form(new Order);        $form->display('id');        $form->display('companys.username', '申请会员');        $form->radio('is_pay', '支付状态')->options([1=>'待付款',2=>'已付款',3=>'已取消']);        $form->display('amount', '订单金额');        $form->display('pay_amount', '现金支付金额');        $form->display('pay_points', '积分支付');        $form->display('service_name', '订单描述');        $form->display('pay_type', '支付方式')->with(function ($pay_type) {            switch ($pay_type) {                case 1:                    return '现金';                    break;                case 2:                    return '积分';                    break;                case 3:                    return '现金+积分';                    break;            }        });        $form->display('oid', '订单号');        $form->display('created_at', '申请时间');        $form->display('payment_time', '支付时间')->with(function ($payment_time) {            if ($payment_time) {                return date('Y-m-d H:i:s', $payment_time);            }            return '';        });        $form->text('notes', '添加备注');        return $form;    }}
 |