当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Order::getOrdersForDiscount方法代码示例

本文整理汇总了PHP中Model_Order::getOrdersForDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Order::getOrdersForDiscount方法的具体用法?PHP Model_Order::getOrdersForDiscount怎么用?PHP Model_Order::getOrdersForDiscount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Order的用法示例。


在下文中一共展示了Model_Order::getOrdersForDiscount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveEnrol

 protected function saveEnrol($iAccountId, $iUserId, $aMeals, $sDayEnd)
 {
     $aMealIdsAll = array();
     // get submited meals id
     for ($i = 0; $i < 7; $i++) {
         if (isset($_POST['day' . $i])) {
             $aMealIdsAll = array_merge($aMealIdsAll, $_POST['day' . $i]);
         }
     }
     // wyszukujemy zamowienia
     $aOrderedMeals = array();
     $aOrderIndex = array();
     $oOrder = new Model_Order();
     $oCourse = new Model_Course();
     $iIndex = 0;
     $sDate = '';
     // rozpoczynamy transakcje
     $oOrder->transaction(true);
     // iterujemy po posilkach w danym tyg.
     foreach ($aMeals as $iMealId => $aMeal) {
         // sprawdzamy czy data nie jest starsza niz obecna
         if (strtotime($aMeal['date'] . ' ' . $sDayEnd) < time()) {
             continue;
         }
         // sprawdzamy czy zmieniono danie na obecny dzien
         if ($aMeal['date'] == date('Y-m-d')) {
             // czyscimy tekst paska informacyjnego
             $this->oCurrentUser->propertie('aMealName', '');
         }
         // zmieniamy na kolejny dzien index tablicy $aMealIds
         if ($sDate != $aMeal['date']) {
             // czyscimy zapisy na wszystkie dania tego dnia
             $oOrder->removeEnrols($iAccountId, $iUserId, $aMeal['date']);
             $sDate = $aMeal['date'];
             $iIndex++;
         }
         // sprawdzamy czy posilek z danego tyg zostal wybrany przez uzytkownika
         if (in_array($iMealId, $aMealIdsAll)) {
             // zapisujemy nowy
             $oOrder->reset();
             $oOrder->date = $aMeal['date'];
             $oOrder->user_id = (int) $this->oCurrentUser->user_id;
             $oOrder->meal_id = (int) $iMealId;
             $oOrder->price = (double) $aMeal['price'];
             $oOrder->account_id = (int) $this->oCurrentUser->account_id;
             if (!$oOrder->save()) {
                 throw new Lithium_Exception('catering.saving_failed');
             }
             // sprawdzamy ilosc zamowien na ten dzien
             $iCount = $oOrder->countOrders((int) $this->oCurrentUser->user_id, $aMeal['date']);
             if ($iCount > 1) {
                 $aOrders = $oOrder->getOrdersForDiscount((int) $this->oCurrentUser->user_id, $aMeal['date']);
                 foreach ($aOrders as $aOrder) {
                     $aOrder['discount'] = (int) $aOrder['discount'];
                     // gdy znizka rowna 0 nie ma co przeliczac
                     if ($aOrder['discount']) {
                         $oOrder->reset();
                         $oOrder->order_id = $aOrder['order_id'];
                         $oOrder->price = round($aOrder['price'] * $aOrder['discount'] / 100, 2);
                         if (!$oOrder->save()) {
                             //								throw new Lithium_Exception( 'catering.saving_failed' );
                         }
                     }
                 }
             }
         }
     }
     if (!$oOrder->transaction()) {
         throw new Lithium_Exception('save_meals_failed');
     }
     $aMeta = $this->mTemplate->aMeta;
     $aMeta[] = '<meta http-equiv="refresh" content="1;url=' . $this->mTemplate->anchor() . '" />';
     $this->mTemplate->aMeta = $aMeta;
     $this->mTemplate->content = $this->getLang('save_meals_successfully');
 }
开发者ID:maxwroc,项目名称:PHP,代码行数:75,代码来源:Catering.php

示例2: saveOrders

 protected function saveOrders($iAccountId, $iUserId, $aMeals)
 {
     $aMealIdsAll = array();
     // get submited meals id
     for ($i = 0; $i < 7; $i++) {
         if (isset($_POST['day' . $i])) {
             $aMealIdsAll = array_merge($aMealIdsAll, $_POST['day' . $i]);
         }
     }
     // wyszukujemy zamowienia
     $aOrderedMeals = array();
     $aOrderIndex = array();
     $oOrder = new Model_Order();
     $oCourse = new Model_Course();
     $iIndex = 0;
     $sDate = '';
     // rozpoczynamy transakcje
     $oOrder->transaction(true);
     // iterujemy po posilkach w danym tyg.
     foreach ($aMeals as $iMealId => $aMeal) {
         // zmieniamy na kolejny dzien index tablicy $aMealIds
         if ($sDate != $aMeal['date']) {
             // czyscimy zapisy na wszystkie dania tego dnia
             $oOrder->removeEnrols($iAccountId, $iUserId, $aMeal['date']);
             $sDate = $aMeal['date'];
             $iIndex++;
         }
         // sprawdzamy czy posilek z danego tyg zostal wybrany przez uzytkownika
         if (in_array($iMealId, $aMealIdsAll)) {
             // zapisujemy nowy
             $oOrder->reset();
             $oOrder->date = $aMeal['date'];
             $oOrder->user_id = (int) $iUserId;
             $oOrder->meal_id = (int) $iMealId;
             $oOrder->price = (double) $aMeal['price'];
             $oOrder->account_id = (int) $iAccountId;
             if (!$oOrder->save()) {
                 throw new Lithium_Exception('Catering.saving_failed');
             }
             // sprawdzamy ilosc zamowien na ten dzien
             $iCount = $oOrder->countOrders((int) $iUserId, $aMeal['date']);
             if ($iCount > 1) {
                 $aOrders = $oOrder->getOrdersForDiscount((int) $iUserId, $aMeal['date']);
                 foreach ($aOrders as $aOrder) {
                     $aOrder['discount'] = (int) $aOrder['discount'];
                     // gdy znizka rowna 0 nie ma co przeliczac
                     if ($aOrder['discount']) {
                         $oOrder->reset();
                         $oOrder->order_id = $aOrder['order_id'];
                         $oOrder->price = round($aOrder['price'] * $aOrder['discount'] / 100, 2);
                         if (!$oOrder->save()) {
                             //								throw new Lithium_Exception( 'catering.saving_failed' );
                         }
                     }
                 }
             }
         }
     }
     if (!$oOrder->transaction()) {
         if (IN_PRODUCTION) {
             return false;
         } else {
             throw new Lithium_Exception('catering.saving_failed');
         }
     }
     return true;
 }
开发者ID:maxwroc,项目名称:PHP,代码行数:67,代码来源:Account.php


注:本文中的Model_Order::getOrdersForDiscount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。