cqpCow 1 gadu atpakaļ
vecāks
revīzija
07fd1a8a0e
1 mainītis faili ar 18 papildinājumiem un 17 dzēšanām
  1. 18 17
      app/Service/CheckService.php

+ 18 - 17
app/Service/CheckService.php

@@ -357,35 +357,35 @@ class CheckService extends Service
         //产品字典
         $product_map = (new ProductService())->getProductDetail(array_column($product,'product_id'));
 
-        //获取产品采购使用金额
-        $map = (new ProductService())->getProductPrice(array_column($product,'product_id'));
-        //获取部门目前使用的分社价
-        $basic_type_id = Depart::where('id',$order['top_depart_id'])->value('basic_type_id');
-        //产品对应的分社价
-        $new_map = [];
-        foreach ($map as $product_id => $value){
-            foreach ($value as $v){
-                if($v['basic_type_id'] == $basic_type_id && ! empty($v['price'])) $new_map[$product_id] = $v['price'];
-            }
-        }
+//        //获取产品采购使用金额
+//        $map = (new ProductService())->getProductPrice(array_column($product,'product_id'));
+//        //获取部门目前使用的分社价
+//        $basic_type_id = Depart::where('id',$order['top_depart_id'])->value('basic_type_id');
+//        //产品对应的分社价
+//        $new_map = [];
+//        foreach ($map as $product_id => $value){
+//            foreach ($value as $v){
+//                if($v['basic_type_id'] == $basic_type_id && ! empty($v['price'])) $new_map[$product_id] = $v['price'];
+//            }
+//        }
 
         $insert = [];
         $product_total = 0;
         foreach ($product as $value){
             $tmp = $product_map[$value['product_id']] ?? [];
-            $fs_price = $new_map[$value['product_id']] ?? 0;
+//            $fs_price = $new_map[$value['product_id']] ?? 0;
             //有分社价就是分社价格 没有就是零售
-            $price = $fs_price ? $fs_price : $tmp['retail_price'];
-            $product_total += $price * $value['number'];
+//            $price = $fs_price ? $fs_price : $tmp['retail_price'];
+            $product_total += $value['price'] * $value['number'];
             $insert[] = [
                 'sales_order_id' => $sales_order_id,
                 'product_id' => $value['product_id'],
                 'number' => $value['number'],
-                'basic_type_id' => $basic_type_id,
-                'price' => $price,
+                'basic_type_id' => $value['basic_type_id'],
+                'price' => $value['price'],
                 'cost' => $tmp['cost'] ?? 0,
                 'retail_price' => $tmp['retail_price'] ?? 0,
-                'final_amount' => $product_total,
+                'final_amount' => $value['price'] * $value['number'],
             ];
         }
         $bool = SalesOrderProductInfo::insert($insert);
@@ -397,6 +397,7 @@ class CheckService extends Service
             'product_total' => $product_total,
             'rate' =>$rate
         ]);
+
         return [true,''];
     }