]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-140] рефактор 3
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 4 Sep 2024 05:36:45 +0000 (08:36 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 4 Sep 2024 05:36:45 +0000 (08:36 +0300)
erp24/services/MotivationService.php

index 0a34bb15d5ff6fa7243b6689db6fd23ded12dc11..e25dff6afc651713b381b2404a4a6ff7d335576d 100644 (file)
@@ -1256,13 +1256,11 @@ class MotivationService
                 $returnSalesIds = ArrayHelper::getColumn($returnSales, 'sales_check');
 
                 // Ищем продукты из категории services
-                $salesProduct = SalesProducts::find()->alias('p')
-                    ->select(['SUM(p.summ) as total'])
-                    ->leftJoin('sales s', 's.id = p.check_id')
+                $salesProduct = SalesProducts::find()
+                    ->select(['SUM(summ) as total'])
                     ->where(['check_id' => $salesIds])
                     ->andWhere(['NOT IN', 'check_id', $returnSalesIds])
                     ->andWhere(['product_id' => array_keys($products1c)])
-                    ->andWhere(['s.store_id' => $store_id])
                     ->asArray()->one();
 
                 $correction = self::getMotivationValue($motivations[$store_id]->id, 8, self::CODE_ASSEMBLY_SERVICES);
@@ -1285,13 +1283,11 @@ class MotivationService
                 $returnSalesIdsDelivery = ArrayHelper::getColumn($returnSalesDelivery, 'sales_check');
 
                 // Ищем продукты из категории services_delivery
-                $salesProductDelivery = SalesProducts::find()->alias('p')
-                    ->select(['SUM(p.summ) as total'])
-                    ->leftJoin('sales s', 's.id = p.check_id')
+                $salesProductDelivery = SalesProducts::find()
+                    ->select(['SUM(summ) as total'])
                     ->where(['check_id' => $salesIdsDelivery])
                     ->andWhere(['NOT IN', 'check_id', $returnSalesIdsDelivery])
                     ->andWhere(['product_id' => array_keys($products1cDelivery)])
-                    ->andWhere(['s.store_id' => $store_id])
                     ->asArray()->one();
 
                 $correctionDelivery = self::getMotivationValue($motivations[$store_id]->id, 8, self::CODE_DELIVERY_SERVICES);