Explorar el Código

[智价云] 品规数量计算更新

tangyuanwang hace 1 mes
padre
commit
272d336724

+ 3 - 3
app/Http/Controllers/Manager/Statistics/BasicPanel.php

@@ -79,9 +79,9 @@ class BasicPanel extends Controller
             ->count(DB::raw('DISTINCT company_name'));
 
         //获取终端类型B端、C端、OTO,配置品规数量
-        $collect_b_product_count = $productModel->whereIn('platform', ['5', '6', '7', '8', '9', '10'])->where('status', 0)->count();
-        $collect_c_product_count = $productModel->whereIn('platform', ['1', '2', '3', '4'])->where('status', 0)->count();
-        $collect_oto_product_count = $productModel->whereIn('platform', [])->where('status', 0)->count();
+        $collect_b_product_count = $productModel->whereIn('platform', ['5', '6', '7', '8', '9', '10'])->where('status', 0)->sum('product_specs_number');
+        $collect_c_product_count = $productModel->whereIn('platform', ['1', '2', '3', '4'])->where('status', 0)->sum('product_specs_number');
+        $collect_oto_product_count = $productModel->whereIn('platform', [])->where('status', 0)->sum('product_specs_number');
 
         // 所有终端品规数量
         $collect_totle_product_count = $collect_b_product_count + $collect_c_product_count + $collect_oto_product_count;

+ 11 - 0
app/Models/Manager/Collect/Product.php

@@ -60,11 +60,16 @@ class Product extends Model
     {
         DB::beginTransaction();
         try {
+            // 计算品规数量
+            $product_specs_data = explode(',', $data['product_specs']);
+            //移除数组内空值
+            $product_specs_data = array_filter($product_specs_data);
             $insert_data = [
                 'enable_full_quantity' => $data['enable_full_quantity'],
                 'platform' => $data['platform'],
                 'product_name' => $data['product_name'],
                 'product_specs' => $data['product_specs'],
+                'product_specs_number' => count($product_specs_data),
                 'minimum_order_quantity' => $data['minimum_order_quantity'],
                 'sampling_cycle' => $data['sampling_cycle'],
                 'sampling_start_time' => $data['sampling_start_time'],
@@ -96,10 +101,16 @@ class Product extends Model
     {
         DB::beginTransaction();
         try {
+            // 计算品规数量
+            $product_specs_data = explode(',', $data['product_specs']);
+            //移除数组内空值
+            $product_specs_data = array_filter($product_specs_data);
+
             $Product->enable_full_quantity = $data['enable_full_quantity'];
             $Product->platform = $data['platform'];
             $Product->product_name = $data['product_name'];
             $Product->product_specs = $data['product_specs'];
+            $Product->product_specs_number = count($product_specs_data);
             $Product->minimum_order_quantity = $data['minimum_order_quantity'];
             $Product->sampling_cycle = $data['sampling_cycle'];
             $Product->sampling_start_time = $data['sampling_start_time'];