1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
buyerstatistic.php
См. документацию.
1<?php
8namespace Bitrix\Sale\Internals;
9
10use Bitrix\Main;
11
28class 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(
49 'ID',
50 array(
51 'autocomplete' => true,
52 'primary' => true,
53 )
54 ),
55
57 'LID',
58 array(
59 'required' => true,
60 )
61 ),
62
64 'CURRENCY',
65 array(
66 'required' => true,
67 'size' => 3
68 )
69 ),
70
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
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 {
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
Определения actionsdefinitions.php:38
$type
Определения options.php:106
static getConnection($name="")
Определения application.php:638
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения ufield.php:9