cqpCow 2 年之前
父節點
當前提交
2a78b97512
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      app/Service/ProductionOrderService.php

+ 5 - 1
app/Service/ProductionOrderService.php

@@ -191,13 +191,17 @@ class ProductionOrderService extends Service
         if($this->isEmpty($data,'quantity')) return [false,'数量不能为空!'];
         if(in_array(false, $data['quantity'], true) || in_array(0, $data['quantity'], true) || in_array('', $data['quantity'], true))return [false,'数量不能为空!'];
 
+        $map = [];
+        foreach ($data['id'] as $key => $value){
+            $map[$value] = $data['quantity'][$key];
+        }
         $result = SaleOrdersProduct::whereIn('id',$data['id'])
             ->select('id as sale_orders_product_id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','price')
             ->orderBy('id','asc')
             ->get()->toArray();
 
         foreach ($result as $key => $value){
-            if($value['production_quantity'] + $data['quantity'][$key] > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];
+            if($value['production_quantity'] + $map[$value['sale_orders_product_id']] > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];
             unset($result[$key]['production_quantity']);//删除销售订单的已生产数量
         }