From d9c031c74c542a24399084a557733bc0169176c8 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Wed, 4 Sep 2024 09:38:20 +0300 Subject: [PATCH] =?utf8?q?[ERP-100]=20=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?utf8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0?= =?utf8?q?=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=D0=B9=20=D0=BF=D0=B5=D1=80?= =?utf8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=B4=D0=BB=D1=8F?= =?utf8?q?=20=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?utf8?q?=20=D0=B8=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=BE?= =?utf8?q?=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 38 ++++------------------------ 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 5186306a..243a4ca9 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -560,26 +560,10 @@ class MotivationService ->andWhere(['product_id' => array_keys($products1c)]) ->asArray()->one(); - $motivationValueGroup = MotivationValueGroup::find()->where(['alias' => 'week' . $ind])->one(); - $motivationCostsItem = MotivationCostsItem::find()->where(['name' => 'Услуги по сборке'])->one(); - /** @var $motivationCostsItem MotivationCostsItem */ $motivation = Motivation::find()->where(['store_id' => $store_id, 'year' => $year, 'month' => $month])->one(); if ($motivation) { - $motivationValue = MotivationValue::find()->where(['motivation_id' => $motivation->id, - 'motivation_group_id' => $motivationValueGroup->id, 'value_id' => $motivationCostsItem->code])->one(); - if (!$motivationValue) { - $motivationValue = new MotivationValue; - $motivationValue->motivation_id = $motivation->id; - $motivationValue->motivation_group_id = $motivationValueGroup->id; - $motivationValue->value_id = $motivationCostsItem->code; - $motivationValue->value_type = $motivationCostsItem->data_type; - } - $motivationValue->value_float = $salesProduct['total']; - $motivationValue->save(); - //var_dump($motivationValue); die; - if ($motivationValue->getErrors()) { - throw new \Exception(Json::encode($motivationValue->getErrors())); - } + self::saveOrUpdateMotivationValue($motivation->id, 'week' . $ind, self::CODE_ASSEMBLY_SERVICES, + 'float', ($salesProduct['total'] ?? 0)); } // Ищем продажи по продуктовым гуидам по каталог-гуидам категории service_delivery @@ -601,26 +585,14 @@ class MotivationService ->select(['SUM(summ) as total']) ->where(['check_id' => $salesIds]) ->andWhere(['NOT IN', 'check_id', $returnSalesIds]) - ->andWhere(['product_id' => array_keys($products1c)]) + ->andWhere(['product_id' => array_keys($products1cDelivery)]) ->asArray()->one(); $motivationCostsItem = MotivationCostsItem::find()->where(['name' => 'Услуги по доставке'])->one(); /** @var $motivationCostsItem MotivationCostsItem */ if ($motivation) { - $motivationValue = MotivationValue::find()->where(['motivation_id' => $motivation->id, - 'motivation_group_id' => $motivationValueGroup->id, 'value_id' => $motivationCostsItem->code])->one(); - if (!$motivationValue) { - $motivationValue = new MotivationValue; - $motivationValue->motivation_id = $motivation->id; - $motivationValue->motivation_group_id = $motivationValueGroup->id; - $motivationValue->value_id = $motivationCostsItem->code; - $motivationValue->value_type = $motivationCostsItem->data_type; - } - $motivationValue->value_float = $salesProduct['total']; - $motivationValue->save(); - if ($motivationValue->getErrors()) { - throw new \Exception(Json::encode($motivationValue->getErrors())); - } + self::saveOrUpdateMotivationValue($motivation->id, 'week' . $ind, self::CODE_DELIVERY_SERVICES, + 'float', ($salesProduct['total'] ?? 0)); } } } -- 2.39.5