AdminPrizeOrderController.php 2.1 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author:kane < chengjin005@163.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\AdminBaseController;
use function Qiniu\thumbnail;
use think\Db;


class AdminPrizeOrderController extends AdminBaseController
{

    public function index()
    {
        //接收搜索参数
        $param = $this->request->param();
        //添加搜索条件
        $where=[];
        $keyword = empty($param['keyword']) ? '' : $param['keyword'];
        if (!empty($keyword)) {
            $where['u.nickname|u.mobile'] = ['like', "%$keyword%"];
        }

        $data = Db::name('prize_order')
            ->alias('po')
            ->join('prize p','po.prize_id=p.id')
            ->join('users u','po.users_id=u.id')
            ->where($where)
            ->field('po.*,p.name,p.score as pscore,po.status as postatus,u.nickname,u.mobile')
            ->order('po.create_time','desc')
            ->paginate('15');
        $data->appends($param);

        $this->assign('page',$data->render());
        $this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
        $this->assign('list', $data);
        return $this->fetch();
    }

    public function check(){
        $id=$this->request->param('id');
        Db::name('prize_order')->where('id',$id)->update(['status'=>1,'check_time'=>time()]);
        $this->success('核销成功');
    }

    public function delete()
    {
        $id = $this->request->param('id');
        Db::name('prize_order')->where('id', $id)->delete();
        $this->success('删除成功');
    }
}