1
0
mirror of synced 2025-01-19 09:21:41 +03:00

Replace CustomerBuilder

This commit is contained in:
Alex Lushpai 2021-04-16 15:12:27 +03:00 committed by GitHub
commit e422557514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 27 deletions

View File

@ -67,4 +67,9 @@ class AddressBuilder extends AbstractBuilder implements RetailcrmBuilderInterfac
return $this;
}
public function reset(): void
{
$this->customerAddress = new CustomerAddress();
}
}

View File

@ -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();
}
}

View File

@ -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

View File

@ -174,6 +174,8 @@ class RetailCrmHistory
retailCrmAfterCustomerSave($customer);
}
}
$customerBuilder->reset();
}
$GLOBALS['RETAIL_CRM_HISTORY'] = false;

View File

@ -1,3 +1,3 @@
- Исправлено формирование картинок в ICML при включеном CDN
- Убрана некорректная запись внешнего идентификатора платежа для новых платежей по истории
- Добавлена проверка на длину email при отправке в систему
- Добавлена проверка на длину email при отправке в систему