Procházet zdrojové kódy

施工单完成一半

cqpCow před 1 rokem
rodič
revize
3c8d710fce
1 změnil soubory, kde provedl 12 přidání a 0 odebrání
  1. 12 0
      app/Service/ConstructionService.php

+ 12 - 0
app/Service/ConstructionService.php

@@ -8,6 +8,7 @@ use App\Model\ConstructionInfo;
 use App\Model\ConstructionProductInfo;
 use App\Model\Customer;
 use App\Model\Employee;
+use App\Model\Product;
 use App\Model\SalesOrder;
 use Illuminate\Support\Facades\DB;
 
@@ -277,12 +278,23 @@ class ConstructionService extends Service
             ->where('construction_id',$construction['id'])
             ->select('id','construction_id','product_id','mark','price','number')
             ->get()->toArray();
+        $pro = Product::whereIn('id',array_column($p_info,'product_id'))
+            ->select('bar_code','code','cost','depart_price','size','title','id')
+            ->get()->toArray();
+        $pro = array_column($pro,null,'id');
         foreach ($p_info as $value){
+            $p = $pro[$value['product_id']] ?? [];
             $construction['product'][] = [
                 'product_id' => $value['product_id'],
                 'mark' => $value['mark'],
                 'retail_price' => $value['price'],
                 'number' => $value['number'],
+                'bar_code' => $p['bar_code'] ?? '',
+                'code' => $p['code'] ?? '',
+                'cost' => $p['cost'] ?? 0,
+                'depart_price' => $p['depart_price'] ?? 0,
+                'size' => $p['size'] ?? '',
+                'title' => $p['title'] ?? '',
             ];
         }
         $construction['crt_name'] = $emp_map[$construction['crt_id']] ?? '';