1
0
mirror of synced 2024-11-24 14:26:08 +03:00

add reset in customer bulder and bump version

This commit is contained in:
Sergey Chazov 2021-03-23 14:36:48 +03:00
parent cec1dafd36
commit 2689836c65
7 changed files with 75 additions and 57 deletions

View File

@ -1,3 +1,6 @@
## 2021-03-23 v.5.6.3
* Исправлена передача полей от одного пользователя к другому в момент загрузки истории из CRM
## 2021-01-14 v.5.6.2 ## 2021-01-14 v.5.6.2
* Исправлено формирование картинок в ICML при включеном CDN * Исправлено формирование картинок в ICML при включеном CDN
* Убрана некорректная запись внешнего идентификатора платежа для новых платежей по истории * Убрана некорректная запись внешнего идентификатора платежа для новых платежей по истории

View File

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

View File

@ -35,21 +35,22 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
$this->customerAddress = new CustomerAddress(); $this->customerAddress = new CustomerAddress();
$this->addressBuilder = new AddressBuilder(); $this->addressBuilder = new AddressBuilder();
} }
/** /**
* @param Customer $customer * @param Customer $customer
* @return $this * @return $this
*/ */
public function setCustomer($customer) public function setCustomer(Customer $customer): CustomerBuilder
{ {
$this->customer = $customer; $this->customer = $customer;
return $this; return $this;
} }
/** /**
* @return Customer * @return Customer
*/ */
public function getCustomer() public function getCustomer(): Customer
{ {
return $this->customer; return $this->customer;
} }
@ -58,7 +59,7 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @param CustomerAddress $customerAddress * @param CustomerAddress $customerAddress
* @return $this * @return $this
*/ */
public function setCustomerAddress($customerAddress) public function setCustomerAddress($customerAddress): CustomerBuilder
{ {
$this->customerAddress = $customerAddress; $this->customerAddress = $customerAddress;
return $this; return $this;
@ -67,7 +68,7 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
/** /**
* @return CustomerAddress * @return CustomerAddress
*/ */
public function getCustomerAddress() public function getCustomerAddress(): CustomerAddress
{ {
return $this->customerAddress; return $this->customerAddress;
} }
@ -76,9 +77,10 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @param array $dataCrm * @param array $dataCrm
* @return $this * @return $this
*/ */
public function setDataCrm($dataCrm) public function setDataCrm($dataCrm): CustomerBuilder
{ {
$this->dataCrm = $dataCrm; $this->dataCrm = $dataCrm;
return $this; return $this;
} }
@ -86,26 +88,28 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @param array $user * @param array $user
* @return $this * @return $this
*/ */
public function setUser($user) public function setUser($user): CustomerBuilder
{ {
$this->user = $user; $this->user = $user;
return $this; return $this;
} }
/** /**
* @param int $registeredUserID * @param int $registeredUserID
* @return $this * @return $this
*/ */
public function setRegisteredUserID($registeredUserID) public function setRegisteredUserID(int $registeredUserID): CustomerBuilder
{ {
$this->registeredUserID = $registeredUserID; $this->registeredUserID = $registeredUserID;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getRegisteredUserID() public function getRegisteredUserID(): int
{ {
return $this->registeredUserID; return $this->registeredUserID;
} }
@ -113,7 +117,7 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
/** /**
* @return bool * @return bool
*/ */
public function getRegisterNewUser() public function getRegisterNewUser(): bool
{ {
return $this->registerNewUser; return $this->registerNewUser;
} }
@ -134,8 +138,8 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
if (isset($this->dataCrm['phones'])) { if (isset($this->dataCrm['phones'])) {
foreach ($this->dataCrm['phones'] as $phone) { foreach ($this->dataCrm['phones'] as $phone) {
if (isset($phone['old_number']) && in_array($phone['old_number'], $this->user)) { if (isset($phone['old_number']) && in_array($phone['old_number'], $this->user, true)) {
$key = array_search($phone['old_number'], $this->user); $key = array_search($phone['old_number'], $this->user, true);
if (isset($phone['number'])) { if (isset($phone['number'])) {
$this->user[$key] = $phone['number']; $this->user[$key] = $phone['number'];
@ -145,14 +149,14 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
} }
if (isset($phone['number'])) { 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->user['PERSONAL_MOBILE'] != $phone['number']
) { ) {
$this->customer->setPersonalPhone($phone['number']); $this->customer->setPersonalPhone($phone['number']);
$this->user['PERSONAL_PHONE'] = $phone['number']; $this->user['PERSONAL_PHONE'] = $phone['number'];
continue; 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->user['PERSONAL_PHONE'] != $phone['number']
) { ) {
$this->customer->setPersonalMobile($phone['number']); $this->customer->setPersonalMobile($phone['number']);
@ -213,26 +217,33 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
$this->customerAddress = null; $this->customerAddress = null;
} }
} }
/** /**
* @param string $login * @param string $login
* @return $this * @return $this
*/ */
public function setLogin($login) public function setLogin(string $login): CustomerBuilder
{ {
$this->customer->setLogin($login); $this->customer->setLogin($login);
return $this; return $this;
} }
/** /**
* @param string $email * @param string $email
* @return $this * @return $this
*/ */
public function setEmail($email) public function setEmail(string $email): CustomerBuilder
{ {
$this->customer->setEmail($email); $this->customer->setEmail($email);
return $this; return $this;
} }
public function reset(): void
{
$this->customer = new Customer();
$this->customerAddress = new CustomerAddress();
$this->addressBuilder->reset();
}
} }

View File

@ -45,155 +45,155 @@ class CustomerAddress extends BaseModel
/**@var string $text */ /**@var string $text */
protected $text; protected $text;
/** /**
* @param string $index * @param string $index
* @return $this * @return $this
*/ */
public function setIndex($index) public function setIndex(string $index): CustomerAddress
{ {
$this->index = $index; $this->index = $index;
return $this; return $this;
} }
/** /**
* @param string $country * @param string $country
* @return $this * @return $this
*/ */
public function setCountry($country) public function setCountry(string $country): CustomerAddress
{ {
$this->country = $country; $this->country = $country;
return $this; return $this;
} }
/** /**
* @param string $region * @param string $region
* @return $this * @return $this
*/ */
public function setRegion($region) public function setRegion(string $region): CustomerAddress
{ {
$this->region = $region; $this->region = $region;
return $this; return $this;
} }
/** /**
* @param string $city * @param string $city
* @return $this * @return $this
*/ */
public function setCity($city) public function setCity(string $city): CustomerAddress
{ {
$this->city = $city; $this->city = $city;
return $this; return $this;
} }
/** /**
* @param string $street * @param string $street
* @return $this * @return $this
*/ */
public function setStreet($street) public function setStreet(string $street): CustomerAddress
{ {
$this->street = $street; $this->street = $street;
return $this; return $this;
} }
/** /**
* @param string $building * @param string $building
* @return $this * @return $this
*/ */
public function setBuilding($building) public function setBuilding(string $building): CustomerAddress
{ {
$this->building = $building; $this->building = $building;
return $this; return $this;
} }
/** /**
* @param string $house * @param string $house
* @return $this * @return $this
*/ */
public function setHouse($house) public function setHouse(string $house): CustomerAddress
{ {
$this->house = $house; $this->house = $house;
return $this; return $this;
} }
/** /**
* @param string $block * @param string $block
* @return $this * @return $this
*/ */
public function setBlock($block) public function setBlock(string $block): CustomerAddress
{ {
$this->block = $block; $this->block = $block;
return $this; return $this;
} }
/** /**
* @param string $flat * @param string $flat
* @return $this * @return $this
*/ */
public function setFlat($flat) public function setFlat(string $flat): CustomerAddress
{ {
$this->flat = $flat; $this->flat = $flat;
return $this; return $this;
} }
/** /**
* @param string $floor * @param string $floor
* @return $this * @return $this
*/ */
public function setFloor($floor) public function setFloor(string $floor): CustomerAddress
{ {
$this->floor = $floor; $this->floor = $floor;
return $this; return $this;
} }
/** /**
* @param string $intercomCode * @param string $intercomCode
* @return $this * @return $this
*/ */
public function setIntercomCode($intercomCode) public function setIntercomCode(string $intercomCode): CustomerAddress
{ {
$this->intercomCode = $intercomCode; $this->intercomCode = $intercomCode;
return $this; return $this;
} }
/** /**
* @param string $metro * @param string $metro
* @return $this * @return $this
*/ */
public function setMetro($metro) public function setMetro(string $metro): CustomerAddress
{ {
$this->metro = $metro; $this->metro = $metro;
return $this; return $this;
} }
/** /**
* @param string $notes * @param string $notes
* @return $this * @return $this
*/ */
public function setNotes($notes) public function setNotes(string $notes): CustomerAddress
{ {
$this->notes = $notes; $this->notes = $notes;
return $this; return $this;
} }
/** /**
* @param string $text * @param string $text
* @return $this * @return $this
*/ */
public function setText($text) public function setText(string $text): CustomerAddress
{ {
$this->text = $text; $this->text = $text;

View File

@ -63,10 +63,9 @@ class RetailCrmHistory
$GLOBALS['RETAIL_CRM_HISTORY'] = true; $GLOBALS['RETAIL_CRM_HISTORY'] = true;
$newUser = new CUser(); $newUser = new CUser();
$customerBuilder = new CustomerBuilder();
foreach ($customers as $customer) { foreach ($customers as $customer) {
$customerBuilder = new CustomerBuilder();
if (function_exists('retailCrmBeforeCustomerSave')) { if (function_exists('retailCrmBeforeCustomerSave')) {
$newResCustomer = retailCrmBeforeCustomerSave($customer); $newResCustomer = retailCrmBeforeCustomerSave($customer);
if (is_array($newResCustomer) && !empty($newResCustomer)) { if (is_array($newResCustomer) && !empty($newResCustomer)) {
@ -175,6 +174,8 @@ class RetailCrmHistory
retailCrmAfterCustomerSave($customer); retailCrmAfterCustomerSave($customer);
} }
} }
$customerBuilder->reset();
} }
$GLOBALS['RETAIL_CRM_HISTORY'] = false; $GLOBALS['RETAIL_CRM_HISTORY'] = false;

View File

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

View File

@ -1,5 +1,5 @@
<? <?php
$arModuleVersion = array( $arModuleVersion = [
"VERSION" => "5.6.2", 'VERSION' => '5.6.3',
"VERSION_DATE" => "2021-01-14 16:00:00" 'VERSION_DATE' => '2021-03-23 14:00:00',
); ];