ajun 5 роки тому
батько
коміт
1b02e1f99a

+ 3 - 3
app/Http/Controllers/TestController.php

@@ -1346,8 +1346,8 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         dump((string)Carbon::now());
         $dataHandlerService = new DataHandlerService();
         $orders = Order::query()
-            ->where('id','<=','4600')
-            ->where('id','>=','4500')
+            ->where('id','<=','4700')
+            ->where('id','>=','4600')
             ->get();
         $orders_params = $orders->chunk(100);
         foreach ($orders_params as $orders_param) {
@@ -1384,7 +1384,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
             ->with(['actAllocationDetails'=>function($query){
                 $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku,ACT_Allocation_Details.Location');
-            }])->whereIn('orderno',['SO201215001087'])->get();
+            }])->whereIn('orderno',['SO201215001738'])->get();
         $service = new OrderCommodityService();
         $service->syncOrderCommodity($orderHeaders);
     }

+ 3 - 2
app/Services/OrderCommodityService.php

@@ -127,12 +127,13 @@ Class OrderCommodityService
         $orderCommodities->each(function($orderCommodity)use(&$map,$owner_id_maps,$dataHandlerService){
             $order = $orderCommodity->order;
             $owner  = $dataHandlerService->getKeyValue(['id'=>$order->owner_id ?? ''],$owner_id_maps);
-            $key = "order_{$order->code}_owner_code_{$owner->code}_sku_{$orderCommodity->commodity->sku}_location_{$orderCommodity->location}_amount_{$orderCommodity->amount}";
+            $sku =  $orderCommodity->commodity->sku ?? '';
+            $key = "order_{$order->code}_owner_code_{$owner['code']}_sku_{ $sku}_location_{$orderCommodity->location}_amount_{$orderCommodity->amount}";
             if(empty($map[$key]))$map[$key]=[];
             $map[$key][]  =[
                 'id' => $orderCommodity->id,
                 'code' => $orderCommodity->order->code ?? '',
-                'sku' => $orderCommodity->commodity->sku,
+                'sku' => $sku,
                 'owner_code' => $owner->code ?? '',
                 'amount' => $orderCommodity->amount,
                 'location' => $orderCommodity->location,