cqp пре 3 месеци
родитељ
комит
e885c9599a
1 измењених фајлова са 12 додато и 1 уклоњено
  1. 12 1
      app/Service/SalesOrderService.php

+ 12 - 1
app/Service/SalesOrderService.php

@@ -590,7 +590,18 @@ class SalesOrderService extends Service
         $sales['take_address'] = $take_address;
         $sales['take_man'] = $take_man;
         $sales['take_phone'] = $take_phone;
-        $sales['storehouse_id'] = Storehouse::where('del_time', 0)->where('top_depart_id', $sales['top_depart_id'])->value('id') ?? 0;
+        if($sales['dispatch_time_second'] > 0){
+            $see = SeeRange::where('del_time',0)
+                ->where('data_id',$sales['id'])
+                ->where('data_type',SeeRange::type_seven)
+                ->where('type',SeeRange::data_three)
+                ->select('param_id')
+                ->first();
+            $top_depart_id = $see->param_id ?? 0;
+            $sales['storehouse_id'] = Storehouse::where('del_time', 0)->where('top_depart_id', $top_depart_id)->value('id') ?? 0;
+        }else{
+            $sales['storehouse_id'] = Storehouse::where('del_time', 0)->where('top_depart_id', $sales['top_depart_id'])->value('id') ?? 0;
+        }
 
         $is_add_construction = 0;
         if($sales['top_depart_id'] == $user['head']['id']){