Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
contactlistupdateservice.php
1
<?php
2
3
namespace
Bitrix\Sender\Service
;
4
5
use
Bitrix\Main\Application
;
6
use
Bitrix\Sender\ContactListTable
;
7
use
Bitrix\Sender\ContactTable
;
8
use
Bitrix\Sender\Internals\Dto\UpdateContactDtoCollection
;
9
use
Bitrix\Sender\Internals\SqlBatch
;
10
11
class
ContactListUpdateService
12
{
22
public
function
updateByCollection
(
UpdateContactDtoCollection
$collection,
int
$listId): void
23
{
24
$codesByType = [];
25
foreach
($collection->
all
() as $updateItem)
26
{
27
$codesByType[$updateItem->typeId][] = $updateItem->code;
28
}
29
$sqlHelper =
Application::getConnection
()->getSqlHelper();
30
31
foreach
($codesByType as $typeId => $allCodes)
32
{
33
$typeId = (int)$typeId;
34
$listId = (int)$listId;
35
$contactTableName =
ContactTable::getTableName
();
36
$contactListTableName =
ContactListTable::getTableName
();
37
foreach
(SqlBatch::divide($allCodes) as $codes)
38
{
39
$codes = SqlBatch::getInString($codes);
40
41
$fields =
'(CONTACT_ID, LIST_ID) '
;
42
$subSelect =
"SELECT ID AS CONTACT_ID, $listId as LIST_ID "
;
43
$subSelect .=
"FROM $contactTableName "
;
44
$subSelect .=
"WHERE TYPE_ID=$typeId AND CODE in ($codes)"
;
45
$sql = $sqlHelper->getInsertIgnore($contactListTableName, $fields, $subSelect);
46
Application::getConnection
()->query($sql);
47
}
48
}
49
}
50
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getConnection
static getConnection($name="")
Definition
application.php:611
Bitrix\Sender\ContactListTable
Definition
contactlist.php:34
Bitrix\Sender\ContactListTable\getTableName
static getTableName()
Definition
contactlist.php:40
Bitrix\Sender\ContactTable
Definition
contact.php:43
Bitrix\Sender\ContactTable\getTableName
static getTableName()
Definition
contact.php:53
Bitrix\Sender\Internals\Dto\UpdateContactDtoCollection
Definition
updatecontactdtocollection.php:9
Bitrix\Sender\Internals\Dto\UpdateContactDtoCollection\all
all()
Definition
updatecontactdtocollection.php:32
Bitrix\Sender\Internals\SqlBatch
Definition
sqlbatch.php:22
Bitrix\Sender\Service\ContactListUpdateService
Definition
contactlistupdateservice.php:12
Bitrix\Sender\Service\ContactListUpdateService\updateByCollection
updateByCollection(UpdateContactDtoCollection $collection, int $listId)
Definition
contactlistupdateservice.php:22
Bitrix\Sender\Service
Definition
contactlistupdateservice.php:3
modules
sender
lib
service
contactlistupdateservice.php
Создано системой
1.10.0