當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OrderQuery::getSaleStats方法代碼示例

本文整理匯總了PHP中Thelia\Model\OrderQuery::getSaleStats方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderQuery::getSaleStats方法的具體用法?PHP OrderQuery::getSaleStats怎麽用?PHP OrderQuery::getSaleStats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Thelia\Model\OrderQuery的用法示例。


在下文中一共展示了OrderQuery::getSaleStats方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: statsAccess

 /**
  * Provides access to sales statistics
  *
  * @param  array $params
  * @param  \Smarty $smarty
  * @return string the value of the requested attribute
  */
 public function statsAccess($params, $smarty)
 {
     if (false === array_key_exists("key", $params)) {
         throw new \InvalidArgumentException(sprintf("missing key attribute in stats access function"));
     }
     if (false === array_key_exists("startDate", $params) || $params['startDate'] === '') {
         throw new \InvalidArgumentException(sprintf("missing startDate attribute in stats access function"));
     }
     if (false === array_key_exists("endDate", $params) || $params['endDate'] === '') {
         throw new \InvalidArgumentException(sprintf("missing endDate attribute in stats access function"));
     }
     if (false !== array_key_exists("includeShipping", $params) && $params['includeShipping'] == 'false') {
         $includeShipping = false;
     } else {
         $includeShipping = true;
     }
     if ($params['startDate'] == 'today') {
         $startDate = new \DateTime();
         $startDate->setTime(0, 0, 0);
     } elseif ($params['startDate'] == 'yesterday') {
         $startDate = new \DateTime();
         $startDate->setTime(0, 0, 0);
         $startDate->modify('-1 day');
     } elseif ($params['startDate'] == 'this_month') {
         $startDate = new \DateTime();
         $startDate->modify('first day of this month');
         $startDate->setTime(0, 0, 0);
     } elseif ($params['startDate'] == 'last_month') {
         $startDate = new \DateTime();
         $startDate->modify('first day of last month');
         $startDate->setTime(0, 0, 0);
     } elseif ($params['startDate'] == 'this_year') {
         $startDate = new \DateTime();
         $startDate->modify('first day of January this year');
         $startDate->setTime(0, 0, 0);
     } elseif ($params['startDate'] == 'last_year') {
         $startDate = new \DateTime();
         $startDate->modify('first day of January last year');
         $startDate->setTime(0, 0, 0);
     } else {
         try {
             $startDate = new \DateTime($params['startDate']);
         } catch (\Exception $e) {
             throw new \InvalidArgumentException(sprintf("invalid startDate attribute '%s' in stats access function", $params['startDate']));
         }
     }
     if ($params['endDate'] == 'today') {
         $endDate = new \DateTime();
         $endDate->setTime(0, 0, 0);
     } elseif ($params['endDate'] == 'yesterday') {
         $endDate = new \DateTime();
         $endDate->setTime(0, 0, 0);
         $endDate->modify('-1 day');
     } elseif ($params['endDate'] == 'this_month') {
         $endDate = new \DateTime();
         $endDate->modify('last day of this month');
         $endDate->setTime(0, 0, 0);
     } elseif ($params['endDate'] == 'last_month') {
         $endDate = new \DateTime();
         $endDate->modify('last day of last month');
         $endDate->setTime(0, 0, 0);
     } elseif ($params['endDate'] == 'this_year') {
         $endDate = new \DateTime();
         $endDate->modify('last day of December this year');
         $endDate->setTime(0, 0, 0);
     } elseif ($params['endDate'] == 'last_year') {
         $endDate = new \DateTime();
         $endDate->modify('last day of December last year');
         $endDate->setTime(0, 0, 0);
     } else {
         try {
             $endDate = new \DateTime($params['endDate']);
         } catch (\Exception $e) {
             throw new \InvalidArgumentException(sprintf("invalid endDate attribute '%s' in stats access function", $params['endDate']));
         }
     }
     switch ($params['key']) {
         case 'sales':
             return OrderQuery::getSaleStats($startDate, $endDate, $includeShipping);
             break;
         case 'orders':
             return OrderQuery::getOrderStats($startDate, $endDate, array(1, 2, 3, 4));
             break;
     }
     throw new \InvalidArgumentException(sprintf("invalid key attribute '%s' in stats access function", $params['key']));
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:93,代碼來源:DataAccessFunctions.php


注:本文中的Thelia\Model\OrderQuery::getSaleStats方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。