private function prepareNotificationMessages($customerPurchases)
 {
     $notifications = [];
     foreach ($customerPurchases as $customer) {
         if (!$customer->getStudents()) {
             continue;
         }
         foreach ($customer->getStudents() as $student) {
             $productsArray = [];
             if ($student->getPurchases()) {
                 foreach ($student->getPurchases() as $purchase) {
                     if ($purchase->getProduct()) {
                         $productsArray[] = $purchase->getProduct();
                     }
                 }
             }
             if ($productsArray) {
                 $notification = new Notification();
                 $notification->setCustomer($customer)->setCustomerNotificationSetting($customer->getCustomerNotificationSetting())->setStudent($student)->setPurchasedAt(new DateTime())->setProductsArray($productsArray);
                 $notifications[] = $notification;
             }
         }
     }
     return $notifications;
 }
 public function sendEmail(Notification $notification, $subject)
 {
     if (!$notification->getEmailMessage()) {
         return FALSE;
     }
     if (!$this->_mailerShortcut->validateEmail($notification->getCustomer()->getEmail())) {
         return FALSE;
     }
     $result = $this->_mailerShortcut->sendMail([$this->emailParameters['no_reply'] => 'KDZ'], $notification->getCustomer()->getEmail(), $subject, $notification->getEmailMessage());
     return $result;
 }
 public function recordNotification(Notification $notification, SettingDecimal $settingSmsExchangeRate)
 {
     if (!$notification->getStudent()) {
         return FALSE;
     }
     if (!$notification->getStudent()->getNfcTag()) {
         return FALSE;
     }
     $item = $this->getNotificationMessageItem();
     $price = bcmul($notification->getPrice(), $settingSmsExchangeRate->getSettingValue(), 2);
     $purchaseService = $this->getPurchaseService();
     $purchaseService->setStudent($notification->getStudent())->setNfcTag($notification->getStudent()->getNfcTag())->setItem($item)->setPrice($price)->setPurchasedAt(new DateTime());
     $this->_manager->persist($purchaseService);
 }