cqpCow 2 年之前
父节点
当前提交
e5fea02116
共有 2 个文件被更改,包括 8 次插入8 次删除
  1. 1 1
      app/Service/DeleteOrderService.php
  2. 7 7
      app/Service/ProductionOrderService.php

+ 1 - 1
app/Service/DeleteOrderService.php

@@ -230,7 +230,7 @@ class DeleteOrderService extends Service
             }
 
             //已派工数量
-            (new DispatchService())->writeDispatchQuantity(array_column($message,'order_product_id'));
+            (new DispatchService())->writeDispatchQuantityDEL(array_column($message,'order_product_id'));
 
             DB::commit();
         }catch (\Throwable $e){

+ 7 - 7
app/Service/ProductionOrderService.php

@@ -64,15 +64,14 @@ class ProductionOrderService extends Service
             OrdersProductMain::insert(['production_no' => $production_no,'crt_time' => time(),'crt_id' => $user['id']]);
 
             //生产数据的源数据
-            $result = $msg;
+            $result = $msg[0];
+            $quantity_map = $msg[1];
 
             $boom = $process = [];
             $time = time();
             foreach ($result as $key => $value){
-                $quantity_tmp = $data['quantity'][$key];
-
                 $result[$key]['production_no'] = $production_no;
-                $result[$key]['production_quantity'] = $quantity_tmp;
+                $result[$key]['production_quantity'] = $quantity_map[$value['sale_orders_product_id']];
                 $result[$key]['production_time'] = $time;
                 $result[$key]['crt_id'] = $user['id'];
             }
@@ -86,7 +85,7 @@ class ProductionOrderService extends Service
 
             $time_arr = [];
             foreach ($result as $key => $value){
-                $quantity_tmp = $data['quantity'][$key];
+                $quantity_tmp = $quantity_map[$value['sale_orders_product_id']];
 
                 $time_tmp = date("Ymd", $value['out_order_no_time']);
                 if(! in_array($time_tmp,$time_arr)) $time_arr[] = $time_tmp;
@@ -201,11 +200,12 @@ class ProductionOrderService extends Service
             ->get()->toArray();
 
         foreach ($result as $key => $value){
-            if($value['production_quantity'] + $map[$value['sale_orders_product_id']] > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];
+            $quantity_tmp = $map[$value['sale_orders_product_id']] ?? 0;
+            if($value['production_quantity'] + $quantity_tmp > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];
             unset($result[$key]['production_quantity']);//删除销售订单的已生产数量
         }
 
-        return [true, $result];
+        return [true, [$result,$map]];
     }
 
     public function fillData($data){