From d711d11760eaa8fec8e42ba009ae3a270340c442 Mon Sep 17 00:00:00 2001 From: developer Date: Fri, 3 Apr 2026 15:30:43 +0800 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=82=D1=80=D0=B5=D0=B9=D1=82=D1=8B=20=D0=B8=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20plan7=20?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=B1=D0=B8=D1=82=D1=80=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Modules/Bitrix/Models/SendDeal.php | 2 +- app/Modules/Bitrix/Traits/Bitrixable.php | 1 + .../Http/Livewire/ClientCreateLivewire.php | 9 ++++++++- app/Modules/Plan7/Traits/Plan7Deal.php | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Modules/Bitrix/Models/SendDeal.php b/app/Modules/Bitrix/Models/SendDeal.php index f3328cc..c35b90c 100644 --- a/app/Modules/Bitrix/Models/SendDeal.php +++ b/app/Modules/Bitrix/Models/SendDeal.php @@ -13,7 +13,7 @@ class SendDeal extends BitrixSender public function __construct(Deal $deal) { $this->addDataItem('complexName', $deal->complex->name); - if ($plan7Data = $deal->getPlan7Data()) { + if ($plan7Data = $deal->plan7Data || $plan7Data = $deal->getPlan7Data()) { $this->addDataItem('plan7', $plan7Data); } } diff --git a/app/Modules/Bitrix/Traits/Bitrixable.php b/app/Modules/Bitrix/Traits/Bitrixable.php index 4afe4a4..c9df95a 100644 --- a/app/Modules/Bitrix/Traits/Bitrixable.php +++ b/app/Modules/Bitrix/Traits/Bitrixable.php @@ -48,6 +48,7 @@ protected static function create(array $attributes = []) $model = new static(); $model->fill($attributes); $model->save(); + try { $model->setBitrixId(); diff --git a/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php b/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php index a80aa5f..73ba369 100644 --- a/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php +++ b/app/Modules/ClientCreateForm/Http/Livewire/ClientCreateLivewire.php @@ -211,7 +211,14 @@ public function back() public function save() { + $deal = new Deal(); + $deal->complex_id = $this->complexId; + $deal->agent_id = $this->agentId; + if ($this->plan7Room) { + $deal->plan7Data = $this->plan7Room; + } if ( + !$deal = Deal::create([ 'agent_id' => $this->agentId, 'complex_id' => $this->complexId, @@ -221,7 +228,7 @@ public function save() $this->status = FormStatus::ERROR; return; } - + if ($this->plan7Room) { $deal->setPlan7Data($this->plan7Room['id'], $this->plan7Room); } diff --git a/app/Modules/Plan7/Traits/Plan7Deal.php b/app/Modules/Plan7/Traits/Plan7Deal.php index aaf9532..bd8820a 100644 --- a/app/Modules/Plan7/Traits/Plan7Deal.php +++ b/app/Modules/Plan7/Traits/Plan7Deal.php @@ -10,8 +10,10 @@ use Modules\Plan7\Models\DealPlan7; trait Plan7Deal { + public $plan7Data; public function setPlan7Data($id, $data) { + $this->plan7Data = $data; return DealPlan7::updateOrCreate(['deal_id' => $this->id], [ 'plan7_id' => $id, 'data' => json_encode($data) @@ -20,6 +22,7 @@ public function setPlan7Data($id, $data) public function getPlan7Data() { if ($plan7 = DealPlan7::where('deal_id', $this->id)->first()) { + $this->plan7Data = json_decode($plan7->data); return $plan7->data; } return [];