wesmiler hace 1 semana
padre
commit
e164bfc1e5
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  1. 8 2
      app/Services/Api/GoodsService.php

+ 8 - 2
app/Services/Api/GoodsService.php

@@ -283,13 +283,19 @@ class GoodsService extends BaseService
         $list = $this->model->whereIn('id', $ids)
         $list = $this->model->whereIn('id', $ids)
             ->where(['status'=>1,'mark'=>1])
             ->where(['status'=>1,'mark'=>1])
             ->select(['id as goods_id','goods_name','category_id','store_id','delivery_fee','sku_type','price','bd_score','cost_price','ls_score_rate','stock','unit','weight','thumb','sku_type'])
             ->select(['id as goods_id','goods_name','category_id','store_id','delivery_fee','sku_type','price','bd_score','cost_price','ls_score_rate','stock','unit','weight','thumb','sku_type'])
-            ->get();
+            ->get()
+            ->keyBy('id');
         $list = $list? $list->toArray() : [];
         $list = $list? $list->toArray() : [];
         if($list){
         if($list){
             $skus = GoodsSkuModel::whereIn('goods_id', $ids)->select(['id','sku_name','price','cost_price','stock'])->get()->keyBy('id');
             $skus = GoodsSkuModel::whereIn('goods_id', $ids)->select(['id','sku_name','price','cost_price','stock'])->get()->keyBy('id');
             $skus = $skus?$skus->toArray() :[];
             $skus = $skus?$skus->toArray() :[];
             $result = ['discount_point'=>$discountPoint,'profit_total'=>0,'store_id'=>0,'discount_total'=>0.00,'delivery_fee'=>0.00,'goods_total'=>0,'order_total'=>0,'bd_score_total'=>0,'count'=>0,'goods'=>[]];
             $result = ['discount_point'=>$discountPoint,'profit_total'=>0,'store_id'=>0,'discount_total'=>0.00,'delivery_fee'=>0.00,'goods_total'=>0,'order_total'=>0,'bd_score_total'=>0,'count'=>0,'goods'=>[]];
-            foreach ($list as $item){
+            foreach ($ids as $id){
+                $item = isset($list[$id])?$list[$id] : [];
+                if(empty($item)){
+                    continue;
+                }
+
                 $item['order_no'] = $orderNo;
                 $item['order_no'] = $orderNo;
                 $id = isset($item['goods_id'])?$item['goods_id']:0;
                 $id = isset($item['goods_id'])?$item['goods_id']:0;
                 $goodsName = isset($item['goods_name'])?$item['goods_name']:'';
                 $goodsName = isset($item['goods_name'])?$item['goods_name']:'';