11 public function init($params)
13 foreach($params as $index=>$item)
15 $entity = Integration\Service\Internal\Entity\Factory::create($this->
getDstEntityTypeId());
17 $entity->setTitle($item[
'TITLE']);
18 $entity->setOriginId($index);
19 $entity->setOriginatorId(static::ANALITICS_ORIGINATOR_ID);
20 $entity->setOpportunity($item[
'PRICE']);
21 $entity->setCurrency($item[
'CURRENCY']);
23 if($item[
'COMPANY_ID'])
25 $entity->setCompanyId($item[
'COMPANY_ID']);
27 if($item[
'CONTACT_ID'])
29 $entity->setContactId($item[
'CONTACT_ID']) ;
32 $this->collection->addItem(
33 Integration\
Service\Internal\Container\Item::create($entity)
34 ->setInternalIndex($index)
42 $proxy = static::getProxy();
43 $r = $proxy->contactItemsGet($id);
47 $result = $r->getData()[
'DATA'][
'result'];
56 static public function dealContactUpdates($id, $params, $contacts)
59 $indexes = self::getIndexesFromParams($params);
60 $contacts = static::getIndexesContactFromParams($contacts);
62 $relations = static::clientRelation($indexes, BusinessValuePersonDomainType::TYPE_I_NAME);
66 foreach ($relations as $relation)
68 $contactIds[] = $relation->getDestinationEntityId();
71 if(count(array_diff($contactIds, $contacts))>0)
73 $proxy = static::getProxy();
74 $r = $proxy->contactItemsSet($id, static::getContactItemsFromIndexes(array_merge($contactIds, $contacts)));
77 $result = $r->getData()[
'DATA'][
'result'];
86 static public function dealContactAdds($id, $params)
89 $indexes = self::getIndexesFromParams($params);
91 $relations = static::clientRelation($indexes, BusinessValuePersonDomainType::TYPE_I_NAME);
95 foreach ($relations as $relation)
97 $contactIds[] = $relation->getDestinationEntityId();
100 if(count($contactIds)>0)
102 $proxy = static::getProxy();
103 $r = $proxy->contactItemsSet($id, static::getContactItemsFromIndexes($contactIds));
106 $result = $r->getData()[
'DATA'][
'result'];
110 throw new Exception\BatchableException(implode(
',', $r->getErrorMessages()));
118 return Integration\EntityType::ORDER;
122 return Integration\CRM\EntityType::DEAL;