19 private $sumConfiguration =
array();
23 $this->userId = $userId;
24 $this->siteId = $siteId;
29 $this->sumConfiguration = $sumConfiguration;
36 if (!Loader::includeModule(
'currency'))
41 if(empty($this->userId))
46 $filter = $this->createFilterBySumConfiguration($this->sumConfiguration);
49 'USER_ID' => $orderUserId,
50 '=LID' => $this->siteId,
56 foreach (
array(self::TYPE_ORDER_NON_ARCHIVED, self::TYPE_ORDER_ARCHIVED) as $orderType)
64 private function createFilterBySumConfiguration($sumConfiguration)
67 if (empty($sumConfiguration))
72 $type = $sumConfiguration[
'type_sum_period'];
73 $periodData = $sumConfiguration[
'sum_period_data'];
75 if (
$type === self::TYPE_COUNT_PERIOD_INTERVAL)
77 if (!empty($periodData[
'order_start']))
81 if (!empty($periodData[
'order_end']))
88 $value = (int)$periodData[
'period_value'];
89 $typeRelativePeriod = $periodData[
'period_type'];
90 if (!in_array($typeRelativePeriod,
array(
'D',
'M',
'Y')))
95 $start =
new Main\Type\DateTime();
96 $end =
$start->add(
"-P{$value}{$typeRelativePeriod}");
98 $filter[
'>=DATE_INSERT'] = $end;
100 elseif (
$type === self::TYPE_COUNT_PERIOD_ALL_TIME)
108 private function sumOrders(
$filter, $orderType)
111 if ($orderType === self::TYPE_ORDER_ARCHIVED)
114 $provider =
'\Bitrix\Sale\Archive\Manager';
116 elseif ($orderType === self::TYPE_ORDER_NON_ARCHIVED)
127 $orders = $provider::getList(
130 'select' =>
array(
'DATE_INSERT',
'PRICE',
'CURRENCY')
136 foreach ($orders as $orderData)
143 if (
$currency !== $orderData[
'CURRENCY'])
145 $sum += \CCurrencyRates::ConvertCurrency($orderData[
'PRICE'], $orderData[
'CURRENCY'],
$currency);
149 $sum += $orderData[
'PRICE'];
static createFromTimestamp($timestamp)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)