public function actionWinnerList($id) { $table = 'scratch_awards'; $winnerList = array(); $winner = ScratchAwardsModel::model($table)->findAll('scratchId=:scratchId and grade>0 and status>0', array(':scratchId' => $id)); foreach ($winner as $w) { $winnerList[] = array('telphone' => $w->telphone, 'grade' => $w->grade, 'code' => $w->code, 'datetime' => date('Y-m-d H:i:s', $w->datetime)); } echo json_encode($winnerList); }
public function actionSave() { //status 更新为2 $success = false; $table = 'scratch_awards'; $tel = $_POST['tel']; $msg = '中奖信息失效或系统异常'; $encryption = $_POST['encryption']; $name = $_POST['code']; list($openid, $grade, $scratchId) = explode('|', Globals::authcode($encryption, 'DECODE')); $scratchInfo = ScratchModel::model()->findByPk($scratchId); if ($scratchInfo && $tel) { $awards = unserialize($scratchInfo->awards); if ($awards[$grade] && $awards[$grade]['name'] == $name) { $success = true; $msg = '你的信息已收录,我们会及时联系你'; //存储用户信息 $codeInfo = ScratchAwardsModel::model($table)->find('openId=:openId and scratchId=:scratchId and grade=:grade', array(':openId' => $openid, ':scratchId' => $scratchId, ':grade' => $grade)); $codeInfo->status = 2; $codeInfo->telphone = $tel; $codeInfo->save(); } } echo json_encode(array('success' => $success, 'msg' => $msg)); }