Beispiel #1
0
 public function actionReststart()
 {
     $this->checkRestAuth();
     //判断是否全部填写
     if (!isset($_GET['openId'])) {
         return $this->sendResponse(400, 'missed required properties');
     }
     $openId = $_GET['openId'];
     // 查询是否已经生成
     $criteria = new CDbCriteria();
     $criteria->compare("open_id", $openId);
     $xmases = Xmas::model()->findAll($criteria);
     $xmas = null;
     if (count($xmases) == 0) {
         $xmas = new Xmas();
         $xmas->open_id = $openId;
         $xmas->bonus = 0;
         // 使用分为计量单位,从零开始
         if (!$xmas->save()) {
             return $this->sendResponse(500, 'faild to save xmas');
         }
     } else {
         $xmas = $xmases[0];
     }
     echo CJSON::encode($this->JSONMapper($xmas));
 }