1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
buyerstatistic.php
См. документацию.
1
<?php
8
namespace
Bitrix\Sale\Internals;
9
10
use Bitrix\Main;
11
28
class
BuyerStatisticTable
extends
Main\Entity\DataManager
29
{
35
public
static
function
getTableName
()
36
{
37
return
'b_sale_buyer_stat'
;
38
}
39
45
public
static
function
getMap
()
46
{
47
return
array
(
48
new
Main
\
Entity
\
IntegerField
(
49
'ID'
,
50
array
(
51
'autocomplete'
=>
true
,
52
'primary'
=>
true
,
53
)
54
),
55
56
new
Main
\
Entity
\
StringField
(
57
'LID'
,
58
array
(
59
'required'
=>
true
,
60
)
61
),
62
63
new
Main
\
Entity
\
StringField
(
64
'CURRENCY'
,
65
array
(
66
'required'
=>
true
,
67
'size'
=> 3
68
)
69
),
70
71
new
Main
\
Entity
\
IntegerField
(
72
'USER_ID'
,
73
array
(
74
'required'
=>
true
,
75
)
76
),
77
78
new
Main
\
Entity
\ReferenceField(
79
'USER'
,
80
'\Bitrix\Main\User'
,
81
array
(
'=this.USER_ID'
=>
'ref.ID'
),
82
array
(
'join_type'
=>
'INNER'
)
83
),
84
85
new
Main
\
Entity
\
DatetimeField
(
'LAST_ORDER_DATE'
),
86
87
new
Main
\
Entity
\
FloatField
(
88
'SUM_PAID'
,
89
array
(
90
'default_value'
=>
'0.0000'
91
)
92
),
93
94
new
Main
\
Entity
\
IntegerField
(
'COUNT_FULL_PAID_ORDER'
),
95
96
new
Main
\
Entity
\
IntegerField
(
'COUNT_PART_PAID_ORDER'
),
97
98
new
Main
\
Entity
\ReferenceField(
99
'GROUP'
,
100
'\Bitrix\Main\UserGroup'
,
101
array
(
'=this.USER_ID'
=>
'ref.USER_ID'
),
102
array
(
'join_type'
=>
'INNER'
)
103
),
104
);
105
}
106
110
public
static
function
recalculate
()
111
{
112
$connection
=
Main\Application::getConnection
();
113
$type
=
$connection
->getType();
114
if
(
$type
==
"mysql"
)
115
{
116
$sqlDelete =
"TRUNCATE TABLE "
.self::getTableName();
117
$connection
->query($sqlDelete);
118
119
$sqlInsertInSelect =
"
120
INSERT INTO "
.self::getTableName().
" (USER_ID, LID, CURRENCY, LAST_ORDER_DATE, COUNT_FULL_PAID_ORDER, COUNT_PART_PAID_ORDER, SUM_PAID)
121
SELECT UN.USER_ID, UN.LID, UN.CURRENCY, MAX(UN.DATE_INSERT), SUM(CASE WHEN UN.PAYED = 'Y' THEN 1 ELSE 0 END), SUM(CASE WHEN NOT UN.SUM_PAID = 0 THEN 1 ELSE 0 END), SUM(UN.SUM_PAID)
122
FROM (
123
(SELECT USER_ID, LID, CURRENCY, DATE_INSERT, PAYED, SUM_PAID FROM b_sale_order)
124
UNION
125
(SELECT USER_ID, LID, CURRENCY, DATE_INSERT, PAYED, SUM_PAID FROM b_sale_order_archive)
126
) UN
127
GROUP BY UN.USER_ID, UN.CURRENCY, UN.LID
128
ORDER BY UN.USER_ID"
;
129
$connection
->query($sqlInsertInSelect);
130
}
131
}
132
}
$connection
$connection
Определения
actionsdefinitions.php:38
$type
$type
Определения
options.php:106
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
Bitrix\Main\ORM\Fields\DatetimeField
Определения
datetimefield.php:22
Bitrix\Main\ORM\Fields\FloatField
Определения
floatfield.php:20
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Определения
stringfield.php:20
Bitrix\Sale\Internals\BuyerStatisticTable
Определения
buyerstatistic.php:29
Bitrix\Sale\Internals\BuyerStatisticTable\getMap
static getMap()
Определения
buyerstatistic.php:45
Bitrix\Sale\Internals\BuyerStatisticTable\recalculate
static recalculate()
Определения
buyerstatistic.php:110
Bitrix\Sale\Internals\BuyerStatisticTable\getTableName
static getTableName()
Определения
buyerstatistic.php:35
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main
bitrix
modules
sale
lib
internals
buyerstatistic.php
Создано системой
1.14.0