本文整理汇总了PHP中CCatalogDiscountSave::__GetDiscountIDByGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscountSave::__GetDiscountIDByGroup方法的具体用法?PHP CCatalogDiscountSave::__GetDiscountIDByGroup怎么用?PHP CCatalogDiscountSave::__GetDiscountIDByGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogDiscountSave
的用法示例。
在下文中一共展示了CCatalogDiscountSave::__GetDiscountIDByGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetDiscount
public function GetDiscount($arParams = array(), $getAll = false)
{
global $DB, $USER;
$adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
$arResult = array();
if (!CCatalog::IsUserExists() || !$USER->IsAuthorized() || !self::IsEnabled()) {
return $arResult;
}
foreach (GetModuleEvents("catalog", "OnGetDiscountSave", true) as $arEvent) {
$mxResult = ExecuteModuleEventEx($arEvent, $arParams);
if ($mxResult !== true) {
return $mxResult;
}
}
if (empty($arParams) || !is_array($arParams)) {
return $arResult;
}
$intUserID = 0;
$arUserGroups = array();
$strSiteID = false;
if (isset($arParams['USER_ID'])) {
$intUserID = (int) $arParams['USER_ID'];
}
if (isset($arParams['USER_GROUPS'])) {
$arUserGroups = $arParams['USER_GROUPS'];
}
if (isset($arParams['SITE_ID'])) {
$strSiteID = $arParams['SITE_ID'];
}
if (self::GetDiscountUserID() > 0) {
$intUserID = (int) self::GetDiscountUserID();
$arUserGroups = array();
}
if ($intUserID <= 0 && !$adminSection) {
$intUserID = (int) $USER->GetID();
$arUserGroups = array();
}
if (empty($arUserGroups)) {
if (!isset(self::$userGroups[$intUserID])) {
self::$userGroups[$intUserID] = $USER->GetUserGroup($intUserID);
}
$arUserGroups = self::$userGroups[$intUserID];
}
if (empty($arUserGroups) || !is_array($arUserGroups) || $intUserID <= 0) {
return $arResult;
}
$key = array_search(2, $arUserGroups);
if ($key !== false) {
unset($arUserGroups[$key]);
}
if (empty($arUserGroups)) {
return $arResult;
}
Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
if (empty($arUserGroups)) {
return $arResult;
}
if ($strSiteID === false) {
$strSiteID = SITE_ID;
}
$cacheKey = md5('U' . implode('_', $arUserGroups));
if (!isset(self::$discountFilterCache[$cacheKey])) {
self::$discountFilterCache[$cacheKey] = CCatalogDiscountSave::__GetDiscountIDByGroup($arUserGroups);
}
if (empty(self::$discountFilterCache[$cacheKey])) {
return $arResult;
}
$arCurrentDiscountID = self::$discountFilterCache[$cacheKey];
if (isset($arParams['ID'])) {
Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
if (!empty($arParams['ID'])) {
$arCurrentDiscountID = array_intersect($arCurrentDiscountID, $arParams['ID']);
}
}
if (!empty($arCurrentDiscountID)) {
$getAll = $getAll === true;
$intCurrentTime = getmicrotime();
$strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime);
$arFilter = array('ID' => $arCurrentDiscountID, 'SITE_ID' => $strSiteID, 'TYPE' => self::ENTITY_ID, 'ACTIVE' => 'Y', '+<=ACTIVE_FROM' => $strDate, '+>=ACTIVE_TO' => $strDate);
CTimeZone::Disable();
$rsDiscSaves = CCatalogDiscountSave::GetList(array(), $arFilter);
CTimeZone::Enable();
while ($arDiscSave = $rsDiscSaves->Fetch()) {
$arDiscSave['ACTION_SIZE'] = (int) $arDiscSave['ACTION_SIZE'];
$arDiscSave['COUNT_SIZE'] = (int) $arDiscSave['COUNT_SIZE'];
$arDiscSave['ACTIVE_FROM_UT'] = false;
$arDiscSave['ACTIVE_TO_UT'] = false;
$arDiscSave['COUNT_FROM_UT'] = false;
$arDiscSave['COUNT_TO_UT'] = false;
$arDiscSave['TYPE'] = (int) $arDiscSave['TYPE'];
$arDiscSave['MODULE_ID'] = 'catalog';
$strCountPeriod = self::COUNT_TIME_ALL;
$strActionPeriod = self::ACTION_TIME_ALL;
$arCountPeriodBack = array();
$arActionPeriodBack = array();
$arActionPeriod = array();
$arStartDate = false;
$arOldOrderSumm = false;
$arOrderSumm = false;
$boolPeriodInsert = true;
//.........这里部分代码省略.........
示例2: GetDiscount
public function GetDiscount($arParams = array())
{
global $DB;
global $USER;
$arResult = array();
if (!(isset($USER) && $USER instanceof CUser && 'CUser' == get_class($USER))) {
return $arResult;
}
if (!$USER->IsAuthorized()) {
return $arResult;
}
if (!self::IsEnabled()) {
return $arResult;
}
foreach (GetModuleEvents("catalog", "OnGetDiscountSave", true) as $arEvent) {
$mxResult = ExecuteModuleEventEx($arEvent, $arParams);
if (true !== $mxResult) {
return $mxResult;
}
}
if (!is_array($arParams) || empty($arParams)) {
return $arResult;
}
$intUserID = 0;
$arUserGroups = array();
$strSiteID = false;
if (isset($arParams['USER_ID'])) {
$intUserID = $arParams['USER_ID'];
}
if (isset($arParams['USER_GROUPS'])) {
$arUserGroups = $arParams['USER_GROUPS'];
}
if (isset($arParams['SITE_ID'])) {
$strSiteID = $arParams['SITE_ID'];
}
if (0 < self::GetDiscountUserID()) {
$intUserID = self::GetDiscountUserID();
$arUserGroups = $USER->GetUserGroup($intUserID);
} else {
$intUserID = intval($intUserID);
if (0 >= $intUserID) {
$intUserID = $USER->GetID();
$arUserGroups = $USER->GetUserGroupArray();
} else {
if (empty($arUserGroups)) {
$arUserGroups = $USER->GetUserGroup($intUserID);
}
}
}
if (!is_array($arUserGroups) || empty($arUserGroups) || 0 >= $intUserID) {
return $arResult;
}
$key = array_search(2, $arUserGroups);
if (false !== $key) {
unset($arUserGroups[$key]);
}
if (empty($arUserGroups)) {
return $arResult;
}
if ($strSiteID === false) {
$strSiteID = SITE_ID;
}
$arCurrentDiscountID = CCatalogDiscountSave::__GetDiscountIDByGroup($arUserGroups);
if (!empty($arCurrentDiscountID)) {
$intCurrentTime = getmicrotime();
$arFilter = array("ID" => $arCurrentDiscountID, 'SITE_ID' => $strSiteID, "TYPE" => DISCOUNT_TYPE_SAVE, 'ACTIVE' => 'Y', "+<=ACTIVE_FROM" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime), "+>=ACTIVE_TO" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime));
$rsDiscSaves = CCatalogDiscountSave::GetList(array(), $arFilter);
while ($arDiscSave = $rsDiscSaves->Fetch()) {
$arDiscSave['ACTION_SIZE'] = intval($arDiscSave['ACTION_SIZE']);
$arDiscSave['COUNT_SIZE'] = intval($arDiscSave['COUNT_SIZE']);
$arDiscSave['ACTIVE_FROM_UT'] = false;
$arDiscSave['ACTIVE_TO_UT'] = false;
$arDiscSave['COUNT_FROM_UT'] = false;
$arDiscSave['COUNT_TO_UT'] = false;
$strCountPeriod = 'U';
$strActionPeriod = 'U';
$arCountPeriodBack = array();
$arActionPeriodBack = array();
$arActionPeriod = array();
$arStartDate = false;
$arOldOrderSumm = false;
$arOrderSumm = false;
$boolPeriodInsert = true;
$intCountTime = $intCurrentTime;
$arOrderFilter = array("USER_ID" => $intUserID, "LID" => $arDiscSave['SITE_ID'], "PAYED" => "Y", "CANCELED" => "N");
$arOldOrderFilter = $arOrderFilter;
if (!empty($arDiscSave['ACTIVE_FROM']) || !empty($arDiscSave['ACTIVE_TO'])) {
$strActionPeriod = 'D';
if (!empty($arDiscSave['ACTIVE_FROM'])) {
$arDiscSave['ACTIVE_FROM_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_FROM']);
}
if (!empty($arDiscSave['ACTIVE_TO'])) {
$arDiscSave['ACTIVE_TO_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_TO']);
}
} elseif (0 < $arDiscSave['ACTION_SIZE'] && in_array($arDiscSave['ACTION_TYPE'], array('D', 'M', 'Y'))) {
$strActionPeriod = 'P';
$arActionPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE']);
$arActionPeriod = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE'], true);
}
if (!empty($arDiscSave['COUNT_FROM']) || !empty($arDiscSave['COUNT_TO'])) {
//.........这里部分代码省略.........