/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return GiftCodeModel the static model class */ public static function model($table_name) { self::$tableName = $table_name; return parent::model(__CLASS__); }
public function actionWinnerList($id) { $table = 'wheel_awards'; $winnerList = array(); $winner = WheelAwardsModel::model($table)->findAll('wheelId=:wheelId and grade>0 and status>0', array(':wheelId' => $id)); foreach ($winner as $w) { $winnerList[] = array('area' => $w->area, '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 = 'wheel_awards'; $area = $_POST['area']; $role = $_POST['role']; $banben = $_POST['banben']; $msg = '中奖信息失效或系统异常'; $encryption = $_POST['encryption']; list($openid, $grade, $wheelId) = explode('|', Globals::authcode($encryption, 'DECODE')); $wheelInfo = WheelModel::model()->findByPk($wheelId); if ($wheelInfo) { $awards = unserialize($wheelInfo->awards); if ($awards[$grade]) { $success = true; $msg = '你的信息已收录,我们会及时联系你'; //存储用户信息 $codeInfo = WheelAwardsModel::model($table)->find('openId=:openId and wheelId=:wheelId and grade=:grade', array(':openId' => $openid, ':wheelId' => $wheelId, ':grade' => $grade)); $codeInfo->status = 2; $codeInfo->area = $area; $codeInfo->role = $role; $codeInfo->banben = $banben; $codeInfo->save(); } } echo json_encode(array('success' => $success, 'msg' => $msg)); }