$this->auth->id, ]; if($status == 0){ //待使用 $where['c.deletetime'] = NULL; $where['c.switch'] = 1; $where['c.starttime'] = ['<',time()]; $where['c.endtime'] = ['>',time()]; $where['cu.status'] = 0; } if($status == 1){ //已使用 $where['cu.status'] = 1; } if($status == 2){ //已失效 $where['c.deletetime'] = NULL; $where['c.switch'] = 1; $where['c.starttime'] = ['<',time()]; $where['c.endtime'] = ['<',time()]; $where['cu.status'] = 0; } $list = Db::name('unishop_coupon_user')->alias('cu') ->field(['c.id','c.title','c.least','c.value','c.starttime','c.endtime','cu.status']) ->join('unishop_coupon c','cu.coupon_id = c.id','LEFT') ->where($where) ->autopage() ->select(); $this->success(1,$list); } }