Ejemplo n.º 1
0
 public static function creatWinner($winnerArr, $recordId, $prizeName)
 {
     $winner = new EarlyBirdWinner();
     $winner->memberId = new \MongoId($winnerArr['id']);
     $winner->prizeLevel = $winnerArr['prizeLevel'];
     $winner->mobile = $winnerArr['mobile'];
     $winner->name = $winnerArr['name'];
     $winner->exchangeGoodsScore = $winnerArr['exchangeGoodsScore'];
     $winner->accountId = Token::getAccountId();
     $winner->createdAt = new \MongoDate();
     $winner->drawRecordId = $recordId;
     $winner->prizeName = $prizeName;
     $winner->save();
     unset($winner);
 }
 public function perform()
 {
     $args = $this->args;
     if (empty($args['accountId']) || empty($args['key']) || empty($args['header'])) {
         ResqueUtil::log(['status' => 'fail to export early bird winners record', 'message' => 'missing params', 'args' => $args]);
         return false;
     }
     // $accountId = new \MongoId($args['accountId']);
     $condition = unserialize($args['condition']);
     $header = $args['header'];
     $fileName = $args['key'];
     $filePath = ExcelUtil::getFile($fileName, 'csv');
     $rows = EarlyBirdWinner::preProcessEarlyBirdWinnerData($condition);
     ExcelUtil::exportCsv($header, $rows, $filePath, 1);
     $hashKey = ExcelUtil::setQiniuKey($filePath, $fileName);
     if ($hashKey) {
         //notice frontend the job is finished
         Yii::$app->tuisongbao->triggerEvent(Message::EVENT_EXPORT_FINISH, ['key' => $fileName], [Message::CHANNEL_GLOBAL . $args['accountId']]);
         return true;
     } else {
         ResqueUtil::log(['status' => 'fail to export early bird winners record', 'message' => 'fail to setQiniuKey', 'filePath' => $filePath]);
         return false;
     }
 }
 private function _saveWinner($winners, $recordId, $prizeName)
 {
     if (!empty($winners)) {
         foreach ($winners as $winner) {
             EarlyBirdWinner::creatWinner($winner, $recordId, $prizeName);
         }
     }
 }