Просмотр исходного кода

修改OrderCommodity删除逻辑

ajun 5 лет назад
Родитель
Сommit
7cd4c0d7f0
1 измененных файлов с 9 добавлено и 3 удалено
  1. 9 3
      app/Services/OrderCommodityService.php

+ 9 - 3
app/Services/OrderCommodityService.php

@@ -64,8 +64,8 @@ Class OrderCommodityService
         $ActAllocationDetail_maps =  $this->getRegroupActAllocationDetails($orderHeaders);
         $orderCommodity_maps = $this->getRegroupOrderCommodities($orderCommodities,$owner_id_maps);
         unset($orderCommodities,$owner_id_maps,$owners,$orderNos);
-        $delete_ids =  $this->getDeleteIds($ActAllocationDetail_maps,$orderCommodity_maps);
         $this->filterHasExist($ActAllocationDetail_maps,$orderCommodity_maps);
+        $delete_ids =  $this->getDeleteIds($ActAllocationDetail_maps,$orderCommodity_maps);
         $create_params = $this->getCreateParams($ActAllocationDetail_maps,$orderCommodity_maps);
         unset($orderCommodity_maps,$ActAllocationDetail_maps);
         $inner_params = $this->getInnerParamsByParams($create_params,$order_code_map,$commodity_map);
@@ -146,8 +146,14 @@ Class OrderCommodityService
         $ids = [];
         if(count($orderCommodity_maps)==0)return $ids;
         foreach ($orderCommodity_maps as $key=>$orderCommodity_map) {
-            if(array_key_exists($key,$orderCommodity_maps))continue;
-            $ActAllocationDetail_map = $ActAllocationDetail_maps[$key];
+            $ActAllocationDetail_map = $ActAllocationDetail_maps[$key]  ?? null;
+            if($ActAllocationDetail_map==null){
+                foreach ($orderCommodity_map as $index=>$orderCommodity) {
+                    $ids[] =$orderCommodity['id'];
+                    unset($orderCommodity_map[$index]);
+                }
+                continue;
+            }
             if(count($ActAllocationDetail_map) == count($orderCommodity_map))continue;
             if(count($ActAllocationDetail_map) < count($orderCommodity_map)){
                 foreach ($orderCommodity_map as $index=>$item) {