auth->id; $password = input('password'); // $password = $this->request->post("password"); // $user = input('user'); // print_r($password);die; $carpass = db('carpass')->where('password', $password)->where('status', '0')->find(); $time = date("Y-m-d H:i:s",time()); if($carpass != null){ $price = db('carpass')->where('password', $password)->value('price'); db('carpass')->where('password', $password)->update(['status'=>1]); db('carpass')->where('password', $password)->update(['etime'=>$time]); db('carpass')->where('password', $password)->update(['user'=>$user]); $money = db('user')->where('id', $user)->value('coin'); db('user')->where('id', $user)->update(['coin'=>$money+$price]); $this->success('卡密兑换成功!'); }else{ $this->error('卡密已使用或者输入卡密有误'); } } public function check() { $user = $this->auth->id; $carpass = db('carpass')->where('user', $user)->where('status', '1')->select(); if($carpass){ $this->success('查询成功', $carpass); } else{ $this->error('暂无卡密充值记录'); } } }