public function actionConfirm() { //status 更新为1,表明用户已经参 $logTable = 'scratch_log'; $status = false; $encryption = $_POST['encryption']; $table = 'scratch_awards'; list($openid, $grade, $scratchId) = explode('|', Globals::authcode($encryption, 'DECODE')); $code = ScratchAwardsModel::model($table)->find('grade=:grade and scratchId=:scratchId and openId=:openId', array(':grade' => $grade, ':scratchId' => $scratchId, ':openId' => $openid)); if ($code) { $code->status = $grade == 0 ? 2 : 1; $code->save(); $status = true; } $log = new ScratchLogModel($logTable); $log->datetime = time(); $log->openId = $openid; $log->scratchId = $scratchId; $log->save(); echo json_encode(array('status' => $status)); }