/** * deal with the data before export * @param $condition,array. (activityId:MongoId, accountId:MongoId) */ public static function preProcessPrizeStatisticData($condition) { $activityId = $condition['activityId']; // $accountId = $condition['accountId']; $prizes = ActivityPrize::find()->where(['activityId' => $activityId])->orderBy(['createdAt' => SORT_ASC])->all(); $rows = []; if (!empty($prizes)) { foreach ($prizes as $prize) { $count = self::getCountByCondition(['prizeId' => $prize->_id, 'activityId' => $activityId]); $createdAt = MongodbUtil::MongoDate2String($prize->createdAt, 'Y-m-d H:i:s', null); $row = ['id' => (string) $prize->_id, 'prizeName' => $prize->name, 'count' => $count, 'createdAt' => $createdAt, 'isDeleted' => $prize->isDeleted ? '是' : '否']; $rows[] = $row; unset($row, $count); } $count = self::getCountByCondition(['prizeId' => 'thanks', 'activityId' => $activityId]); $row = ['id' => 'thanks', 'prizeName' => '銘謝惠顧', 'count' => $count, 'createdAt' => '', 'isDeleted' => '']; $rows[] = $row; unset($row, $count, $createdAt); } return $rows; }