|
@@ 279-315 (lines=37) @@
|
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
break; |
| 279 |
|
case 'week': |
| 280 |
|
// Rechercher tous les IG non gagnés pour chaque jour puis soustrais à ceux à créer |
| 281 |
|
$occurences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |
| 282 |
|
$nbOccurencesToCreate = $game->getOccurrenceNumber() - count($occurences); |
| 283 |
|
$nbWeeksInterval = (int) ($dateInterval/(60*24*7)); |
| 284 |
|
// If a week don't last 7d, I consider it as a week anyway. |
| 285 |
|
if ($dateInterval%(60*24*7) > 0) { |
| 286 |
|
++$nbWeeksInterval; |
| 287 |
|
} |
| 288 |
|
$beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 00:00:00'); |
| 289 |
|
$endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 23:59:59'); |
| 290 |
|
$endDrawDate->add(new \DateInterval('P6D')); |
| 291 |
|
if ($endDrawDate > $end) { |
| 292 |
|
$endDrawDate = $end; |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
if ($nbOccurencesToCreate > 0) { |
| 296 |
|
for ($d=1; $d<=$nbWeeksInterval; $d++) { |
| 297 |
|
for ($i=1; $i<=$nbOccurencesToCreate; $i++) { |
| 298 |
|
$randomDate = $this->getRandomDate($beginningDrawDate->format('U'), $endDrawDate->format('U')); |
| 299 |
|
$randomDate = \DateTime::createFromFormat('Y-m-d H:i:s', $randomDate); |
| 300 |
|
$occurrence = new \PlaygroundGame\Entity\InstantWinOccurrence(); |
| 301 |
|
$occurrence->setInstantwin($game); |
| 302 |
|
$occurrence->setValue($randomDate->format('Y-m-d H:i:s')); |
| 303 |
|
$occurrence->setActive(1); |
| 304 |
|
|
| 305 |
|
$this->getInstantWinOccurrenceMapper()->insert($occurrence); |
| 306 |
|
} |
| 307 |
|
$beginningDrawDate->add(new \DateInterval('P1W')); |
| 308 |
|
$endDrawDate->add(new \DateInterval('P1W')); |
| 309 |
|
if ($endDrawDate > $end) { |
| 310 |
|
$endDrawDate = $end; |
| 311 |
|
} |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
break; |
| 316 |
|
case 'month': |
| 317 |
|
$occurences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |
| 318 |
|
$nbOccurencesToCreate = $game->getOccurrenceNumber() - count($occurences); |
|
@@ 316-352 (lines=37) @@
|
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
break; |
| 316 |
|
case 'month': |
| 317 |
|
$occurences = $this->getInstantWinOccurrenceMapper()->findBy(array('instantwin' => $game)); |
| 318 |
|
$nbOccurencesToCreate = $game->getOccurrenceNumber() - count($occurences); |
| 319 |
|
$nbMonthsInterval = (int) ($dateInterval/(60*24*30)); |
| 320 |
|
// If a week don't last 30d, I consider it as a month anyway. |
| 321 |
|
if ($dateInterval%(60*24*30) > 0) { |
| 322 |
|
++$nbMonthsInterval; |
| 323 |
|
} |
| 324 |
|
$beginningDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 00:00:00'); |
| 325 |
|
$endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 23:59:59'); |
| 326 |
|
$endDrawDate->add(new \DateInterval('P1M')); |
| 327 |
|
$endDrawDate->sub(new \DateInterval('P1D')); |
| 328 |
|
if ($endDrawDate > $end) { |
| 329 |
|
$endDrawDate = $end; |
| 330 |
|
} |
| 331 |
|
|
| 332 |
|
if ($nbOccurencesToCreate > 0) { |
| 333 |
|
for ($d=1; $d<=$nbMonthsInterval; $d++) { |
| 334 |
|
for ($i=1; $i<=$nbOccurencesToCreate; $i++) { |
| 335 |
|
$randomDate = $this->getRandomDate($beginningDrawDate->format('U'), $endDrawDate->format('U')); |
| 336 |
|
$randomDate = \DateTime::createFromFormat('Y-m-d H:i:s', $randomDate); |
| 337 |
|
$occurrence = new \PlaygroundGame\Entity\InstantWinOccurrence(); |
| 338 |
|
$occurrence->setInstantwin($game); |
| 339 |
|
$occurrence->setValue($randomDate->format('Y-m-d H:i:s')); |
| 340 |
|
$occurrence->setActive(1); |
| 341 |
|
|
| 342 |
|
$this->getInstantWinOccurrenceMapper()->insert($occurrence); |
| 343 |
|
} |
| 344 |
|
$beginningDrawDate->add(new \DateInterval('P1M')); |
| 345 |
|
$endDrawDate->add(new \DateInterval('P1M')); |
| 346 |
|
if ($endDrawDate > $end) { |
| 347 |
|
$endDrawDate = $end; |
| 348 |
|
} |
| 349 |
|
} |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
break; |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
return true; |