/**
  * 助力数据
  * GET api/activity/finddiff/{finddiffId}/result 
  */
 public function actionRestlist()
 {
     $this->checkRestAuth();
     $finddiff = Finddiff::model()->findByPk($_GET['finddiffId']);
     if ($finddiff == null) {
         $this->sendResponse(404, 'not found');
     }
     $criteria = new CDbCriteria();
     $take = 1000;
     $criteria->compare('finddiff_id', $finddiff->id);
     $criteria->limit = $take;
     $criteria->offset = 0;
     $criteria->order = 'created_time DESC';
     $result = FinddiffResult::model()->findAll($criteria);
     $json = new JsonData();
     $json->limit = $take;
     $json->total = (int) FinddiffResult::model()->count($criteria);
     $json->result = $this->JSONArrayMapper($result);
     echo CJSON::encode($json);
 }
Esempio n. 2
0
 /**
  * 重置榜单
  * GET /api/activity/finddiff/fix
  */
 public function actionRestfix()
 {
     // 所有异常的结果
     $criteria = new CDbCriteria();
     $criteria->addCondition("bonus > :bonus");
     $criteria->params[':bonus'] = 35;
     $results = FinddiffResult::model()->findAll($criteria);
     foreach ($results as $result) {
         $result->bonus = 15;
         $result->save();
     }
     // 所有异常的发起
     $criteria = new CDbCriteria();
     $criteria->addCondition("bonus > :bonus");
     $criteria->params[':bonus'] = 0;
     $finddiffs = Finddiff::model()->findAll($criteria);
     foreach ($finddiffs as $finddiff) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('finddiff_id=:finddiffId');
         $criteria->params = array(':finddiffId' => $finddiff->id);
         $results = FinddiffResult::model()->findAll($criteria);
         $bonus = 0;
         foreach ($results as $result) {
             $bonus += (int) $result->bonus;
         }
         echo $bonus;
         echo '<br>';
         if ($bonus > 0) {
             $finddiff->bonus = $bonus;
             $finddiff->save();
         }
     }
 }