1
0
mirror of synced 2024-11-28 08:16:07 +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

@ -40,16 +40,17 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @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,9 +88,10 @@ 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;
} }
@ -96,16 +99,17 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @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']);
@ -218,7 +222,7 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @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);
@ -229,10 +233,17 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa
* @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

@ -50,7 +50,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -61,7 +61,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -72,7 +72,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -83,7 +83,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -94,7 +94,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -105,7 +105,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -116,7 +116,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -127,7 +127,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -138,7 +138,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -149,7 +149,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -160,7 +160,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -171,7 +171,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -182,7 +182,7 @@ class CustomerAddress extends BaseModel
* @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;
@ -193,7 +193,7 @@ class CustomerAddress extends BaseModel
* @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();
foreach ($customers as $customer) {
$customerBuilder = new CustomerBuilder(); $customerBuilder = new CustomerBuilder();
foreach ($customers as $customer) {
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',
); ];