diff --git a/intaro.retailcrm/classes/general/AddressBuilder.php b/intaro.retailcrm/classes/general/AddressBuilder.php index ebc1b269..8db7ddf0 100644 --- a/intaro.retailcrm/classes/general/AddressBuilder.php +++ b/intaro.retailcrm/classes/general/AddressBuilder.php @@ -67,4 +67,9 @@ class AddressBuilder extends AbstractBuilder implements RetailcrmBuilderInterfac return $this; } + + public function reset(): void + { + $this->customerAddress = new CustomerAddress(); + } } diff --git a/intaro.retailcrm/classes/general/CustomerBuilder.php b/intaro.retailcrm/classes/general/CustomerBuilder.php index 1f3b5031..1fad30b0 100644 --- a/intaro.retailcrm/classes/general/CustomerBuilder.php +++ b/intaro.retailcrm/classes/general/CustomerBuilder.php @@ -35,14 +35,15 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa $this->customerAddress = new CustomerAddress(); $this->addressBuilder = new AddressBuilder(); } - + /** * @param Customer $customer * @return $this */ - public function setCustomer($customer) + public function setCustomer(Customer $customer) { $this->customer = $customer; + return $this; } @@ -58,7 +59,7 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa * @param CustomerAddress $customerAddress * @return $this */ - public function setCustomerAddress($customerAddress) + public function setCustomerAddress($customerAddress): CustomerBuilder { $this->customerAddress = $customerAddress; return $this; @@ -79,6 +80,7 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa public function setDataCrm($dataCrm) { $this->dataCrm = $dataCrm; + return $this; } @@ -89,16 +91,18 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa public function setUser($user) { $this->user = $user; + return $this; } - + /** * @param int $registeredUserID * @return $this */ - public function setRegisteredUserID($registeredUserID) + public function setRegisteredUserID(int $registeredUserID) { $this->registeredUserID = $registeredUserID; + return $this; } @@ -145,14 +149,14 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa } if (isset($phone['number'])) { - if ((!isset($this->user['PERSONAL_PHONE']) || strlen($this->user['PERSONAL_PHONE']) == 0) + if ((!isset($this->user['PERSONAL_PHONE']) || '' == $this->user['PERSONAL_PHONE']) && $this->user['PERSONAL_MOBILE'] != $phone['number'] ) { $this->customer->setPersonalPhone($phone['number']); $this->user['PERSONAL_PHONE'] = $phone['number']; continue; } - if ((!isset($this->user['PERSONAL_MOBILE']) || strlen($this->user['PERSONAL_MOBILE']) == 0) + if ((!isset($this->user['PERSONAL_MOBILE']) || '' == $this->user['PERSONAL_MOBILE']) && $this->user['PERSONAL_PHONE'] != $phone['number'] ) { $this->customer->setPersonalMobile($phone['number']); @@ -213,26 +217,33 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa $this->customerAddress = null; } } - + /** * @param string $login * @return $this */ - public function setLogin($login) + public function setLogin(string $login) { $this->customer->setLogin($login); return $this; } - + /** * @param string $email * @return $this */ - public function setEmail($email) + public function setEmail(string $email) { $this->customer->setEmail($email); return $this; } + + public function reset(): void + { + $this->customer = new Customer(); + $this->customerAddress = new CustomerAddress(); + $this->addressBuilder->reset(); + } } diff --git a/intaro.retailcrm/classes/general/Model/CustomerAddress.php b/intaro.retailcrm/classes/general/Model/CustomerAddress.php index c229091d..47501eaf 100644 --- a/intaro.retailcrm/classes/general/Model/CustomerAddress.php +++ b/intaro.retailcrm/classes/general/Model/CustomerAddress.php @@ -45,7 +45,7 @@ class CustomerAddress extends BaseModel /**@var string $text */ protected $text; - + /** * @param string $index * @return $this @@ -56,7 +56,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $country * @return $this @@ -67,7 +67,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $region * @return $this @@ -78,7 +78,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $city * @return $this @@ -89,7 +89,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $street * @return $this @@ -100,7 +100,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $building * @return $this @@ -111,7 +111,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $house * @return $this @@ -122,7 +122,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $block * @return $this @@ -133,7 +133,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $flat * @return $this @@ -144,18 +144,18 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $floor * @return $this */ - public function setFloor($floor) + public function setFloor(string $floor) { $this->floor = $floor; return $this; } - + /** * @param string $intercomCode * @return $this @@ -166,7 +166,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $metro * @return $this @@ -177,7 +177,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $notes * @return $this @@ -188,7 +188,7 @@ class CustomerAddress extends BaseModel return $this; } - + /** * @param string $text * @return $this diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 0b27656c..3aa04755 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -174,6 +174,8 @@ class RetailCrmHistory retailCrmAfterCustomerSave($customer); } } + + $customerBuilder->reset(); } $GLOBALS['RETAIL_CRM_HISTORY'] = false; diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index db3af293..83198c85 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1,3 +1,3 @@ - Исправлено формирование картинок в ICML при включеном CDN - Убрана некорректная запись внешнего идентификатора платежа для новых платежей по истории -- Добавлена проверка на длину email при отправке в систему +- Добавлена проверка на длину email при отправке в систему \ No newline at end of file